PDA

View Full Version : Free Script of the Week?


Sir Penguin
25-03-2003, 20:31:46
I propose a regular thingy wherin a neato script/source and its binary equivalent are featured. I've got a few prepared (kind of). Would anybody be interested were this to attain fruition?

SP

Sean
25-03-2003, 20:35:46
Do you want people to submit scripts they have written, or ones they have found?

Sir Penguin
25-03-2003, 20:40:49
Either would be fine. Anything that isn't under a license which restricts re-distribution. Credit would be given to the author.

SP

Sean
25-03-2003, 20:44:58
May as well go for it, then.

Nav
25-03-2003, 21:12:21
Cool idea.

Deacon
25-03-2003, 21:47:09
I have a nifty C program that works like cat, except that it prints the lines in reverse order. It uses stack code that I stole from a webpage (http://www.cs.helsinki.fi/u/nikki/c/mzstackdemo.c) and more code stolen from the "man 3 getline" example section. It's a companion program to a script I wrote that uses find and diff to find changes made to certain directories. It doesn't do anything fancy like keep track of dependencies or detect changes made to config files, but it's good enough to give me an idea of what files to delete if I screw something up with LFS and install files to the wrong place. Lots of source packages have no "make uninstall".

I compile the C program with the -static option so I can use it for chapter 6 of the LFS 4.0 book. It's all part of my attempts to automate chapter 6. I've basically stripped the build commands out of the .txt version of the book by hand, using "QQ" as a delimiter. A perl script uses that and other text files to generate a bash script for each package from the Linux 2.4.20 headers to the LFS bootscripts. The only problem is that there are "exec /bin/bash --login" lines in a couple places, so the only think I can think of is putting "source somescript" in .bashrc and editing the somescript to pick up where everything left off.

Sir Penguin
25-03-2003, 22:02:20
That kicks ass. But I think it's a ways out of the scope of this feature. :)

I can't get gcc to complete stage 2 of its compilation process for LFS 4.0 chapter 5. It segfaults in a variety of files and fuctions after about 8-9 SBUs.

If I'm going to do this, I need to be able to post news items, Navagement. :cute:

SP

Nav
25-03-2003, 22:20:23
You will be contacted when the time is right.

Sir Penguin
25-03-2003, 22:24:37
Meditate until that time, I shall.

SP

Deacon
25-03-2003, 22:25:15
What host distribution are you using? I used Debian 3.0 testing and it was fine.

Sir Penguin
25-03-2003, 22:31:35
I did it on Debian 3.0 testing and stable. I don't trust my hardware, though, so as it stands I'm blaming that.

SP

Deacon
29-03-2003, 07:00:59
I'm goofy. There's already a program called tac that comes standard with textutils, the package that contains cat. It prints the lines in reverse order. But I have succeeded with making Chapter 6 go fast. I use a couple of Perl scripts to generate a big shell script that does everything in Chapter 6. I tried to make a general function for the .bashrc trick, but eventually gave up and wrote the basic structure by hand. It's easy....

{commands before exec bash}
cat > ~/afterwards << "EXECEOF"
{commands after exec bash}
cp ~/bashrc.bak ~/.bashrc
EXECEOF
cp ~/.bashrc ~/bashrc.bak
echo "source ~/afterwards" | cat ~/bashrc.bak - > ~/.bashrc
exec /bin/bash

Everything else is stored in some string, so the whole thing gets generated with a print << EOF; Perl statement. I'm not sure if Perl and Bash are smart enough to match the various EOFs that are "straddled" instead of nested, so I use different identifiers. I think it is safe to use the same "afterwards" file across multiple exec bash statements, since all the commands in it are executed before it's overwritten.

Deacon
29-03-2003, 07:07:31
And the hypen is the way to reference standard input. I think. It works. :)

Sir Penguin
29-03-2003, 08:12:36
Got chapter 5 completed today! Now, for some reason, root doesn't have permission to use /dev/null in the chrooted environment, even during the MAKEDEV execution. Tomorrow (today) I'll look up the numbers and see what happens when I make it myself. (Damned scripts, never trusted the buggers)

SP

Deacon
30-03-2003, 09:25:01
Someday they'll tell everybody to use devfs. I don't use it because I'm afraid. But I hear that in the devfs future, there will be no more major and minor device numbers. Most of us may never use it because I don't think I'll ever run more than 26 hard drives in the same machine. :)

Deacon
30-03-2003, 10:03:42
I thought all MAKEDEV did was run mknod again and again?

Sir Penguin
30-03-2003, 23:06:44
Pretty much. My installation denies user 0 permission to read from or write to all device nodes. I think it must have something to do with how the partition's mounted, but I can't think what. I can read, write, and execute regular files.

Some day, somebody will say nobody will ever need to run more than 640 hard drives in a machine. :rolleyes:

SP

Deacon
31-03-2003, 07:05:57
What options did you use to mount the partition? I used "defaults" in my fstab file.

Sir Penguin
31-03-2003, 07:46:11
I think I just used defaults, too, but I might have users thrown in there for chapter 5. The crappy thing is I can't compile stuff without null. I guess I could make it a regular file and just delete it every so often... maybe.

SP

Deacon
01-04-2003, 00:34:01
I just read the manpage for mount. It says...

users
Allow every user to mount and unmount the file system. This option implies the options noexec, nosuid, and nodev (unless overridden by subsequent options, as in the option line users,exec,dev,suid).

Sir Penguin
01-04-2003, 02:44:02
Yeah, I set it to that so that user lfs could access it.

SP

Deacon
02-04-2003, 08:04:16
nodev could be blocking device creation. Not that I've ever tried this. The "devices won't be interpreted" clause is good 'ol vague documentation at its best.