Archaic wrote: > On Wed, Aug 10, 2005 at 07:25:27AM +0100, Richard A Downing wrote: > >>My way now is never to type the commands directly, but create a >>scriptlet for each package built from a template that is essentially >>Bruce's script plus some checks. > > > And to take automation one step further, you could put Bruce's code into > a functions file and call it from the scriptlet to further reduce > duplicated code. And then, you can write a very simple script to > combine those scriptlets. Before you know it, you are typing one > command and coming back a few hours later to a finished product. :) >
Do you mean something like this? :) -- Bruce
#!/tools/bin/bash echo "Starting Chapter 6" export PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin export TZ=CST6CDT set +h SCRIPTDIR=/tools/src/scripts cd /tools/src # Change ownershp of everything to root chown -R 0:0 /tools # Create the directories install -d /{bin,boot,dev,etc/opt,home,lib,mnt} install -d /{sbin,srv,usr/local,var,opt} install -d /root -m 0750 install -d /tmp /var/tmp -m 1777 install -d /media/{floppy,cdrom} install -d /usr/{bin,include,lib,sbin,share,src} ln -sf share/{man,doc,info} /usr install -d /usr/share/{doc,info,locale,man} install -d /usr/share/{misc,terminfo,zoneinfo} install -d /usr/share/man/man{1,2,3,4,5,6,7,8} install -d /usr/local/{bin,etc,include,lib,sbin,share,src} ln -sf share/{man,doc,info} /usr/local install -d /usr/local/share/{doc,info,locale,man} install -d /usr/local/share/{misc,terminfo,zoneinfo} install -d /usr/local/share/man/man{1,2,3,4,5,6,7,8} install -d /var/{lock,log,mail,run,spool} install -d /var/{opt,cache,lib/{misc,locate},local} install -d /opt/{bin,doc,include,info} install -d /opt/{lib,man/man{1,2,3,4,5,6,7,8}} # Make essential symlinks ln -sf /tools/bin/{bash,pwd,cat,stty} /bin ln -sf /tools/bin/perl /usr/bin ln -sf /tools/lib/libgcc_s.so.1 /usr/lib ln -sf bash /bin/sh # Password and group files cat > /etc/passwd << "EOF" root:x:0:0:root:/root:/bin/bash EOF 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: video:x:12: utmp:x:13: usb:x:14: EOF touch /var/run/utmp /var/log/{btmp,lastlog,wtmp} chgrp utmp /var/run/utmp /var/log/lastlog chmod 664 /var/run/utmp /var/log/lastlog # Make devices mknod -m 600 /dev/console c 5 1 mknod -m 666 /dev/null c 1 3 touch /etc/fstab mount -n -t ramfs none /dev /tools/sbin/udevstart ln -sf /proc/self/fd /dev/fd ln -sf /proc/self/fd/0 /dev/stdin ln -sf /proc/self/fd/1 /dev/stdout ln -sf /proc/self/fd/2 /dev/stderr ln -sf /proc/kcore /dev/core mkdir -p /dev/pts mkdir -p /dev/shm mount -t devpts -o gid=4,mode=620 none /dev/pts mount -t tmpfs none /dev/shm ################### $SCRIPTDIR/make6-kernel-headers || { echo "make6-kernel-headers failed" ; exit 1; } $SCRIPTDIR/make6-man-pages || { echo "make6-man-pages failed" ; exit 1; } $SCRIPTDIR/make6-glibc || { echo "make6-glibc failed" ; exit 1; } ################### # Re-adjust the toolchain BINUTILS=binutils-2.15.91.0.2 before2=`df -k / | grep / | sed -e "s/ \{2,\}/ /g" | cut -d' ' -f3` time { \ { echo "Readjusting Toolchain" date pushd binutils-build && make -C ld INSTALL=/tools/bin/install install && popd && rm -rf binutils-build && rm -rf $BINUTILS && sed -i 's@ /tools/lib/ld-linux.so.2@ /lib/[EMAIL PROTECTED]' `gcc --print-file specs` } } 2>&1 | tee -a build.log # Note - not '../build.log' here if [ $PIPESTATUS -ne 0 ]; then exit 1; fi; after2=`df -k / | grep / | sed -e "s/ \{2,\}/ /g" | cut -d" " -f3` echo "$(($after2-$before2)) kilobytes / build size - $PROGRAM" | tee -a build.log echo 'main(){}' > dummy.c echo "cc dummy.c" | tee -a build.log cc dummy.c 2>&1 | tee -a build.log if [ $PIPESTATUS -ne 0 ]; then echo "Failure in Toolchain check"; exit 1; fi; readelf -l a.out | grep ': /lib' | tee -a build.log rm dummy.c a.out ################### $SCRIPTDIR/make6-binutils || { echo "make6-bunutils failed" ; exit 1; } $SCRIPTDIR/make6-gcc || { echo "make6-gcc failed" ; exit 1; } mount -t ext3 /dev/hda1 /boot $SCRIPTDIR/make6-coreutils || { echo "make6-coreutils failed" ; exit 1; } $SCRIPTDIR/make6-zlib || { echo "make6-zlib failed" ; exit 1; } $SCRIPTDIR/make6-mktemp || { echo "make6-mktemp failed" ; exit 1; } $SCRIPTDIR/make6-iana-etc || { echo "make6-iana-etc failed" ; exit 1; } $SCRIPTDIR/make6-findutils || { echo "make6-findutils failed" ; exit 1; } $SCRIPTDIR/make6-gawk || { echo "make6-gawk failed" ; exit 1; } $SCRIPTDIR/make6-ncurses || { echo "make6-ncurses failed" ; exit 1; } $SCRIPTDIR/make6-readline || { echo "make6-readline failed" ; exit 1; } $SCRIPTDIR/make6-vim || { echo "make6-vim failed" ; exit 1; } $SCRIPTDIR/make6-m4 || { echo "make6-m4 failed" ; exit 1; } $SCRIPTDIR/make6-bison || { echo "make6-bison failed" ; exit 1; } $SCRIPTDIR/make6-less || { echo "make6-less failed" ; exit 1; } $SCRIPTDIR/make6-groff || { echo "make6-groff failed" ; exit 1; } $SCRIPTDIR/make6-sed || { echo "make6-sed failed" ; exit 1; } $SCRIPTDIR/make6-flex || { echo "make6-flex failed" ; exit 1; } $SCRIPTDIR/make6-gettext || { echo "make6-gettext failed" ; exit 1; } $SCRIPTDIR/make6-inetutils || { echo "make6-inetutils failed" ; exit 1; } $SCRIPTDIR/make6-iproute2 || { echo "make6-iproute2 failed" ; exit 1; } $SCRIPTDIR/make6-perl || { echo "make6-perl failed" ; exit 1; } $SCRIPTDIR/make6-texinfo || { echo "make6-texinfo failed" ; exit 1; } $SCRIPTDIR/make6-autoconf || { echo "make6-autoconf failed" ; exit 1; } $SCRIPTDIR/make6-automake || { echo "make6-automake failed" ; exit 1; } $SCRIPTDIR/make6-bash || { echo "make6-bash failed" ; exit 1; } $SCRIPTDIR/make6-file || { echo "make6-file failed" ; exit 1; } $SCRIPTDIR/make6-libtool || { echo "make6-libtool failed" ; exit 1; } $SCRIPTDIR/make6-bzip2 || { echo "make6-bzip2 failed" ; exit 1; } $SCRIPTDIR/make6-diffutils || { echo "make6-diffutils failed" ; exit 1; } $SCRIPTDIR/make6-kbd || { echo "make6-kbd failed" ; exit 1; } $SCRIPTDIR/make6-e2fsprogs || { echo "make6-e2fsprogs failed" ; exit 1; } $SCRIPTDIR/make6-grep || { echo "make6-grep failed" ; exit 1; } $SCRIPTDIR/make6-grub || { echo "make6-grub failed" ; exit 1; } $SCRIPTDIR/make6-gzip || { echo "make6-gzip failed" ; exit 1; } $SCRIPTDIR/make6-man || { echo "make6-man failed" ; exit 1; } $SCRIPTDIR/make6-make || { echo "make6-make failed" ; exit 1; } $SCRIPTDIR/make6-mod-init-tools || { echo "make6-mod-init-tools failed" ; exit 1; } $SCRIPTDIR/make6-patch || { echo "make6-patch failed" ; exit 1; } $SCRIPTDIR/make6-procps || { echo "make6-procps failed" ; exit 1; } $SCRIPTDIR/make6-psmisc || { echo "make6-psmisc failed" ; exit 1; } $SCRIPTDIR/make6-shadow || { echo "make6-shadow failed" ; exit 1; } $SCRIPTDIR/make6-sysklogd || { echo "make6-sysklogd failed" ; exit 1; } $SCRIPTDIR/make6-sysvinit || { echo "make6-sysvinit failed" ; exit 1; } $SCRIPTDIR/make6-tar || { echo "make6-tar failed" ; exit 1; } $SCRIPTDIR/make6-udev || { echo "make6-udev failed" ; exit 1; } $SCRIPTDIR/make6-util-linux || { echo "make6-util-linux failed" ; exit 1; } ################### #### Start Chapter 7 export PATH=/bin:/usr/bin:/sbin:/usr/sbin before2=`df -k / | grep / | sed -e "s/ \{2,\}/ /g" | cut -d' ' -f3` BOOTSCRIPTS=lfs-bootscripts-2.2.2 tar -jxf $BOOTSCRIPTS.tar.bz2 cd $BOOTSCRIPTS { time \ { echo "Installing Bootscripts" date make install } } 2>&1 | tee -a ../build.log echo "`du -k ../$BOOTSCRIPTS.tar.bz2` size" | tee -a ../build.log after2=`df -k / | grep / | sed -e "s/ \{2,\}/ /g" | cut -d" " -f3` echo "$(($after2-$before2)) kilobytes / build size - Bootscripts" | tee -a ../build.log cd .. rm -r $BOOTSCRIPTS ######## #ln -s path/to/keymap /usr/share/kbd/keymaps/defkeymap.map.gz #loadkeys -m /usr/share/kbd/keymaps/defkeymap.map.gz > \ # /usr/src/linux-2.4.22/drivers/char/defkeymap.c ######### # Configuring the setclock script cat > /etc/sysconfig/clock << "EOF" # Begin /etc/sysconfig/clock UTC=1 # End /etc/sysconfig/clock EOF # Creating the /etc/inputrc file cat > /etc/inputrc << "EOF" # Begin /etc/inputrc # Modified by Chris Lynn <[EMAIL PROTECTED]> # Make sure we don't output everything on the 1 line set horizontal-scroll-mode Off # Enable 8bit input set meta-flag On set input-meta On # Turns off 8th bit stripping set convert-meta Off # Keep the 8th bit for display set output-meta On # none, visible or audible set bell-style none # Give alternatives immediately set show-all-if-ambiguous on # All of the following map the escape sequence of the # value contained inside the 1st argument to the # readline specific functions "\eOd": backward-word "\eOc": forward-word # for linux console "\e[1~": beginning-of-line "\e[4~": end-of-line "\e[5~": beginning-of-history "\e[6~": end-of-history "\e[3~": delete-char "\e[2~": quoted-insert # for xterm "\eOH": beginning-of-line "\eOF": end-of-line # for Konsole "\e[H": beginning-of-line "\e[F": end-of-line # End /etc/inputrc EOF # Bash Shell Startup Files cat > /etc/profile << "EOF" # Begin /etc/profile export LC_ALL=en_US export LANG=en_US export INPUTRC=/etc/inputrc # End /etc/profile EOF # Configuring the localnet script echo "HOSTNAME=station1" > /etc/sysconfig/network # Creating the /etc/hosts file cat > /etc/hosts << "EOF" # Begin /etc/hosts (network card version) 127.0.0.1 localhost.localdomain localhost 10.11.130.210 station1.sac.accd.edu station1 s1 10.11.130.181 station2.sac.accd.edu station2 s2 10.11.130.211 station3.sac.accd.edu station3 s3 10.11.130.194 station4.sac.accd.edu station4 s4 10.11.130.199 station5.sac.accd.edu station5 s5 10.11.130.204 station6.sac.accd.edu station6 s6 10.11.130.47 station7.sac.accd.edu station7 s7 10.11.131.7 station8.sac.accd.edu station8 s8 10.11.130.235 station9.sac.accd.edu station9 s9 10.11.131.22 station10.sac.accd.edu station10 s10 10.11.130.201 station11.sac.accd.edu station11 s11 10.11.130.197 station12.sac.accd.edu station12 s12 10.11.131.12 station13.sac.accd.edu station13 s13 10.11.130.89 station14.sac.accd.edu station14 s14 # End /etc/hosts (network card version) EOF # Configuring the network script pushd /etc/sysconfig/network-devices && mkdir ifconfig.eth0 &&cat > ifconfig.eth0/ipv4 << "EOF" ONBOOT=yes SERVICE=ipv4-static IP=10.11.130.210 GATEWAY=10.11.130.1 PREFIX=23 BROADCAST=10.11.131.255 EOF popd cat > /etc/resolv.conf << "EOF" # Begin /etc/resolv.conf search cis.sac.accd.edu nameserver 10.12.100.25 nameserver 10.12.0.11 nameserver 10.12.100.7 # End /etc/resolv.conf EOF ##### Start Chapter 8 cat > /etc/fstab << "EOF" # Begin /etc/fstab # filesystem mount-point fs-type options dump fsck # order /dev/hda1 /boot ext3 defaults 1 2 /dev/hda2 /home ext3 defaults 1 2 /dev/hda5 / ext3 defaults 1 1 /dev/hda3 swap swap pri=1 0 0 ramfs /dev ramfs defaults 0 0 proc /proc proc defaults 0 0 sysfs /sys sysfs defaults 0 0 devpts /dev/pts devpts gid=4,mode=620 0 0 shm /dev/shm tmpfs defaults 0 0 #usbfs /proc/bus/usb usbfs devgid=14,devmode=0660 0 0 /dev/cdrom /media/cdrom auto defaults,noauto,owner,ro 0 0 /dev/fd0 /media/floppy auto noauto,owner 0 0 # End /etc/fstab EOF # Fix a problem with mountfs sed -i -e "26i\ \t\tmount -f /dev || failed=1" /etc/rc.d/init.d/mountfs $SCRIPTDIR/make6-kernel || { echo "make6-kernel failed" ; exit 1; } #### Chapter 9 date=$(date +%Y%m%d) echo "6.0-$date" > /etc/lfs-build-info #### Finish echo "Strip binaries and libraries from within the new environment:" find /{,usr/}{bin,lib,sbin} -type f -exec strip --strip-debug {} \; 2>/dev/null echo "Copy kernel and System.map to /boot" echo "Set up /boot/grub/menu.lst" cat > /boot/grub/menu.lst << EOF # grub configuration file default=0 timeout=30 title LFS 6.0 root (hd0,0) kernel /linux-2.6.8.1-$date root=/dev/hda5 EOF pushd /boot/grub ln -s menu.lst grub.conf popd umount /boot echo "Chapters 6, 7, and 8 are finished." echo "1. Update HOSTNAME in /etc/sysconfig/network" echo "2. Update IP address in /etc/sysconfig/network-devices/ifconfig.eth0/ipv4" echo "3. Run GRUB" echo "4. Remove CD" echo "5. Reboot" exit 0
-- http://linuxfromscratch.org/mailman/listinfo/blfs-dev FAQ: http://www.linuxfromscratch.org/blfs/faq.html Unsubscribe: See the above information page