-   Linux From Scratch (
-   -   Please check this script for error (

AxXium 07-18-2005 02:20 PM

Please check this script for error
This script is a rip off of instructions from the LFS 6.1 book btw, I dare not take credit.

Is this script do-able to install binutils pass-1?


# Check the LFS environment variable.

echo $LFS

# Install Binutils- - Pass 1

cd $LFS/sources

tar xvjf binutils-

cd $LFS/sources/binutils-

mkdir ../binutils-build

cd ../binutils-build

../binutils- --prefix=/tools --disable-nls


make install

make -C ld clean

make -C ld LIB_PATH=/tools/lib

Or will it only work as such


cd $LFS/sources && tar xvjf binutils- && cd $LFS/sources/binutils- && mkdir ../binutils-build && cd ../binutils-build && ../binutils- --prefix=/tools --disable-nls && make && make install && make -C ld clean && make -C ld LIB_PATH=/tools/lib
What ya think?

ParticleHunter 07-18-2005 03:06 PM


it looks OK, at least at first-sight, as my base system is completed, I'm not in the situation of being able to test it, but... it seems to be good, wheter you create the script or you concatenate the commmands with the '&&' operator, althought there's something 'redundant' for me in the 'script' version...

why do you perform 'cd $LFS/sources/binutils-' after unpacking the tarball? if the script is OK, after 'cd $LFS/sources' you're efectively in the sources directory, so a simple 'cd binutils-' will do the trick ;)


zonk 07-18-2005 03:07 PM

both versions will work.

but in the first version, you might want to set $LFS rather than just echo it. that way you can be sure it'll be what you need it to be. if $LFS is set to "hahahaiamusingtehintarwebz", it'll just echo that and then proceed installing with that not exactly sane value.

AxXium 07-18-2005 03:16 PM


When would it matter if I began the script with




or would it ever?

My understanding is that the system is blind to anything behind a #

I really appreciate your help!

Did you guys run into trouble when you created the symlinks in chapter 6.6 for

6.6. Creating Essential Symlinks

Some programs use hard-wired paths to programs which do not exist yet.
In order to satisfy these programs, create a number of symbolic links
which will be replaced by real files throughout the course of this
chapter after the software has been installed.
ln -s /tools/bin/{bash,cat,pwd,stty} /bin
ln -s /tools/bin/perl /usr/bin
ln -s /tools/lib/{,.1} /usr/lib
ln -s bash /bin/sh

my [ sh ] couldn't be found when I tried to install

6.10.1. Installation of Man-pages

Install Man-pages by running:
make install

To fix it I had to

rm -r /bin/sh

ln -s /tools/bin/bash /bin/sh

The book wasn't too clear to me when I read it.

Are we supposed have [ sh ] pointing to /tools/bash or /bin/bash in which case /bin/bash is a symlink to /tools/bash

Does it matter

ParticleHunter 07-18-2005 03:34 PM


/bin/sh and /bin/bash are the same in the sense that sh is supposed to be a symlink for bash, so as long as the /etc/shells file is present in your host distribution you must not have any problem with that, as the /etc/shells file contains the following (extracted from the BLFS book (SVN):

cat > /etc/shells << "EOF"
# Begin /etc/shells


# End /etc/shells

so if this file is present, it's not relevant wheter you use !/bin/sh or /bin/bash in your script

I didn't had any problem with that part of the book, in fact, as I compiled my system from a terminal window in GNOME having another window with Firefox and the LFS book, I just had to copy-and-paste over the terminal :D

I think the ln -s /tools/bin/bash /bin/sh command is executed because in that step of the book, you still haven't installed the final bash, but you're using your build-tools' bash to do the trick... as stated before, I didn't had any problem with this


zonk 07-18-2005 04:40 PM

and just to add: the #! is called shebang. in the very first line of a script, you can specify the interpreter of the script. thus, # always represents a comment line (does not get executed). but if on the first line the # is followed by a !, it signifies the interpreter. what really happens is not that each line of the script gets executed by the shell you are in when you call the script, rather the interpreter on the first line is called (a new shell is started) than then executes the script. if you had php installed, say, this would be perfectly good for a script:


that would start an instance of php that would then execute the rest of the code.

All times are GMT -5. The time now is 07:22 PM.