arsyante wrote:
> actually i trying to make script for building LFS
> i ve tries jhlfs, i like it but i want to use selfmade scripr
>
This is kind of like learning to walk before you crawl. Of course, it
is possible, but it's going to be difficult and you will learn a lot as
you go through it, prompting multiple rewrites I'm sure. You probably
need to get used to using numeric return values. Look at the following
for example:
[EMAIL PROTECTED] /]# cd ~
[EMAIL PROTECTED] ~]# mkdir test
[EMAIL PROTECTED] ~]# echo $?
0
[EMAIL PROTECTED] ~]# mkdir test
mkdir: cannot create directory `test': File exists
[EMAIL PROTECTED] ~]# echo $?
1
[EMAIL PROTECTED] ~]#
The same thing applies to every program, 0 is successful, anything else
is an exception (either it failed or it completed but not as expected).
This concept is identical to the use of %errorlevel% in DOS.
Next on your list of commands to learn is if and while commands. They
usually utilize the command 'test'. The commands '[' and 'test' are
synonymous (however, when using bash, '[' is a built-in command and must
be closed with a matching ']').
Using the same commands as the example above.
The first run of this program will return 0 and print "Successful!" to
the screen. Any subsequent runs will print "Unsuccessful!" but will
still return 0 as the last command (the echo command) completed
successfully.
============================================
#!/bin/bash
# Begin /home/dj/bin/example_testcase.sh
cd ~
mkdir test 2>&1 > /dev/null
if [ $? != 0 ]
then
echo "Unsuccessful!"
else
echo "Successful!"
fi
# End /home/dj/bin/example_testcase.sh
=========================================
> my plan is the script read "done.log" 'n assign the value to $done
> just assuming that bash script have "jump" and "label"
> so the script became
>
>
<Snip>
> ======================
> so if we already install foo.tar.gz
> and when compile bar.tar.gz it's interupted (e.g segmentation fault)
> so if we execut the script again
> the script not start from begining but from ":foo" (compiling
> bar.tar.gz) and continue to the rest
>
> but this is just simple script before we entering the chroot
> and when we entering chroot we use another script
>
> any suggestion??
>
=======================================================================
LOGFILE="/media/lfs/done.log"
########
# <SNIP>
########
## Build GlibC
grep "glibc" $LOGFILE
if [ $? != 0 ]
then
#insert commands (or better, an external script) to build glibc
## if you use an external script, then do not use any exit
## values so that the last command in the external script
## determines the return value of the script itself. This so
## that you can check to see if it was successful or not like so:
if [ $? == 0 ]
then
echo "glibc" >> $LOGFILE
else
echo "Build failed while building glibc!"
exit 1
fi
fi
===================================================
Finally, coding style...the above is sloppy IMO, but it works. It was
done that way for you to only see the necessary parts. I personally
quote everything, and use {} for clarity.
ex: 'echo "${?}"' and 'echo $?' are identical, but when running strings
together, the first example is much easier to read when looking at a
really long script. Also, one other trick: '&&' at the end of a command
is a shorter test case...if the command fails, then the next command in
line is not run (and '&&' is cumulative..all lines are skipped until
_after_ one is not terminated with '&&'). The functions file in the LFS
bootscripts make use of many of the shell tricks so you might like to
look at those for some ideas.
> btw, is there any hint to build lfs with reiser4 as root partition,
> is it true that reiser4 is "the fastest file system"
> and how doyou think about reiser4 stability, and its future
>
> sorry for my bad english
Sorry, I haven't tried it and likely will not. I'm not sure exactly how
stable it is yet, but Reiser4 is still pretty young in comparison and
the original developer is no longer able to work on it due to loosing
his marbles and being incarcerated as a result.
http://www.boingboing.net/2008/07/07/programmer-and-murde.html
-- DJ Lucas
--
http://linuxfromscratch.org/mailman/listinfo/blfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page