install script diffs

Seth W. Klein sklein at mint.net
Fri Nov 24 10:31:40 PST 2000


Gerard Beekmans wrote:
> 
> > Would it be possible to simply have one large file containing the all
> > the book's install commands so that we could "diff" one version
> > against the next to see the few lines that changed? That would be so
> > much more useful (for me, anyway) than a change log, and I would
> > imagine there are lots of other people who would find it useful too.
> > It's a real headache to hand-compare each web page against the
> > scripts I already have to find the few interesting tidbits that
> > changed.
> 
> I know the .txt and the nochunk.html have been pointed out but that's not
> really usable because I also change the text around it so you'd have to
> compare every section individually. I can see that would be a lot of work.

I tried this between 2.4.2 and 2.4.3, and yes, it's not too useful.
diff is smart enough that if only the commands changed, it would be
fine. (Especially with a unified diff.) But there are too many typo
corrections.

> This "command diff" sounds like something a lot of us could use. Of course
> setting it up is a nice big job (having to paste all the commands into a
> file) but once that first file is created it's a minor thing to maintain the
> file. I quite like this proposal. I'll start working on it. If you're (we're)
> lucky I might have it ready by 2.4.4 (and no there is no release date yet).
> 
> Oh, this always counts: if somebody has enough spare time to create this file
> him/herself you can do right ahead and send it to me. Just let me know if
> somebody plans to work on it (reply to this message and let us know will do)
> so nobody is doing double work for nothing.

With apologies to David Sagnol who has already volunteered something,
i went through the text version of 2.4.3 and cut out everything but
the commands. It didn't take long so i won't be upset if it isn't useful.

I assume you'll maintain the commands as entities in a seperate file
and diff that, or some such. If so, let me know if i can help with
any of the grunt work.

cheers,
sklein
-- 
sklein at mint.net                          http://members.mint.net/sklein/
-------------- next part --------------

# Linux From Scratch

# Creating directories
cd $LFS
mkdir bin boot dev dev/pts etc home lib mnt proc root sbin tmp var
for dirname in $LFS/usr $LFS/usr/local
	do
	mkdir $dirname
	cd $dirname
	mkdir bin etc include lib sbin share src tmp var
	ln -s share/man man
	ln -s share/doc doc
	ln -s share/info info
	cd $dirname/share
	mkdir dict doc info locale man nls misc terminfo zoneinfo
	cd $dirname/share/man
	mkdir man1 man2 man3 man4 man5 man6 man7 man8
done
cd $LFS/var
mkdir lock log mail run spool tmp

cd $LFS &&
chmod 0750 root &&
chmod 1777 tmp usr/tmp var/tmp

# Chapter 5. Preparing the LFS system

# Installing Bash

../configure --enable-static-link --prefix=$LFS/usr \
--bindir=$LFS/bin --disable-nls --with-ncurses &&
make &&
make install &&
cd $LFS/bin &&
ln -s bash sh

# Installing Binutils

../configure --prefix=$LFS/usr --disable-nls &&
make -e LDFLAGS=-all-static tooldir=$LFS/usr &&
make -e tooldir=$LFS/usr install

# Installing Bzip2

sed \
	s/"\$(CC) \$(CFLAGS) -o"/"\$(CC) \$(CFLAGS) \$(LDFLAGS) -o"/ \
	Makefile | make -f - LDFLAGS=-static &&
make PREFIX=$LFS/usr install &&
cd $LFS/usr/bin &&
mv bzcat bunzip2 bzip2 bzip2recover $LFS/bin

# Installing Diffutils

CPPFLAGS=-Dre_max_failures=re_max_failures2 \
	./configure --prefix=$LFS/usr --disable-nls &&
make LDFLAGS=-static &&
make install

# Installing Fileutils

../configure --disable-nls --prefix=$LFS/usr --bindir=$LFS/bin &&
make LDFLAGS=-static &&
make install &&
cd $LFS/usr/bin &&
ln -s ../../bin/install install

# Installing GCC on the LFS system

mkdir $LFS/usr/src/gcc-build &&
cd $LFS/usr/src/gcc-build &&
.../gcc-2.95.2/configure --prefix=/usr \
	--with-gxx-include-dir=/usr/include/g++ \
	--enable-languages=c,c++ --disable-nls &&
make -e LDFLAGS=-static bootstrap &&
make prefix=$LFS/usr local_prefix=$LFS/usr/local \
	gxx_include_dir=$LFS/usr/include/g++ install

# Creating necessary symlinks

cd $LFS/lib &&
ln -s ../usr/lib/gcc-lib/*/2.95.2/cpp cpp &&
cd $LFS/usr/lib &&
ln -s gcc-lib/*/2.95.2/cpp cpp &&
cd $LFS/usr/bin &&
ln -s gcc cc

# Installing Linux Kernel

yes "" | make config

make dep

cd $LFS/usr/include &&
ln -s ../src/linux/include/linux linux &&
ln -s ../src/linux/include/asm asm

# Installing Glibc

mkdir $LFS/usr/src/glibc-build &&
cd $LFS/usr/src/glibc-build

cat > configparms << "EOF"
# Begin configparms
slibdir=/lib
sysconfdir=/etc
# End configparms
EOF

cd ../glibc-2.1.3 &&
patch -Np1 -i ../glibc-2.1.3.patch &&
cd $LFS/usr/src/glibc-build &&
.../glibc-2.1.3/configure \
	--prefix=/usr --enable-add-ons \
	--with-headers=$LFS/usr/include &&
make &&
make install_root=$LFS install &&
make install_root=$LFS localedata/install-locales


# Installing Grep

CPPFLAGS=-Dre_max_failures=re_max_failures2 \
   ./configure --prefix=$LFS/usr --disable-nls &&
make LDFLAGS=-static &&
make install

# Installing Gzip

patch -Np1 -i ../gzip-1.2.4a.patch &&
../configure --prefix=$LFS/usr --disable-nls &&
make LDFLAGS=-static &&
make install &&
cp $LFS/usr/bin/gunzip $LFS/usr/bin/gzip $LFS/bin &&
rm $LFS/usr/bin/gunzip $LFS/usr/bin/gzip

# Installing Make

../configure --prefix=$LFS/usr --disable-nls &&
make LDFLAGS=-static &&
make install

# Installing Sed

CPPFLAGS=-Dre_max_failures=re_max_failures2 \
   ./configure --prefix=$LFS/usr --disable-nls --bindir=$LFS/bin &&
make LDFLAGS=-static &&
make install

# Installing Shellutils

../configure --prefix=$LFS/usr --disable-nls &&
make LDFLAGS=-static &&
make install &&
cd $LFS/usr/bin &&
mv date echo false pwd stty $LFS/bin &&
mv su true uname hostname $LFS/bin

# Installing Tar

cd src &&
patch -i ../../gnutarpatch.txt &&
cd ..

../configure --prefix=$LFS/usr --disable-nls &&
make LDFLAGS=-static &&
make prefix=$LFS/usr install &&
mv $LFS/usr/bin/tar $LFS/bin

# Installing Textutils

../configure --prefix=$LFS/usr --disable-nls &&
make LDFLAGS=-static &&
make install &&
mv $LFS/usr/bin/cat $LFS/bin

# Creating passwd and group files

echo "root:x:0:0:root:/root:/bin/bash" > $LFS/etc/passwd

cat > $LFS/etc/group << "EOF"
root:x:0:
bin:x:1:
sys:x:2:
kmem:x:3:
tty:x:4:
uucp:x:5:
daemon:x:6:
floppy:x:7:
disk:x:8:
EOF

# Mounting $LFS/proc file system

mount proc $LFS/proc -t proc

# Chapter 6. Installing basic system software

# Creating $LFS/root/.bash_profile

cat > $LFS/root/.bash_profile << "EOF"
# Begin /root/.bash_profile
alias ls='ls -a --color'
PS1='\u:\w\$ '
TERM=linux
CFLAGS="-O3 -march=xxx"
CXXFLAGS=$CFLAGS
export PS1 TERM CFLAGS CXXFLAGS
# End /root/.bash_profile
EOF

# Entering the chroot'ed environment

cd $LFS &&
chroot $LFS env -i HOME=/root bash --login

# Setting up locale

localedef -i en_US -f ISO-8859-1 en_US

# Creating device files

# Installation of MAKEDEV

sed "s/# 9/9/" MAKEDEV >/dev/MAKEDEV &&
chmod 755 /dev/MAKEDEV

# Creating the /dev entries

cd /dev &&
../MAKEDEV -v generic

# Installing Ed

../configure --prefix=/usr &&
make &&
make install &&
mv /usr/bin/ed /usr/bin/red /bin

# Installing Patch

../configure --prefix=/usr &&
make &&
make install

# Installing Findutils

patch -Np1 -i ../findutils-4.1.patch &&
../configure --prefix=/usr &&
make &&
make install

# Installing Mawk

../configure &&
make &&
make BINDIR=/usr/bin \
   MANDIR=/usr/share/man/man1 install &&
cd /usr/bin &&
ln -s mawk awk

# Installing Ncurses

../configure --prefix=/usr --libdir=/lib \
   --with-shared --disable-termcap &&
make &&
make install &&
cd /lib &&
ln -s libncurses.a libcurses.a

# Installing Vim

../configure --prefix=/usr &&
make &&
make install &&
cd /usr/bin &&
ln -s vim vi

# Installing GCC

mkdir /usr/src/gcc-build &&
cd /usr/src/gcc-build &&
.../gcc-2.95.2/configure --prefix=/usr \
   --with-gxx-include-dir=/usr/include/g++ \
   --enable-shared --enable-languages=c,c++ &&
make bootstrap &&
make install

# Installing Bison

../configure --prefix=/usr \
   --datadir=/usr/share/bison &&
make &&
make install

cat > /usr/bin/yacc << "EOF"
#!/bin/sh
# Begin /usr/bin/yacc
/usr/bin/bison -y $*
# End /usr/bin/yacc
EOF
chmod 755 /usr/bin/yacc

# Installing Less

../configure --prefix=/usr --bindir=/bin &&
make &&
make install

# Installing Groff

../configure --prefix=/usr &&
make &&
make install

# Installing Man

../configure -default &&
make &&
make install &&
sed s/AWK=/"AWK=\/usr\/bin\/mawk"/ /usr/sbin/makewhatis >
makewhatis-new &&
mv makewhatis-new /usr/sbin/makewhatis && 
chmod 755 /usr/sbin/makewhatis

# Installing Perl

../Configure -Dprefix=/usr &&
make &&
make install

# Installing M4

../configure --prefix=/usr &&
make &&
make install

# Installing Texinfo

../configure --prefix=/usr &&
make &&
make install

# Installing Autoconf

../configure --prefix=/usr &&
make &&
make install

# Installing Automake

../configure --prefix=/usr &&
make install

# Installing Bash

../configure --prefix=/usr --with-curses &&
make &&
make install &&
logout


mv $LFS/usr/bin/bash $LFS/usr/bin/bashbug $LFS/bin &&
chroot $LFS env -i HOME=/root bash --login

# Installing Flex

../configure --prefix=/usr &&
make &&
make install

# Installing File

../configure --prefix=/usr --datadir=/usr/share/misc &&
make &&
make install

# Installing Libtool

../configure --prefix=/usr &&
make &&
make install

# Installing Bin86

make &&
make PREFIX=/usr install

# Installing Binutils

../configure --prefix=/usr --enable-shared &&
make -e tooldir=/usr &&
make -e tooldir=/usr install

# Installing Bzip2

make -f Makefile-libbz2_so &&
make bzip2recover libbz2.a &&
cp bzip2-shared /bin/bzip2 &&
cp bzip2recover /bin &&
cp bzip2.1 /usr/share/man/man1 &&
cp bzlib.h /usr/include &&
cp -a libbz2.so* libbz2.a /lib &&
rm /usr/lib/libbz2.a &&
cd /bin &&
rm bunzip2 && ln -s bzip2 bunzip2 &&
rm bzcat && ln -s bzip2 bzcat &&
cd /usr/share/man/man1 &&
ln -s bzip2.1 bunzip2.1 &&
ln -s bzip2.1 bzcat.1 &&
ln -s bzip2.1 bzip2recover.1


# Installing Gettext

../configure --prefix=/usr &&
make &&
make install &&
mv /po-mode.el /usr/share/gettext

# Installing Consoletools

patch -Np1 -i ../console-tools-0.2.3.patch &&
../configure --prefix=/usr &&
make &&
make install

# Installing Consoledata

../configure --prefix=/usr &&
make &&
make install &&
cd /usr/share/keymaps &&
ln -s <path-to-kmap-file> defkeymap.kmap.gz

# Installing Diffutils

../configure --prefix=/usr &&
make &&
make install

# Installing E2fsprogs

../configure --prefix=/usr --with-root-prefix= \
   --enable-elf-shlibs &&
make &&
make install &&
make install-libs

# Installing Fileutils

../configure --prefix=/usr --bindir=/bin &&
make &&
make install

# Installing Grep

../configure --prefix=/usr &&
make &&
make install

# Installing Gzip

../configure --prefix=/usr &&
make &&
make install &&
cd /usr/bin &&
mv gzip /bin &&
rm gunzip /bin/gunzip &&
cd /bin &&
ln -s gzip gunzip

# Installing Ldso

cd util &&
make ldd ldconfig &&
cp ldd /bin &&
cp ldconfig /sbin &&
cd ../man &&
cp ldd.1 /usr/share/man/man1 &&
cp *.8 /usr/share/man/man8 &&
rm /usr/bin/ldd &&
hash -r

# Installing Lilo

make &&
make install

# Installing Make

../configure --prefix=/usr &&
make &&
make install

# Installing Modutils

../configure &&
make &&
make install

# Installing Procinfo

sed "s/-ltermcap/-lncurses/" Makefile >Makefile2 &&
make -f Makefile2 &&
make install

# Installing Procps

sed "s/XConsole/#XConsole/" Makefile >Makefile2 &&
make -f Makefile2 &&
make -f Makefile2 install &&
mv /usr/bin/kill /bin

# Installing Psmisc

sed "s/-ltermcap/-lncurses/" Makefile >Makefile2 &&
make -f Makefile2 &&
make install

# Installing Sed

../configure --prefix=/usr --bindir=/bin &&
make &&
make install

# Installing Shellutils

../configure --prefix=/usr &&
make &&
make install &&
cd /usr/bin &&
mv date echo false pwd stty /bin &&
mv su true uname hostname /bin

# Installing Shadowpwd

../configure --prefix=/usr &&
make &&
make install &&
cd etc &&
cp limits login.access \
   login.defs.linux shells suauth /etc &&
mv /etc/login.defs.linux /etc/login.defs

# Installing Sysklogd

make &&
make install

# Installing Sysvinit

cd src &&
make &&
make install

# Installing Tar

cd src &&
patch -i ../../gnutarpatch.txt &&
cd ..

../configure --prefix=/usr &&
make &&
make install &&
mv /usr/bin/tar /bin

Installing Textutils

../configure --prefix=/usr &&
make &&
make install &&
mv /usr/bin/cat /bin

# Installing Utillinux


#   Before we can install the package we have to edit the MCONFIG file,
#   find and modify the following variables as follows:
#   
#     HAVE_SLN=yes
#     HAVE_TSORT=yes
#     
#   Now find the following lines in the MCONFIG file:
#   
#     # Different optimizations for different cpus.
#     ifeq "$(ARCH)" "intel"
#       ifeq "$(CPU)" "i386"
#         OPT=        -pipe -O2 -m386 -fomit-frame-pointer
#       else
#         OPT=        -pipe -O2 -m486 -fomit-frame-pointer
#       endif
#     else
#     <cut the rest of the lines in this optimizations section>
#     
#   Modify the proper OPT variable to include the -march option. If you
#   modify the first or second OPT variable, replace -m486 with the -march
#   variable and value you wish to use like -march=i686.

../configure &&
make &&
make install

# Installing Man-pages

yes n|cp -avi man* /usr/share/man

# Configuring essential software

# Configuring Vim

cat > /root/.vimrc << "EOF"
" Begin /root/.vimrc
set nocompatible
set bs=2
" End /root/.vimrc
EOF

# Configuring Glibc

cat > /etc/nsswitch.conf << "EOF"
# Begin /etc/nsswitch.conf
passwd: files
group: files
shadow: files
publickey: files
hosts: files dns
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: db files
# End /etc/nsswitch.conf
EOF

#   Run the tzselect script and answer the questions regarding your
#   timezone. When you're done, the script will give you the location of
#   the timezone file you need.

cd /etc &&
rm localtime &&
ln -s ../usr/share/zoneinfo/<tzselect's output> localtime

# Configuring Dynamic Loader

cat > /etc/ld.so.conf << "EOF"
# Begin /etc/ld.so.conf
/lib
/usr/lib
/usr/local/lib
# End /etc/ld.so.conf
EOF

# Configuring Lilo

cp /etc/lilo.conf $LFS/etc
cp /boot/<kernel images> $LFS/boot

# Configuring Sysklogd

cat > /etc/syslog.conf << "EOF"
# Begin /etc/syslog.conf
auth,authpriv.* -/var/log/auth.log
*.*;auth,authpriv.none -/var/log/sys.log
daemon.* -/var/log/daemon.log
kern.* -/var/log/kern.log
mail.* -/var/log/mail.log
user.* -/var/log/user.log
*.emerg *
# End /etc/syslog.conf
EOF

# Configuring Sysvinit

cat > /etc/inittab << "EOF"
# Begin /etc/inittab
id:3:initdefault:
si::sysinit:/etc/init.d/rcS
l0:0:wait:/etc/init.d/rc 0
l1:S1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
f1:0:respawn:/sbin/sulogin
f2:6:respawn:/sbin/sulogin
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
su:S1:respawn:/sbin/sulogin
1:2345:respawn:/sbin/agetty tty1 9600
2:2345:respawn:/sbin/agetty tty2 9600
3:2345:respawn:/sbin/agetty tty3 9600
4:2345:respawn:/sbin/agetty tty4 9600
5:2345:respawn:/sbin/agetty tty5 9600
6:2345:respawn:/sbin/agetty tty6 9600
# End /etc/inittab
EOF

# Creating the /var/run/utmp, /var/log/wtmp and /var/log/btmp files

touch /var/run/utmp /var/log/wtmp /var/log/btmp /var/log/lastlog &&
chmod 644 /var/run/utmp /var/log/wtmp /var/log/btmp
/var/log/lastlog

# Creating root password

passwd root

# Chapter 7. Creating system boot scripts

# Creating directories

cd /etc &&
mkdir sysconfig rc0.d rc1.d rc2.d rc3.d &&
mkdir rc4.d rc5.d rc6.d init.d rcS.d &&
cd init.d

# Creating the rc script

cat > rc << "EOF"
#!/bin/sh
# Begin /etc/init.d/rc
#
# By Jason Pearce  - jason.pearce at linux.org
# Modified by Gerard Beekmans - gerard at linuxfromscratch.org
# print_error_msg based on ideas by Simon Perreault - nomis80 at yahoo.co
m
source /etc/init.d/functions
print_error_msg()
{
        echo
        $FAILURE
        echo -n "You should not read this error message. It means "
        echo "that an unforseen error "
        echo -n "took place and subscript $i exited with "
        echo "a return value "
        echo -n "of $error_value for an unknown reason. If you're able
 "
        echo "to trace this error down "
        echo -n "to a bug in one of the files provided by this book, "
        echo "please be so kind to "
        echo -n "inform us at lfs-discuss at linuxfromscratch.org"
        $NORMAL
        echo
}
# Un-comment the following for debugging.
# debug=echo
#
# Start script or program.
#
startup() {
case "$1" in
        *.sh)
                $debug sh "$@"
                ;;
        *)
                $debug "$@"
                ;;
