ULK2 发表于 2003-6-17 00:11:30

What't This!!

搞了一天.现在发现网上还有这个东西.呵呵..
# <---- install begin ---->

# the shell script for building LFS

# 1. environment
# ===========

#Filesystem         1K-blocks      Used Available Use% Mounted on
#rootfs                25347784   193055222129624   9% /
#/dev/root             25347784   193055222129624   9% /
#/dev/hda1            1011928   16436    944088   2% /mnt/lfs
#/dev/hda2             10080520   32828   9535624   1% /mnt/lfs/usr
#/dev/hda3            1011960   16428    944124   2% /mnt/lfs/var

#This is not important. The script works provided that you have a $LFS variable
#set in envorinment. The fstab file will assume this configuration but users
#will have the chance to modify that.

# LFS version 4.0 with minor modification (chinese work, lilo, e2fsprog)

# 2. Preparation for installing
case "$1" in
        "")
echo "==== Preparation ===="

echo "setup variables..."
export LFS=/mnt/lfs
export BASE=/root
export VER=new
export SRC=lfs-packages-$VER
export SRCDIR=$BASE/$SRC
export SRCBAK=/mnt/cdrom
export STATIC=$LFS/usr/static
echo "done"

echo "create static directory"
mkdir $STATIC
echo "done"

# place source in base
#echo "get and extract sources..."
#cd $SRCDIR &&
#wget -i pkg.lst &&
#echo "done"

# create shell environment
echo "create shell env..."
cat > ~/.bash_profile << "EOF"
PS1='\u@\h:\w\$ '
umask 022

LFS=/mnt/lfs
LC_ALL=POSIX
export LFS LC_ALL

# LFS optimization
# comment these for GCC, GLibc and binutils
export CFLAGS="-O3 -march=pentium3 -msse -mfpmath=sse"
export CXXFLAGS="-O3 -march=pentium3 -msse -mfpmath=sse"
export CPPFLAGS="-O3 -march=pentium3 -msse -mfpmath=sse"
export CC="gcc -s"
EOF
source ~/.bash_profile &&
echo "done"

# 3. Installing part I (chapter 5)
echo "==== Install Phase I ===="
echo "install packages..."

# install softwares with static link

# homepage:        http://www.gnu.org/directory/GNU/bash.html
# source:        http://ftp.gnu.org/pub/gnu/bash/bash-2.05b.tar.gz
echo "install bash..."
cd $SRCDIR &&
tar xzf bash-2.05b.tar.gz &&
cd bash-2.05b &&
./configure --enable-static-link --prefix=$STATIC --with-curses &&
make &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/binutils.html
# soure:        http://ftp.gnu.org/gnu/binutils/binutils-2.13.2.1.tar.bz2
echo "install binutils..."
cd $SRCDIR &&
bzcat binutils-2.13.2.1.tar.bz2 | tar xf - &&
cd $SRCDIR/binutils-2.13.2.1 &&
export CFLAGS="" &&
export CXXFLAGS="" &&
export CPPFLAGS="" &&
mkdir ../binutils-build &&
cd ../binutils-build &&
../binutils-2.13.2.1/configure --prefix=$STATIC --disable-nls &&
make LDFLAGS=-all-static &&
make install &&
source $BASE/.bash_profile &&
echo "done"

# homepage:        http://sources.redhat.com/bzip2/
# source:        ftp://sources.redhat.com/pub/bzip2/v102/bzip2-1.0.2.tar.gz
echo "install bzip2..."
cd $SRCDIR &&
tar xzf bzip2-1.0.2.tar.gz &&
cd $SRCDIR/bzip2-1.0.2 &&
make CC="gcc -static -s" &&
make PREFIX=$STATIC install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/diffutils.html
# source:        http://ftp.gnu.org/pub/gnu/diffutils/diffutils-2.8.1.tar.gz
echo "install diffutils-2.8.1...."
cd $SRCDIR &&
tar xzf diffutils-2.8.1.tar.gz &&
cd $SRCDIR/diffutils-2.8.1 &&
LDFLAGS=-static CPPFLAGS="-Dre_max_failures=re_max_failures2 -O3 -march=pentium3 -msse -mfpmath=sse" \
    ./configure --prefix=$STATIC --disable-nls &&
make &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/fileutils.html
# source:        http://ftp.gnu.org/gnu/fileutils/fileutils-4.1.tar.gz
echo "install fileutils-4.1..."
cd $SRCDIR &&
tar xzf fileutils-4.1.tar.gz &&
cd $SRCDIR/fileutils-4.1 &&
## the following lines are for AMD/Glibc-2.2.3 *only*
#bunzip2 fileutils-4.1.patch.bz2 &&
#patch -Np1 -i ../fileutils-4.1.patch &&
LDFLAGS=-static \
    ./configure --disable-nls --prefix=$STATIC &&
make &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/findutils.html
# source:        http://ftp.gnu.org/pub/gnu/findutils/findutils-4.1.tar.gz
echo "install findutils-4.1..."
cd $SRCDIR &&
tar xzf findutils-4.1.tar.gz &&
cd $SRCDIR/findutils-4.1 &&
bzcat ../findutils-4.1.patch.bz2 | patch -Np1 -i - &&
CPPFLAGS="-Dre_max_failures=re_max_failures2 -O3 -march=pentium3 -msse -mfpmath=sse" \
    ./configure --prefix=$STATIC &&
make LDFLAGS=-static &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/gawk.html
# source:        http://ftp.gnu.org/gnu/gawk/gawk-3.1.1.tar.gz
echo "install gawk-3.1.1..."
cd $SRCDIR &&
tar xzf gawk-3.1.1.tar.gz &&
cd $SRCDIR/gawk-3.1.1 &&
CPPFLAGS="-Dre_max_failures=re_max_failures2" \
    LDFLAGS="-static" \
    ./configure --prefix=$STATIC --disable-nls &&
make &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/software/gcc/gcc.html
# source:        http://ftp.gnu.org/pub/gnu/gcc/gcc-3.2.1/gcc-3.2.1.tar.gz
echo "install gcc-3.2.1..."
cd $SRCDIR &&
tar xzf gcc-3.2.1.tar.gz &&
cd $SRCDIR/gcc-3.2.1 &&
export CFLAGS="" &&
export CXXFLAGS="" &&
export CPPFLAGS="" &&
mkdir ../gcc-build &&
cd ../gcc-build &&
../gcc-3.2.1/configure --prefix=/static --disable-nls --disable-shared \
    --with-as=$LFS/static/bin/as --with-ld=$LFS/static/bin/ld &&
