From 0170229c2bdeb79d77b0ae706b7480221c3df022 Mon Sep 17 00:00:00 2001 From: Manuel Canales Esparcia Date: Tue, 7 Mar 2006 20:02:53 +0000 Subject: [PATCH] Added base files from George's jhalfs-experimental-2 POC. WARNING: This code is broken due files renaming. --- BLFS/blfs.xsl | 190 ++++++ BLFS/config | 30 + BLFS/master.sh | 100 +++ CLFS/clfs.xsl | 0 CLFS/config | 66 ++ CLFS/master.sh | 1318 +++++++++++++++++++++++++++++++++++++ HLFS/config | 38 ++ HLFS/functions | 59 ++ HLFS/hlfs.xsl | 230 +++++++ HLFS/master.sh | 662 +++++++++++++++++++ HLFS/patcheslist.xsl | 25 + LFS/config | 34 + LFS/lfs.xsl | 196 ++++++ LFS/master.sh | 392 +++++++++++ blfs | 1 + clfs | 1 + common/common-functions | 801 ++++++++++++++++++++++ common/config | 49 ++ common/makefile-functions | 105 +++ hlfs | 1 + lfs | 1 + master.sh | 457 +++++++++++++ 22 files changed, 4756 insertions(+) create mode 100644 BLFS/blfs.xsl create mode 100644 BLFS/config create mode 100755 BLFS/master.sh create mode 100644 CLFS/clfs.xsl create mode 100644 CLFS/config create mode 100755 CLFS/master.sh create mode 100644 HLFS/config create mode 100644 HLFS/functions create mode 100644 HLFS/hlfs.xsl create mode 100755 HLFS/master.sh create mode 100644 HLFS/patcheslist.xsl create mode 100644 LFS/config create mode 100644 LFS/lfs.xsl create mode 100755 LFS/master.sh create mode 120000 blfs create mode 120000 clfs create mode 100644 common/common-functions create mode 100644 common/config create mode 100644 common/makefile-functions create mode 120000 hlfs create mode 120000 lfs create mode 100755 master.sh diff --git a/BLFS/blfs.xsl b/BLFS/blfs.xsl new file mode 100644 index 0000000..6f7e28c --- /dev/null +++ b/BLFS/blfs.xsl @@ -0,0 +1,190 @@ + + + + + + + + + + + + ftp://anduin.linuxfromscratch.org/BLFS/conglomeration + + + + + + + + + + + + + + + + + + + + + + + #!/bin/sh set -e + + + + + + cd ~/sources/ + + rm -rf $UNPACKDIR + + exit + + + + + + + + + + + + mkdir -p ~/sources/ + + cd ~/sources/ + + + + + + + + + + tar -xvf + + .* > /tmp/unpacked + UNPACKDIR=`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'` + cd $UNPACKDIR + + + + + + + + + + + + + + + # REQUIRED: + + + + + # RECOMMENDED: + + + + + # OPTIONAL: + + + + + + + + + + + + + + + + + + wget + + || \ + + + wget + + || \ + + + wget + + / + + / + + .bz2 + + + + wget + + + + + + + + + + + + + + sudo + + + + + + + + + + + make -k + + || true + + + + + + + + + + **EDITME + + EDITME** + + + diff --git a/BLFS/config b/BLFS/config new file mode 100644 index 0000000..8a027b0 --- /dev/null +++ b/BLFS/config @@ -0,0 +1,30 @@ +##### +# +# Configuration file for the blfs module +# +##### + +#--- Book's sources directory +# If you have previously checked out the book from the repository +BOOK= + +#--- Book version +LFSVRS=development + +#--- FTP/HTTP mirror used as fallback (full path) +SERVER=ftp://anduin.linuxfromscratch.org/BLFS/conglomeration + +#--- Dependencies 0(required)/1(recommended)/2(optional) +DEPEND=1 + +#--- Run test suites 0(no)/1(yes) +TEST=0 + + +#==== INTERNAL VARIABLES ==== +# Don't edit it unless you know what you are doing + +#--- Default stylesheet + XSL=dump-blfs-scripts.xsl +MKFILE=$JHALFSDIR/blfs-Makefile + diff --git a/BLFS/master.sh b/BLFS/master.sh new file mode 100755 index 0000000..f83dedc --- /dev/null +++ b/BLFS/master.sh @@ -0,0 +1,100 @@ +#!/bin/sh + + +#----------------------------# +build_Makefile() { +#----------------------------# + echo -n "Creating Makefile... " + cd $JHALFSDIR/${PROGNAME}-commands + + # Start with a clean Makefile file + >$MKFILE + + + # Add a header, some variables and include the function file + # to the top of the real Makefile. +( + cat << EOF +$HEADER + +include makefile-functions + +EOF +) > $MKFILE + + # Drop in a dummy target 'all:'. +( + cat << EOF +all: + @echo -e "\nThere is no default target predefined" + @echo -e "You must to tell what package(s) you want to install" + @echo -e "or edit the \"all\" Makefile target to create your own" + @echo -e "defualt target.\n" + @exit +EOF +) >> $MKFILE + + # Bring over the build targets. + for file in */* ; do + # Keep the script file name + case $file in + gnome/config ) + this_script=config-gnome + ;; + gnome/pre-install-config ) + this_script=pre-intall-config-gnome + ;; + kde/config ) + this_script=config-kde + ;; + kde/pre-install-config ) + this_script=pre-intall-config-kde + ;; + * ) + this_script=`basename $file` + ;; + esac + + # Dump the package dependencies. + REQUIRED=`grep "REQUIRED" $file | sed 's/# REQUIRED://' | tr -d '\n'` + if [ "$DEPEND" != "0" ] ; then + RECOMMENDED=`grep "RECOMMENDED" $file | sed 's/# RECOMMENDED://' | tr -d '\n'` + fi + if [ "$DEPEND" = "2" ] ; then + OPTIONAL=`grep "OPTIONAL" $file | sed 's/# OPTIONAL://' | tr -d '\n'` + fi + + # Drop in the name of the target on a new line plus its dependencies + # and call the echo_message function. +( + cat << EOF + +$this_script: $REQUIRED $RECOMMENDED $OPTIONAL + @\$(call echo_message, Building) +EOF +) >> $MKFILE + + # Insert date and disk usage at the top of the log file, the script run + # and date and disk usage again at the bottom of the log file. +( + cat << EOF + @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude=logs/* /\`\n" >logs/$this_script && \\ + $JHALFSDIR/${PROGNAME}-commands/$file >>logs/$this_script 2>&1 && \\ + echo -e "\n\`date\`\n\nKB: \`du -sk --exclude=logs/* /\`\n" >>logs/$this_script +EOF +) >> $MKFILE + + # Include a touch of the target name so make can check + # if it's already been made. +( + cat << EOF + @touch \$@ +EOF +) >> $MKFILE + + done + echo -ne "done\n" +} + + + diff --git a/CLFS/clfs.xsl b/CLFS/clfs.xsl new file mode 100644 index 0000000..e69de29 diff --git a/CLFS/config b/CLFS/config new file mode 100644 index 0000000..0355460 --- /dev/null +++ b/CLFS/config @@ -0,0 +1,66 @@ +##### +# +# Configuration file for the CLFS module +# +##### + +declare -r HTTP=http://ftp.lfs-matrix.net/pub/clfs/conglomeration + +#--- Which target architecture, +# used to select proper book and set TARGETS +#-------------------------------- +TARGET32="" +TARGET= +# >>>> 32-32 BUILD <<<< +# ARCH=x86 ; TARGET="i486-pc-linux-gnu" +# ARCH=x86 ; TARGET="i586-pc-linux-gnu" +# ARCH=x86 ; TARGET="i686-pc-linux-gnu" +# ARCH=ppc ; TARGET="powerpc-unknown-linux-gnu" +# ARCH=mips ; TARGET="mipsel-unknown-linux-gnu" +# ARCH=mips ; TARGET="mis-unknown-linux-gnu" +# ARCH=sparc ; TARGET="sparcv9-unknown-linux-gnu" +# ARCH=sparcv8 ; TARGET="sparc-unknown-linux-gnu" +#-------------------------------- +# >>>> 64-64 BUILD <<<< + ARCH=x86_64-64 ; TARGET="x86_64-unknown-linux-gnu" +# ARCH=mips64-64 ; TARGET="mipsel-unknown-linux-gnu" +# ARCH=mips64-64 ; TARGET="mis-unknown-linux-gnu" +# ARCH=sparc64-64 ; TARGET="sparc64-unknown-linux-gnu" +# ARCH=alpha ; TARGET="alpha-unknown-linux-gnu" +#-------------------------------- +# >>>> MULTILIB 32/64 <<<< +# ARCH=x86_64 ; TARGET="x86_64-unknown-linux-gnu" ; TARGET32="i686-pc-linux-gnu" +# ARCH=mips64 ; TARGET="mipsel-unknown-linux-gnu" ; TARGET32="mipsel-unknown-linux-gnu" +# ARCH=mips64 ; TARGET="mis-unknown-linux-gnu" ; TARGET32="mis-unknown-linux-gnu" +# ARCH=sparc64 ; TARGET="sparc64-unknown-linux-gnu" ; TARGET32="sparcv9-unknown-linux-gnu" + +#--- Create a minimal boot system 0(chroot)/1(bootmin) +# NOTE: not all combinations are 'bootable' yet. +BOOTMINIMAL=1 + +#--- Location of fstab file (if empty, a template is created) +FSTAB=$BUILDDIR/sources/fstab + +#--- Location of kernel config file (if the kernel is to be compiled) +#--- This file MUST reside in the sources directory +CONFIG=$BUILDDIR/sources/linux-2.6.15.1-x86_64.config + +#--- Book's sources directory +# If you have previously checked out the book from the repository +BOOK= + +#==== INTERNAL VARIABLES ==== +# Don't edit it unless you know what you are doing + +#--- Files that will be copied to $JHALFSDIR +FILES="" + +#--- Default stylesheet +XSL=dump-clfs-scripts.xsl + +#--- Book version +LFSVRS=development +MKFILE=$JHALFSDIR/clfs-Makefile + +#--- FTP/HTTP mirror used as fallback (full path) +SERVER=ftp://anduin.linuxfromscratch.org/LFS/conglomeration diff --git a/CLFS/master.sh b/CLFS/master.sh new file mode 100755 index 0000000..5be4951 --- /dev/null +++ b/CLFS/master.sh @@ -0,0 +1,1318 @@ +#!/bin/sh + +################################### +### FUNCTIONS ### +################################### + +unset extract_commands +#----------------------------# +extract_commands() { # +#----------------------------# + + #Check for libxslt instead of just letting the script hit 'xsltproc' and fail. + test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\" + exit 1" + + cd $JHALFSDIR + VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@@@'` + + # Start clean + if [ -d ${PROGNAME}-commands ]; then + rm -rf ${PROGNAME}-commands + else + mkdir -v ${PROGNAME}-commands + fi + echo "Extracting commands... ${BOLD}START${OFF}" + + echo "${tab_}Extracting commands for ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture" + xsltproc --xinclude \ + --nonet \ + --output ./${PROGNAME}-commands/ \ + $BOOK/stylesheets/dump-commands.xsl $BOOK/$ARCH-index.xml + + # Grab the patches and package names. + cd $JHALFSDIR + + echo "${tab_}Creating the packages and patches files" ; + for i in patches packages ; do rm -f $i ; done + + grep "\-version " $BOOK/packages.ent | sed -e 's@@"@' \ + -e '/generic/d' >> packages + + # Download the vim-lang package if it must be installed + if [ "$VIMLANG" = "1" ] ; then + echo `grep "vim" packages | sed 's@vim@&-lang@'` >> packages + fi + + grep "^<\!ENTITY" $BOOK/patches.ent | sed -e 's/.* "//' -e 's/">//' >> patches + # Needed for Groff patchlevel patch + GROFFLEVEL=`grep "groff-patchlevel" $BOOK/general.ent | sed -e 's/groff-patchlevel //' \ + -e 's/"//g' \ + -e 's@||'` + sed -i 's|&groff-patchlevel;|'$GROFFLEVEL'|' patches + + + # Preprocess the cmd scripts.. + echo "${tab_}Preprocessing the cmd scripts" + # + local file this_script package vrs URLs + # + # Create a list of URLs.. + echo "${tab_}${tab_}Writing a list of URLs to filelist_.wget " + xsltproc --nonet \ + --xinclude \ + -o filelist_.wget \ + $BOOK/stylesheets/wget.xsl \ + $BOOK/$ARCH-index.xml > /dev/null 2>&1 + # + # Loop through all the command scripts + echo "${tab_}${tab_}Modifying the cmd scripts" + for file in `ls ${PROGNAME}-commands/*/*`;do + # + # 1. Compress the script file (remove blank lines) + # 2. Add a variable header and a footer to selected scripts + this_script=`basename $file` + # + # DO NOT play with the chroot scripts.. they are used as is later + [[ `_IS_ $this_script "chroot"` ]] && continue + # + # Strip leading index number and misc test.. This is a miserable method + package=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \ + -e 's@-static@@' \ + -e 's@-final@@' \ + -e 's@temp-@@' \ + -e 's@-64bit@@' \ + -e 's@-64@@' \ + -e 's@64@@' \ + -e 's@-n32@@' \ + -e 's@-build@@' \ + -e 's@glibc-headers@glibc@'` + # + # Find the package version of the command files + # + # A little package name manipulation + case $package in + bootscripts) package="lfs-bootscripts" ;; + kernel) package="linux" ;; + esac + vrs=`grep "^$package-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'` + # + # If $vrs isn't empty, we've got a package... + # NOTE: The included \n causes the separator to be written + # on the next line. This is for cosmetic purposes only... + # + # Set the appropriate 'sha-bang'.. depending of the phase.. + case $package in + *introduction* | \ + *changingowner* | \ + *creatingdirs* | \ + *createfiles* ) sha_bang='' + ;; + *) sha_bang='#!/bin/bash' + ;; + esac + # + # + if [ "$vrs" != "" ] ; then + HEADER_STR="cd \$PKGDIR${nl_}#------------------" + FOOTER_STR="#------------------${nl_}exit" + else + HEADER_STR="#------------------" + FOOTER_STR="#------------------${nl_}exit" + fi + PKG_URL=`grep -e "$package-$vrs.*tar." $JHALFSDIR/filelist_.wget` && true + PATCHES=`grep "$package-$vrs.*patch" $JHALFSDIR/filelist_.wget` && true + # + # There would be no URL for a cmd only script, reset package name + if [[ $PKG_URL = "" ]]; then + package="" + fi +( +cat << EOF +${sha_bang} +set -e + +##################################### + NAME=${this_script} + PACKAGE=${package} + VERSION=${vrs} + PKG_URL=( ${PKG_URL} ) + PATCHES=( ${PATCHES} ) +##################################### + +${HEADER_STR} +`grep '.' ${file}` +${FOOTER_STR} +EOF +) > tmp.script +mv tmp.script ${file} + + done # for file in `ls $PROGNAME-commands/*/*` + # + # Make the scripts executable. + chmod -R +x $JHALFSDIR/${PROGNAME}-commands + + # Done. Moving on... + echo "Extracting commands... ${BOLD}DONE${OFF}" + get_sources + +} + + + +#----------------------------# +host_prep_Makefiles() { # Initialization of the system +#----------------------------# + local LFS_HOST + + echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files${R_arrow}" + + # defined here, only for ease of reading + LFS_HOST="`echo ${MACHTYPE} | sed -e 's/unknown/cross/g' -e 's/-pc-/-cross-/g'`" +( +cat << EOF +023-creatingtoolsdir: + @\$(call echo_message, Building) + @mkdir -v \$(MOUNT_PT)/tools && \\ + rm -fv /tools && \\ + ln -sv \$(MOUNT_PT)/tools / + @if [ ! -d \$(MOUNT_PT)/sources ]; then \\ + mkdir \$(MOUNT_PT)/sources; \\ + fi; + @chmod a+wt \$(MOUNT_PT)/sources && \\ + touch \$@ + +024-creatingcrossdir: 023-creatingtoolsdir + @mkdir -v \$(MOUNT_PT)/cross-tools && \\ + rm -fv /cross-tools && \\ + ln -sv \$(MOUNT_PT)/cross-tools / + @touch \$@ + +025-addinguser: 024-creatingcrossdir + @\$(call echo_message, Building) + @if [ ! -d /home/lfs ]; then \\ + groupadd lfs; \\ + useradd -s /bin/bash -g lfs -m -k /dev/null lfs; \\ + else \\ + touch user-lfs-exist; \\ + fi; + @chown lfs \$(MOUNT_PT) && \\ + chown lfs \$(MOUNT_PT)/tools && \\ + chown lfs \$(MOUNT_PT)/cross-tools && \\ + chown lfs \$(MOUNT_PT)/sources && \\ + touch \$@ + +026-settingenvironment: 025-addinguser + @\$(call echo_message, Building) + @if [ -f /home/lfs/.bashrc -a ! -f /home/lfs/.bashrc.XXX ]; then \\ + mv -v /home/lfs/.bashrc /home/lfs/.bashrc.XXX; \\ + fi; + @if [ -f /home/lfs/.bash_profile -a ! -f /home/lfs/.bash_profile.XXX ]; then \\ + mv -v /home/lfs/.bash_profile /home/lfs/.bash_profile.XXX; \\ + fi; + @echo "set +h" > /home/lfs/.bashrc && \\ + echo "umask 022" >> /home/lfs/.bashrc && \\ + echo "LFS=\$(MOUNT_PT)" >> /home/lfs/.bashrc && \\ + echo "LC_ALL=POSIX" >> /home/lfs/.bashrc && \\ + echo "PATH=/cross-tools/bin:/bin:/usr/bin" >> /home/lfs/.bashrc && \\ + echo "export LFS LC_ALL PATH" >> /home/lfs/.bashrc && \\ + echo "" >> /home/lfs/.bashrc && \\ + echo "unset CFLAGS" >> /home/lfs/.bashrc && \\ + echo "unset CXXFLAGS" >> /home/lfs/.bashrc && \\ + echo "" >> /home/lfs/.bashrc && \\ + echo "export LFS_HOST=\"${LFS_HOST}\"" >> /home/lfs/.bashrc && \\ + echo "export LFS_TARGET=\"${TARGET}\"" >> /home/lfs/.bashrc && \\ + echo "export LFS_TARGET32=\"${TARGET32}\"" >> /home/lfs/.bashrc && \\ + echo "source $JHALFSDIR/envars" >> /home/lfs/.bashrc + @chown lfs:lfs /home/lfs/.bashrc && \\ + touch envars && \\ + touch \$@ +EOF +) >> $MKFILE.tmp + +} + + + +#-----------------------------# +cross_tools_Makefiles() { # +#-----------------------------# + echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools${R_arrow}" + + for file in cross-tools/* ; do + # Keep the script file name + this_script=`basename $file` + # + # Skip this script... + case $this_script in + *cflags* | *variables* ) # work done in host_prep_Makefiles + continue; ;; + *) ;; + esac + # + # Set the dependency for the first target. + if [ -z $PREV ] ; then PREV=026-settingenvironment ; fi + + # First append each name of the script files to a list (this will become + # the names of the targets in the Makefile + cross_tools="$cross_tools $this_script" + + # Grab the name of the target (minus the -headers or -cross in the case of gcc + # and binutils in chapter 5) + name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \ + -e 's@-static@@' \ + -e 's@-final@@' \ + -e 's@-headers@@' \ + -e 's@-64@@' \ + -e 's@-n32@@'` + # Adjust 'name' and patch a few scripts on the fly.. + case $name in + linux-libc) name=linux-libc-headers ;; + esac + # + # Find the version of the command files, if it corresponds with the building of a specific package + vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'` + + + #--------------------------------------------------------------------# + # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Drop in the name of the target on a new line, and the previous target + # as a dependency. Also call the echo_message function. + echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp + # + # If $vrs isn't empty, we've got a package... + # + [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar" + # + wrt_run_as_lfs "${this_script}" "${file}" + # + [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}" + # + # Include a touch of the target name so make can check if it's already been made. + echo -e '\t@touch $@' >> $MKFILE.tmp + # + #--------------------------------------------------------------------# + # >>>>>>>> END OF Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Keep the script file name for Makefile dependencies. + PREV=$this_script + + done # for file in .... +} + + +#-----------------------------# +temptools_Makefiles() { # +#-----------------------------# + echo "${tab_}${GREEN}Processing... ${L_arrow}temp system${R_arrow}" + + for file in temp-system/* ; do + # Keep the script file name + this_script=`basename $file` + # + # First append each name of the script files to a list (this will become + # the names of the targets in the Makefile + temptools="$temptools $this_script" + + # + # Grab the name of the target, strip id number, XXX-script + name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'` + # + # Find the version of the command files, if it corresponds with the building of a specific package + vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'` + + + #--------------------------------------------------------------------# + # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Drop in the name of the target on a new line, and the previous target + # as a dependency. Also call the echo_message function. + echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp + # + # If $vrs isn't empty, we've got a package... + # Insert instructions for unpacking the package and to set the PKGDIR variable. + # + [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar" + # + wrt_run_as_lfs "${this_script}" "${file}" + # + [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}" + # + # Include a touch of the target name so make can check if it's already been made. + echo -e '\t@touch $@' >> $MKFILE.tmp + # + #--------------------------------------------------------------------# + # >>>>>>>> END OF Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Keep the script file name for Makefile dependencies. + PREV=$this_script + done # for file in .... +} + + +#-----------------------------# +boot_Makefiles() { # +#-----------------------------# + echo "${tab_}${GREEN}Processing... ${L_arrow}boot${R_arrow}" + + for file in boot/* ; do + # Keep the script file name + this_script=`basename $file` + + # A little housekeeping on the scripts + case $this_script in + *grub*) continue ;; + *whatnext*) continue ;; + *settingenvironment*) sed 's@PS1=@set +h\nPS1=@' -i $file ;; + *kernel) + sed "s|make mrproper|make mrproper\ncp $CONFIG .config|" -i $file + # You cannot run menuconfig from within the makefile + sed 's|menuconfig|oldconfig|' -i $file + #If defined include the keymap in the kernel + if [[ -n "$KEYMAP" ]]; then + sed "s|^loadkeys -m.*>|loadkeys -m $KEYMAP >|" -i $file + else + sed '/loadkeys -m/d' -i $file + sed '/drivers\/char/d' -i $file + fi + # if there is no kernel config file do not build the kernel + [[ -z $CONFIG ]] && continue + ;; + esac + # + # First append each name of the script files to a list (this will become + # the names of the targets in the Makefile + boottools="$boottools $this_script" + # + # Grab the name of the target, strip id number and misc words. + case $this_script in + *kernel) name=linux ;; + *bootscripts) name=lfs-bootscripts ;; + *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;; + esac + + vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'` + + #--------------------------------------------------------------------# + # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Drop in the name of the target on a new line, and the previous target + # as a dependency. Also call the echo_message function. + echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp + # + # If $vrs isn't empty, we've got a package... + # Insert instructions for unpacking the package and changing directories + # + [[ "$vrs" != "" ]] && wrt_unpack3 "$name-$vrs.tar.*" + # + # Select a script execution method + case $this_script in + *changingowner*) wrt_run_as_root "${this_script}" "${file}" ;; + *devices*) wrt_run_as_root "${this_script}" "${file}" ;; + *fstab*) if [[ -n "$FSTAB" ]]; then + wrt_copy_fstab "${this_script}" + else + wrt_run_as_lfs "${this_script}" "${file}" + fi + ;; + *) wrt_run_as_lfs "${this_script}" "${file}" ;; + esac + # + # Housekeeping...remove any build directory(ies) except if the package build fails. + [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}" + # + # Include a touch of the target name so make can check if it's already been made. + echo -e '\t@touch $@' >> $MKFILE.tmp + # + #--------------------------------------------------------------------# + # >>>>>>>> END OF Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Keep the script file name for Makefile dependencies. + PREV=$this_script + + done + # This will force the Makefile to exit and not allow it to be restarted with + # the command , The user will have to issue the cmd + echo -e "\t@\$(call echo_boot_finished,$VERSION) && \\" >> $MKFILE.tmp + echo -e "\tfalse" >> $MKFILE.tmp +} + + +#-----------------------------# +chroot_Makefiles() { # +#-----------------------------# + echo "${tab_}${GREEN}Processing... ${L_arrow}chroot${R_arrow}" + + for file in chroot/* ; do + # Keep the script file name + this_script=`basename $file` + # + # Skipping scripts is done now and not included in the build tree. + [[ `_IS_ $this_script chroot` ]] && continue + + # + # First append each name of the script files to a list (this will become + # the names of the targets in the Makefile + chroottools="$chroottools $this_script" + + # + # A little housekeeping on the script contents + case $this_script in + *kernfs*) sed '/exit/d' -i $file ;; + *pwdgroup*) sed '/exec/d' -i $file ;; + esac + # + # Grab the name of the target, strip id number, XXX-script + name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'` + vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'` + + #--------------------------------------------------------------------# + # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Drop in the name of the target on a new line, and the previous target + # as a dependency. Also call the echo_message function. + echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp + # + # If $vrs isn't empty, we've got a package... + # Insert instructions for unpacking the package and changing directories + # + if [ "$vrs" != "" ] ; then + case $this_script in + *util-linux) wrt_unpack "$name-$vrs.tar" ;; + *) wrt_unpack2 "$name-$vrs.tar.*" ;; + esac + fi + # + # Select a script execution method + case $this_script in + *kernfs) wrt_run_as_root "${this_script}" "${file}" ;; + *util-linux) wrt_run_as_lfs "${this_script}" "${file}" ;; + *) wrt_run_as_chroot1 "${this_script}" "${file}" ;; + esac + # + # Housekeeping...remove the build directory(ies), except if the package build fails. + [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}" + # + # Include a touch of the target name so make can check if it's already been made. + echo -e '\t@touch $@' >> $MKFILE.tmp + # + #--------------------------------------------------------------------# + # >>>>>>>> END OF Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Keep the script file name for Makefile dependencies. + PREV=$this_script + + done # for file in... +} + + +#-----------------------------# +testsuite_tools_Makefiles() { # +#-----------------------------# + echo "${tab_}${GREEN}Processing... ${L_arrow}testsuite tools${R_arrow}" + + for file in testsuite-tools/* ; do + # Keep the script file name + this_script=`basename $file` + + # First append each name of the script files to a list (this will become + # the names of the targets in the Makefile + testsuitetools="$testsuitetools $this_script" + + # Grab the name of the target, strip id number, XXX-script + name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\ + -e 's@-64bit@@' \ + -e 's@-64@@' \ + -e 's@64@@' \ + -e 's@n32@@'` + + vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'` + + #--------------------------------------------------------------------# + # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Drop in the name of the target on a new line, and the previous target + # as a dependency. Also call the echo_message function. + echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp + # + case $name in + tcl) wrt_unpack2 "$name$vrs-src.tar" ;; + *) wrt_unpack2 "$name-$vrs.tar" ;; + esac + # + wrt_run_as_chroot1 "${this_script}" "${file}" + # + wrt_remove_build_dirs "${name}" + # + # Include a touch of the target name so make can check if it's already been made. + echo -e '\t@touch $@' >> $MKFILE.tmp + # + #--------------------------------------------------------------------# + # >>>>>>>> END OF Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Keep the script file name for Makefile dependencies. + PREV=$this_script + + done +} + + +#--------------------------------# +bm_testsuite_tools_Makefiles() { # +#--------------------------------# + echo "${tab_}${GREEN}Processing... ${L_arrow}(minimal boot) testsuite tools${R_arrow}" + + for file in testsuite-tools/* ; do + # Keep the script file name + this_script=`basename $file` + + # First append each name of the script files to a list (this will become + # the names of the targets in the Makefile + testsuitetools="$testsuitetools $this_script" + + # Grab the name of the target, strip id number, XXX-script + name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\ + -e 's@-64bit@@' \ + -e 's@-64@@' \ + -e 's@64@@' \ + -e 's@n32@@'` + + vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'` + + #--------------------------------------------------------------------# + # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Drop in the name of the target on a new line, and the previous target + # as a dependency. Also call the echo_message function. + echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp + # + case $name in + tcl) wrt_unpack4 "$name$vrs-src.tar.*" ;; + *) wrt_unpack4 "$name-$vrs.tar.*" ;; + esac + # + wrt_run_as_root2 "${this_script}" "${file}" + # + wrt_remove_build_dirs2 "${name}" + # + # Include a touch of the target name so make can check if it's already been made. + echo -e '\t@touch $@' >> $MKFILE.tmp + # + #--------------------------------------------------------------------# + # >>>>>>>> END OF Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Keep the script file name for Makefile dependencies. + PREV=$this_script + + done +} + + +#-----------------------------# +final_system_Makefiles() { # +#-----------------------------# + echo "${tab_}${GREEN}Processing... ${L_arrow}final system${R_arrow}" + + for file in final-system/* ; do + # Keep the script file name + this_script=`basename $file` + + # Skipping scripts is done now so they are not included in the Makefile. + case $this_script in + *stripping*) continue ;; + *grub*) continue ;; + esac + # + # First append each name of the script files to a list (this will become + # the names of the targets in the Makefile + basicsystem="$basicsystem $this_script" + # + # A little customizing via sed scripts first.. + if [[ $TEST = "0" ]]; then + # Drop any package checks.. + sed -e '/make check/d' -e '/make test/d' -i $file + fi + case $this_script in + *coreutils*) sed 's@set -e@set -e; set +h@' -i $file ;; + *groff*) sed "s@\*\*EDITME.*EDITME\*\*@$PAGE@" -i $file ;; + *vim*) sed '/vim -c/d' -i $file ;; + *bash*) sed '/exec /d' -i $file ;; + *shadow*) sed -e '/grpconv/d' -e '/pwconv/d' -e '/passwd root/d' -i $file + sed '/sed -i libtool/d' -i $file + sed '/search_path/d' -i $file + ;; + *glibc*) sed '/tzselect/d' -i $file + sed "s@\*\*EDITME.*EDITME\*\*@$TIMEZONE@" -i $file + # Manipulate glibc's test to work with Makefile + sed -e 's/glibc-check-log.*//' \ + -e 's@make -k check >@make -k check >glibc-check-log 2>\&1 || true\ngrep Error glibc-check-log || true@' -i $file + ;; + *binutils*) sed '/expect /d' -i $file + if [[ $TOOLCHAINTEST = "0" ]]; then + sed '/make check/d' -i $file + fi + ;; + *gcc*) # Ignore all gcc testing for now.. + sed -e '/make -k check/d' -i $file + sed -e '/test_summary/d' -i $file + ;; + *texinfo*) # This sucks as a way to trim a script + sed -e '/cd \/usr/d' \ + -e '/rm dir/d' \ + -e '/for f in/d' \ + -e '/do inst/d' \ + -e '/done/d' -i $file + ;; + esac + + # Grab the name of the target, strip id number, XXX-script + name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \ + -e 's@temp-@@' \ + -e 's@-64bit@@' \ + -e 's@-64@@' \ + -e 's@64@@' \ + -e 's@n32@@'` + + vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'` + + #--------------------------------------------------------------------# + # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Drop in the name of the target on a new line, and the previous target + # as a dependency. Also call the echo_message function. + echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp + + # If $vrs isn't empty, we've got a package... + if [ "$vrs" != "" ] ; then + case $name in + temp-perl) wrt_unpack2 "perl-$vrs.tar.*" ;; + *) wrt_unpack2 "$name-$vrs.tar.*" ;; + esac + # + # Export a few 'config' vars.. + case $this_script in + *glibc*) # For glibc we can set then TIMEZONE envar. + wrt_export_timezone ;; + *groff*) # For Groff we need to set PAGE envar. + wrt_export_pagesize ;; + esac + fi + # + wrt_run_as_chroot1 "${this_script}" "${file}" + # + [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}" + # + # Include a touch of the target name so make can check if it's already been made. + echo -e '\t@touch $@' >> $MKFILE.tmp + # + #--------------------------------------------------------------------# + # >>>>>>>> END OF Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Keep the script file name for Makefile dependencies. + PREV=$this_script + + done # for file in final-system/* ... +} + + +#-----------------------------# +bm_final_system_Makefiles() { # +#-----------------------------# + echo "${tab_}${GREEN}Processing... ${L_arrow}(minimal boot) final system${R_arrow}" + + for file in final-system/* ; do + # Keep the script file name + this_script=`basename $file` + + # Skipping scripts is done now so they are not included in the Makefile. + case $this_script in + *stripping*) continue ;; + *grub*) continue ;; + esac + + # First append each name of the script files to a list (this will become + # the names of the targets in the Makefile + basicsystem="$basicsystem $this_script" + + # + # A little customizing via sed scripts first.. + if [[ $TEST = "0" ]]; then + # Drop any package checks.. + sed -e '/make check/d' -e '/make test/d' -i $file + fi + case $this_script in + *coreutils*) sed 's@set -e@set -e; set +h@' -i $file ;; + *groff*) sed "s@\*\*EDITME.*EDITME\*\*@$PAGE@" -i $file ;; + *vim*) sed '/vim -c/d' -i $file ;; + *bash*) sed '/exec /d' -i $file ;; + *shadow*) sed -e '/grpconv/d' \ + -e '/pwconv/d' \ + -e '/passwd root/d' -i $file + sed '/sed -i libtool/d' -i $file + sed '/search_path/d' -i $file + ;; + *psmisc*) # Build fails on creation of this link. installed in sysvinit + sed -e 's/^ln -s/#ln -s/' -i $file + ;; + *glibc*) sed '/tzselect/d' -i $file + sed "s@\*\*EDITME.*EDITME\*\*@$TIMEZONE@" -i $file + # Manipulate glibc's test to work with Makefile + sed -e 's/glibc-check-log.*//' -e 's@make -k check >@make -k check >glibc-check-log 2>\&1 || true\ngrep Error glibc-check-log || true@' -i $file + ;; + *binutils*) sed '/expect /d' -i $file + if [[ $TOOLCHAINTEST = "0" ]]; then + sed '/make check/d' -i $file + fi + ;; + *gcc*) # Ignore all gcc testing for now.. + sed -e '/make -k check/d' -i $file + sed -e '/test_summary/d' -i $file + ;; + *texinfo*) # This sucks as a way to trim a script + sed -e '/cd \/usr/d' \ + -e '/rm dir/d' \ + -e '/for f in/d' \ + -e '/do inst/d' \ + -e '/done/d' -i $file + ;; + esac + + # Grab the name of the target, strip id number, XXX-script + name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \ + -e 's@temp-@@' \ + -e 's@-64bit@@' \ + -e 's@-64@@' \ + -e 's@64@@' \ + -e 's@n32@@'` + + vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'` + + #--------------------------------------------------------------------# + # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Drop in the name of the target on a new line, and the previous target + # as a dependency. Also call the echo_message function. + echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp + + # If $vrs isn't empty, we've got a package... + if [ "$vrs" != "" ] ; then + case $name in + temp-perl) wrt_unpack4 "perl-$vrs.tar.*" ;; + *) wrt_unpack4 "$name-$vrs.tar.*" ;; + esac + # + # Export a few 'config' vars.. + case $this_script in + *glibc*) # For glibc we can set then TIMEZONE envar. + echo -e '\t@echo "export TIMEZONE=$(TIMEZONE)" >> envars' >> $MKFILE.tmp ;; + *groff*) # For Groff we need to set PAGE envar. + echo -e '\t@echo "export PAGE=$(PAGE)" >> envars' >> $MKFILE.tmp ;; + esac + fi + # + wrt_run_as_root2 "${this_script}" "${file}" + # + [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}" + # + # Include a touch of the target name so make can check if it's already been made. + echo -e '\t@touch $@' >> $MKFILE.tmp + # + #--------------------------------------------------------------------# + # >>>>>>>> END OF Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Keep the script file name for Makefile dependencies. + PREV=$this_script + + done # for file in final-system/* ... +} + + +#-----------------------------# +bootscripts_Makefiles() { # +#-----------------------------# + echo "${tab_}${GREEN}Processing... ${L_arrow}bootscripts${R_arrow}" + + for file in bootscripts/* ; do + # Keep the script file name + this_script=`basename $file` + + case $this_script in + *udev*) continue ;; # This is not a script but a commentary + *console*) continue ;; # Use the files that came with the bootscripts + *) ;; + esac + + # First append each name of the script files to a list (this will become + # the names of the targets in the Makefile + bootscripttools="$bootscripttools $this_script" + + # A little bit of script modification + case $this_script in + *profile*) # Over-ride the book cmds, write our own simple one. +( +cat <<- EOF + cat > /etc/profile << "_EOF_" + # Begin /etc/profile + + export LC_ALL=${LC_ALL} + export LANG=${LANG} + export INPUTRC=/etc/inputrc + + # End /etc/profile + _EOF_ +EOF +) > $file + ;; + esac + + # Grab the name of the target, strip id number, XXX-script + name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\ + -e 's@-64bit@@' \ + -e 's@-64@@' \ + -e 's@64@@' \ + -e 's@n32@@'` + if [[ `_IS_ $name bootscripts` ]]; then name=lfs-bootscripts; fi + + vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'` + + #--------------------------------------------------------------------# + # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Drop in the name of the target on a new line, and the previous target + # as a dependency. Also call the echo_message function. + echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp + # + # If $vrs isn't empty, we've got a package... + # + [[ "$vrs" != "" ]] && wrt_unpack2 "$name-$vrs.tar.*" + # + wrt_run_as_chroot1 "${this_script}" "${file}" + # + [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}" + # + # Include a touch of the target name so make can check if it's already been made. + echo -e '\t@touch $@' >> $MKFILE.tmp + # + #--------------------------------------------------------------------# + # >>>>>>>> END OF Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Keep the script file name for Makefile dependencies. + PREV=$this_script + + done # for file in bootscripts/* ... + +} + +#-----------------------------# +bm_bootscripts_Makefiles() { # +#-----------------------------# + echo "${tab_}${GREEN}Processing... ${L_arrow}(minimal boot) bootscripts${R_arrow}" + + for file in bootscripts/* ; do + # Keep the script file name + this_script=`basename $file` + + case $this_script in + *udev*) continue ;; # This is not a script but a commentary + *console*) continue ;; # Use the files that came with the bootscripts + *) ;; + esac + + # First append each name of the script files to a list (this will become + # the names of the targets in the Makefile + bootscripttools="$bootscripttools $this_script" + + # A little bit of script modification + case $this_script in + *profile*) # Over-ride the book cmds, write our own simple one. +( +cat <<- EOF + cat > /etc/profile << "_EOF_" + # Begin /etc/profile + + export LC_ALL=${LC_ALL} + export LANG=${LANG} + export INPUTRC=/etc/inputrc + + # End /etc/profile + _EOF_ +EOF +) > $file + ;; + esac + + # Grab the name of the target, strip id number, XXX-script + name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\ + -e 's@-64bit@@' \ + -e 's@-64@@' \ + -e 's@64@@' \ + -e 's@n32@@'` + if [[ `_IS_ $name bootscripts` ]]; then name=lfs-bootscripts; fi + + vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'` + + #--------------------------------------------------------------------# + # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Drop in the name of the target on a new line, and the previous target + # as a dependency. Also call the echo_message function. + echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp + # + # If $vrs isn't empty, we've got a package... + # + [[ "$vrs" != "" ]] && wrt_unpack4 "$name-$vrs.tar.*" + # + wrt_run_as_root2 "${this_script}" "${file}" + # + [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}" + # + # Include a touch of the target name so make can check if it's already been made. + echo -e '\t@touch $@' >> $MKFILE.tmp + # + #--------------------------------------------------------------------# + # >>>>>>>> END OF Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Keep the script file name for Makefile dependencies. + PREV=$this_script + + done # for file in bootscripts/* ... + +} + + + +#-----------------------------# +bootable_Makefiles() { # +#-----------------------------# + echo "${tab_}${GREEN}Processing... ${L_arrow}make bootable${R_arrow}" + + for file in bootable/* ; do + # Keep the script file name + this_script=`basename $file` + + # A little housekeeping on the scripts + case $this_script in + *grub*) continue ;; + *kernel) + sed "s|make mrproper|make mrproper\ncp $CONFIG .config|" -i $file + # You cannot run menuconfig from within the makefile + sed 's|menuconfig|oldconfig|' -i $file + # If defined include the keymap in the kernel + if [[ -n "$KEYMAP" ]]; then + sed "s|^loadkeys -m.*>|loadkeys -m $KEYMAP >|" -i $file + else + sed '/loadkeys -m/d' -i $file + sed '/drivers\/char/d' -i $file + fi + # if there is no kernel config file do not build the kernel + [[ -z $CONFIG ]] && continue + ;; + esac + # + # First append each name of the script files to a list (this will become + # the names of the targets in the Makefile + bootabletools="$bootabletools $this_script" + # + # Grab the name of the target, strip id number and misc words. + name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` + [[ `_IS_ $this_script "kernel"` ]] && name=linux + + vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'` + + #--------------------------------------------------------------------# + # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Drop in the name of the target on a new line, and the previous target + # as a dependency. Also call the echo_message function. + echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp + # + # If $vrs isn't empty, we've got a package... + # Insert instructions for unpacking the package and changing directories + # + [[ "$vrs" != "" ]] && wrt_unpack3 "$name-$vrs.tar.*" + # + # Select a script execution method + case $this_script in + *fstab*) if [[ -n "$FSTAB" ]]; then + wrt_copy_fstab "${this_script}" + else + wrt_run_as_lfs "${this_script}" "${file}" + fi + ;; + *) wrt_run_as_lfs "${this_script}" "${file}" ;; + esac + # + # Housekeeping...remove any build directory(ies) except if the package build fails. + [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}" + # + # Include a touch of the target name so make can check if it's already been made. + echo -e '\t@touch $@' >> $MKFILE.tmp + # + #--------------------------------------------------------------------# + # >>>>>>>> END OF Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Keep the script file name for Makefile dependencies. + PREV=$this_script + + done + +} + + + +#-----------------------------# +bm_bootable_Makefiles() { # +#-----------------------------# + echo "${tab_}${GREEN}Processing... ${L_arrow}(minimal boot) make bootable${R_arrow}" + + for file in bootable/* ; do + # Keep the script file name + this_script=`basename $file` + + # A little housekeeping on the scripts + case $this_script in + *grub*) continue ;; + *kernel) cfg_file="/sources/`basename $CONFIG`" + sed "s|make mrproper|make mrproper\ncp $cfg_file .config|" -i $file + # You cannot run menuconfig from within the makefile + sed 's|menuconfig|oldconfig|' -i $file + # If defined include the keymap in the kernel + if [[ -n "$KEYMAP" ]]; then + sed "s|^loadkeys -m.*>|loadkeys -m $KEYMAP >|" -i $file + else + sed '/loadkeys -m/d' -i $file + sed '/drivers\/char/d' -i $file + fi + # if there is no kernel config file do not build the kernel + [[ -z $CONFIG ]] && continue + ;; + esac + # + # First append each name of the script files to a list (this will become + # the names of the targets in the Makefile + bootabletools="$bootabletools $this_script" + # + # Grab the name of the target, strip id number and misc words. + case $this_script in + *kernel) name=linux + ;; + *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;; + esac + + vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'` + + #--------------------------------------------------------------------# + # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Drop in the name of the target on a new line, and the previous target + # as a dependency. Also call the echo_message function. + echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp + # + # If $vrs isn't empty, we've got a package... + # Insert instructions for unpacking the package and changing directories + # + [[ "$vrs" != "" ]] && wrt_unpack4 "$name-$vrs.tar.*" + # + # Select a script execution method + case $this_script in + *fstab*) if [[ -n "$FSTAB" ]]; then + wrt_copy_fstab2 "${this_script}" + else + wrt_run_as_root2 "${this_script}" "${file}" + fi + ;; + *) wrt_run_as_root2 "${this_script}" "${file}" ;; + esac + # + # Housekeeping...remove any build directory(ies) except if the package build fails. + [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}" + # + # Include a touch of the target name so make can check if it's already been made. + echo -e '\t@touch $@' >> $MKFILE.tmp + # + #--------------------------------------------------------------------# + # >>>>>>>> END OF Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Keep the script file name for Makefile dependencies. + PREV=$this_script + + done + +} + + + +#-----------------------------# +the_end_Makefiles() { # +#-----------------------------# + echo "${tab_}${GREEN}Processing... ${L_arrow}THE END${R_arrow}" +} + + +#-----------------------------# +build_Makefile() { # Construct a Makefile from the book scripts +#-----------------------------# + echo "Creating Makefile... ${BOLD}START${OFF}" + + cd $JHALFSDIR/${PROGNAME}-commands + # Start with a clean Makefile.tmp file + >$MKFILE.tmp + + host_prep_Makefiles + cross_tools_Makefiles + temptools_Makefiles + if [[ $BOOTMINIMAL = "0" ]]; then + chroot_Makefiles + if [[ $TOOLCHAINTEST = "1" ]]; then + testsuite_tools_Makefiles + fi + final_system_Makefiles + bootscripts_Makefiles + bootable_Makefiles + else + boot_Makefiles # This phase must die at the end of its run.. + if [[ $TOOLCHAINTEST = "1" ]]; then + bm_testsuite_tools_Makefiles + fi + bm_final_system_Makefiles + bm_bootscripts_Makefiles + bm_bootable_Makefiles + fi +# the_end_Makefiles + + + # Add a header, some variables and include the function file + # to the top of the real Makefile. +( + cat << EOF +$HEADER + +SRC= /sources +MOUNT_PT= $BUILDDIR +PAGE= $PAGE +TIMEZONE= $TIMEZONE + +include makefile-functions + +EOF +) > $MKFILE + + # Add chroot commands + i=1 + for file in chroot/*chroot* ; do + chroot=`cat $file | sed -e '/#!\/bin\/sh/d' \ + -e '/^export/d' \ + -e '/^logout/d' \ + -e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \ + -e 's|\\$|&&|g' \ + -e 's|exit||g' \ + -e 's|$| -c|' \ + -e 's|"$$LFS"|$(MOUNT_PT)|'\ + -e 's|set -e||'` + echo -e "CHROOT$i= $chroot\n" >> $MKFILE + i=`expr $i + 1` + done + + # Drop in the main target 'all:' and the chapter targets with each sub-target + # as a dependency. +( + cat << EOF +all: chapter2 chapter3 chapter4 chapter5 chapter6 chapter7 chapter8 + @\$(call echo_finished,$VERSION) + +chapter2: 023-creatingtoolsdir 024-creatingcrossdir 025-addinguser 026-settingenvironment + +chapter3: chapter2 $cross_tools + +chapter4: chapter3 $temptools + +chapter5: chapter4 $chroottools $boottools + +chapter6: chapter5 $basicsystem + +chapter7: chapter6 $bootscripttools + +chapter8: chapter7 $bootabletools + +clean-all: clean + rm -rf ./{${PROGNAME}-commands,logs,Makefile,dump-clfs-scripts.xsl,functions,packages,patches} + +clean: clean-chapter4 clean-chapter3 clean-chapter2 + +clean-chapter2: + -if [ ! -f user-lfs-exist ]; then \\ + userdel lfs; \\ + rm -rf /home/lfs; \\ + fi; + rm -rf \$(MOUNT_PT)/tools + rm -f /tools + rm -rf \$(MOUNT_PT)/cross-tools + rm -f /cross-tools + rm -f envars user-lfs-exist + rm -f 02* logs/02*.log + +clean-chapter3: + rm -rf \$(MOUNT_PT)/tools/* + rm -f $cross_tools restore-lfs-env sources-dir + cd logs && rm -f $cross_tools && cd .. + +clean-chapter4: + -umount \$(MOUNT_PT)/sys + -umount \$(MOUNT_PT)/proc + -umount \$(MOUNT_PT)/dev/shm + -umount \$(MOUNT_PT)/dev/pts + -umount \$(MOUNT_PT)/dev + rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,lib64,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var} + rm -f $temptools + cd logs && rm -f $temptools && cd .. + + +restore-lfs-env: + @\$(call echo_message, Building) + @if [ -f /home/lfs/.bashrc.XXX ]; then \\ + mv -fv /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\ + fi; + @if [ -f /home/lfs/.bash_profile.XXX ]; then \\ + mv -v /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\ + fi; + @chown lfs:lfs /home/lfs/.bash* && \\ + touch \$@ + +EOF +) >> $MKFILE + + + # Bring over the items from the Makefile.tmp + cat $MKFILE.tmp >> $MKFILE + rm $MKFILE.tmp + echo "Creating Makefile... ${BOLD}DONE${OFF}" + +} + diff --git a/HLFS/config b/HLFS/config new file mode 100644 index 0000000..4fe5b4b --- /dev/null +++ b/HLFS/config @@ -0,0 +1,38 @@ +##### +# +# Configuration file for the HLFS module +# +##### +declare -r HTTP=http://ftp.lfs-matrix.net/pub/hlfs/conglomeration + +#--- Which library model to use uclibc/glibc +MODEL=glibc + +#--- The host system has grsecurity options enabled 0(no)/1(yes) +GRSECURITY_HOST=0 + +#--- Location of fstab file (if empty, a template is created) +FSTAB=$BUILDDIR/sources/fstab + +#--- Location of kernel config file (if the kernel is to be compiled) +CONFIG=$BUILDDIR/sources/linux-2.6.14.6-HLFS.config + +#--- Book's sources directory +# If you have previously checked out the book from the repository +BOOK= + +#==== INTERNAL VARIABLES ==== +# Don't edit it unless you know what you are doing + +#--- Files that will be copied to $JHAHLFSDIR +FILES="dump-hlfs-scripts.xsl hlfs-patcheslist_.xsl" + +#--- Default stylesheet +XSL=dump-hlfs-scripts.xsl + +#--- Book version +LFSVRS=development +MKFILE=$JHALFSDIR/hlfs-Makefile + +#--- FTP/HTTP mirror used as fallback (full path) +SERVER=ftp://anduin.linuxfromscratch.org/HLFS/conglomeration diff --git a/HLFS/functions b/HLFS/functions new file mode 100644 index 0000000..b4683a0 --- /dev/null +++ b/HLFS/functions @@ -0,0 +1,59 @@ +BOLD= "" +RED= "" +GREEN= "" +ORANGE= "" +BLUE= "" +WHITE= "" + +define echo_message + @echo $(BOLD) + @echo -------------------------------------------------------------------------------- + @echo $(BOLD)$(1) target $(BLUE)$@$(BOLD) + @echo --------------------------------------------------------------------------------$(WHITE) +endef + +define unpack + @if [ -f $(HLFS)$(SRC)/$(1).bz2 ] ; then \ + cd $(HLFS)$(SRC) ; tar -xvjf $(1).bz2 > /tmp/unpacked ; \ + else \ + cd $(HLFS)$(SRC) ; tar -xvzf $(1).gz > /tmp/unpacked ; \ + fi ; +endef + +define unpack2 + @cd $(HLFS)$(SRC) ; /tools/bin/tar -xvf $(1) > /tmp/unpacked +endef + +define echo_finished + @echo $(BOLD) + @echo -------------------------------------------------------------------------------- + @echo $(BOLD) Finished the build of $(BLUE)HLFS-$(1)$(BOLD) + @echo -------------------------------------------------------------------------------- + @echo -e \\t\\t$(RED)W A R N I N G$(BOLD) + @echo -------------------------------------------------------------------------------- + @echo + @echo To be able to boot your new HLFS system you need to follow + @echo the next steps:$(WHITE) + @echo + @echo -e \\t- Enter to the chroot using the command found + @echo -e \\tin chapter06/revisedchroot.html + @echo + @echo -e \\t- Set a password for the root user + @echo + @echo -e \\t- Edit /etc/fstab, /etc/hosts, /etc/sysconfig/clock, + @echo -e \\t/etc/sysconfig/console, /etc/sysconfig/network, + @echo -e \\t/etc/sysconfig//network-devices/ifconfig.eth0/ipv4 and + @echo -e \\tany other configuration file required to suit your needs. + @echo + @echo -e \\t- Set-up Grub. See chapter08/grub.html + @echo + @echo -e \\t- Unmount the filesystems. + @echo + @echo If you are an experienced HLFS user, several of those steps can be + @echo skipped or done in a different way. But then, that is something + @echo that you already know and there is no need to discuss it here. + @echo $(BOLD) + @echo -------------------------------------------------------------------------------- + @echo -e \\t\\t$(GREEN)Have a nice day $(ORANGE):-\)$(BOLD) + @echo --------------------------------------------------------------------------------$(WHITE) +endef diff --git a/HLFS/hlfs.xsl b/HLFS/hlfs.xsl new file mode 100644 index 0000000..c137965 --- /dev/null +++ b/HLFS/hlfs.xsl @@ -0,0 +1,230 @@ + + + %general-entities; +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 00 + + + + 0 + + + + + + + + + + + + + + #!/tools/bin/bash set -e + + + + #!/bin/sh + + + + #!/bin/sh set -e + + + + + cd $PKGDIR + + tar -xvf ../vim-&vim-version;-lang.* --strip-components=1 + + + pushd ../; tar -xvf gettext-&gettext-version;.*; popd; + + + pushd ../; tar -xvf gettext-&gettext-version;.*; popd; + + + tar -xvf ../glibc-libidn-&glibc-version;.* + + + tar -xvf ../glibc-libidn-&glibc-version;.* + + + pushd ../; tar -xvf gcc-g++-&gcc-version;.*; popd; + + + pushd ../; tar -xvf gcc-g++-&gcc-version;.*; popd; + + + pushd ../; tar -xvf blfs-bootscripts-&blfs-bootscripts-version;.* ; popd; + + + + exit + + + + + + + + + + + + + + + + + + + + make -k + + || true + + + + + + + + + tar.* + + + + + + + patch -Z + + + + + + + make mrproper + cp -v /sources/kernel-config .config + + + + + + + + + + + make -k check || true + + + + + + + + + + || true + + + + + + + + + + + + + + + + + + || true + + + + + + + + + + + + + + $TIMEZONE + + + $TIMEZONE + + + $PAGE + + + **EDITME + + EDITME** + + + + + + diff --git a/HLFS/master.sh b/HLFS/master.sh new file mode 100755 index 0000000..d697ca7 --- /dev/null +++ b/HLFS/master.sh @@ -0,0 +1,662 @@ +#!/bin/sh +set -e # Enable error trapping + + +################################### +### FUNCTIONS ### +################################### + + +#----------------------------# +get_sources() { # +#----------------------------# + local IFS + + # Test if the packages must be downloaded + if [ ! "$HPKG" = "1" ] ; then + return + fi + + # Modify the 'internal field separator' to break on 'LF' only + IFS=$'\x0A' + + if [ ! -d $BUILDDIR/sources ] ; then mkdir $BUILDDIR/sources ; fi + cd $BUILDDIR/sources + + > MISSING_FILES.DMP # Files not in md5sum end up here + + if [ -f MD5SUMS ] ; then rm MD5SUMS ; fi + if [ -f MD5SUMS-$VERSION ] ; then rm MD5SUMS-$VERSION ; fi + + # Retrieve the master md5sum file + download "" MD5SUMS + + # Iterate through each package and grab it, along with any patches it needs. + for i in `cat $JHALFSDIR/packages` ; do + PKG=`echo $i | sed -e 's/-version.*//' \ + -e 's/-file.*//' \ + -e 's/uclibc/uClibc/' ` + + # Needed for Groff patchlevel patch on UTF-8 branch + GROFFLEVEL=`grep "groff-patchlevel" $JHALFSDIR/packages | sed -e 's/groff-patchlevel //' -e 's/"//g'` + + # + # How to deal with orphan packages..?? + # + VRS=`echo $i | sed -e 's/.* //' -e 's/"//g'` + case "$PKG" in + "expect-lib" ) continue ;; # not valid packages + "linux-dl" ) continue ;; + "groff-patchlevel" ) continue ;; + "uClibc-patch" ) continue ;; + + "tcl" ) FILE="$PKG$VRS-src.tar.bz2" ; download $PKG $FILE ;; + "vim-lang" ) FILE="vim-$VRS-lang.tar.bz2"; PKG="vim" ; download $PKG $FILE ;; + "udev-config" ) FILE="$VRS" ; PKG="udev" ; download $PKG $FILE ;; + + "uClibc-locale" ) FILE="$PKG-$VRS.tar.bz2" ; PKG="uClibc" + download $PKG $FILE + # There can be no patches for this file + continue ;; + + "gcc" ) download $PKG "gcc-core-$VRS.tar.bz2" + download $PKG "gcc-g++-$VRS.tar.bz2" + ;; + "glibc") download $PKG "$PKG-$VRS.tar.bz2" + download $PKG "$PKG-libidn-$VRS.tar.bz2" + ;; + * ) FILE="$PKG-$VRS.tar.bz2" + download $PKG $FILE + ;; + esac + + for patch in `grep "$PKG-&$PKG" $JHALFSDIR/patches` ; do + PATCH=`echo $patch | sed 's@&'$PKG'-version;@'$VRS'@'` + download $PKG $PATCH + done + + done + + # .... U G L Y .... what to do with the grsecurity patch to the kernel.. + download grsecurity `grep grsecurity $JHALFSDIR/patches` + + # .... U G L Y .... deal with uClibc-locale-xxxxx.tar.bz2 format issue. + bzcat uClibc-locale-030818.tar.bz2 | gzip > uClibc-locale-030818.tgz + + if [[ -s $BUILDDIR/sources/MISSING_FILES.DMP ]]; then + echo -e "\n\n${tab_}${RED} One or more files were not retrieved.\n${tab_} Check for names ${OFF}\n\n" + fi +} + + +#----------------------------# +chapter4_Makefiles() { # Initialization of the system +#----------------------------# + local TARGET LOADER + + echo "${YELLOW} Processing Chapter-4 scripts ${OFF}" + + # Define a few model dependant variables + if [[ ${MODEL} = "uclibc" ]]; then + TARGET="tools-linux-uclibc"; LOADER="ld-uClibc.so.0" + else + TARGET="tools-linux-gnu"; LOADER="ld-linux.so.2" + fi + + # 022- + # If /home/hlfs is already present in the host, we asume that the + # hlfs user and group are also presents in the host, and a backup + # of their bash init files is made. +( +cat << EOF +020-creatingtoolsdir: + @\$(call echo_message, Building) + @mkdir -v \$(MOUNT_PT)/tools && \\ + rm -fv /tools && \\ + ln -sv \$(MOUNT_PT)/tools / + @if [ ! -d \$(MOUNT_PT)/sources ]; then \\ + mkdir \$(MOUNT_PT)/sources; \\ + fi; + @chmod a+wt \$(MOUNT_PT)/sources && \\ + touch \$@ + +021-addinguser: 020-creatingtoolsdir + @\$(call echo_message, Building) + @if [ ! -d /home/lfs ]; then \\ + groupadd lfs; \\ + useradd -s /bin/bash -g lfs -m -k /dev/null lfs; \\ + else \\ + touch user-lfs-exist; \\ + fi; + @chown lfs \$(MOUNT_PT)/tools && \\ + chown lfs \$(MOUNT_PT)/sources && \\ + touch \$@ + +022-settingenvironment: 021-addinguser + @\$(call echo_message, Building) + @if [ -f /home/lfs/.bashrc -a ! -f /home/lfs/.bashrc.XXX ]; then \\ + mv -v /home/lfs/.bashrc /home/lfs/.bashrc.XXX; \\ + fi; + @if [ -f /home/lfs/.bash_profile -a ! -f /home/lfs/.bash_profile.XXX ]; then \\ + mv -v /home/lfs/.bash_profile /home/lfs/.bash_profile.XXX; \\ + fi; + @echo "set +h" > /home/lfs/.bashrc && \\ + echo "umask 022" >> /home/lfs/.bashrc && \\ + echo "HLFS=\$(MOUNT_PT)" >> /home/lfs/.bashrc && \\ + echo "LC_ALL=POSIX" >> /home/lfs/.bashrc && \\ + echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/lfs/.bashrc && \\ + echo "export HLFS LC_ALL PATH" >> /home/lfs/.bashrc && \\ + echo "" >> /home/lfs/.bashrc && \\ + echo "target=$(uname -m)-${TARGET}" >> /home/lfs/.bashrc && \\ + echo "ldso=/tools/lib/${LOADER}" >> /home/lfs/.bashrc && \\ + echo "export target ldso" >> /home/lfs/.bashrc && \\ + echo "source $JHALFSDIR/envars" >> /home/lfs/.bashrc && \\ + chown lfs:lfs /home/lfs/.bashrc && \\ + touch envars && \\ + touch \$@ +EOF +) >> $MKFILE.tmp + +} + +#----------------------------# +chapter5_Makefiles() { # Bootstrap or temptools phase +#----------------------------# + local file + local this_script + + echo "${YELLOW} Processing Chapter-5 scripts${OFF}" + + for file in chapter05/* ; do + # Keep the script file name + this_script=`basename $file` + + # Skip this script depending on jhalfs.conf flags set. + case $this_script in + # If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed + *tcl* ) [[ "$TOOLCHAINTEST" = "0" ]] && continue; ;; + *expect* ) [[ "$TOOLCHAINTEST" = "0" ]] && continue; ;; + *dejagnu* ) [[ "$TOOLCHAINTEST" = "0" ]] && continue; ;; + # Test if the stripping phase must be skipped + *stripping* ) [[ "$STRIP" = "0" ]] && continue ;; + # Select the appropriate library + *glibc*) [[ ${MODEL} = "uclibc" ]] && continue ;; + *uclibc*) [[ ${MODEL} = "glibc" ]] && continue ;; + *) ;; + esac + + # First append each name of the script files to a list (this will become + # the names of the targets in the Makefile + chapter5="$chapter5 $this_script" + + # Grab the name of the target (minus the -headers or -cross in the case of gcc + # and binutils in chapter 5) + name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-cross@@' -e 's@-headers@@'` + + # >>>>>>>>>> U G L Y <<<<<<<<< + # Adjust 'name' and patch a few scripts on the fly.. + case $name in + linux-libc) name=linux-libc-headers + ;; + uclibc) # this sucks as method to deal with gettext/libint inside uClibc + sed 's@^cd gettext-runtime@cd ../gettext-*/gettext-runtime@' -i chapter05/$this_script + ;; + gcc) # to compensate for the compiler test inside gcc (which fails), disable error trap + sed 's@^gcc -o test test.c@set +e; gcc -o test test.c@' -i chapter05/$this_script + ;; + esac + + # Set the dependency for the first target. + if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi + + + #--------------------------------------------------------------------# + # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Drop in the name of the target on a new line, and the previous target + # as a dependency. Also call the echo_message function. + wrt_target "$this_script" "$PREV" + + # Find the version of the command files, if it corresponds with the building of + # a specific package + vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'` + # If $vrs isn't empty, we've got a package... + if [ "$vrs" != "" ] ; then + # Deal with non-standard names + case $name in + tcl) FILE="$name$vrs-src.tar" ;; + uclibc) FILE="uClibc-$vrs.tar" ;; + gcc) FILE="gcc-core-$vrs.tar" ;; + *) FILE="$name-$vrs.tar" ;; + esac + # Insert instructions for unpacking the package and to set the PKGDIR variable. + wrt_unpack "$FILE" + fi + + case $this_script in + *binutils* ) # Dump the path to sources directory for later removal + echo -e '\techo "$(MOUNT_PT)$(SRC)/$$ROOT" >> sources-dir' >> $MKFILE.tmp + ;; + *adjusting* ) # For the Adjusting phase we must to cd to the binutils-build directory. + echo -e '\t@echo "export PKGDIR=$(MOUNT_PT)$(SRC)/binutils-build" > envars' >> $MKFILE.tmp + ;; + * ) # Everything else, add a true statment so we don't confuse make + echo -e '\ttrue' >> $MKFILE.tmp + ;; + esac + + # Insert date and disk usage at the top of the log file, the script run + # and date and disk usage again at the bottom of the log file. + wrt_run_as_su "${this_script}" "${file}" + + # Remove the build directory(ies) except if the package build fails + # (so we can review config.cache, config.log, etc.) + # For Binutils the sources must be retained for some time. + if [ "$vrs" != "" ] ; then + if [[ ! `_IS_ $this_script binutils` ]]; then + wrt_remove_build_dirs "$name" + fi + fi + + # Remove the Binutils pass 1 sources after a successful Adjusting phase. + if [[ `_IS_ $this_script adjusting` ]] ; then +( +cat << EOF + @rm -r \`cat sources-dir\` && \\ + rm -r \$(MOUNT_PT)\$(SRC)/binutils-build && \\ + rm sources-dir +EOF +) >> $MKFILE.tmp + fi + + # Include a touch of the target name so make can check if it's already been made. + echo -e '\t@touch $@' >> $MKFILE.tmp + # + #--------------------------------------------------------------------# + # >>>>>>>> END OF Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + + # Keep the script file name for Makefile dependencies. + PREV=$this_script + done # end for file in chapter05/* +} + + +#----------------------------# +chapter6_Makefiles() { # sysroot or chroot build phase +#----------------------------# + local TARGET LOADER + local file + local this_script + + # + # Set these definitions early and only once + # + if [[ ${MODEL} = "uclibc" ]]; then + TARGET="pc-linux-uclibc"; LOADER="ld-uClibc.so.0" + else + TARGET="pc-linux-gnu"; LOADER="ld-linux.so.2" + fi + + echo -e "${YELLOW} Processing Chapter-6 scripts ${OFF}" + for file in chapter06/* ; do + # Keep the script file name + this_script=`basename $file` + + # Skip this script depending on jhalfs.conf flags set. + case $this_script in + # We'll run the chroot commands differently than the others, so skip them in the + # dependencies and target creation. + *chroot* ) continue ;; + # Test if the stripping phase must be skipped + *-stripping* ) [[ "$STRIP" = "0" ]] && continue ;; + # Select the appropriate library + *glibc*) [[ ${MODEL} = "uclibc" ]] && continue ;; + *uclibc*) [[ ${MODEL} = "glibc" ]] && continue ;; + *) ;; + esac + + # First append each name of the script files to a list (this will become + # the names of the targets in the Makefile + chapter6="$chapter6 $this_script" + + # Grab the name of the target + name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'` + + # + # Sed replacement for 'nodump' tag in xml scripts until Manuel has a chance to fix them + # + case $name in + kernfs) + # We are using LFS instead of HLFS.. + sed 's/HLFS/LFS/' -i chapter06/$this_script + # Remove sysctl code if host does not have grsecurity enabled + if [[ "$GRSECURITY_HOST" = "0" ]]; then + sed '/sysctl/d' -i chapter06/$this_script + fi + ;; + module-init-tools) + if [[ "$TEST" = "0" ]]; then # This needs rework.... + sed '/make distclean/d' -i chapter06/$this_script + fi + ;; + glibc) # PATCH.. Turn off error trapping for the remainder of the script. + sed 's|^make install|make install; set +e|' -i chapter06/$this_script + ;; + uclibc) # PATCH.. + sed 's/EST5EDT/${TIMEZONE}/' -i chapter06/$this_script + # PATCH.. Cannot use interactive programs/scripts. + sed 's/make menuconfig/make oldconfig/' -i chapter06/$this_script + sed 's@^cd gettext-runtime@cd ../gettext-*/gettext-runtime@' -i chapter06/$this_script + ;; + gcc) # PATCH.. + sed 's/rm /rm -f /' -i chapter06/$this_script + ;; + esac + + #--------------------------------------------------------------------# + # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Drop in the name of the target on a new line, and the previous target + # as a dependency. Also call the echo_message function. + wrt_target "$this_script" "$PREV" + + # Find the version of the command files, if it corresponds with the building of + # a specific package + vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'` + + # If $vrs isn't empty, we've got a package... + # Insert instructions for unpacking the package and changing directories + if [ "$vrs" != "" ] ; then + # Deal with non-standard names + case $name in + tcl) FILE="$name$vrs-src.tar.*" ;; + uclibc) FILE="uClibc-$vrs.tar.*" ;; + gcc) FILE="gcc-core-$vrs.tar.*" ;; + *) FILE="$name-$vrs.tar.*" ;; + esac + wrt_unpack2 "$FILE" + wrt_target_vars + fi + + case $this_script in + *readjusting*) # For the Re-Adjusting phase we must to cd to the binutils-build directory. + echo -e '\t@echo "export PKGDIR=$(SRC)/binutils-build" > envars' >> $MKFILE.tmp + ;; + *glibc* | *uclibc* ) # For glibc and uClibc we need to set TIMEZONE envar. + wrt_export_timezone + ;; + *groff* ) # For Groff we need to set PAGE envar. + wrt_export_pagesize + ;; + esac + + # In the mount of kernel filesystems we need to set HLFS and not to use chroot. + if [[ `_IS_ $this_script kernfs` ]] ; then + wrt_run_as_root "${this_script}" "${file}" + # + # The rest of Chapter06 + else + wrt_run_as_chroot1 "${this_script}" "${file}" + fi + # + # Remove the build directory(ies) except if the package build fails. + if [ "$vrs" != "" ] ; then + wrt_remove_build_dirs "$name" + fi + # + # Remove the Binutils pass 2 sources after a successful Re-Adjusting phase. + if [[ `_IS_ $this_script readjusting` ]] ; then +( +cat << EOF + @rm -r \`cat sources-dir\` && \\ + rm -r \$(MOUNT_PT)\$(SRC)/binutils-build && \\ + rm sources-dir +EOF +) >> $MKFILE.tmp + fi + + # Include a touch of the target name so make can check if it's already been made. + echo -e '\t@touch $@' >> $MKFILE.tmp + # + #--------------------------------------------------------------------# + # >>>>>>>> END OF Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + + # Keep the script file name for Makefile dependencies. + PREV=$this_script + done # end for file in chapter06/* + +} + +#----------------------------# +chapter7_Makefiles() { # Create a bootable system.. kernel, bootscripts..etc +#----------------------------# + local file + local this_script + + echo "${YELLOW} Processing Chapter-7 scripts ${OFF}" + for file in chapter07/*; do + # Keep the script file name + this_script=`basename $file` + + # Grub must be configured manually. + # The filesystems can't be unmounted via Makefile and the user + # should enter the chroot environment to create the root + # password, edit several files and setup Grub. + case $this_script in + *grub) continue ;; + *reboot) continue ;; + *console) continue ;; # Use the file generated by lfs-bootscripts + + *kernel) # How does Manuel add this string to the file.. + sed 's|cd \$PKGDIR.*||' -i chapter07/$this_script + # You cannot run menuconfig from within the makefile + sed 's|make menuconfig|make oldconfig|' -i chapter07/$this_script + # The files in the conglomeration dir are xxx.bz2 + sed 's|.patch.gz|.patch.bz2|' -i chapter07/$this_script + sed 's|gunzip|bunzip2|' -i chapter07/$this_script + # If defined include the keymap in the kernel + if [[ -n "$KEYMAP" ]]; then + sed "s|^loadkeys -m.*>|loadkeys -m $KEYMAP >|" -i chapter07/$this_script + else + sed '/loadkeys -m/d' -i chapter07/$this_script + sed '/drivers\/char/d' -i chapter07/$this_script + fi + # If no .config file is supplied, the kernel build is skipped + [[ -z $CONFIG ]] && continue + ;; + *usage) # The script bombs, disable error trapping + sed 's|set -e|set +e|' -i chapter07/$this_script + ;; + *profile) # Add the config values to the script + sed "s|LC_ALL=\*\*EDITME.*EDITME\*\*|LC_ALL=$LC_ALL|" -i chapter07/$this_script + sed "s|LANG=\*\*EDITME.*EDITME\*\*|LANG=$LANG|" -i chapter07/$this_script + ;; + esac + + # First append then name of the script file to a list (this will become + # the names of the targets in the Makefile + chapter7="$chapter7 $this_script" + + #--------------------------------------------------------------------# + # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + # + # Drop in the name of the target on a new line, and the previous target + # as a dependency. Also call the echo_message function. + wrt_target "$this_script" "$PREV" + + if [[ `_IS_ $this_script bootscripts` ]] ; then + vrs=`grep "^lfs-bootscripts-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'` + FILE="lfs-bootscripts-$vrs.tar.*" + # The bootscript pkg references both lfs AND blfs bootscripts... + # see XML script for other additions to bootscripts file + # PATCH + vrs=`grep "^blfs-bootscripts-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'` + sed "s|make install$|make install; cd ../blfs-bootscripts-$vrs|" -i chapter07/$this_script + wrt_unpack2 "$FILE" +( +cat << EOF + echo "\$(MOUNT_PT)\$(SRC)/blfs-bootscripts-$vrs" > sources-dir +EOF +) >> $MKFILE.tmp + fi + + if [[ `_IS_ $this_script kernel` ]] ; then + # not much really, script does everything.. + echo -e "\t@cp -f $CONFIG \$(MOUNT_PT)/sources/kernel-config" >> $MKFILE.tmp + fi + + # Check if we have a real /etc/fstab file + if [[ `_IS_ $this_script fstab` ]] && [[ -n "$FSTAB" ]] ; then + wrt_copy_fstab "$this_script" + else + # Initialize the log and run the script + wrt_run_as_chroot2 "${this_script}" "${file}" + fi + + # Remove the build directory except if the package build fails. + if [[ `_IS_ $this_script bootscripts` ]]; then +( +cat << EOF + @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\ + rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT + @rm -r \`cat sources-dir\` && \\ + rm sources-dir +EOF +) >> $MKFILE.tmp + fi + + # Include a touch of the target name so make can check if it's already been made. + echo -e '\t@touch $@' >> $MKFILE.tmp + # + #--------------------------------------------------------------------# + # >>>>>>>> END OF Makefile ENTRY <<<<<<<< # + #--------------------------------------------------------------------# + + # Keep the script file name for Makefile dependencies. + PREV=$this_script + done # for file in chapter07/* +} + + +#----------------------------# +build_Makefile() { # Construct a Makefile from the book scripts +#----------------------------# + echo -e "${GREEN}Creating Makefile... ${OFF}" + + cd $JHALFSDIR/${PROGNAME}-commands + # Start with a clean Makefile.tmp file + >$MKFILE.tmp + + chapter4_Makefiles + chapter5_Makefiles + chapter6_Makefiles + chapter7_Makefiles + + # Add a header, some variables and include the function file + # to the top of the real Makefile. +( + cat << EOF +$HEADER + +SRC= /sources +MOUNT_PT= $BUILDDIR +PAGE= $PAGE +TIMEZONE= $TIMEZONE + +include makefile-functions + +EOF +) > $MKFILE + + + # Add chroot commands + i=1 + for file in chapter06/*chroot* ; do + chroot=`cat $file | sed -e '/#!\/bin\/sh/d' \ + -e '/^export/d' \ + -e '/^logout/d' \ + -e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \ + -e 's|\\$|&&|g' \ + -e 's|exit||g' \ + -e 's|$| -c|' \ + -e 's|"$$HLFS"|$(MOUNT_PT)|'\ + -e 's|set -e||'` + echo -e "CHROOT$i= $chroot\n" >> $MKFILE + i=`expr $i + 1` + done + + # Drop in the main target 'all:' and the chapter targets with each sub-target + # as a dependency. +( + cat << EOF +all: chapter4 chapter5 chapter6 chapter7 + @\$(call echo_finished,$VERSION) + +chapter4: 020-creatingtoolsdir 021-addinguser 022-settingenvironment + +chapter5: chapter4 $chapter5 restore-hlfs-env + +chapter6: chapter5 $chapter6 + +chapter7: chapter6 $chapter7 + +clean-all: clean + rm -rf ./{hlfs-commands,logs,Makefile,dump-hlfs-scripts.xsl,functions,packages,patches} + +clean: clean-chapter7 clean-chapter6 clean-chapter5 clean-chapter4 + +clean-chapter4: + -if [ ! -f user-hlfs-exist ]; then \\ + userdel hlfs; \\ + rm -rf /home/hlfs; \\ + fi; + rm -rf \$(MOUNT_PT)/tools + rm -f /tools + rm -f envars user-hlfs-exist + rm -f 02* logs/02*.log + +clean-chapter5: + rm -rf \$(MOUNT_PT)/tools/* + rm -f $chapter5 restore-hlfs-env sources-dir + cd logs && rm -f $chapter5 && cd .. + +clean-chapter6: + -umount \$(MOUNT_PT)/sys + -umount \$(MOUNT_PT)/proc + -umount \$(MOUNT_PT)/dev/shm + -umount \$(MOUNT_PT)/dev/pts + -umount \$(MOUNT_PT)/dev + rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var} + rm -f $chapter6 + cd logs && rm -f $chapter6 && cd .. + +clean-chapter7: + rm -f $chapter7 + cd logs && rm -f $chapter7 && cd .. + +restore-hlfs-env: + @\$(call echo_message, Building) + @if [ -f /home/lfs/.bashrc.XXX ]; then \\ + mv -fv /home/lfs/.bashrc.XXX /home/hlfs/.bashrc; \\ + fi; + @if [ -f /home/hlfs/.bash_profile.XXX ]; then \\ + mv -v /home/lfs/.bash_profile.XXX /home/hlfs/.bash_profile; \\ + fi; + @chown lfs:lfs /home/lfs/.bash* && \\ + touch \$@ + +EOF +) >> $MKFILE + + # Bring over the items from the Makefile.tmp + cat $MKFILE.tmp >> $MKFILE + rm $MKFILE.tmp + echo -ne "${GREEN}done\n${OFF}" +} + + diff --git a/HLFS/patcheslist.xsl b/HLFS/patcheslist.xsl new file mode 100644 index 0000000..025a9f9 --- /dev/null +++ b/HLFS/patcheslist.xsl @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LFS/config b/LFS/config new file mode 100644 index 0000000..8addc9f --- /dev/null +++ b/LFS/config @@ -0,0 +1,34 @@ +##### +# +# Configuration file for the LFS module +# +##### +declare -r HTTP=http://ftp.lfs-matrix.net/pub/lfs/conglomeration + +#--- Location of fstab file (if empty, a template is created) +FSTAB=$BUILDDIR/sources/fstab + +#--- Location of kernel config file (if the kernel is to be compiled) +CONFIG=$PWD/config_files/linux-2.6.15.1-LFS.config + +#--- Book's sources directory +# If you have previously checked out the book from the repository +BOOK= + +#==== INTERNAL VARIABLES ==== +# Don't edit it unless you know what you are doing + +#--- Files that will be copied to $JHALFSDIR +FILES="" + +#--- Default stylesheet +XSL=dump-lfs-scripts.xsl + +#--- Book version +LFSVRS=development + +#--- Name of the makefile +MKFILE=$JHALFSDIR/lfs-Makefile + +#--- FTP/HTTP mirror used as fallback (full path) +SERVER=ftp://anduin.linuxfromscratch.org/LFS/conglomeration diff --git a/LFS/lfs.xsl b/LFS/lfs.xsl new file mode 100644 index 0000000..c1b7c3c --- /dev/null +++ b/LFS/lfs.xsl @@ -0,0 +1,196 @@ + + + %general-entities; +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 00 + + + + 0 + + + + + + + + + + + + #!/tools/bin/bash set -e + + + #!/bin/sh + + + #!/bin/sh set -e + + + + cd $PKGDIR + + tar -xvf ../vim-&vim-version;-lang.* --strip-components=1 + + + + exit + + + + + + + + + + + + + + + + + + + make -k + + || true + + + + + + + + + tar.* + + + + + + + patch -Z + + + + + + make mrproper + cp -v ../kernel-config .config + + + + + + + + + make -k check || true + + + + + + + + + + || true + + + + + + + + + + + + + + + + + + || true + + + + + + + + + + + + + $TIMEZONE + + + $PAGE + + + **EDITME + + EDITME** + + + + + diff --git a/LFS/master.sh b/LFS/master.sh new file mode 100755 index 0000000..93dd418 --- /dev/null +++ b/LFS/master.sh @@ -0,0 +1,392 @@ +#!/bin/sh + + +################################### +### FUNCTIONS ### +################################### + + + +#----------------------------# +chapter4_Makefiles() { +#----------------------------# + +# If /home/lfs is already present in the host, we asume that the +# lfs user and group are also presents in the host, and a backup +# of their bash init files is made. +( + cat << EOF +020-creatingtoolsdir: + @\$(call echo_message, Building) + @mkdir -v \$(MOUNT_PT)/tools && \\ + rm -fv /tools && \\ + ln -sv \$(MOUNT_PT)/tools / && \\ + touch \$@ + +021-addinguser: 020-creatingtoolsdir + @\$(call echo_message, Building) + @if [ ! -d /home/lfs ]; then \\ + groupadd lfs; \\ + useradd -s /bin/bash -g lfs -m -k /dev/null lfs; \\ + else \\ + touch user-lfs-exist; \\ + fi; + @chown lfs \$(MOUNT_PT)/tools && \\ + chown lfs \$(MOUNT_PT)/sources && \\ + touch \$@ + +022-settingenvironment: 021-addinguser + @\$(call echo_message, Building) + @if [ -f /home/lfs/.bashrc -a ! -f /home/lfs/.bashrc.XXX ]; then \\ + mv -v /home/lfs/.bashrc /home/lfs/.bashrc.XXX; \\ + fi; + @if [ -f /home/lfs/.bash_profile -a ! -f /home/lfs/.bash_profile.XXX ]; then \\ + mv -v /home/lfs/.bash_profile /home/lfs/.bash_profile.XXX; \\ + fi; + @echo "set +h" > /home/lfs/.bashrc && \\ + echo "umask 022" >> /home/lfs/.bashrc && \\ + echo "LFS=/mnt/lfs" >> /home/lfs/.bashrc && \\ + echo "LC_ALL=POSIX" >> /home/lfs/.bashrc && \\ + echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/lfs/.bashrc && \\ + echo "export LFS LC_ALL PATH" >> /home/lfs/.bashrc && \\ + echo "source $JHALFSDIR/envars" >> /home/lfs/.bashrc && \\ + chown lfs:lfs /home/lfs/.bashrc && \\ + touch envars && \\ + touch \$@ +EOF +) >> $MKFILE.tmp +} + +#----------------------------# +chapter5_Makefiles() { +#----------------------------# + for file in chapter05/* ; do + # Keep the script file name + this_script=`basename $file` + + # If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed + if [ "$TOOLCHAINTEST" = "0" ]; then + if [[ `_IS_ ${this_script} tcl` ]] || [[ `_IS_ ${this_script} expect` ]] || [[ `_IS_ ${this_script} dejagnu` ]] ; then + continue + fi + fi + + # Test if the stripping phase must be skipped + if [ "$STRIP" = "0" ] && [[ `_IS_ ${this_script} stripping` ]] ; then + continue + fi + +# NOTE Replace with xsl work... + if [[ `_IS_ $this_script adjusting` ]]; then + sed '/cd $PKGDIR/d' -i chapter05/$this_script + fi + + # First append each name of the script files to a list (this will become + # the names of the targets in the Makefile + chapter5="$chapter5 ${this_script}" + + # Grab the name of the target (minus the -pass1 or -pass2 in the case of gcc + # and binutils in chapter 5) + name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@' -e 's@-pass[0-9]\{1\}@@'` + + # Set the dependency for the first target. + if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi + + # Drop in the name of the target on a new line, and the previous target + # as a dependency. Also call the echo_message function. + wrt_target "${this_script}" "$PREV" + + # Find the version of the command files, if it corresponds with the building of + # a specific package + vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'` + + # If $vrs isn't empty, we've got a package... + if [ "$vrs" != "" ] ; then + if [ "$name" = "tcl" ] ; then + FILE="$name$vrs-src.tar" + else + FILE="$name-$vrs.tar" + fi + + # Insert instructions for unpacking the package and to set + # the PKGDIR variable. + wrt_unpack "$FILE" + echo -e '\ttrue' >> $MKFILE.tmp + fi + + # Insert date and disk usage at the top of the log file, the script run + # and date and disk usage again at the bottom of the log file. + wrt_run_as_su "${this_script}" "$file" + + # Remove the build directory(ies) except if the package build fails + # (so we can review config.cache, config.log, etc.) + if [ "$vrs" != "" ] ; then + wrt_remove_build_dirs "$name" + fi + + # Include a touch of the target name so make can check + # if it's already been made. + echo -e '\t@touch $@' >> $MKFILE.tmp + + # Keep the script file name for Makefile dependencies. + PREV=${this_script} + done # end for file in chapter05/* +} + +#----------------------------# +chapter6_Makefiles() { +#----------------------------# + for file in chapter06/* ; do + # Keep the script file name + this_script=`basename $file` + + # We'll run the chroot commands differently than the others, so skip them in the + # dependencies and target creation. + if [[ `_IS_ ${this_script} chroot` ]] ; then + continue + fi + + # Test if the stripping phase must be skipped + if [ "$STRIP" = "0" ] && [[ `_IS_ ${this_script} stripping` ]] ; then + continue + fi + +# NOTE Replace with xsl work... + if [[ `_IS_ $this_script adjusting` ]]; then + sed '/cd $PKGDIR/d' -i chapter06/$this_script + fi + + # First append each name of the script files to a list (this will become + # the names of the targets in the Makefile + chapter6="$chapter6 ${this_script}" + + # Grab the name of the target + name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@'` + + # Drop in the name of the target on a new line, and the previous target + # as a dependency. Also call the echo_message function. + wrt_target "${this_script}" "$PREV" + + # Find the version of the command files, if it corresponds with the building of + # a specific package + vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'` + + # If $vrs isn't empty, we've got a package... + # Insert instructions for unpacking the package and changing directories + if [ "$vrs" != "" ] ; then + FILE="$name-$vrs.tar.*" + wrt_unpack2 "$FILE" + fi + + if [[ `_IS_ ${this_script} glibc` ]] ; then # For Glibc we need to set TIMEZONE envar. + wrt_export_timezone + elif [[ `_IS_ ${this_script} groff` ]] ; then # For Groff we need to set PAGE envar. + wrt_export_pagesize + fi + + # In the mount of kernel filesystems we need to set LFS + # and not to use chroot. + if [[ `_IS_ ${this_script} kernfs` ]] ; then + wrt_run_as_root "${this_script}" "$file" + else # The rest of Chapter06 + wrt_run_as_chroot1 "${this_script}" "$file" + fi + + # Remove the build directory(ies) except if the package build fails. + if [ "$vrs" != "" ] ; then + wrt_remove_build_dirs "$name" + fi + + # Include a touch of the target name so make can check + # if it's already been made. + echo -e '\t@touch $@' >> $MKFILE.tmp + + # Keep the script file name for Makefile dependencies. + PREV=${this_script} + done # end for file in chapter06/* +} + +#----------------------------# +chapter789_Makefiles() { +#----------------------------# + for file in chapter0{7,8,9}/* ; do + # Keep the script file name + this_script=`basename $file` + + # Grub must be configured manually. + # The filesystems can't be unmounted via Makefile and the user + # should enter the chroot environment to create the root + # password, edit several files and setup Grub. + if [[ `_IS_ ${this_script} grub` ]] || [[ `_IS_ ${this_script} reboot` ]] ; then + continue + fi + + # If no .config file is supplied, the kernel build is skipped + if [ -z $CONFIG ] && [[ `_IS_ ${this_script} kernel` ]] ; then + continue + fi + + # First append each name of the script files to a list (this will become + # the names of the targets in the Makefile + chapter789="$chapter789 ${this_script}" + + # Drop in the name of the target on a new line, and the previous target + # as a dependency. Also call the echo_message function. + wrt_target "${this_script}" "$PREV" + + # Find the bootscripts and kernel package names + if [[ `_IS_ ${this_script} bootscripts` ]] || [[ `_IS_ ${this_script} kernel` ]] ; then + if [[ `_IS_ ${this_script} bootscripts` ]] ; then + vrs=`grep "^lfs-bootscripts-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'` + FILE="lfs-bootscripts-$vrs.tar.*" + elif [[ `_IS_ ${this_script} kernel` ]] ; then + vrs=`grep "^linux-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'` + FILE="linux-$vrs.tar.*" + fi + wrt_unpack2 "$FILE" + fi + + # Put in place the kernel .config file + if [[ `_IS_ ${this_script} kernel` ]] ; then +( + cat << EOF + @cp $CONFIG \$(MOUNT_PT)/sources/kernel-config +EOF +) >> $MKFILE.tmp + fi + + # Check if we have a real /etc/fstab file + if [[ `_IS_ ${this_script} fstab` ]] && [[ -n "$FSTAB" ]] ; then + wrt_copy_fstab "${this_script}" + else + # Initialize the log and run the script + wrt_run_as_chroot2 "$this_script" "$file" + fi + + # Remove the build directory except if the package build fails. + if [[ `_IS_ ${this_script} bootscripts` ]] || [[ `_IS_ ${this_script} kernel` ]] ; then + wrt_remove_build_dirs "dummy" + fi + + # Include a touch of the target name so make can check + # if it's already been made. + echo -e '\t@touch $@' >> $MKFILE.tmp + + # Keep the script file name for Makefile dependencies. + PREV=${this_script} + done # for file in chapter0{7,8,9}/* +} + + +#----------------------------# +build_Makefile() { +#----------------------------# + echo -n "Creating Makefile... " + cd $JHALFSDIR/${PROGNAME}-commands + + # Start with a clean Makefile.tmp file + >$MKFILE.tmp + + chapter4_Makefiles + chapter5_Makefiles + chapter6_Makefiles + chapter789_Makefiles + + + # Add a header, some variables and include the function file + # to the top of the real Makefile. +( + cat << EOF +$HEADER + +SRC= /sources +MOUNT_PT= $BUILDDIR +PAGE= $PAGE +TIMEZONE= $TIMEZONE + +include makefile-functions + +EOF +) > $MKFILE + + + # Add chroot commands + i=1 + for file in chapter06/*chroot* ; do + chroot=`cat $file | sed -e '/#!\/bin\/sh/d' -e 's@ \\\@ @g' | tr -d '\n' | sed \ + -e 's/ */ /g' -e 's|\\$|&&|g' -e 's|exit||g' -e 's|$| -c|' \ + -e 's|"$$LFS"|$(MOUNT_PT)|' -e 's|set -e||'` + echo -e "CHROOT$i= $chroot\n" >> $MKFILE + i=`expr $i + 1` + done + + # Drop in the main target 'all:' and the chapter targets with each sub-target + # as a dependency. +( + cat << EOF +all: chapter4 chapter5 chapter6 chapter789 + @\$(call echo_finished,$VERSION) + +chapter4: 020-creatingtoolsdir 021-addinguser 022-settingenvironment + +chapter5: chapter4 $chapter5 restore-lfs-env + +chapter6: chapter5 $chapter6 + +chapter789: chapter6 $chapter789 + +clean-all: clean + rm -rf ./{lfs-commands,logs,Makefile,dump-lfs-scripts.xsl,functions,packages,patches} + +clean: clean-chapter789 clean-chapter6 clean-chapter5 clean-chapter4 + +clean-chapter4: + -if [ ! -f user-lfs-exist ]; then \\ + userdel lfs; \\ + rm -rf /home/lfs; \\ + fi; + rm -rf \$(MOUNT_PT)/tools + rm -f /tools + rm -f envars user-lfs-exist + rm -f 02* logs/02*.log + +clean-chapter5: + rm -rf \$(MOUNT_PT)/tools/* + rm -f $chapter5 restore-lfs-env sources-dir + cd logs && rm -f $chapter5 && cd .. + +clean-chapter6: + -umount \$(MOUNT_PT)/sys + -umount \$(MOUNT_PT)/proc + -umount \$(MOUNT_PT)/dev/shm + -umount \$(MOUNT_PT)/dev/pts + -umount \$(MOUNT_PT)/dev + rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var} + rm -f $chapter6 + cd logs && rm -f $chapter6 && cd .. + +clean-chapter789: + rm -f $chapter789 + cd logs && rm -f $chapter789 && cd .. + +restore-lfs-env: + @\$(call echo_message, Building) + @if [ -f /home/lfs/.bashrc.XXX ]; then \\ + mv -fv /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\ + fi; + @if [ -f /home/lfs/.bash_profile.XXX ]; then \\ + mv -v /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\ + fi; + @chown lfs:lfs /home/lfs/.bash* && \\ + touch \$@ + +EOF +) >> $MKFILE + + # Bring over the items from the Makefile.tmp + cat $MKFILE.tmp >> $MKFILE + rm $MKFILE.tmp + echo -ne "done\n" +} + + diff --git a/blfs b/blfs new file mode 120000 index 0000000..fba0373 --- /dev/null +++ b/blfs @@ -0,0 +1 @@ +master.sh \ No newline at end of file diff --git a/clfs b/clfs new file mode 120000 index 0000000..fba0373 --- /dev/null +++ b/clfs @@ -0,0 +1 @@ +master.sh \ No newline at end of file diff --git a/common/common-functions b/common/common-functions new file mode 100644 index 0000000..d6c82e0 --- /dev/null +++ b/common/common-functions @@ -0,0 +1,801 @@ +#!/bin/bash +set +e + +# VT100 colors +declare -r BLACK=$'\e[1;30m' +declare -r DK_GRAY=$'\e[0;30m' + +declare -r RED=$'\e[31m' +declare -r GREEN=$'\e[32m' +declare -r YELLOW=$'\e[33m' +declare -r BLUE=$'\e[34m' +declare -r MAGENTA=$'\e[35m' +declare -r CYAN=$'\e[36m' +declare -r WHITE=$'\e[37m' + +declare -r OFF=$'\e[0m' +declare -r BOLD=$'\e[1m' +declare -r REVERSE=$'\e[7m' +declare -r HIDDEN=$'\e[8m' + +declare -r tab_=$'\t' +declare -r nl_=$'\n' + +declare -r DD_BORDER="${BOLD}${WHITE}==============================================================================${OFF}" +declare -r SD_BORDER="${BOLD}${WHITE}------------------------------------------------------------------------------${OFF}" +declare -r STAR_BORDER="${BOLD}${WHITE}******************************************************************************${OFF}" + +# bold yellow > < pair +declare -r R_arrow=$'\e[1;33m>\e[0m' +declare -r L_arrow=$'\e[1;33m<\e[0m' + + + +usage() { + 'clear' +cat <<- -EOF- +${DD_BORDER} +${BOLD} + Usage: $0 ${BOLD}[OPTION] + +Options: +${BOLD} -h, --help${OFF} + print this help, then exit +${BOLD} --readme${OFF} + print a small readme file, then exit +${BOLD} -V, --version${OFF} + print version number, then exit +${BOLD} -d --directory DIR${OFF} + use DIR directory for building HLFS; all files jhahlfs produces will be + in the directory DIR/jhahlfs. Default is \"/mnt/lfs\". +${BOLD} --rebuild${OFF} + clean the build directory before to perfom any other task. The directory + is cleaned only if it was populated by a previous jhahlfs run. +${BOLD} -P, --get-packages${OFF} + download the packages and patches. This assumes that the server declared in the + jhahlfs.conf file has the proper packages and patches for the book version being + processed. +${BOLD} -D, --download-client CLIENT + use CLIENT as the program for retrieving packages (use in conjunction with -P) +${BOLD} -W, --working-copy DIR${OFF} + use the local working copy placed in DIR as the HLFS book +${BOLD} -L, --HLFS-version VER${OFF} + checkout VER version of the HLFS book. Supported versions at this time are: + dev* | trunk | SVN aliases for Development HLFS +${BOLD} --fstab FILE${OFF} + use FILE as the /etc/fstab file for the HLFS system. If not specified, + a default /etc/fstab file with dummy values is created. +${BOLD} -C, --kernel-config FILE${OFF} + use the kernel configuration file specified in FILE to build the kernel. + if the file is not found, or if not specified, the kernel build is skipped. +${BOLD} -M, --run-make${OFF} + run make on the generated Makefile +${DD_BORDER} +-EOF- + exit +} + + +blfs_usage() { + 'clear' +cat <<- -EOF- +${DD_BORDER} +${BOLD} + Usage: $0 ${BOLD}[OPTION] + +Options: +${BOLD} -h, --help${OFF} + print this help, then exit + +${BOLD} -V, --version${OFF} + print version number, then exit + +${BOLD} -B, --BLFS-version VER${OFF} + checkout VER version of the BLFS book. + If not set, the development version is used. + + Supported versions at this time are: + dev* | trunk | SVN aliases for Development BLFS + +${BOLD} -W, --working-copy DIR${OFF} + use the local working copy placed in DIR as the BLFS book + +${BOLD} -D, --dependencies TYPE${OFF} + add dependencies of type TYPE to the build tree. + If not set, both required a recommended are used. + + Possible values are: + + required only required dependecies are used + recommended both required a recommended dependencies are used + optional all dependencies are used + +${BOLD} -S, --server SERVER${OFF} + set the FTP/HTTP server used as fallback to download the packages. + If not specified, the one set in jhablfs.conf is used. + +${BOLD} -T, --testsuites${OFF} + add support to run the optional testsuites +${DD_BORDER} +-EOF- + exit +} + + +_inline_doc=" + This script, ${PROGNAME}, strives to create an accurate makefile + directly from the xml files used to generate the Hardened Linux From + Scratch document. + The usage of this script assumes you have read and are familiar with + the book and therefore the configuration variables found in jhahlfs.conf + will have meaning to you. There are a limited number of command line + switches which, if used, will override the config file settings. + + NOTES:: + *. The resulting Makefile takes considerable time to run to completion, + lay in a supply of caffeine beverages. + + *. It is recommended that you temporarily unpack your linux kernel and + run and configure the kernal as per the book and save + the resulting .config file. + + *. Chapter07 contains numerous command files which require customizing + before you start console, profile, hosts, network, fstab, kernel. +" + +version=" +${BOLD}\"${PROGNAME}\"${OFF} script module (development) \$Date$ + +Written by Jeremy Huntwork, + Manuel Caneles Esparcia, + George Boudreau + +This program is published under the ${BOLD}Gnu General Public License, Version 2.${OFF} +" + + +no_empty_builddir() { + 'clear' +cat <<- -EOF- +${DD_BORDER} + +${tab_}${tab_}${BOLD}${RED}W A R N I N G${OFF} + Looks like the \$BUILDDIR directory contains subdirectories + from a previous HLFS build. + + Please format the partition mounted on \$BUILDDIR or set + a different build directory before running jhahlfs. +${OFF} +${DD_BORDER} +-EOF- + exit +} + + +help="${nl_}Try '$0 --help' for more information." + + +exit_missing_arg="\ +echo \"Option '\$1' requires an argument\" >&2 +echo \"\$help\" >&2 +exit 1" + +no_dl_client="\ +echo \"Could not find a way to download the CLFS sources.\" >&2 +echo \"Attempting to continue.\" >&2" + +HEADER="# This file is automatically generated by jhalfs +# DO NOT EDIT THIS FILE MANUALLY +# +# Generated on `date \"+%F %X %Z\"`" + + + + + +#----------------------------------# +wrt_target() { # +#----------------------------------# + local i=$1 + local PREV=$2 +( +cat << EOF + +$i: $PREV + @\$(call echo_message, Building) +EOF +) >> $MKFILE.tmp +} + + +#----------------------------------# +wrt_unpack() { # +#----------------------------------# + local FILE=$1 +( +cat << EOF + @\$(call unpack,$FILE) + @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\ + echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\ + + chown -R lfs \$(MOUNT_PT)\$(SRC)/\$\$ROOT +EOF +) >> $MKFILE.tmp +} + + +#=============================# +wrt_unpack3() { # Unpack and set 'ROOT' var +#=============================# + local FILE=$1 +( +cat << EOF + @\$(call unpack3,$FILE) + @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\ + echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\ + + chown -R lfs \$(MOUNT_PT)\$(SRC)/\$\$ROOT +EOF +) >> $MKFILE.tmp +} + + +#----------------------------------# +wrt_unpack2() { # +#----------------------------------# + local FILE=$1 +( +cat << EOF + @\$(call unpack2,$FILE) + @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\ + echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars +EOF +) >> $MKFILE.tmp +} + + +#=============================# +wrt_unpack4() { # Unpack and set 'ROOT' var +#=============================# + local FILE=$1 +( +cat << EOF + @\$(call unpack4,$FILE) + @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\ + echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars +EOF +) >> $MKFILE.tmp +} + + + +#----------------------------------# +wrt_target_vars() { # Target vars for hlfs (cross-build method) +#----------------------------------# +( +cat << EOF + echo "export target=$(uname -m)-${TARGET}" >> envars && \\ + echo "export ldso=/lib/${LOADER}" >> envars +EOF +) >> $MKFILE.tmp + +} + + +#----------------------------------# +wrt_run_as_su() { # +#----------------------------------# + local this_script=$1 + local file=$2 +( +cat << EOF + @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/$this_script && \\ + su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 && \\ + echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/$this_script +EOF +) >> $MKFILE.tmp +} + + +#==================================# +wrt_run_as_lfs() { # header to log file, execute script, footer to log file +#==================================# + local this_script=$1 + local file=$2 +( +cat << EOF + @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/$this_script && \\ + su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 && \\ + echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/$this_script +EOF +) >> $MKFILE.tmp +} + + +#----------------------------------# +wrt_run_as_root() { # +#----------------------------------# + local this_script=$1 + local file=$2 +( +cat << EOF + @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/$this_script && \\ + export LFS=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 && \\ + echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/$this_script +EOF +) >> $MKFILE.tmp +} + + +#=============================# +wrt_run_as_root2() { # Some scripts must be run as root.. +#=============================# + local this_script=$1 + local file=$2 +( +cat << EOF + @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \`\n" >logs/$this_script && \\ + source envars && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 && \\ + echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \`\n" >>logs/$this_script +EOF +) >> $MKFILE.tmp +} + + +#----------------------------------# +wrt_remove_build_dirs() { # +#----------------------------------# + local name=$1 +( +cat << EOF + @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\ + rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\ + if [ -e \$(MOUNT_PT)\$(SRC)/$name-build ]; then \\ + rm -r \$(MOUNT_PT)\$(SRC)/$name-build; \\ + fi; +EOF +) >> $MKFILE.tmp +} + + +#----------------------------------# +wrt_remove_build_dirs2() { # +#----------------------------------# + local name=$1 +( +cat << EOF + @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\ + rm -r \$(SRC)/\$\$ROOT && \\ + if [ -e \$(SRC)/$name-build ]; then \\ + rm -r \$(SRC)/$name-build; \\ + fi; +EOF +) >> $MKFILE.tmp +} + + + +#----------------------------------# +wrt_run_as_chroot1() { # +#----------------------------------# + local this_script=$1 + local file=$2 +( + cat << EOF + @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/${this_script} && \\ + \$(CHROOT1) 'cd /jhalfs && source envars && /jhalfs/${PROGNAME}-commands/$file >>/jhalfs/logs/${this_script} 2>&1' && \\ + echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/${this_script} +EOF +) >> $MKFILE.tmp +} + + +#----------------------------------# +wrt_run_as_chroot2() { # +#----------------------------------# + local this_script=$1 + local file=$2 +( +cat << EOF + @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/${this_script} && \\ + \$(CHROOT2) 'cd /jhalfs && source envars && /jhalfs/${PROGNAME}-commands/$file >>/jhalfs/logs/${this_script} 2>&1' && \\ + echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/${this_script} +EOF +) >> $MKFILE.tmp +} + + +#----------------------------------# +wrt_copy_fstab() { # +#----------------------------------# + local i=$1 +( + cat << EOF + @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/$i && \\ + cp -v $FSTAB \$(MOUNT_PT)/etc/fstab >>logs/$i 2>&1 && \\ + echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/$i +EOF +) >> $MKFILE.tmp +} + +#----------------------------------# +wrt_copy_fstab2() { # +#----------------------------------# + local i=$1 +( + cat << EOF + @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \`\n" >logs/$i && \\ + cp -v $FSTAB /etc/fstab >>logs/$i 2>&1 && \\ + echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \`\n" >>logs/$i +EOF +) >> $MKFILE.tmp +} + + +#----------------------------------# +wrt_export_timezone() { # +#----------------------------------# + echo -e '\t@echo "export TIMEZONE=$(TIMEZONE)" >> envars' >> $MKFILE.tmp +} + + +#----------------------------------# +wrt_export_pagesize() { # +#----------------------------------# + echo -e '\t@echo "export PAGE=$(PAGE)" >> envars' >> $MKFILE.tmp +} + + +#----------------------------------# +wrt_export_pkgdir() { # +#----------------------------------# +( + cat << EOF + @echo "export PKGDIR=\$(SRC)/binutils-build" > envars +EOF +) >> $MKFILE.tmp +} + + +#----------------------------# +run_make() { +#----------------------------# + # Test if make must be run. + if [ "$RUNMAKE" = "1" ] ; then + # Test to make sure we're running the build as root + if [ "$UID" != "0" ] ; then + echo "You must be logged in as root to successfully build LFS." + exit 1 + fi + # Build the system + if [ -e $MKFILE ] ; then + echo -ne "Building the LFS system...\n" + cd $JHALFSDIR && make -f ${PROGNAME}-Makefile + echo -ne "done\n" + fi + fi +} + + +#----------------------------# +clean_builddir() { +#----------------------------# + # Test if the clean must be done. + if [ "$CLEAN" = "1" ] ; then + # Test to make sure we're running the clean as root + if [ "$UID" != "0" ] ; then + echo "You must be logged in as root to clean the build directory." + exit 1 + fi + # Test to make sure that the build directory was populated by jhalfs + if [ ! -d $JHALFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then + echo "Looks like $BUILDDIR was not populated by a previous jhalfs run." + exit 1 + else + # Clean the build directory + echo -ne "Cleaning $BUILDDIR...\n" + rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,tools,usr,var} + echo -ne "Cleaning $JHALFSDIR...\n" + rm -rf $JHALFSDIR/{0*,1*,envars,sources-dir,commands,logs,Makefile,dump-lfs-scripts.xsl,functions,packages,patches} + echo -ne "Cleaning remainig extracted sources in $BUILDDIR/sources...\n" + rm -rf `find $BUILDDIR/sources/* -maxdepth 0 -type d` + echo -ne "done\n" + fi + fi +} + +#----------------------------# +get_book() { +#----------------------------# + cd $JHALFSDIR + + if [ -z $WC ] ; then + # Check for Subversion instead of just letting the script hit 'svn' and fail. + test `type -p svn` || eval "echo \"This feature requires Subversion.\" + exit 1" + echo -n "Downloading the $PROGNAME document, $LFSVRS version... " + + case $PROGNAME in + lfs) svn_root="LFS" ;; + hlfs) svn_root="HLFS" ;; + clfs) svn_root="cross-lfs" ;; + blfs) svn_root="BLFS" ;; + *) echo "BOOK not defined in function " + exit 1 ;; + esac + # Grab a fresh LFS book if it's missing, otherwise, update it from the + # repo. If we've already extracted the commands, move on to getting the + # sources. + if [ -d ${PROGNAME}-$LFSVRS ] ; then + cd ${PROGNAME}-$LFSVRS + if LC_ALL=C svn up | grep -q At && test -d $JHALFSDIR/commands && \ + test -f $JHALFSDIR/packages && test -f $JHALFSDIR/patches ; then + echo -ne "done\n" + # Set the canonical book version + cd $JHALFSDIR + VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@@@'` + get_sources + else + echo -ne "done\n" + # Set the canonical book version + cd $JHALFSDIR + VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@@@'` + extract_commands + fi + else + case $LFSVRS in + development) + svn co $SVN/${svn_root}/trunk/BOOK ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;; + alphabetical) + svn co $SVN/${svn_root}/branches/$LFSVRS/BOOK ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;; + esac + echo -ne "done\n" + # Set the canonical book version + cd $JHALFSDIR + VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@@@'` + extract_commands + fi + else + echo -ne "Using $BOOK as book's sources ...\n" + # Set the canonical book version + cd $JHALFSDIR + VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@@@'` + extract_commands + fi +} + + +#----------------------------# +build_patches_file() { # Supply a suitably formated list of patches. +#----------------------------# + local saveIFS=$IFS + + LOC_add_patches_entry() { + for f in `grep "/$1-" patcheslist_.wget`; do + basename $f | sed "s|${2}|\&${1}-version;|" >> patches + done + } + + xsltproc --nonet \ + --xinclude \ + -o patcheslist_.wget \ + hlfs-patcheslist_.xsl \ + $BOOK/index.xml > /dev/null 2>&1 + + rm -f patches + + IFS=$'\x0A' # Modify the 'internal field separator' to break on 'LF' only + for f in `cat packages`; do + IFS=$saveIFS + LOC_add_patches_entry \ + `echo $f | sed -e 's/-version//' \ + -e 's/-file.*//' \ + -e 's/"//g' \ + -e 's/uclibc/uClibc/'` + done + + # .... U G L Y .... what to do with the grsecurity patch to the kernel.. + for f in `grep "/grsecurity-" patcheslist_.wget`; do + basename $f >> patches + done + + IFS=$saveIFS + rm -f patcheslist_.wget +} + + + +#----------------------------# +extract_commands() { # +#----------------------------# + # Check for libxslt instead of just letting the script hit 'xsltproc' and fail. + test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\" + exit 1" + + cd $JHALFSDIR + VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@@@'` + + # Start clean + if [ -d commands ]; then + rm -rf commands + mkdir -v commands + fi + echo -n "Extracting commands..." + + # Dump the commands in shell script form from the HLFS book. + case ${PROGNAME} in + clfs) + echo "${tab_}Extracting commands for ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture" + xsltproc --xinclude \ + --nonet \ + --output ./${PROGNAME}-commands/ \ + $BOOK/stylesheets/dump-commands.xsl $BOOK/$ARCH-index.xml + ;; + hlfs) + echo "${tab_}Extracting commands for ${L_arrow}${BOLD}$MODEL${R_arrow} HLFS architecture" + xsltproc --nonet \ + --xinclude \ + --stringparam model $MODEL \ + --stringparam testsuite $TEST \ + --stringparam toolchaintest $TOOLCHAINTEST \ + --stringparam vim-lang $VIMLANG \ + -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1 + ;; + lfs) + echo "${tab_}Extracting commands for ${L_arrow}${BOLD}LFS${R_arrow} build" + xsltproc --nonet \ + --xinclude \ + --stringparam testsuite $TEST \ + --stringparam toolchaintest $TOOLCHAINTEST \ + --stringparam vim-lang $VIMLANG \ + -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1 + ;; + blfs) + echo "${tab_}Extracting commands for ${L_arrow}${BOLD}BLFS${R_arrow} build" + xsltproc --nonet \ + --xinclude \ + --stringparam testsuite $TEST \ + --stringparam server $SERVER \ + -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1 + ;; + *) exit 1 + esac + + + + # Make the scripts executable. + chmod -R +x $JHALFSDIR/${PROGNAME}-commands + + # Grab the patches and package names. + cd $JHALFSDIR + for i in patches packages ; do rm -f $i ; done + grep "\-version" $BOOK/general.ent | sed -e 's@@"@' \ + -e '/generic/d' >> packages + + # Download the vim-lang package if it must be installed + if [ "$VIMLANG" = "1" ] ; then + echo `grep "vim" packages | sed 's@vim@&-lang@'` >> packages + fi + echo `grep "udev-config-file" $BOOK/general.ent | sed -e 's@@"@'` >> packages + + # There is no HLFS patches.ent file so we will create one. + + case "${PROGNAME}" in + hlfs) build_patches_file ;; + clfs) ;; + lfs) ;; + blfs) ;; + *) exit 1 + esac + + + # Done. Moving on... + echo -ne " ... done\n" + get_sources +} + + +#----------------------------# +download() { # Download file, write name to MISSING_FILES.DMP if an error +#----------------------------# + cd $BUILDDIR/sources + + # Hackish fix for the bash-doc, glibc-{linuxthreads,libidn} and + # module-init-tools-testsuite packages that don't conform to + # norms in the URL scheme. + DIR=`echo $1 | sed 's@-doc@@;s@-linuxthreads@@;s@-libidn@@;s@-testsuite@@'` + + # Find the md5 sum for this package. + if [ $2 != MD5SUMS ] ; then + set +e + MD5=`grep " $2" MD5SUMS` + if [ $? -ne 0 ]; then + set -e + echo "${RED}$2 not found in MD5SUMS${OFF}" + echo "$2 not found in MD5SUMS" >> MISSING_FILES.DMP + return + fi + set -e + fi + + if [ ! -f $2 ] ; then + case $DL in + wget ) wget $HTTP/$DIR/$2 ;; + curl ) `curl -# $HTTP/$DIR/$2 -o $2` ;; + * ) echo "$DL not supported at this time." ;; + esac + elif ! echo "$MD5" | md5sum -c - >/dev/null 2>/dev/null ; then + case $DL in + wget ) wget -c $HTTP/$DIR/$2 ;; + curl ) `curl -# -C - $HTTP/$DIR/$2 -o $2` ;; + * ) echo "$DL not supported at this time." ;; + esac + fi + + if [ $2 != MD5SUMS ] && ! echo "$MD5" | md5sum -c - ; then + exit 1 + fi + if [ $2 != MD5SUMS ] ; then + echo `grep "$MD5" MD5SUMS` >> MD5SUMS-$VERSION + fi +} + + +#----------------------------# +get_sources() { +#----------------------------# + + # Test if the packages must be downloaded + if [ "$HPKG" = "1" ] ; then + + # This variable is necessary to make sure the `cat $JHALFSDIR/packages` + # separates each iteration by lines. It is necessary to have the second + # ' on the next line. + IFS=' +' + + if [ ! -d $BUILDDIR/sources ] ; then mkdir $BUILDDIR/sources ; fi + cd $BUILDDIR/sources + if [ -f MD5SUMS ] ; then rm MD5SUMS ; fi + if [ -f MD5SUMS-$VERSION ] ; then rm MD5SUMS-$VERSION ; fi + + download "" MD5SUMS + + # Iterate through each package and grab it, along with any patches it needs. + for i in `cat $JHALFSDIR/packages` ; do + PKG=`echo $i | sed -e 's/-version.*//' -e 's/-file.*//'` + + # There are some entities that aren't valid packages. + if [ "$PKG" = "expect-lib" -o "$PKG" = "linux-dl" -o "$PKG" = "groff-patchlevel" ] ; then continue ; fi + + VRS=`echo $i | sed -e 's/.* //' -e 's/"//g'` + case $PKG in + tcl) FILE="$PKG$VRS-src.tar.bz2" ;; + vim-lang) PKG="vim" + FILE="vim-$VRS-lang.tar.bz2" ;; + udev-config) PKG="udev" + FILE="$VRS" ;; + *) FILE="$PKG-$VRS.tar.bz2" ;; + esac + download $PKG $FILE + + # Download any associated patches + for patch in `grep "&$PKG-version" $JHALFSDIR/patches` ; do + PATCH=`echo $patch | sed 's@&'$PKG'-version;@'$VRS'@'` + download $PKG $PATCH + done + done + fi +} + +#-----------------------------------------------# +_IS_() # Function to test build scripts names +#-----------------------------------------------# +{ + # Returns substr $2 or null str + # Must use string testing + case $1 in + *$2*) echo "$2" ;; + *) echo "" ;; + esac +} diff --git a/common/config b/common/config new file mode 100644 index 0000000..bc85516 --- /dev/null +++ b/common/config @@ -0,0 +1,49 @@ +##### +# +# Masterscript configuration file +# +##### + +declare -r SVN="svn://svn.linuxfromscratch.org" +declare -r LOG=000-masterscript.log + +#--- Mount point for the build +BUILDDIR=/mnt/SourceFiles + +#--- Download the source packages 0(no)/1(yes) +HPKG=0 + +#--- Run the makefile at the end 0(no)/1(yes) +RUNMAKE=0 + +#--- Run test suites 0(no)/1(yes) +TEST=1 + +#--- Run the toolchain tests 0(no)/1(yes) +TOOLCHAINTEST=1 + +#--- Run the stripping phases 0(no)/1(yes) +STRIP=1 + +#--- page definition for groff letter/A4 +PAGE=letter + +#--- set default timezone. +TIMEZONE=America/Toronto + +#--- install the optional vim-lang package 0(no)/1(yes) +VIMLANG=0 + +#--- Language information, /etc/profile see for values +LC_ALL=en_CA +LANG=en_CA + +#--- Include the keymap in the kernel if defined +KEYMAP=/usr/share/kbd/keymaps/i386/qwerty/us.map.gz + +#==== INTERNAL VARIABLES ==== +# Don't edit it unless you know what you are doing + +#--- Working directories +JHALFSDIR=$BUILDDIR/jhalfs + LOGDIR=$JHALFSDIR/logs diff --git a/common/makefile-functions b/common/makefile-functions new file mode 100644 index 0000000..e288622 --- /dev/null +++ b/common/makefile-functions @@ -0,0 +1,105 @@ +BOLD= "" +RED= "" +GREEN= "" +ORANGE= "" +BLUE= "" +WHITE= "" + +define echo_message + @echo $(BOLD) + @echo -------------------------------------------------------------------------------- + @echo $(BOLD)$(1) target $(BLUE)$@$(BOLD) + @echo --------------------------------------------------------------------------------$(WHITE) +endef + +define unpack + @if [ -f $(MOUNT_PT)$(SRC)/$(1).bz2 ] ; then \ + cd $(MOUNT_PT)$(SRC) ; tar -xvjf $(1).bz2 > /tmp/unpacked ; \ + else \ + cd $(MOUNT_PT)$(SRC) ; tar -xvzf $(1).gz > /tmp/unpacked ; \ + fi ; +endef + +define unpack2 + @cd $(MOUNT_PT)$(SRC) ; /tools/bin/tar -xvf $(1) > /tmp/unpacked +endef + +define unpack3 + @cd $(MOUNT_PT)$(SRC) ; tar -xvf $(1) > /tmp/unpacked +endef + +define unpack4 + @cd $(SRC) ; tar -xvf $(1) > /tmp/unpacked +endef + +define echo_finished + @echo $(BOLD) + @echo -------------------------------------------------------------------------------- + @echo $(BOLD) Finished the build of $(BLUE)$(1)$(BOLD) + @echo -------------------------------------------------------------------------------- + @echo -e \\t\\t$(RED)W A R N I N G$(BOLD) + @echo -------------------------------------------------------------------------------- + @echo + @echo To be able to boot your new LFS system you need to follow + @echo the next steps:$(WHITE) + @echo + @echo -e \\t- Enter to the chroot using the command found + @echo -e \\tin 8.4 Entering the Chroot Environment + @echo + @echo -e \\t- Set a password for the root user + @echo + @echo -e \\t- Edit /etc/fstab, /etc/hosts, /etc/sysconfig/clock, + @echo -e \\t/etc/sysconfig/console, /etc/sysconfig/network, + @echo -e \\t/etc/sysconfig//network-devices/ifconfig.eth0/ipv4 and + @echo -e \\tany other configuration file required to suit your needs. + @echo + @echo -e \\t- Set-up Grub. See chapter08/grub.html + @echo + @echo -e \\t- Unmount the filesystems. + @echo + @echo If you are an experienced LFS user, several of those steps can be + @echo skipped or done in a different way. But then, that is something + @echo that you already know and there is no need to discuss it here. + @echo $(BOLD) + @echo -------------------------------------------------------------------------------- + @echo -e \\t\\t$(GREEN)Have a nice day $(ORANGE):-\)$(BOLD) + @echo --------------------------------------------------------------------------------$(WHITE) +endef + +define echo_boot_finished + @echo $(BOLD) + @echo -------------------------------------------------------------------------------- + @echo $(BOLD) Finished building a minimal boot system for $(BLUE)$(1)$(BOLD) + @echo -------------------------------------------------------------------------------- + @echo -e \\t\\t$(RED)W A R N I N G$(BOLD) + @echo -------------------------------------------------------------------------------- + @echo + @echo The build is not complete. Follow the next steps:$(WHITE) + @echo + @echo -e \\t- Enter to the chroot using the command found + @echo -e \\tin 8.4 Entering the Chroot Environment + @echo + @echo -e \\t- Set a password for the root user + @echo + @echo -e \\t- Edit /etc/fstab, /etc/hosts, /etc/sysconfig/clock, + @echo -e \\t/etc/sysconfig/console, /etc/sysconfig/network, + @echo -e \\t/etc/sysconfig//network-devices/ifconfig.eth0/ipv4 and + @echo -e \\tany other configuration file required to suit your needs. + @echo + @echo -e \\t- Set-up Grub. + @echo + @echo -e \\t- Unmount the filesystems. + @echo + @echo If you are an experienced LFS user, several of those steps can be + @echo skipped or done in a different way. But then, that is something + @echo that you already know and there is no need to discuss it here. + @echo $(BOLD) + @echo $(BOLD)$(YELLOW) + @echo Boot the new partition. Once you are logged in issue the following cmds + @echo -e \\t cd /jhahlfs + @echo -e \\t make XXXXXXXX + @echo The build process should resume. Follow any instructions that appear. + @echo -------------------------------------------------------------------------------- + @echo -e \\t\\t$(GREEN)Have a nice day $(ORANGE):-\)$(BOLD) + @echo --------------------------------------------------------------------------------$(WHITE) +endef diff --git a/hlfs b/hlfs new file mode 120000 index 0000000..fba0373 --- /dev/null +++ b/hlfs @@ -0,0 +1 @@ +master.sh \ No newline at end of file diff --git a/lfs b/lfs new file mode 120000 index 0000000..fba0373 --- /dev/null +++ b/lfs @@ -0,0 +1 @@ +master.sh \ No newline at end of file diff --git a/master.sh b/master.sh new file mode 100755 index 0000000..1a1b13e --- /dev/null +++ b/master.sh @@ -0,0 +1,457 @@ +#!/bin/bash +set -e + + +#>>>>>>>>>>>>>>>ERROR TRAPPING >>>>>>>>>>>>>>>>>>>> +#-----------------------# +simple_error() { # Basic error trap.... JUST DIE +#-----------------------# + # If +e then disable text output + if [[ "$-" =~ "e" ]]; then + echo -e "\n${RED}ERROR:${GREEN} basic error trapped!${OFF}\n" >&2 + fi +} + +see_ya() { + echo -e "\n\t${BOLD}Goodbye and thank you for choosing ${L_arrow}JHALFS${R_arrow}\n" +} +##### Simple error TRAPS +# ctrl-c SIGINT +# ctrl-y +# ctrl-z SIGTSTP +# SIGHUP 1 HANGUP +# SIGINT 2 INTRERRUPT FROM KEYBOARD Ctrl-C +# SIGQUIT 3 +# SIGKILL 9 KILL +# SIGTERM 15 TERMINATION +# SIGSTOP 17,18,23 STOP THE PROCESS +##### +set -e +trap see_ya 0 +trap simple_error ERR +trap 'echo -e "\n\n${RED}INTERRUPT${OFF} trapped\n" && exit 2' 1 2 3 15 17 18 23 +#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + PROGNAME=$(basename $0) + VERSION="0.0.1" + MODULE=$PROGNAME.module +MODULE_CONFIG=$PROGNAME.conf + +echo -n "Loading common-func.module..." +source common-func.module +[[ $? > 0 ]] && echo "common-func.module did not load.." && exit +echo "OK" +# + +if [ ! -L $0 ] ; then + echo "${nl_}${tab_}${BOLD}${RED}This script cannot be called directly: EXITING ${OFF}${nl_}" + exit 1 +fi + +echo -n "Loading masterscript.conf..." +source masterscript.conf +[[ $? > 0 ]] && echo "masterscript.conf did not load.." && exit +echo "OK" +# +echo -n "Loading config module <$MODULE_CONFIG>..." +source $MODULE_CONFIG +[[ $? > 0 ]] && echo "$MODULE_CONFIG did not load.." && exit 1 +echo "OK" +# +echo -n "Loading code module <$MODULE>..." +source $MODULE +if [[ $? > 0 ]]; then + echo "$MODULE did not load.." + exit 2 +fi +echo "OK" +# +echo "---------------${nl_}" + + +#=========================================================== +# If the var BOOK contains something then, maybe, it points +# to a working doc.. set WC=1, else 'null' +#=========================================================== +WC=${BOOK:+1} +#=========================================================== + + +#*******************************************************************# + + +#----------------------------# +check_requirements() { # Simple routine to validate gcc and kernel versions against requirements +#----------------------------# + # Minimum values acceptable + # bash 3.0> + # gcc 3.0> + # kernel 2.6.2> + + [[ $1 = "1" ]] && echo "${nl_}BASH: ${L_arrow}${BOLD}${BASH_VERSION}${R_arrow}" + case $BASH_VERSION in + [3-9].*) ;; + *) 'clear' + echo -e " +$DD_BORDER +\t\t${OFF}${RED}BASH version ${BOLD}${YELLOW}-->${WHITE} $BASH_VERSION ${YELLOW}<--${OFF}${RED} is too old. +\t\t This script requires 3.0${OFF}${RED} or greater +$DD_BORDER" + exit 1 + ;; + esac + + [[ $1 = "1" ]] && echo "GCC: ${L_arrow}${BOLD}`gcc -dumpversion`${R_arrow}" + case `gcc -dumpversion` in + [3-9].[0-9].* ) ;; + *) 'clear' + echo -e " +$DD_BORDER +\t\t${OFF}${RED}GCC version ${BOLD}${YELLOW}-->${WHITE} $(gcc -dumpversion) ${YELLOW}<--${OFF}${RED} is too old. +\t\t This script requires ${BOLD}${WHITE}3.0${OFF}${RED} or greater +$DD_BORDER" + exit 1 + ;; + esac + + # + # >>>> Check kernel version against the minimum acceptable level <<<< + # + [[ $1 = "1" ]] && echo "LINUX: ${L_arrow}${BOLD}`uname -r`${R_arrow}" + + local IFS + declare -i major minor revision change + min_kernel_vers=2.6.2 + + IFS=".-" # Split up w.x.y.z as well as w.x.y-rc (catch release candidates) + set -- $min_kernel_vers # set postional parameters to minimum ver values + major=$1; minor=$2; revision=$3 + # + set -- `uname -r` # Set postional parameters to user kernel version + #Compare against minimum acceptable kernel version.. + (( $1 > major )) && return + (( $1 == major )) && ((( $2 > minor )) || + ((( $2 == minor )) && (( $3 >= revision )))) && return + + # oops.. write error msg and die + echo -e " +$DD_BORDER +\t\t${OFF}${RED}The kernel version ${BOLD}${YELLOW}-->${WHITE} $(uname -r) ${YELLOW}<--${OFF}${RED} is too old. +\t\tThis script requires version ${BOLD}${WHITE}$min_kernel_vers${OFF}${RED} or greater +$DD_BORDER" + exit 1 +} + + +#----------------------------# +validate_config() { # Are the config values sane (within reason) +#----------------------------# + local -r lfs_PARAM_LIST="BUILDDIR HPKG TEST TOOLCHAINTEST STRIP VIMLANG PAGE RUNMAKE" + local -r blfs_PARAM_LIST="BUILDDIR TEST DEPEND" + local -r hlfs_PARAM_LIST="BUILDDIR HPKG MODEL TEST TOOLCHAINTEST STRIP VIMLANG PAGE GRSECURITY_HOST RUNMAKE TIMEZONE" + local -r clfs_PARAM_LIST="ARCH BOOTMINIMAL RUNMAKE MKFILE" + local -r global_PARAM_LIST="BUILDDIR HPKG RUNMAKE TEST TOOLCHAINTEST STRIP PAGE TIMEZONE VIMLANG" + + local PARAM_LIST= + + local -r ERROR_MSG='The variable \"${L_arrow}${config_param}${R_arrow}\" value ${L_arrow}${BOLD}${!config_param}${R_arrow} is invalid, ${nl_}check the config file ${BOLD}${GREEN}\<$PROGNAME.conf\>${OFF}' + local -r PARAM_VALS='${config_param}: ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}' + local config_param + local validation_str + + write_error_and_die() { + echo -e "\n${DD_BORDER}" + echo -e "`eval echo ${ERROR_MSG}`" >&2 + echo -e "${DD_BORDER}\n" + exit 1 + } + + set +e + for PARAM_GROUP in global_PARAM_LIST ${PROGNAME}_PARAM_LIST; do + for config_param in ${!PARAM_GROUP}; do + # This is a tricky little piece of code.. executes a cmd string. + [[ $1 = "1" ]] && echo -e "`eval echo $PARAM_VALS`" + case $config_param in + BUILDDIR) # We cannot have an or root mount point + if [[ "xx x/x" =~ "x${!config_param}x" ]]; then + write_error_and_die + fi + continue ;; + TIMEZONE) continue;; + MKFILE) continue;; + HPKG) validation_str="x0x x1x" ;; + RUNMAKE) validation_str="x0x x1x" ;; + TEST) validation_str="x0x x1x" ;; + STRIP) validation_str="x0x x1x" ;; + VIMLANG) validation_str="x0x x1x" ;; + DEPEND) validation_str="x0x x1x x2x" ;; + MODEL) validation_str="xglibcx xuclibcx" ;; + PAGE) validation_str="xletterx xA4x" ;; + ARCH) validation_str="xx86x xx86_64x xx86_64-64x xsparcx xsparcv8x xsparc64x xsparc64-64x xmipsx xmips64x xmips64-64x xppcx xalphax" ;; + TOOLCHAINTEST) validation_str="x0x x1x" ;; + GRSECURITY_HOST) validation_str="x0x x1x" ;; + BOOTMINIMAL) validation_str="x0x x1x";; + *) + echo "WHAT PARAMETER IS THIS.. <<${config_param}>>" + exit + ;; + esac + # + # This is the 'regexp' test available in bash-3.0.. + # using it as a poor man's test for substring + if [[ ! "${validation_str}" =~ "x${!config_param}x" ]] ; then + # parameter value entered is no good + write_error_and_die + fi + done # for loop + + # Not further tests needed on globals + if [[ "$PARAM_GROUP" = "global_PARAM_LIST" ]]; then + echo " ${BOLD}${GREEN}${PARAM_GROUP%%_*T} parameters are valid${OFF}" + continue + fi + + for config_param in LC_ALL LANG; do + [[ $1 = "1" ]] && echo "`eval echo $PARAM_VALS`" + [[ -z "${!config_param}" ]] && continue + # See it the locale values exist on this machine + [[ "`locale -a | grep -c ${!config_param}`" > 0 ]] && continue + + # If you make it this far then there is a problem + write_error_and_die + done + + for config_param in FSTAB CONFIG KEYMAP BOOK; do + [[ $1 = "1" ]] && echo "`eval echo $PARAM_VALS`" + if [[ $config_param = BOOK ]]; then + [[ ! "${WC}" = 1 ]] && continue + fi + [[ -z "${!config_param}" ]] && continue + [[ -e "${!config_param}" ]] && [[ -s "${!config_param}" ]] && continue + + # If you make it this far then there is a problem + write_error_and_die + done + echo " ${BOLD}${GREEN}${PARAM_GROUP%%_*T} parameters are valid${OFF}" + done + set -e + echo "$tab_***${BOLD}${GREEN}Config parameters look good${OFF}***" +} + + + +################################### +### MAIN ### +################################### + +# Evaluate any command line switches + +while test $# -gt 0 ; do + case $1 in + --version | -V ) + clear + echo "$version" + exit 0 + ;; + + --help | -h ) + if [[ "$PROGNAME" = "blfs" ]]; then + blfs_usage + else + usage + fi + ;; + + --LFS-version | -L ) + test $# = 1 && eval "$exit_missing_arg" + shift + case $1 in + dev* | SVN | trunk ) + LFSVRS=development + ;; + 6.1.1 ) + echo "For stable 6.1.1 book, please use jhalfs-0.2." + exit 0 + ;; + alpha*) + LFSVRS=alphabetical + ;; + * ) + echo "$1 is an unsupported version at this time." + exit 1 + ;; + esac + ;; + + --directory | -d ) + test $# = 1 && eval "$exit_missing_arg" + shift + BUILDDIR=$1 + JHALFSDIR=$BUILDDIR/jhalfs + LOGDIR=$JHALFSDIR/logs + MKFILE=$JHALFSDIR/${PROGNAME}-Makefile + ;; + + --rebuild ) CLEAN=1 ;; + + --download-client | -D ) + echo "The download feature is temporarily disable.." + exit + test $# = 1 && eval "$exit_missing_arg" + shift + DL=$1 + ;; + + --working-copy | -W ) + test $# = 1 && eval "$exit_missing_arg" + shift + if [ -f $1/patches.ent ] ; then + WC=1 + BOOK=$1 + else + echo -e "\nLook like $1 isn't a supported working copy." + echo -e "Verify your selection and the command line.\n" + exit 1 + fi + ;; + + --testsuites | -T ) TEST=1 ;; + --get-packages | -P ) HPKG=1 ;; + --run-make | -M ) RUNMAKE=1 ;; + --no-toolchain-test ) TOOLCHAINTEST=0 ;; + --no-strip ) STRIP=0 ;; + --no-vim-lang ) VIMLANG=0 ;; + + --page_size ) + test $# = 1 && eval "$exit_missing_arg" + shift + case $1 in + letter | A4 ) + PAGE=$1 + ;; + * ) + echo "$1 isn't a supported page size." + exit 1 + ;; + esac + ;; + + --timezone ) + test $# = 1 && eval "$exit_missing_arg" + shift + if [ -f /usr/share/zoneinfo/$1 ] ; then + TIMEZONE=$1 + else + echo -e "\nLooks like $1 isn't a valid timezone description." + echo -e "Verify your selection and the command line.\n" + exit 1 + fi + ;; + + --fstab ) + test $# = 1 && eval "$exit_missing_arg" + shift + if [ -f $1 ] ; then + FSTAB=$1 + else + echo -e "\nFile $1 not found. Verify your command line.\n" + exit 1 + fi + ;; + + --kernel-config | -C ) + test $# = 1 && eval "$exit_missing_arg" + shift + if [ -f $1 ] ; then + CONFIG=$1 + else + echo -e "\nFile $1 not found. Verify your command line.\n" + exit 1 + fi + ;; + + * ) + if [[ "$PROGNAME" = "blfs" ]]; then + blfs_usage + else + usage + fi + ;; + esac + shift +done + + +# Prevents setting "-d /" by mistake. + +if [ $BUILDDIR = / ] ; then + echo -ne "\nThe root directory can't be used to build LFS.\n\n" + exit 1 +fi + +# If $BUILDDIR has subdirectories like tools/ or bin/, stop the run +# and notify the user about that. + +if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] && [ -z $CLEAN ] ; then + eval "$no_empty_builddir" +fi + +# If requested, clean the build directory +clean_builddir + +# Find the download client to use, if not already specified. + +if [ -z $DL ] ; then + if [ `type -p wget` ] ; then + DL=wget + elif [ `type -p curl` ] ; then + DL=curl + else + eval "$no_dl_client" + fi +fi + +#=================================================== +# Set the document location... +# BOOK is either defined in +# xxx.config +# comand line +# default +# If set by conf file leave or cmd line leave it +# alone otherwise load the default version +#=================================================== +BOOK=${BOOK:=$PROGNAME-$LFSVRS} +#=================================================== + +if [[ ! -d $JHALFSDIR ]]; then + mkdir -pv $JHALFSDIR +fi + +if [[ "$PWD" != "$JHALFSDIR" ]]; then + cp -v makefile-functions $JHALFSDIR/ + if [[ -n "$FILES" ]]; then + cp -v $FILES $JHALFSDIR/ + fi + sed 's,FAKEDIR,'$BOOK',' $XSL > $JHALFSDIR/${XSL} + export XSL=$JHALFSDIR/${XSL} +fi + +if [[ ! -d $LOGDIR ]]; then + mkdir -v $LOGDIR +fi +>$LOGDIR/$LOG +echo "---------------${nl_}" + + +# Check for minumum gcc and kernel versions +check_requirements 1 # 0/1 0-do not display values. +echo "---------------${nl_}" +validate_config 1 # 0/1 0-do not display values +echo "---------------${nl_}" +get_book +echo "---------------${nl_}" +build_Makefile +echo "---------------${nl_}" +#run_make +