esac
}
# Ignore CTRL-C only in this shell, so we can interrupt subprocesses.
trap ":" INT QUIT TSTP
# Set onlcr to avoid staircase effect.
stty onlcr 0>&1
# Now find out what the current and what the previous runlevel are.
runlevel=$RUNLEVEL
# Get first argument. Set new runlevel to this argument.
[ "$1" != "" ] && runlevel=$1
if [ "$runlevel" = "" ]
then
        echo "Usage: $0 <runlevel>" >&2
        exit 1
fi
previous=$PREVLEVEL
[ "$previous" = "" ] && previous=N
export runlevel previous
# Is there an rc directory for this new runlevel?
if [ -d /etc/rc$runlevel.d ]
then
        # First, run the KILL scripts for this runlevel.
        if [ $previous != N ]
        then
                for i in /etc/rc$runlevel.d/K*
                do
                [ ! -f $i ] && continue
                        suffix=${i#/etc/rc$runlevel.d/K[0-9][0-9]}
                        previous_start=/etc/rc$previous.d/S[0-9][0-9]$
suffix
                        sysinit_start=/etc/rcS.d/S[0-9][0-9]$suffix
                        # Stop the service if there is a start script
                        # in the previous run level.
                        [ ! -f $previous_start ] &&
                        [ ! -f $sysinit_start ] && continue
                        startup $i stop
                        error_value=$?
                        if [ $error_value != 0 ]
                        then
                                print_error_msg
                        fi
                done
        fi
        # Now run the START scripts for this runlevel.
        for i in /etc/rc$runlevel.d/S*
        do
                [ ! -f $i ] && continue
                if [ $previous != N ]
        then
                        # Find start script in previous runlevel and
                        # stop script in this runlevel.
                        suffix=${i#/etc/rc$runlevel.d/S[0-9][0-9]}
                        stop=/etc/rc$runlevel.d/K[0-9][0-9]$suffix
                        previous_start=/etc/rc$previous.d/S[0-9][0-9]$
suffix
                        # If there is a start script in the previous
                        # level
                        # and _no_ stop script in this level, we don't
                        # have to re-start the service.
                        [ -f $previous_start ] && [ ! -f $stop ] &&
                        continue
                fi
                case "$runlevel" in
                        0|6)
                                startup $i stop
                                error_value=$?
                                if [ $error_value != 0 ]
                                then
                                        print_error_msg
                                fi
                                ;;
                        *)
                                startup $i start
                                error_value=$?
                                if [ $error_value != 0 ]
                                then
                                        print_error_msg
                                fi
                                ;;
                esac
        done