make BOOT_LDFLAGS="-static" bootstrap &&
make prefix=$STATIC install-no-fixedincludes &&
ln -s gcc $STATIC/bin/cc &&
source $BASE/.bash_profile &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/grep.html
# source:        http://ftp.gnu.org/pub/gnu/grep/grep-2.5.tar.bz2
echo "install grep-2.5..."
cd $SRCDIR &&
bzcat grep-2.5.tar.bz2 | tar xf - &&
cd $SRCDIR/grep-2.5 &&
LDFLAGS=-static CPPFLAGS="-Dre_max_failures=re_max_failures2 -O3 -march=pentium3 -msse -mfpmath=sse" \
    ./configure --prefix=$STATIC --disable-nls --disable-perl-regexp &&
make &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/gzip.html
# source:        http://ftp.gnu.org/gnu/make/gzip/gzip-1.2.4a.tar.gz
echo "install gzip-1.2.4a..."
cd $SRCDIR &&
tar xzf gzip-1.2.4a.tar.gz &&
cd $SRCDIR/gzip-1.2.4a &&
./configure --prefix=$STATIC &&
make LDFLAGS="-static" &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/make.html
# source:        http://ftp.gnu.org/gnu/make/make-3.80.tar.bz2
echo "install make-3.80..."
cd $SRCDIR &&
bzcat make-3.80.tar.bz2 | tar xf - &&
cd $SRCDIR/make-3.80 &&
./configure --prefix=$STATIC --disable-nls &&
make LDFLAGS=-static &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/patch.html
# source:        http://ftp.gnu.org/pub/gnu/patch/patch-2.5.4.tar.gz
echo "install patch-2.5.4..."
cd $SRCDIR &&
tar xzf patch-2.5.4.tar.gz &&
cd $SRCDIR/patch-2.5.4 &&
CPPFLAGS="-D_GNU_SOURCE -O3 -march=pentium3 -msse -mfpmath=sse" \
    LDFLAGS="-static" ./configure --prefix=$STATIC &&
make &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/sed.html
# source:        http://ftp.gnu.org/gnu/sed/sed-4.0.5.tar.gz
echo "install sed-4.0.5..."
cd $SRCDIR &&
tar xzf sed-4.0.5.tar.gz &&
cd $SRCDIR/sed-4.0.5 &&
CPPFLAGS="-Dre_max_failures=re_max_failures2 -O3 -march=pentium3 -msse -mfpmath=sse" \
    LDFLAGS="-static" ./configure --prefix=$STATIC --disable-nls &&
make &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/shellutils.html
# source:        http://ftp.gnu.org/gnu/sh-utils/sh-utils-2.0.tar.gz
echo "install sh-utils-2.0..."
cd $SRCDIR &&
tar xzf sh-utils-2.0.tar.gz &&
cd $SRCDIR/sh-utils-2.0 &&
LDFLAGS="-static" ./configure --prefix=$STATIC --disable-nls &&
make &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/tar.html
# source:        http://ftp.gnu.org/pub/gnu/tar/tar-1.13.tar.gz
echo "install tar-1.13..."
cd $SRCDIR &&
tar xzf tar-1.13.tar.gz &&
cd $SRCDIR/tar-1.13 &&
bzcat ../tar-1.13.patch.bz2 | patch -Np1 -i - &&
LDFLAGS="-static" ./configure --prefix=$STATIC --disable-nls &&
make &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/texinfo.html
# source:        http://ftp.gnu.org/gnu/texinfo/texinfo-4.3.tar.bz2
echo "install texinfo-4.3..."
cd $SRCDIR &&
bzcat texinfo-4.3.tar.bz2 | tar xf - &&
cd $SRCDIR/texinfo-4.3 &&
LDFLAGS="-static" ./configure --prefix=$STATIC --disable-nls &&
make &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/textutils.html
# source:        http://ftp.gnu.org/pub/gnu/textutils/textutils-2.1.tar.gz
echo "install textutils-2.1..."
cd $SRCDIR &&
bzcat textutils-2.1.tar.bz2 | tar xf - &&
cd $SRCDIR/textutils-2.1 &&
CPPFLAGS="-Dre_max_failures=re_max_failures2 -O3 -march=pentium3 -msse -mfpmath=sse" \
    LDFLAGS="-static" ./configure --prefix=$STATIC --disable-nls &&
make &&
make install &&
echo "done"

# homepage:        http://ftp.kernel.org/pub/linux/utils/util-linux/
# source:        http://ftp.kernel.org/pub/linux/utils/util-linux/util-linux-2.11y.tar.bz2
echo "install util-linux-2.11y..."
cd $SRCDIR &&
tar xzf util-linux-2.11y.tar.gz &&
cd util-linux-2.11y &&
LDFLAGS="-static" ./configure &&
make -C lib &&
make -C mount mount umount &&
cp mount/{mount,umount} $STATIC/bin &&
echo "done"

# 4. Installing part II (chapter 6)
echo "==== Install Phase II ===="

# place source in static
echo "get and extract sources..."
mkdir $STATIC/$SRC &&
cd $SRCDIR &&
cat file.lst | xargs -i cp {} $STATIC/$SRC &&
chmod 700 $STATIC/$SRC/install.sh &&
echo "done"

echo "change root..."
echo "after root changed, please enter '/static/install.sh 1' to continue"
chroot $LFS /usr/static/bin/env -i \
    HOME=/root TERM=$TERM PS1='\u:\w\$ ' \
    PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/static/bin \
    /usr/static/bin/bash --login &&
echo "glibc installed"
echo "exit chroot environment"
echo "done"

echo "change root again ..."
echo "after root changed, please enter '/static/install.sh 2' to continue"
chroot $LFS /usr/static/bin/env -i \
    HOME=/root TERM=$TERM PS1='\u:\w\$ ' \
    PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/static/bin \
    /bin/bash --login &&
echo "exit chroot environment"
echo "done"

echo "change root again and again ..."
echo "after root changed, please enter '/static/install.sh 3' to continue"
chroot $LFS /usr/static/bin/env -i \
    HOME=/root TERM=$TERM PS1='\u:\w\$ ' \
    PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/static/bin \
    /bin/bash --login &&
echo "glibc re-installed"
echo "exit chroot environment"
echo "done"

echo "change root the last time ..."
echo "after root changed, please enter '/static/install.sh 4' to continue"
chroot $LFS /usr/bin/env -i \
    HOME=/root TERM=$TERM PS1='\u:\w\$ ' \
    PATH=/bin:/usr/bin:/sbin:/usr/sbin \
    /bin/bash --login &&
echo "exit chroot environment"
echo "done"

echo "install complete, restart you computer by 'reboot', good luck!"
exit;;

# <---- install end ---->

        "1")
#!/static/bin/bash
# <---- first_time begin ---->

