LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (http://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   Please check this script for error (http://www.linuxquestions.org/questions/linux-from-scratch-13/please-check-this-script-for-error-344343/)

AxXium 07-18-2005 01: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?



Code:

#!/bin/sh
#
# Check the LFS environment variable.

echo $LFS

# Install Binutils-2.15.94.0.2.2 - Pass 1

cd $LFS/sources

tar xvjf binutils-2.15.94.0.2.2.tar.bz2

cd $LFS/sources/binutils-2.15.94.0.2.2

mkdir ../binutils-build

cd ../binutils-build

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

make

make install

make -C ld clean

make -C ld LIB_PATH=/tools/lib

Or will it only work as such

Code:

cd $LFS/sources && tar xvjf binutils-2.15.94.0.2.2.tar.bz2 && cd $LFS/sources/binutils-2.15.94.0.2.2 && mkdir ../binutils-build && cd ../binutils-build && ../binutils-2.15.94.0.2.2/configure --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 02:06 PM

Hi,

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-2.15.94.0.2.2' 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-2.15.94.0.2.2' will do the trick ;)

Julio

zonk 07-18-2005 02: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 02:16 PM

Great

When would it matter if I began the script with

#!/bin/sh

or

#!/bin/bash

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/libgcc_s.so{,.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 02:34 PM

Hi,

/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

/bin/sh
/bin/bash

# End /etc/shells
EOF


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

Julio

zonk 07-18-2005 03: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:

#!/usr/bin/php
<?php
phpinfo();
?>

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 01:09 AM.