fi
# End /etc/init.d/rc
EOF

# Creating the rcS script

cat > rcS << "EOF"
#!/bin/sh
# Begin /etc/init.d/rcS
runlevel=S
prevlevel=N
umask 022
export runlevel prevlevel
trap ":" INT QUIT TSTP
for i in /etc/rcS.d/S??*
do
        [ ! -f  "$i" ] && continue;
                $i start
done
# End /etc/init.d/rcS
EOF

# Creating the functions script

cat > functions << "EOF"
#!/bin/sh
# Begin /etc/init.d/functions
COL=70
SET_COL="echo -en \\033[${COL}G"
NORMAL="echo -en \\033[0;39m"
SUCCESS="echo -en \\033[1;32m"
FAILURE="echo -en \\033[1;31m"
evaluate_retval()
{
        if [ $? = 0 ]
        then
                print_status success
        else
                print_status failure
        fi
}
print_status()
{
        if [ $# = 0 ]
        then
                echo "Usage: print_status {success|failure}"
                exit 1
        fi
        case "$1" in
                success)
                        $SET_COL
                        echo -n "[  "
                        $SUCCESS
                        echo -n "OK"
                        $NORMAL
                        echo "  ]"
                        ;;
                failure)
                        $SET_COL
                        echo -n "["
                        $FAILURE
                        echo -n "FAILED"
                        $NORMAL
                        echo "]"
                        ;;
        esac
}
loadproc()
{
        if [ $# = 0 ]
        then
                echo "Usage: loadproc {program}"
                exit 1
        fi
        base=`/usr/bin/basename $1`
        pidlist=`/bin/pidof -o $$ -o $PPID -o %PPID -x $base`
        pid=""
        for apid in $pidlist
        do
                if [ -d /proc/$apid ]
                then
                        pid="$pid $apid"
                fi
        done
        if [ ! -n "$pid" ]
        then
                $*
                evaluate_retval
        else
                print_status failure
        fi
}
killproc()
{
        if [ $# = 0 ]
        then
                echo "Usage: killproc {program} [signal]"
                exit 1
        fi
        base=`/usr/bin/basename $1`
        if [ "$2" != "" ]
        then
                killlevel=$2
        else
                nolevel=1
        fi
        pidlist=`/bin/pidof -o $$ -o $PPID -o %PPID -x $base`
        pid=""
        for apid in $pidlist
        do
                if [ -d /proc/$apid ]
                then
                        pid="$pid $apid"
                fi
        done
        if [ -n "$pid" ]
        then
                if [ "$nolevel" = 1 ]
                then
                        /bin/kill -TERM $pid
                        if ps h $pid >/dev/null 2>&1
                        then
                                /bin/kill -KILL $pid
                        fi
                        /bin/ps h $pid >/dev/null 2>&1
                        if [ $? = 0 ]
                        then
                                print_status failure
                        else
                                /bin/rm -f /var/run/$base.pid
                                print_status success
                        fi
                else
                        /bin/kill $killlevel $pid
                        /bin/ps h $pid >/dev/null 2>&1
                        if [ $? = 0 ]
                        then
                                print_status failure
                        else
                                /bin/rm -f /var/run/$base.pid
                                print_status success
                        fi
                fi
        else
                print_status failure
        fi
}
reloadproc()
{
        if [ $# = 0 ]
        then
                echo "Usage: reloadproc {program} [signal]"
                exit 1
        fi
        base=`/usr/bin/basename $1`
        if [ -n "$2" ]
        then
                killlevel=-$2
        else
                nolevel=1
        fi
        pidlist=`/bin/pidof -o $$ -o $PPID -o %PPID -x $base`
        pid=""
        for apid in $pidlist
        do
                if [ -d /proc/$apid ]
                then
                        pid="$pid $apid"
                fi
        done
        if [ -n "$pid" ]
        then
                if [ "$nolevel" = 1 ]
                then
                        /bin/kill -SIGHUP $pid
                        evaluate_retval
                else
                        /bin/kill -$killlevel $pid
                        evaluate_retval
                fi
        else
                print_status failure
        fi
}
statusproc()
{
        if [ $# = 0 ]
        then
                echo "Usage: status {program}"
                return 1
        fi
        pid=`/bin/pidof -o $$ -o $PPID -o %PPID -x $1`
        if [ -n "$pid" ]
        then
                echo "$1 running with Process ID $pid"
                return 0
        fi
        if [ -f /var/run/$1.pid ]
        then
                pid=`/usr/bin/head -1 /var/run/$1.pid`
                if [ -n "$pid" ]
                then
                        echo "$1 not running but /var/run/$1.pid exist
s"
                        return 1
                fi
        else
                echo "$i is not running"
        fi
}
# End /etc/init.d/functions
EOF

# Creating the checkfs script

cat > checkfs << "EOF"
#!/bin/sh
# Begin /etc/init.d/checkfs
source /etc/init.d/functions
echo -n "Activating swap..."
/sbin/swapon -a
evaluate_retval
if [ -f /fastboot ]
then
        echo "Fast boot, no file system check"
else
        /bin/mount -n -o remount,ro /
        if [ $? = 0 ]
        then
                if [ -f /forcefsck ]
                then
                        echo -n "/forcefsck exists, forcing "
                        echo "file system check"
                        force="-f"
                else
                        force=""
                fi
                echo "Checking file systems..."
                /sbin/fsck $force -a -A -C -T
                if [ $? -gt 1 ]
                then
                        $FAILURE
                        echo
                        echo -n "fsck failed. Please repair your file
"
                        echo "systems manually by running /sbin/fsck"
                        echo "without the -a option"
                        echo
                        echo -n "Please note that the root file system
 "
                        echo "is currently mounted in read-only mode."
                        echo
                        echo -n "I will start sulogin now. When you  "
                        echo "logout I will reboot your system."
                        echo
                        $NORMAL
                        /sbin/sulogin
                        /sbin/reboot -f
                else
                        print_status success
                fi
        else
                echo -n "Cannot check root file system because it "
                echo "could not be mounted in read-only mode."
        fi
fi
# End /etc/init.d/checkfs
EOF

# Creating the halt script

cat > halt << "EOF"
#!/bin/sh
# Begin /etc/init.d/halt
/sbin/halt -d -f -i -p
# End /etc/init.d/halt
EOF

# Creating the loadkeys script

cat > loadkeys << "EOF"
#!/bin/sh
# Begin /etc/init.d/loadkeys
source /etc/init.d/functions
echo -n "Loading keymap..."
/usr/bin/loadkeys -d >/dev/null
evaluate_retval
# End /etc/init.d/loadkeys
EOF

# Creating the mountfs script

cat > mountfs << "EOF"
#!/bin/sh
# Begin /etc/init.d/mountfs
source /etc/init.d/functions
echo -n "Remounting root file system in read-write mode..."
/bin/mount -n -o remount,rw /
evaluate_retval
echo > /etc/mtab
/bin/mount -f -o remount,rw /
/bin/rm -f /fastboot /forcefsck
echo -n "Mounting other file systems..."
/bin/mount -a
evaluate_retval
# End /etc/init.d/mountfs
EOF

# Creating the reboot script

cat > reboot << "EOF"
#!/bin/sh
# Begin /etc/init.d/reboot
echo "System reboot in progress..."
/sbin/reboot -d -f -i
# End /etc/init.d/reboot
EOF

# Creating the sendsignals script

cat > sendsignals << "EOF"
#!/bin/sh
# Begin /etc/init.d/sendsignals
source /etc/init.d/functions
echo -n "Sending all processes the TERM signal..."
/sbin/killall5 -15
evaluate_retval
echo -n "Sending all processes the KILL signal..."
/sbin/killall5 -9
evaluate_retval
# End /etc/init.d/sendsignals
EOF

# Creating the setclock script

cat > setclock << "EOF"
#!/bin/sh
# Begin /etc/init.d/setclock
source /etc/init.d/functions
source /etc/sysconfig/clock
CLOCKPARAMS="--hctosys"
case "$UTC" in
        yes|true|1)
                CLOCKPARAMS="$CLOCKPARAMS -u"
                ;;
esac
echo -n "Setting clock..."
/sbin/hwclock $CLOCKPARAMS
evaluate_retval
# End /etc/init.d/setclock
EOF

# Creating the /etc/sysconfig/clock file

cat > /etc/sysconfig/clock << "EOF"
# Begin /etc/sysconfig/clock
UTC=1
# End /etc/sysconfig/clock
EOF

# Creating the sysklogd script

cat > sysklogd << "EOF"
#!/bin/sh
# Begin /etc/init.d/sysklogd
source /etc/init.d/functions
case "$1" in
        start)
                echo -n "Starting system log daemon..."
                loadproc /usr/sbin/syslogd -m 0
                echo -n "Starting kernel log daemon..."
                loadproc /usr/sbin/klogd
                ;;
        stop)
                echo -n "Stopping kernel log daemon..."
                killproc klogd
                echo -n "Stopping system log daemon..."
                killproc syslogd
                ;;
        reload)
        echo -n "Reloading system log daemon configuration file..."
                reloadproc syslogd 1
                ;;
        restart)
                $0 stop
                /usr/bin/sleep 1
                $0 start
                ;;
        status)
                statusproc /usr/sbin/syslogd
                statusproc /usr/sbin/klogd
                ;;
        *)
                echo "Usage: $0 {start|stop|reload|restart|status}"
                exit 1
        ;;