echo "preparing env..."
export LFS=/notexist
export BASE=/usr/static
export VER=new
export SRC=lfs-packages-$VER
export SRCDIR=$BASE/$SRC
echo "done"

echo "change ownership..."
chown -R 0:0 /usr/static &&
echo "done"

echo "creating directories..."
mkdir -p /{bin,boot,dev/pts,etc/opt,home,lib,mnt,proc} &&
mkdir -p /{root,sbin,tmp,usr/local,var,opt} &&
for dirname in /usr /usr/local
    do
    mkdir $dirname/{bin,etc,include,lib,sbin,share,src}
    ln -s share/{man,doc,info} $dirname
    mkdir $dirname/share/{dict,doc,info,locale,man}
    mkdir $dirname/share/{nls,misc,terminfo,zoneinfo}
    mkdir $dirname/share/man/man{1,2,3,4,5,6,7,8}
done &&
mkdir /var/{lock,log,mail,run,spool} &&
mkdir -p /var/{tmp,opt,cache,lib/misc,local} &&
mkdir /opt/{bin,doc,include,info} &&
mkdir -p /opt/{lib,man/man{1,2,3,4,5,6,7,8}} &&
ln -s ../var/tmp /usr &&
chmod 0750 /root &&
chmod 1777 /tmp /var/tmp &&
echo "done"

echo "creating root env..."
cat > /root/.bash_profile << "EOF"
export LC_ALL=POSIX

# LFS optimization
# comment these for GCC, GLibc and binutils
export CFLAGS="-O3 -march=pentium3 -msse -mfpmath=sse"
export CXXFLAGS="-O3 -march=pentium3 -msse -mfpmath=sse"
export CPPFLAGS="-O3 -march=pentium3 -msse -mfpmath=sse"
export CC="gcc -s"
EOF
source /root/.bash_profile
echo "done"

echo "mounting proc..."
mount proc /proc -t proc &&
echo "done"

echo "creating /etc/mtab link..."
ln -sf /proc/mounts /etc/mtab &&
echo "done"

echo "creating bash/sh link..."
ln -s /usr/static/bin/bash /bin/bash &&
ln -s bash /bin/sh &&
echo "done"

echo "creating passwd and group..."
echo "root:x:0:0:root:/root:/bin/bash" > /etc/passwd &&
cat > /etc/group << "EOF"
root:x:0:
bin:x:1:
sys:x:2:
kmem:x:3:
tty:x:4:
tape:x:5:
daemon:x:6:
floppy:x:7:
disk:x:8:
lp:x:9:
dialout:x:10:
audio:x:11:
EOF
echo "done"

# echo "creating devices..."
cd $SRCDIR &&
bzcat MAKEDEV-1.7.bz2 > /dev/MAKEDEV &&
cd /dev &&
chmod 754 MAKEDEV &&
./MAKEDEV -v generic-nopty &&
echo "done"

# homepage:        http://www.kernel.org/
# source:        http://www.kernel.org/pub/linux/kernel/v2.4/linux-2.4.20.tar.gz
echo "install kernel header 2.4.20..."
cd $SRCDIR &&
bzcat linux-2.4.20.tar.bz2 | tar xf - &&
cd $SRCDIR/linux-2.4.20 &&
ln -s /usr/static/bin/pwd /bin/pwd &&
make mrproper &&
make include/linux/version.h &&
make symlinks &&
#mkdir /usr/include/asm &&
cp -HR include/asm /usr/include &&
cp -R include/asm-generic /usr/include &&
cp -R include/linux /usr/include &&
touch /usr/include/linux/autoconf.h &&
rm /bin/pwd &&
echo "done"

# homepage:        http://www.linuxfromscratch.org
# source:        ftp://ftp.kernel.org/pub/linux/docs/manpages/man-pages-1.54.tar.bz2
echo "install man-pages-1.54..."
cd $SRCDIR &&
bzcat man-pages-1.54.tar.bz2 | tar xf - &&
cd $SRCDIR/man-pages-1.54 &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/glibc.html
# source:        http://ftp.gnu.org/gnu/glibc/glibc-2.3.1.tar.gz
                http://ftp.gnu.org/gnu/glibc/glibc-linuxthreads-2.3.1.tar.gz
echo "install glibc-2.3.1..."
cd $SRCDIR &&
tar xzf glibc-2.3.1.tar.gz &&
cd $SRCDIR/glibc-2.3.1 &&
tar xzf ../glibc-linuxthreads-2.3.1.tar.gz &&
export CFLAGS="" &&
export CXXFLAGS="" &&
export CPPFLAGS="" &&
patch -Np1 -i ../glibc-2.3.1.patch &&
#patch -Np1 -i ../glibc-2.3.1-root-perl.patch &&
touch /etc/ld.so.conf &&
mkdir ../glibc-build &&
cd ../glibc-build &&
../glibc-2.3.1/configure --prefix=/usr --disable-profile \
    --enable-add-ons --libexecdir=/usr/bin &&
echo "cross-compiling = no" > configparms &&
make &&
make install &&
make localedata/install-locales &&
echo "done"

echo "type 'exit' or press Ctrl-d to continue...";;

# <---- first_time end ---->

# this will exit the first time script
# user should type 'exit' to continue to install LFS

        "2")
#!/static/bin/bash
# <---- second_time begin ---->

echo "preparing env..."
export LFS=/notexist
export BASE=/usr/static
export VER=new
export SRC=lfs-packages-$VER
export SRCDIR=$BASE/$SRC
source /root/.bash_profile
echo "done"

# homepage:        http://www.gnu.org/software/gcc/gcc.html
# source:        http://ftp.gnu.org/pub/gnu/gcc/gcc-3.2.1/gcc-3.2.1.tar.gz
# I got error when configuring in 'gcc-build' directory but the configuration
# in 'gcc-3.2.1' directory is ok, I must move the CFLAGS etc. after config
# to get it work
echo "install gcc-3.2.1..."
cd $SRCDIR &&
tar xzf gcc-3.2.1.tar.gz &&
mkdir gcc-build &&
cd gcc-build &&
../gcc-3.2.1/configure --prefix=/usr --enable-shared \
    --enable-threads=posix --with-slibdir=/lib --enable-__cxa_atexit \
    --enable-clocale=gnu &&
export CFLAGS="" &&
export CXXFLAGS="" &&
export CPPFLAGS="" &&
make bootstrap &&
make install &&
ln -s /usr/bin/cpp /lib &&
ln -s /usr/bin/cpp /usr/lib &&
ln -s /usr/bin/gcc /usr/bin/cc &&
source ~/.bash_profile &&
echo "done"