esac
# End /etc/init.d/sysklogd
EOF

# Creating the template script

cat > template << "EOF"
#!/bin/sh
# Begin /etc/init.d/
source /etc/init.d/functions
case "$1" in
        start)
                echo -n "Starting ..."
                loadproc
                ;;
        stop)
                echo -n "Stopping ..."
                killproc
                ;;
        reload)
                echo -n "Reloading ..."
                reloadproc
                ;;
        restart)
                $0 stop
                /usr/bin/sleep 1
                $0 start
                ;;
        status)
                statusproc
                ;;
        *)
                echo "Usage: $0 {start|stop|reload|restart|status}"
                exit 1
        ;;
esac
# End /etc/init.d/
EOF

# Creating the umountfs script

cat > umountfs << "EOF"
#!/bin/sh
# Begin /etc/init.d/umountfs
source /etc/init.d/functions
echo -n "Deactivating swap..."
/sbin/swapoff -a
evaluate_retval
echo -n "Unmounting file systems..."
/bin/umount -a -r
evaluate_retval
# End /etc/init.d/umountfs
EOF

# Setting up symlinks and permissions

cd /etc/init.d &&
chmod 754 rc rcS functions checkfs halt loadkeys mountfs reboot &&
chmod 754 sendsignals setclock sysklogd template umountfs &&
cd ../rc0.d &&
ln -s ../init.d/sysklogd K90sysklogd &&
ln -s ../init.d/sendsignals S80sendsignals && 
ln -s ../init.d/umountfs S90umountfs &&
ln -s ../init.d/halt S99halt &&
cd ../rc6.d &&
ln -s ../init.d/sysklogd K90sysklogd &&
ln -s ../init.d/sendsignals S80sendsignals && 
ln -s ../init.d/umountfs S90umountfs &&
ln -s ../init.d/reboot S99reboot &&
cd ../rcS.d &&
ln -s ../init.d/checkfs S05checkfs &&
ln -s ../init.d/mountfs S10mountfs &&
ln -s ../init.d/setclock S20setclock &&
ln -s ../init.d/loadkeys S30loadkeys &&
cd ../rc1.d &&
ln -s ../init.d/sysklogd K90sysklogd &&
cd ../rc2.d &&
ln -s ../init.d/sysklogd S03sysklogd &&
cd ../rc3.d &&
ln -s ../init.d/sysklogd S03sysklogd &&
cd ../rc4.d &&
ln -s ../init.d/sysklogd S03sysklogd &&
cd ../rc5.d &&
ln -s ../init.d/sysklogd S03sysklogd

# Creating the /etc/fstab file

cat > /etc/fstab << "EOF"
# Begin /etc/fstab
/dev/<LFS-partition designation> / ext2 defaults 1 1
/dev/<swap-partition designation> swap swap defaults 0 0
proc /proc proc defaults 0 0
# End /etc/fstab
EOF

# Chapter 8. Making the LFS system bootable

# Installing a kernel

cd /usr/src/linux &&
make mrproper &&
make menuconfig &&
make dep &&
make bzImage &&
make modules &&
make modules_install &&
cp arch/i386/boot/bzImage /boot/lfskernel && 
cp System.map /boot

# Adding an entry to LILO

cat >> /etc/lilo.conf << "EOF"
image=/boot/lfskernel
        label=lfs
        root=<partition>
        read-only
EOF

/sbin/lilo

# Rebooting the system

# Chapter 9. Setting up basic networking

# Installing network software

# Installing Netkit-base

../configure --prefix=/usr &&
make &&
make install &&
cd etc.sample &&
cp services protocols /etc

# Installing Net-tools

make &&
make install

# Creating network boot scripts

# Creating the /etc/init.d/localnet bootscript

cat > /etc/init.d/localnet << "EOF"
#!/bin/sh
# Begin /etc/init.d/localnet
source /etc/init.d/functions
source /etc/sysconfig/network
case "$1" in
        start)
                echo -n "Bringing up the loopback interface..."
                /sbin/ifconfig lo 127.0.0.1
                evaluate_retval
                echo -n "Setting up hostname..."
                /bin/hostname $HOSTNAME
                evaluate_retval
                ;;
        stop)
                echo -n "Bringing down the loopback interface..."
                /sbin/ifconfig lo down
                evaluate_retval
                ;;
        *)
                echo "Usage: $0: {start|stop}"
                exit 1
                ;;