# homepage:        http://www.gzip.org/zlib/
# source:        ftp://ftp.info-zip.org/pub/infozip/zlib/zlib-1.1.4.tar.bz2
echo "install zlib-1.1.4..."
cd $SRCDIR &&
tar xzf zlib-1.1.4.tar.gz &&
cd $SRCDIR/zlib-1.1.4 &&
CFLAGS="$CFLAGS -fPIC"./configure --prefix=/usr --shared &&
make LIBS="libz.so.1.1.4 libz.a" &&
make LIBS="libz.so.1.1.4 libz.a" install &&
mv /usr/lib/libz.so.* /lib &&
ln -sf ../../lib/libz.so.1 /usr/lib/libz.so &&
cp zlib.3 /usr/share/man/man3 &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/findutils.html
# source:        http://ftp.gnu.org/pub/gnu/findutils/findutils-4.1.tar.gz
echo "install findutils-4.1..."
cd $SRCDIR &&
tar xzf findutils-4.1.tar.gz &&
cd $SRCDIR/findutils-4.1 &&
bzcat $SRCDIR/findutils-4.1.patch.bz2 | patch -Np1 -i - &&
patch -Np1 -i ../findutils-4.1-segfault.patch &&
./configure --prefix=/usr &&
make libexecdir=/usr/bin &&
make libexecdir=/usr/bin install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/gawk.html
# source:        http://ftp.gnu.org/gnu/gawk/gawk-3.1.1.tar.gz
echo "install gawk-3.1.1..."
cd $SRCDIR &&
tar xzf gawk-3.1.1.tar.gz &&
cd $SRCDIR/gawk-3.1.1 &&
patch -Np1 -i ../gawk-3.1.1-3.patch &&
./configure --prefix=/usr --libexecdir=/usr/bin &&
make &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/ncurses.html
# source:        http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.3.tar.gz
echo "install ncurses-5.3..."
cd $SRCDIR &&
tar xzf ncurses-5.3.tar.gz &&
cd $SRCDIR/ncurses-5.3 &&
./configure --prefix=/usr --with-shared &&
make &&
make install &&
chmod 755 /usr/lib/*.5.3 &&
mv /usr/lib/libncurses.so.5* /lib &&
ln -sf libncurses.a /usr/lib/libcurses.a &&
ln -sf ../../lib/libncurses.so.5 /usr/lib/libncurses.so &&
ln -sf ../../lib/libncurses.so.5 /usr/lib/libcurses.so &&
echo "done"

# homepage:        http://www.vim.org
# source:        ftp://ftp.vim.org/pub/vim/unix/vim-6.1.tar.bz2
echo "install vim-6.1..."
cd $SRCDIR &&
bzcat vim-6.1.tar.bz2 | tar xf - &&
cd $SRCDIR/vim61 &&
bzcat $SRCDIR/vim-6.1.patch.bz2 | patch -Np1 -i - &&
./configure --prefix=/usr &&
make CPPFLAGS=-DSYS_VIMRC_FILE=\\\"/etc/vimrc\\\" &&
make install &&
ln -s vim /usr/bin/vi &&
source ~/.bash_profile &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/gnum4.html
# source:        http://ftp.gnu.org/pub/gnu/m4/m4-1.4.tar.gz
echo "install m4-1.4..."
cd $SRCDIR &&
tar xzf m4-1.4.tar.gz &&
cd $SRCDIR/m4-1.4 &&
./configure --prefix=/usr &&
make &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/bison.html
# source:        http://ftp.gnu.org/pub/gnu/bison/bison-1.875.tar.bz2
echo "install bison-1.875..."
cd $SRCDIR &&
bzcat bison-1.875.tar.bz2 | tar xf - &&
cd $SRCDIR/bison-1.875 &&
./configure --prefix=/usr &&
make &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/less.html
# source:        http://www.greenwoodsoftware.com/less/less-378.tar.gz
echo "install less-378..."
cd $SRCDIR &&
tar xzf less-378.tar.gz &&
cd $SRCDIR/less-378 &&
./configure --prefix=/usr --bindir=/bin --sysconfdir=/etc &&
make &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/groff.html
# source:        http://ftp.gnu.org/pub/gnu/groff/groff-1.18.1.tar.gz
echo "install groff-1.18.1..."
cd $SRCDIR &&
tar xzf groff-1.18.1.tar.gz &&
cd $SRCDIR/groff-1.18.1 &&
./configure --prefix=/usr &&
make &&
make install &&
ln -s soelim /usr/bin/zsoelim &&
ln -s eqn /usr/bin/geqn &&
ln -s tbl /usr/bin/gtbl &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/textutils.html
# source:        http://ftp.gnu.org/pub/gnu/textutils/textutils-2.1.tar.gz
echo "install textutils-2.1..."
cd $SRCDIR &&
bzcat textutils-2.1.tar.bz2 | tar xf - &&
cd $SRCDIR/textutils-2.1 &&
./configure --prefix=/usr &&
make &&
make install &&
mv /usr/bin/{cat,head} /bin &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/sed.html
# source:        http://ftp.gnu.org/pub/gnu/sed/sed-4.0.5.tar.gz
echo "install sed-4.0.5..."
cd $SRCDIR &&
tar xzf sed-4.0.5.tar.gz &&
cd $SRCDIR/sed-4.0.5 &&
./configure --prefix=/usr --bindir=/bin &&
make &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/software/flex/
# source:        http://ftp.gnu.org/pub/gnu/non-gnu/flex/flex-2.5.4a.tar.gz
echo "install flex-2.5.4a..."
cd $SRCDIR &&
tar xzf flex-2.5.4a.tar.gz &&
cd $SRCDIR/flex-2.5.4 &&
./configure --prefix=/usr &&
make &&
make install &&
ln -s libfl.a /usr/lib/libl.a &&
cat > /usr/bin/lex << "EOF"
#!/bin/sh
# Begin /usr/bin/lex

exec /usr/bin/flex -l "$@"

# End /usr/bin/lex
EOF
chmod 755 /usr/bin/lex &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/binutils.html
# source:        http://ftp.gnu.org/gnu/binutils/binutils-2.13.2.1.tar.gz
echo "install binutils-2.13.2.1..."
cd $SRCDIR &&
bzcat binutils-2.13.2.1.tar.bz2 | tar xf - &&
cd $SRCDIR/binutils-2.13.2.1 &&
export CFLAGS="" &&
export CPPFLAGS="" &&
export CXXFLAGS="" &&
mkdir ../binutils-build &&
cd ../binutils-build &&
../binutils-2.13.2.1/configure --prefix=/usr --enable-shared &&
make tooldir=/usr &&
make tooldir=/usr install &&
make tooldir=/usr install-info &&
cp ../binutils-2.13.2.1/include/libiberty.h /usr/include &&
source /root/.bash_profile &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/fileutils.html
# source:        http://ftp.gnu.org/gnu/fileutils/fileutils-4.1.tar.gz
echo "install fileutils-4.1..."
cd $SRCDIR &&
tar xzf fileutils-4.1.tar.gz &&
cd $SRCDIR/fileutils-4.1 &&
patch -Np1 -i ../fileutils-4.1.patch &&
./configure --prefix=/usr --bindir=/bin &&
make &&
make install &&
ln -s ../../bin/install /usr/bin &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/shellutils.html
# source:        http://ftp.gnu.org/gnu/sh-utils/sh-utils-2.0.tar.gz
echo "install sh-utils-2.0..."
cd $SRCDIR &&
tar xzf sh-utils-2.0.tar.gz &&
cd $SRCDIR/sh-utils-2.0 &&
patch -Np1 -i ../sh-utils-2.0.patch &&
bzcat sh-utils-2.0-hostname.patch.bz2 | patch -Np1 -i - &&
./configure --prefix=/usr &&
make &&
make install &&
mv /usr/bin/{basename,date,echo,false,pwd} /bin &&
mv /usr/bin/{sleep,stty,su,test,true,uname} /bin &&
mv /usr/bin/chroot /usr/sbin &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/gettext.html
# source:        http://ftp.gnu.org/pub/gnu/gettext/gettext-0.11.5.tar.gz
echo "install gettext-0.11.5..."
cd $SRCDIR &&
tar xzf gettext-0.11.5.tar.gz &&
cd $SRCDIR/gettext-0.11.5 &&
./configure --prefix=/usr &&
make &&
make install &&
echo "done"

# homepage:        http://www.tazenda.demon.co.uk/phil/net-tools/
# source:        http://www.tazenda.demon.co.uk/phil/net-tools/net-tools-1.60.tar.bz2
echo "install net-tools-1.60..."
cd $SRCDIR &&
bzcat net-tools-1.60.tar.bz2 | tar xf - &&
cd $SRCDIR/net-tools-1.60 &&
yes "" | make &&
make update &&
echo "done"

# homepage:        http://www.perl.org/
# source:        http://www.cpan.org/src/stable.tar.gz
echo "install perl-5.8.0..."
cd $SRCDIR &&
tar xzf stable.tar.gz &&
cd $SRCDIR/perl-5.8.0 &&
./configure.gnu --prefix=/usr &&
make &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/texinfo.html
# source:        http://ftp.gnu.org/pub/gnu/texinfo/texinfo-4.3.tar.bz2
echo "install texinfo-4.3..."
cd $SRCDIR &&
bzcat texinfo-4.3.tar.bz2 | tar xf - &&
cd $SRCDIR/texinfo-4.3 &&
./configure --prefix=/usr &&
make &&
make install &&
make TEXMF=/usr/share/texmf install-tex &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/autoconf.html
# source:        http://ftp.gnu.org/pub/gnu/autoconf/autoconf-2.57.tar.bz2
echo "install autoconf-2.57..."
cd $SRCDIR &&
bzcat autoconf-2.57.tar.bz2 | tar xf - &&
cd $SRCDIR/autoconf-2.57 &&
./configure --prefix=/usr &&
make &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/automake.html
# source:        http://ftp.gnu.org/pub/gnu/automake/automake-1.7.2.tar.bz2
echo "install automake-1.7.2..."
cd $SRCDIR &&
bzcat automake-1.7.2.tar.bz2 | tar xf - &&
cd $SRCDIR/automake-1.7.2 &&
./configure --prefix=/usr &&
make install &&
ln -s automake-1.7 /usr/share/automake &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/bash.html
# source:        http://ftp.gnu.org/pub/gnu/bash/bash-2.05b.tar.gz
echo "install bash-2.05b..."
cd $SRCDIR &&
tar xzf bash-2.05b.tar.gz &&
cd $SRCDIR/bash-2.05b &&
./configure --prefix=/usr --bindir=/bin --enable-alias \
        --enable-arith-for-command --enable-array-variables \
        --enable-bang-history --enable-brace-expansion \
        --enable-command-timing --enable-cond-command \
        --enable-directory-stack --enable-dparen-arithmetic \
        --enable-help-builtin --enable-history --enable-job-control \
        --enable-readline --enable-select &&
make &&
make install &&
echo "done"

echo "type 'exit' or Ctrl-d to continue";;
# <---- second_time end ---->

        "3")
#!/bin/bash
# <---- third_time begin ---->

echo "preparing env..."
export LFS=/notexist
export BASE=/usr/static
export VER=new
export SRC=lfs-packages-$VER
export SRCDIR=$BASE/$SRC
source /root/.bash_profile
echo "done"

# homepage:        http://freshmeat.net/projects/file/?topic_id=861
# source:        ftp://ftp.gw.com/mirrors/pub/unix/file/file-3.39.tar.gz
echo "install file-3.39..."
cd $SRCDIR &&
tar xzf file-3.39.tar.gz &&
cd $SRCDIR/file-3.39 &&
./configure --prefix=/usr --datadir=/usr/share/misc &&
make &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/libtool.html
# source:        http://ftp.gnu.org/pub/gnu/libtool/libtool-1.4.3.tar.gz
echo "install libtool-1.4.3..."
cd $SRCDIR &&
tar xzf libtool-1.4.3.tar.gz &&
cd $SRCDIR/libtool-1.4.3 &&
./configure --prefix=/usr &&
make &&
make install &&
echo "done"

# homepage:        http://www.cix.co.uk/~mayday/
# source:        http://www.cix.co.uk/~mayday/dev86/bin86-0.16.10.tar.gz
echo "install bin86-0.16.10..."
cd $SRCDIR &&
tar xzf bin86-0.16.10.tar.gz &&
cd $SRCDIR/bin86-0.16.10 &&
make &&
make PREFIX=/usr install &&
echo "done"

# homepage:        ftp://sources.redhat.com/pub/bzip2/v102/
# source:        ftp://sources.redhat.com/pub/bzip2/v102/bzip2-1.0.2.tar.gz
echo "install bzip2-1.0.2..."
cd $SRCDIR &&
tar xzf bzip2-1.0.2.tar.gz &&
cd $SRCDIR/bzip2-1.0.2 &&
make -f Makefile-libbz2_so &&
make &&
make install &&
cp bzip2-shared /bin/bzip2 &&
ln -s libbz2.so.1.0 libbz2.so &&
cp -a libbz2.so* /lib &&
rm /lib/libbz2.so &&
ln -s ../../lib/libbz2.so.1.0 /usr/lib/libbz2.so &&
rm /usr/bin/{bunzip2,bzcat,bzip2} &&
mv /usr/bin/{bzip2recover,bzless,bzmore} /bin &&
ln -s bzip2 /bin/bunzip2 &&
ln -s bzip2 /bin/bzcat &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/ed.html
# source:        http://ftp.gnu.org/gnu/ed/ed-0.2.tar.gz
echo "install ed-0.2..."
cd $SRCDIR &&
tar xzf ed-0.2.tar.gz &&
cd $SRCDIR/ed-0.2 &&
bzcat $SRCDIR/ed-0.2.patch.bz2 | patch -Np1 -i - &&
./configure --prefix=/usr &&
make &&
make install &&
mv /usr/bin/{ed,red} /bin &&
echo "done"

# homepage:        http://freshmeat.net/projects/kbd/?topic_id=861
# source:        ftp://ftp.win.tue.nl/pub/home/aeb/linux-local/utils/kbd/kbd-1.08.tar.gz
echo "install kbd-1.08..."
cd $SRCDIR &&
bzcat kbd-1.08.tar.bz2 | tar xf - &&
cd $SRCDIR/kbd-1.08 &&
patch -Np1 -i ../kbd-1.08.patch &&
./configure &&
make &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/diffutils.html
# source:        http://ftp.gnu.org/pub/gnu/diffutils/diffutils-2.8.1.tar.gz
echo "install diffutils-2.8.1..."
cd $SRCDIR &&
tar xzf diffutils-2.8.1.tar.gz &&
cd $SRCDIR/diffutils-2.8.1 &&
./configure --prefix=/usr &&
make &&
make install &&
echo "done"

# homepage:        http://e2fsprogs.sourceforge.net/
# source:        http://unc.dl.sourceforge.net/sourceforge/e2fsprogs/e2fsprogs-1.32.tar.gz
echo "install e2fsprogs-1.32..."
cd $SRCDIR &&
tar xzf e2fsprogs-1.32.tar.gz &&
cd $SRCDIR/e2fsprogs-1.32 &&
mkdir ../e2fsprogs-build &&
cd ../e2fsprogs-build &&
../e2fsprogs-1.32/configure --prefix=/usr --with-root-prefix="" \
    --enable-elf-shlibs &&
make &&
make install &&
make install-libs &&
install-info /usr/share/info/libext2fs.info /usr/share/info/dir &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/grep.html
# source:        http://ftp.gnu.org/pub/gnu/grep/grep-2.5.tar.gz
echo "install grep-2.5..."
cd $SRCDIR &&
bzcat grep-2.5.tar.bz2 | tar xf - &&
cd $SRCDIR/grep-2.5 &&
./configure --prefix=/usr --bindir=/bin &&
make &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/gzip.html
# source:        http://ftp.gnu.org/gnu/make/gzip/gzip-1.2.4a.tar.gz
echo "install gzip-1.2.4a..."
cd $SRCDIR &&
tar xzf gzip-1.2.4a.tar.gz &&
cd $SRCDIR/gzip-1.2.4a &&
bzcat ../gzip-1.2.4b.patch.bz2 | patch -Np1 -i - &&
./configure --prefix=/usr &&
cp gzexe.in{,.backup} &&
sed 's%"BINDIR"%/bin%' gzexe.in.backup > gzexe.in &&
make &&
make install &&
mv /usr/bin/gzip /bin &&
rm /usr/bin/{gunzip,zcat} &&
ln -s gzip /bin/gunzip &&
ln -s gzip /bin/zcat &&
ln -s gunzip /bin/uncompress &&
echo "done"

# homepage:        ftp://ftp.win.tue.nl/pub/linux-local/utils/man/
# source:        ftp://ftp.win.tue.nl/pub/linux-local/utils/man/man-1.5k.tar.gz
echo "install man-1.5k..."
cd $SRCDIR &&
tar xzf man-1.5k.tar.gz &&
cd $SRCDIR/man-1.5k &&
patch -Np1 -i ../man-1.5k-2.patch &&
PATH=$PATH:/usr/bin:/bin \
    ./configure -default -confdir=/etc &&
make &&
make install &&
echo "done"

# homepage:        http://nasm.sourceforge.net/
# source:        http://unc.dl.sourceforge.net/sourceforge/nasm/nasm-0.98.35.tar.bz2
echo "install nasm-0.98.35..."
cd $SRCDIR &&
bzcat nasm-0.98.35.tar.bz2 | tar xf - &&
cd $SRCDIR/nasm-0.98.35 &&
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var &&
make &&
make install &&
echo "done"

# homepage:        http://www.brun.dyndns.org/pub/linux/lilo/
# source:        http://home.san.rr.com/johninsd/pub/linux/lilo/lilo-22.3.4.tar.gz
echo "install lilo-22.3.4..."
cd $SRCDIR &&
tar xzf lilo-22.3.4.tar.gz &&
cd $SRCDIR/lilo-22.3.4 &&
make &&
make install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/make.html
# source:        http://ftp.gnu.org/pub/gnu/make/make-3.80.tar.bz2
echo "install make-3.80..."
cd $SRCDIR &&
bzcat make-3.80.tar.bz2 | tar xf - &&
cd $SRCDIR/make-3.80 &&
./configure --prefix=/usr &&
make &&
make install &&
chgrp root /usr/bin/make &&
chmod 755 /usr/bin/make &&
echo "done"

# homepage:        ftp://ftp.kernel.org/pub/linux/utils/kernel/modutils/
# source:        ftp://ftp.kernel.org/pub/linux/utils/kernel/modutils/v2.4/modutils-2.4.22.tar.bz2
echo "install modutils-2.4.22..."
cd $SRCDIR &&
bzcat modutils-2.4.22.tar.bz2 | tar xf - &&
cd $SRCDIR/modutils-2.4.22 &&
./configure &&
make &&
make install &&
echo "done"

# homepage:        ftp://ftp.uk.linux.org/pub/linux/Networking/netkit/
# source:        ftp://ftp.uk.linux.org/pub/linux/Networking/netkit/netkit-base-0.17.tar.gz
echo "install netkit-base-0.17..."
cd $SRCDIR &&
tar xzf netkit-base-0.17.tar.gz &&
cd $SRCDIR/netkit-base-0.17 &&
./configure &&
make &&
make install &&
cp etc.sample/{services,protocols} /etc &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/patch.html
# source:        http://ftp.gnu.org/pub/gnu/patch/patch-2.5.4.tar.gz
echo "install patch-2.5.4..."
cd $SRCDIR &&
tar xzf patch-2.5.4.tar.gz &&
cd $SRCDIR/patch-2.5.4 &&
CPPFLAGS=-D_GNU_SOURCE \
    ./configure --prefix=/usr &&
make &&
make install &&
echo "done"

# homepage:        ftp://ftp.cistron.nl/pub/people/svm/
# source:        ftp://ftp.cistron.nl/pub/people/svm/procinfo-18.tar.gz
echo "install procinfo-18..."
cd $SRCDIR &&
tar xzf procinfo-18.tar.gz &&
cd $SRCDIR/procinfo-18 &&
make LDLIBS=-lncurses &&
make install &&
echo "done"

# homepage:        http://procps.sourceforge.net/
# source:        http://procps.sourceforge.net/procps-3.1.5.tar.gz
echo "install procps-3.1.5..."
cd $SRCDIR &&
tar xzf procps-3.1.5.tar.gz &&
cd $SRCDIR/procps-3.1.5 &&
patch -Np1 -i ../procps-3.1.5.patch &&
make &&
make XSCPT="" install &&
echo "done"

# homepage:        http://psmisc.sourceforge.net/
# source:        http://unc.dl.sourceforge.net/sourceforge/psmisc/psmisc-21.2.tar.gz
echo "install psmisc-21.2..."
cd $SRCDIR &&
tar xzf psmisc-21.2.tar.gz &&
cd $SRCDIR/psmisc-21.2 &&
./configure --prefix=/usr --exec-prefix=/ &&
make &&
make install &&
echo "done"

# homepage:        ftp://ftp.pld.org.pl/software/shadow/
# source:        ftp://ftp.pld.org.pl/software/shadow/shadow-4.0.3.tar.bz2
echo "install shadow-4.0.3..."
cd $SRCDIR &&
bzcat shadow-4.0.3.tar.bz2 | tar xf - &&
cd $SRCDIR/shadow-4.0.3 &&
./configure --prefix=/usr \
    --libdir=/usr/lib --enable-shared &&
make &&
make install &&
cp etc/{limits,login.access} /etc &&
sed 's%/var/spool/mail%/var/mail%' \
    etc/login.defs.linux > /etc/login.defs &&
ln -s vipw /usr/sbin/vigr &&
rm /bin/vipw &&
mv /bin/sg /usr/bin &&
mv /usr/lib/lib{shadow,misc}.so.0* /lib &&
ln -sf ../../lib/libshadow.so.0 /usr/lib/libshadow.so &&
ln -sf ../../lib/libmisc.so.0 /usr/lib/libmisc.so &&
mv /etc/login.defs /etc/login.defs.bak &&
sed -e 's/^#MD5_CRYPT_ENAB.*no/MD5_CRYPT_ENAB yes/' \
        /etc/login.defs.bak > /etc/login.defs &&
rm /etc/login.defs.bak &&
echo "done"

# homepage:        http://freshmeat.net/projects/sysklogd/
# source:        http://www.ibiblio.org/pub/Linux/system/daemons/sysklogd-1.4.1.tar.gz
echo "install sysklogd-1.4.1..."
cd $SRCDIR &&
tar xzf sysklogd-1.4.1.tar.gz &&
cd $SRCDIR/sysklogd-1.4.1 &&
make &&
make install &&
echo "done"

# homepage:        http://freshmeat.net/projects/sysvinit/
# source:        ftp://ftp.cistron.nl/pub/people/miquels/sysvinit/sysvinit-2.84.tar.gz
echo "install sysvinit-2.84..."
cd $SRCDIR &&
tar xzf sysvinit-2.84.tar.gz &&
cd $SRCDIR/sysvinit-2.84 &&
cp src/init.c{,.backup} &&
sed 's/Sending processes/Sending processes started by init/g' \
    src/init.c.backup > src/init.c &&
make -C src &&
make -C src install &&
echo "done"

# homepage:        http://www.gnu.org/directory/GNU/tar.html
# source:        http://ftp.gnu.org/pub/gnu/tar/tar-1.13.tar.gz
echo "install tar-1.13..."
cd $SRCDIR &&
tar xzf tar-1.13.tar.gz &&
cd $SRCDIR/tar-1.13 &&
bzcat ../tar-1.13.patch.bz2 | patch -Np1 -i - &&
./configure --prefix=/usr \
    --libexecdir=/usr/bin --bindir=/bin &&
make &&
make install &&
echo "done"

# homepage:        http://ftp.kernel.org/pub/linux/utils/util-linux/
# source:        http://ftp.kernel.org/pub/linux/utils/util-linux/util-linux-2.11y.tar.bz2
echo "install util-linux-2.11y..."
cd $SRCDIR &&
tar xzf util-linux-2.11y.tar.gz &&
cd $SRCDIR/util-linux-2.11y &&
./configure &&
make HAVE_SLN=yes &&
make HAVE_SLN=yes install &&
echo "done"

# install linux manpage
echo "install linux manpages..."
cd $SRCDIR/linux-2.4.20 &&
make mandocs &&
cp -a Documentation/man /usr/share/man/man9 &&
echo "done"

# install glibc-2.3.1 again
echo "re-install glibc-2.3.1..."
cd $SRCDIR &&
rm -fr glibc-2.3.1 &&
rm -fr glibc-build &&
tar xzf glibc-2.3.1.tar.gz &&
cd $SRCDIR/glibc-2.3.1 &&
tar xzf ../glibc-linuxthreads-2.3.1.tar.gz &&
mkdir ../glibc-build &&
cd ../glibc-build &&
export CFLAGS="" &&
export CXXFLAGS="" &&
export CPPFLAGS="" &&
../glibc-2.3.1/configure --prefix=/usr --disable-profile \
    --enable-add-ons --libexecdir=/usr/bin &&
make &&
make install &&
make -C ../glibc-2.3.1/linuxthreads/man &&
make -C ../glibc-2.3.1/linuxthreads/man install &&
echo "done"

echo "type 'exit' or press Ctrl-d to continue...";;

# <---- third_time end ---->

# this will exit the third time script
# user should type 'exit' to continue to install LFS

      "4")
#!/static/bin/bash
# <---- fourth_time begin ---->

echo "preparing env..."
export LFS=/notexist
export BASE=/usr/static
export VER=new
export SRC=lfs-packages-$VER
export SRCDIR=$BASE/$SRC
source /root/.bash_profile
echo "done"

# homepage:        http://www.linuxfromscratch.org/
# source:        ftp://ftp.linuxfromscratch.org/lfs-packages/cvs/lfs-bootscripts-1.10.tar.bz2
echo "install lfs-bootscripts-1.10..."
cd $SRCDIR &&
bzcat lfs-bootscripts-1.10.tar.bz2 | tar xf - &&
cd $SRCDIR/lfs-bootscripts-1.10 &&
cp -a rc.d sysconfig /etc &&
chown -R root:root /etc/rc.d /etc/sysconfig &&
echo "done"

echo "configuring vim..."
cd $SRCDIR &&
cp /usr/share/vim/vim61/vimrc_example.vim ~/.vimrc &&
echo "done"

echo "configuring glibc..."
cd $SRCDIR &&
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
cd /etc &&
ln -sf ../usr/share/zoneinfo/Hongkong localtime &&
echo "done"

echo "configuring dynamic loader..."
cd $SRCDIR &&
cat > /etc/ld.so.conf << "EOF"
# Begin /etc/ld.so.conf

/usr/local/lib
/opt/lib

# End /etc/ld.so.conf
EOF
echo "done"

echo "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
echo "done"

echo "configuring shadow password suite..."
/usr/sbin/pwconv &&
echo "done"

echo "configuring sysvinit..."
cat > /etc/inittab << "EOF"
# Begin /etc/inittab

id:3:initdefault:

si::sysinit:/etc/rc.d/init.d/rc sysinit

l0:0:wait:/etc/rc.d/init.d/rc 0
l1:S1:wait:/etc/rc.d/init.d/rc 1
l2:2:wait:/etc/rc.d/init.d/rc 2
l3:3:wait:/etc/rc.d/init.d/rc 3
l4:4:wait:/etc/rc.d/init.d/rc 4
l5:5:wait:/etc/rc.d/init.d/rc 5
l6:6:wait:/etc/rc.d/init.d/rc 6

#ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

su:S016:once:/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
echo "done"

echo "configuring keyboard..."
echo "skipping..."
echo "done"

echo "creating /var/run..."
touch /var/run/utmp /var/log/{btmp,lastlog,wtmp} &&
chmod 644 /var/run/utmp /var/log/{btmp,lastlog,wtmp} &&
echo "done"

echo "setting root password..."
passwd root
echo "done"

# chapter 7
echo "configuring setclock..."
cat > /etc/sysconfig/clock << "EOF"
# Begin /etc/sysconfig/clock

UTC=1

# End /etc/sysconfig/clock
EOF
echo "done"

echo "delete the loadkey script..."
rm /etc/rc.d/rcsysinit.d/S70loadkeys &&
echo "done"

echo "configuring localnet..."
echo "skip..."
echo "done"

echo "creating /etc/hosts..."
cat > /etc/hosts << "EOF"
# Begin /etc/hosts (network card version)

127.0.0.1 localhost.localdomain localhost
137.189.90.26 pc90026.cse.cuhk.edu.hk pc90026

# End /etc/hosts (network card version)
EOF
echo "done"

echo "creating network interface configuration..."
cat >> /etc/sysconfig/network << "EOF"
# Begin /etc/sysconfig/network (network card version)

NETWORKING=yes
GATEWAY_IF=eth0
#HOSTNAME=lfs
HOSTNAME=pc90026.cse.cuhk.edu.hk
DOMAINNAME=cse.cuhk.edu.hk
GATEWAY=137.189.91.254

# End /etc/sysconfig/network (network card version)
EOF
cat > /etc/sysconfig/network-devices/ifconfig.eth0 << "EOF"
ONBOOT=yes
IP=137.189.90.26
NETMASK=255.255.252.0
BROADCAST=137.189.91.255
EOF
#cat > /etc/sysconfig/network-devices/ifup-eth0 << "EOF"
##!/bin/bash
#/usr/local/sbin/dhcpcd
#EOF
#chmod 755 /etc/sysconfig/network-devices/ifup-eth0 &&
echo "done"

echo "creating /etc/resolv.conf"
cat > /etc/resolv.conf << "EOF"
# Begin /etc/resolv.conf

nameserver 137.189.91.187
nameserver 137.189.91.188

# End /etc/resolv.conf
EOF
echo "done"

echo "creating /etc/fstab..."
cat > /etc/fstab << "EOF"
# Begin /etc/fstab

# filesystem   mount-point fs-type    options   dump    fsck-order

/dev/hda1      /         ext3       defaults    1       1
/dev/hda2      /usr      ext3       defaults    1       2
/dev/hda3      /var      ext3       defaults    1       2
/dev/hda5      swap      swap       pri=1       0       0
/dev/hda6      /home       ext3       defaults    1       2
proc         /proc       proc       defaults    0       0
devpts         /dev/pts    devpts   gid=4,mode=620 0    0
#usbdevfs      /proc/bus/usb usbdevfs defaults    0       0

# End /etc/fstab
EOF
echo "done"

echo "install /etc/modules.conf..."
cat > /etc/modules.conf << "EOF"
# Begin /etc/modules.conf

alias parport_lowlevel parport_pc
alias eth0 3c59x
alias sound-slot-0 es1371
#alias sound-slot-0 maestro3
#alias usb-controller usb-uhci

# End /etc/modules.conf
EOF
echo "done"

echo "install linux-2.4.20..."
cd /usr/src &&
bzcat $SRCDIR/linux-2.4.20.tar.bz2 | tar xf - &&
ln -sf linux-2.4.20 linux &&
cd linux &&
make mrproper &&
cp $SRCDIR/kernel.config .config &&
make menuconfig
make dep &&
make bzImage &&
make modules &&
make modules_install &&
cp arch/i386/boot/bzImage /boot/lfskernel &&
cp System.map /boot
echo "done"

echo "configuring lilo..."
cat > /etc/lilo.conf << "EOF"
boot=/dev/hda
map=/boot/System.map
install=/boot/boot.b
prompt
timeout=50
default=lfs
#message=/boot/message
lba32

image=/boot/lfskernel
      label=lfs
      root=/dev/hda1
      read-only
EOF
/sbin/lilo -v -b /dev/hda &&
echo "done"

echo "stripping..."
find /{,usr/,usr/local/}{bin,sbin,lib} -type f \
   -exec /usr/bin/strip --strip-debug '{}' ';' &&
echo 4.0 > /etc/lfs &&
echo "done"

echo "modify partition label"
e2label /dev/hda1 /
e2label /dev/hda2 /usr
e2label /dev/hda3 /var
e2label /dev/hda6 /home
echo "done";;

# <---- fourth_time end ---->
        *) echo "invalid argument";;
esac

tram 发表于 2003-6-17 00:31:24

no,no,no
这个不好,好的脚本有很多,但个人并不推荐用脚本或自动编译工具,LFS的优势不是编译,是学习。

carlos 发表于 2003-6-17 21:33:53

LFS的优势不是编译,是学习。
absolutely right

dalin 发表于 2003-6-17 23:14:38

no,no,no
这个不好,好的脚本有很多,但个人并不推荐用脚本或自动编译工具,LFS的优势不是编译,是学习。
绝对赞成,如果为了使用而去装LFS,我还不如乖乖用windows呢。

Kuye 发表于 2003-6-26 00:25:09

说真的(我这个人比较懒啊。。。)

我觉得可以自己试着写自动编译脚本编译 LFS。。。

atfa 发表于 2003-6-26 00:43:55

把这个写出来你就是牛人了
页: [1]
查看完整版本: What't This!!