esac
# End /etc/init.d/localnet
EOF

# Setting up permissions and symlink

cd /etc/init.d &&
chmod 754 localnet &&
cd ../rcS.d &&
ln -s ../init.d/localnet S03localnet

# Creating the /etc/sysconfig/network file

echo "HOSTNAME=lfs" > /etc/sysconfig/network

# Creating the /etc/hosts file

cat > /etc/hosts << "EOF"
# Begin /etc/hosts (no network card version)
127.0.0.1 www.mydomain.com <value of HOSTNAME> localhost
# End /etc/hosts (no network card version)
EOF

cat > /etc/hosts << "EOF"
# Begin /etc/hosts (network card version)
127.0.0.1 localhost.localdomain localhost
192.168.1.1 www.mydomain.org <value of HOSTNAME>
# End /etc/hosts (network card version)
EOF

# Creating the /etc/init.d/ethnet script

cat > /etc/init.d/ethnet << "EOF"
#!/bin/sh
# Begin /etc/init.d/ethnet
source /etc/init.d/functions
source /etc/sysconfig/network
case "$1" in
        start)
for interface in `ls /etc/sysconfig/network-scripts/ifcfg* | grep -v i
fcfg-lo`
        do
            source $interface
            name=`/usr/bin/basename $interface | sed 's/^ifcfg-//g'`
            echo -n "Brining up the $name interface..."
    /sbin/ifconfig $name $IP broadcast $BROADCAST netmask $NETMASK
            evaluate_retval
        done
#        echo -n "Setting up default route..."
#        /sbin/route add default gw $GATEWAY
#        evaluate_retval
                ;;
        stop)
for interface in `ls /etc/sysconfig/network-scripts/ifcfg* | grep -v i
fcfg-lo`
        do
            source $interface
            name=`/usr/bin/basename $interface | sed 's/^ifcfg-//g'`
            echo -n "Brining down the $name interface..."
            /sbin/ifconfig $name down
            evaluate_retval
        done
                ;;
        *)
                echo "Usage: $0 {start|stop}"
                exit 1
                ;;
esac
# End /etc/init.d/ethnet
EOF

# Adding default gateway to /etc/sysconfig/network

#   If you require a default gateway to be setup, uncomment the following
#   three lines in the ethnet script:
#   
#     #        echo -n "Setting up default route..."
#     #        /sbin/route add default gw $GATEWAY
#     #        evaluate_retval
#     
#   And run the following command:

cat >> /etc/sysconfig/network << "EOF"
GATEWAY=192.168.1.2
EOF

#    Change GATEWAY to match your network setup.

# Creating NIC configuration files

mkdir /etc/sysconfig/network-scripts

#   Now, create new files in that directory containing the following.
#   Example file names are ifcfg-eth0, ifcfg-eth0:3 and ifcfg-eth1:2
#   
#     IP=192.168.1.1
#     NETMASK=255.255.255.0
#     BROADCAST=192.168.1.255
#     
#   Of course, change the values of those three variables in every file to
#   match the proper setup. Usually NETMASK and BROADCAST will remain the
#   same, just the IP will change per network interface.

# Setting up permissions and symlink

cd /etc/init.d &&
chmod 754 ethnet &&
cd ../rc1.d &&
ln -s ../init.d/ethnet K80ethnet &&
cd ../rc2.d &&
ln -s ../init.d/ethnet K80ethnet &&
cd ../rc3.d &&
ln -s ../init.d/ethnet S10ethnet &&
cd ../rc4.d &&
ln -s ../init.d/ethnet S10ethnet &&
cd ../rc5.d &&
ln -s ../init.d/ethnet S10ethnet



More information about the lfs-dev mailing list