From 83d73fb98517f7bbc7190e06b80721fd2623bd96 Mon Sep 17 00:00:00 2001 From: Manuel Canales Esparcia Date: Sun, 30 Jul 2006 11:34:49 +0000 Subject: [PATCH] Ported new HLFS code and LFS Udev fix to 1.0 branch. --- HLFS/hlfs.xsl | 90 +++++------- HLFS/master.sh | 305 ++++++++++++++++++++++------------------ LFS/lfs.xsl | 6 + LFS/master.sh | 3 - common/common-functions | 2 +- common/config | 4 +- 6 files changed, 218 insertions(+), 192 deletions(-) diff --git a/HLFS/hlfs.xsl b/HLFS/hlfs.xsl index 0d0ffdc..366e3ba 100644 --- a/HLFS/hlfs.xsl +++ b/HLFS/hlfs.xsl @@ -26,7 +26,7 @@ 0 = none 1 = only chapter06 Glibc, GCC and Binutils testsuites 2 = all chapter06 testsuites - 3 = all chapter05 and chapter06 testsuites--> + 3 = alias to 2 --> @@ -94,32 +94,30 @@ + not(@id='bootable-kernel'))"> cd $PKGDIR pushd ../; tar -xvf gettext-&gettext-version;.*; popd; - - tar -xvf ../glibc-libidn-&glibc-version;.* + + + + tar -xvf gcc-core-&gcc-version;.*; + tar -xvf gcc-g++-&gcc-version;.*; + tar -xvf binutils-&binutils-version;.*; - - pushd ../; tar -xvf gcc-g++-&gcc-version;.*; popd; - - - pushd ../; tar -xvf gcc-testsuite-&gcc-version;.*; popd; - - - pushd ../; tar -xvf gcc-testsuite-&gcc-version;.*; popd; + + + tar -xvf gcc-testsuite-&gcc-version;.*; + + pushd ../; tar -xvf blfs-bootscripts-&blfs-bootscripts-version;.* ; popd; - - export HLFS=$LFS - exit @@ -135,24 +133,12 @@ - - - make -k check >> $TEST_LOG 2>&1 || true - - - - make -k - - >> $TEST_LOG 2>&1 || true - - + contains(string(),'check')) and + ($testsuite = '2' or $testsuite = '3')"> + + make -k + + >> $TEST_LOG 2>&1 || true @@ -227,29 +213,23 @@ - - - - - make -k check >> $TEST_LOG 2>&1 || true - - - - + + - make -k check >> $TEST_LOG 2>&1 || true - + + + + + + >> $TEST_LOG 2>&1 || true + + + + + + + + >logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\ + echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script +EOF +) >> $MKFILE.tmp +} + + +#----------------------------------# +wrt_Unpack_SetOwner() { # Unpack and set owner. Assign 'ROOT' var +#----------------------------------# + local USER_ACCT=$1 + local FILE=$2 + local optSAVE_PREVIOUS=$3 + + if [ "${optSAVE_PREVIOUS}" != "1" ]; then + wrt_remove_existing_dirs "$FILE" + fi +( +cat << EOF + @\$(call unpack,$FILE) + @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\ + echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\ + chown -R ${USER_ACCT} \$(MOUNT_PT)\$(SRC)/\$\$ROOT +EOF +) >> $MKFILE.tmp +} + +#----------------------------------# +wrt_RunAsRoot() { # Some scripts must be run as root.. +#----------------------------------# + local user_ACCT=$(echo $1 | tr [a-z] [A-Z]) + local this_script=$2 + local file=$3 + +( +cat << EOF + @( time { export ${user_ACCT}=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\ + echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script +EOF +) >> $MKFILE.tmp +} + + +#----------------------------# +process_toolchain() { # embryo,cocoon and butterfly need special handling +#----------------------------# + local toolchain=$1 + local this_script=$2 + local tc_phase + + echo "${tab_}${tab_}${GREEN}toolchain ${L_arrow}${toolchain}${R_arrow}" + + case ${toolchain} in + *butterfly*) + [[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}" +( +cat << EOF + @echo "export PKGDIR=\$(SRC)" > envars +EOF +) >> $MKFILE.tmp + wrt_run_as_chroot1 "$toolchain" "$this_script" + ;; + + *) +( +cat << EOF + @echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)" > envars +EOF +) >> $MKFILE.tmp + wrt_ExecuteAsUser "hlfs" "$toolchain" "$this_script" + ;; + esac + # + # Safe method to remove packages unpacked outside the toolchain + pkg_tarball=$(get_package_tarball_name "binutils") + wrt_remove_existing_dirs "$pkg_tarball" + pkg_tarball=$(get_package_tarball_name "gcc-core") + wrt_remove_existing_dirs "$pkg_tarball" + # + # Manually remove the toolchain directories.. + tc_phase=`echo $toolchain | sed -e 's@[0-9]\{3\}-@@' -e 's@-toolchain@@'` +( +cat << EOF + @rm -r \$(MOUNT_PT)\$(SRC)/${tc_phase}-toolchain && \\ + rm -r \$(MOUNT_PT)\$(SRC)/${tc_phase}-build +EOF +) >> $MKFILE.tmp + +} + #----------------------------# chapter3_Makefiles() { # Initialization of the system #----------------------------# - local TARGET LOADER echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter3${R_arrow}" # Define a few model dependant variables if [[ ${MODEL} = "uclibc" ]]; then - TARGET="tools-linux-uclibc"; LOADER="ld-uClibc.so.0" + TARGET="pc-linux-gnu"; LOADER="ld-uClibc.so.0" else - TARGET="tools-linux-gnu"; LOADER="ld-linux.so.2" + TARGET="pc-linux-gnu"; LOADER="ld-linux.so.2" fi - # NOTE: We use the lfs username and groupname also in HLFS - # 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 + # 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 @@ -43,38 +140,38 @@ cat << EOF 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; \\ + @if [ ! -d /home/hlfs ]; then \\ + groupadd hlfs; \\ + useradd -s /bin/bash -g hlfs -m -k /dev/null hlfs; \\ else \\ - touch user-lfs-exist; \\ + touch user-hlfs-exist; \\ fi; - @chown lfs \$(MOUNT_PT)/tools && \\ - chown lfs \$(MOUNT_PT)/sources && \\ + @chown hlfs \$(MOUNT_PT)/tools && \\ + chown hlfs \$(MOUNT_PT)/sources && \\ touch \$@ && \\ echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\ echo --------------------------------------------------------------------------------\$(WHITE) 022-settingenvironment: 021-addinguser @\$(call echo_message, Building) - @if [ -f /home/lfs/.bashrc -a ! -f /home/lfs/.bashrc.XXX ]; then \\ - mv /home/lfs/.bashrc /home/lfs/.bashrc.XXX; \\ + @if [ -f /home/hlfs/.bashrc -a ! -f /home/hlfs/.bashrc.XXX ]; then \\ + mv /home/hlfs/.bashrc /home/hlfs/.bashrc.XXX; \\ fi; - @if [ -f /home/lfs/.bash_profile -a ! -f /home/lfs/.bash_profile.XXX ]; then \\ - mv /home/lfs/.bash_profile /home/lfs/.bash_profile.XXX; \\ + @if [ -f /home/hlfs/.bash_profile -a ! -f /home/hlfs/.bash_profile.XXX ]; then \\ + mv /home/hlfs/.bash_profile /home/hlfs/.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 "set +h" > /home/hlfs/.bashrc && \\ + echo "umask 022" >> /home/hlfs/.bashrc && \\ + echo "HLFS=\$(MOUNT_PT)" >> /home/hlfs/.bashrc && \\ + echo "LC_ALL=POSIX" >> /home/hlfs/.bashrc && \\ + echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/hlfs/.bashrc && \\ + echo "export HLFS LC_ALL PATH" >> /home/hlfs/.bashrc && \\ + echo "" >> /home/hlfs/.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 && \\ + echo "source $JHALFSDIR/envars" >> /home/hlfs/.bashrc && \\ + chown hlfs:hlfs /home/hlfs/.bashrc && \\ touch envars && \\ touch \$@ && \\ echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\ @@ -113,14 +210,11 @@ chapter5_Makefiles() { # Bootstrap or temptools phase # 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@@'` + # Grab the name of the target + name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'` # Adjust 'name' case $name in - linux-libc) name="linux-libc-headers" ;; - gcc) name="gcc-core" ;; uclibc) name="uClibc" ;; esac @@ -133,66 +227,41 @@ chapter5_Makefiles() { # Bootstrap or temptools phase # # 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" + # This is a very special script and requires manual processing + # NO Optimization allowed + if [[ ${name} = "embryo-toolchain" ]] || \ + [[ ${name} = "cocoon-toolchain" ]]; then + wrt_target "$this_script" "$PREV" + process_toolchain "${this_script}" "${file}" + wrt_touch + PREV=$this_script + continue + fi + # + wrt_target "$this_script" "$PREV" # Find the version of the command files, if it corresponds with the building of # a specific package pkg_tarball=$(get_package_tarball_name $name) # If $pkg_tarball isn't empty, we've got a package... if [ "$pkg_tarball" != "" ] ; then # Insert instructions for unpacking the package and to set the PKGDIR variable. - case $this_script in - *binutils* ) wrt_unpack "$pkg_tarball" 1 ;; # Do not delete an existing package directories - *) wrt_unpack "$pkg_tarball" ;; - esac + wrt_Unpack_SetOwner "hlfs" "$pkg_tarball" # If the testsuites must be run, initialize the log file [[ "$TEST" = "3" ]] && wrt_test_log "${this_script}" # If using optimizations, write the instructions [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name" fi - - case $this_script in - *binutils* ) # Dump the path to sources directory for later removal -( -cat << EOF - @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\ - echo "\$(MOUNT_PT)\$(SRC)/\$\$ROOT" >> sources-dir -EOF -) >> $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 - ;; - 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}" + wrt_ExecuteAsUser "hlfs" "$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 [ "$pkg_tarball" != "" ] ; then - case "${this_script}" in - *binutils*) : ;; # do NOTHING - *gcc*) wrt_remove_build_dirs "gcc" ;; - *) wrt_remove_build_dirs "$name" ;; - esac + wrt_remove_build_dirs "$name" fi - # Remove the Binutils pass 1 sources after a successful Adjusting phase. - case "${this_script}" in - *adjusting*) -( -cat << EOF - @rm -r \`cat sources-dir\` && \\ - rm -r \$(MOUNT_PT)\$(SRC)/binutils-build && \\ - rm sources-dir -EOF -) >> $MKFILE.tmp - ;; - esac - # Include a touch of the target name so make can check if it's already been made. wrt_touch # @@ -209,7 +278,6 @@ EOF #----------------------------# chapter6_Makefiles() { # sysroot or chroot build phase #----------------------------# - local TARGET LOADER local file local this_script # Set envars and scripts for iteration targets @@ -237,14 +305,6 @@ chapter6_Makefiles() { # sysroot or chroot build phase fi echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N${R_arrow}" - # - # 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 for file in chapter06$N/* ; do # Keep the script file name @@ -262,17 +322,7 @@ chapter6_Makefiles() { # sysroot or chroot build phase # Grab the name of the target name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'` - # - # Sed replacement to fix some rm command that could fail. - # That should be fixed in the book sources. - # case $name in - glibc) sed 's/rm /rm -f /' -i chapter06$N/$this_script ;; - gcc) sed 's/rm /rm -f /' -i chapter06$N/$this_script ;; - esac - - case $name in - gcc) name="gcc-core" ;; uclibc) name="uClibc" ;; esac @@ -301,17 +351,24 @@ chapter6_Makefiles() { # sysroot or chroot build phase #--------------------------------------------------------------------# # # Drop in the name of the target on a new line, and the previous target - # as a dependency. Also call the echo_message function. + # as a dependency. Also call the echo_message function. + if [[ ${name} = "butterfly-toolchain" ]]; then + wrt_target "$this_script" "$PREV" + process_toolchain "${this_script}" "${file}" + wrt_touch + PREV=$this_script + continue + fi + wrt_target "${this_script}${N}" "$PREV" # If $pkg_tarball isn't empty, we've got a package... # Insert instructions for unpacking the package and changing directories if [ "$pkg_tarball" != "" ] ; then wrt_unpack2 "$pkg_tarball" - wrt_target_vars # If the testsuites must be run, initialize the log file case $name in - binutils | gcc-core | glibc ) + glibc ) [[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}" ;; * ) @@ -322,16 +379,10 @@ chapter6_Makefiles() { # sysroot or chroot build phase [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name" 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 - ;; - esac - - # In the mount of kernel filesystems we need to set LFS and not to use chroot. + # In the mount of kernel filesystems we need to set HLFS and not to use chroot. case "${this_script}" in *kernfs*) - wrt_run_as_root "${this_script}" "${file}" + wrt_RunAsRoot "hlfs" "${this_script}" "${file}" ;; *) # The rest of Chapter06 wrt_run_as_chroot1 "${this_script}" "${file}" @@ -343,19 +394,6 @@ chapter6_Makefiles() { # sysroot or chroot build phase wrt_remove_build_dirs "$name" fi # - # Remove the Binutils pass 2 sources after a successful Re-Adjusting phase. - case "${this_script}" in - *readjusting*) -( -cat << EOF - @rm -r \`cat sources-dir\` && \\ - rm -r \$(MOUNT_PT)\$(SRC)/binutils-build && \\ - rm sources-dir -EOF -) >> $MKFILE.tmp - ;; - esac - # Include a touch of the target name so make can check if it's already been made. wrt_touch # @@ -389,7 +427,6 @@ chapter7_Makefiles() { # Create a bootable system.. kernel, bootscripts..e case $this_script in *usage) continue ;; # Contains example commands *grub) continue ;; - *reboot) continue ;; *console) continue ;; # Use the file generated by lfs-bootscripts *kernel) @@ -519,7 +556,7 @@ all: chapter3 chapter5 chapter6 chapter7 do-housekeeping chapter3: 020-creatingtoolsdir 021-addinguser 022-settingenvironment -chapter5: chapter3 $chapter5 restore-lfs-env +chapter5: chapter3 $chapter5 restore-hlfs-env chapter6: chapter5 $chapter6 @@ -533,18 +570,18 @@ clean: clean-chapter7 clean-chapter6 clean-chapter5 clean-chapter3 restart: restart_code all clean-chapter3: - -if [ ! -f user-lfs-exist ]; then \\ - userdel lfs; \\ - rm -rf /home/lfs; \\ + -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-lfs-exist + rm -f envars user-hlfs-exist rm -f 02* logs/02*.log clean-chapter5: rm -rf \$(MOUNT_PT)/tools/* - rm -f $chapter5 restore-lfs-env sources-dir + rm -f $chapter5 restore-hlfs-env sources-dir cd logs && rm -f $chapter5 && cd .. clean-chapter6: @@ -561,15 +598,15 @@ clean-chapter7: rm -f $chapter7 cd logs && rm -f $chapter7 && cd .. -restore-lfs-env: +restore-hlfs-env: @\$(call echo_message, Building) - @if [ -f /home/lfs/.bashrc.XXX ]; then \\ - mv -f /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\ + @if [ -f /home/hlfs/.bashrc.XXX ]; then \\ + mv -f /home/hlfs/.bashrc.XXX /home/hlfs/.bashrc; \\ fi; - @if [ -f /home/lfs/.bash_profile.XXX ]; then \\ - mv /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\ + @if [ -f /home/hlfs/.bash_profile.XXX ]; then \\ + mv /home/hlfs/.bash_profile.XXX /home/hlfs/.bash_profile; \\ fi; - @chown lfs:lfs /home/lfs/.bash* && \\ + @chown hlfs:hlfs /home/hlfs/.bash* && \\ touch \$@ && \\ echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\ echo --------------------------------------------------------------------------------\$(WHITE) @@ -580,25 +617,25 @@ do-housekeeping: @-umount \$(MOUNT_PT)/dev @-umount \$(MOUNT_PT)/sys @-umount \$(MOUNT_PT)/proc - @-if [ ! -f user-lfs-exist ]; then \\ - userdel lfs; \\ - rm -rf /home/lfs; \\ + @-if [ ! -f user-hlfs-exist ]; then \\ + userdel hlfs; \\ + rm -rf /home/hlfs; \\ fi; restart_code: - @echo ">>> This feature is experimental, BUGS may exist" - + @echo ">>> This feature is experimental, BUGS may exist" + @if [ ! -L /tools ]; then \\ echo -e "\\nERROR::\\n /tools is NOT a symlink.. /tools must point to \$(MOUNT_PT)/tools\\n" && false;\\ fi; - + @if [ ! -e /tools ]; then \\ echo -e "\\nERROR::\\nThe target /tools points to does not exist.\\nVerify the target.. \$(MOUNT_PT)/tools\\n" && false;\\ fi; - + @if ! stat -c %N /tools | grep "\$(MOUNT_PT)/tools" >/dev/null ; then \\ echo -e "\\nERROR::\\nThe symlink \\"/tools\\" does not point to \\"\$(MOUNT_PT)/tools\\".\\nCorrect the problem and rerun\\n" && false;\\ - fi; + fi; @if [ -f ???-kernfs ]; then \\ mkdir -pv \$(MOUNT_PT)/{proc,sys};\\ diff --git a/LFS/lfs.xsl b/LFS/lfs.xsl index 7ab84f6..13da29f 100644 --- a/LFS/lfs.xsl +++ b/LFS/lfs.xsl @@ -132,6 +132,12 @@ + + + if [[ ! -d /lib/udev/devices ]] ; then + + fi + diff --git a/LFS/master.sh b/LFS/master.sh index 43c8d88..8ab0dd6 100755 --- a/LFS/master.sh +++ b/LFS/master.sh @@ -165,9 +165,6 @@ chapter6_Makefiles() { done # Remove Bzip2 binaries before make install sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i chapter06$N/*-bzip2 - # Let some Udev pre-installation commands to fail - sed -e 's@/lib/udev/devices/fd@& || true@' \ - -e 's/mknod -m.*/& || true/' -i chapter06$N/*-udev fi echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N${R_arrow}" diff --git a/common/common-functions b/common/common-functions index fd1de8e..a7e249e 100644 --- a/common/common-functions +++ b/common/common-functions @@ -82,7 +82,7 @@ ${BOLD} -T, --testsuites N ${OFF} 1 = only final system Glibc, GCC and Binutils testsuites 2 = all final system testsuites 3 = all temporary tools and final system testsuites - In CLFS, 3 is an alias to 2 + In CLFS and HLFS, 3 is an alias to 2 ${BOLD} -W, --working-copy DIR${OFF} use the local working copy placed in DIR as the $(echo $PROGNAME | tr [a-z] [A-Z]) book diff --git a/common/config b/common/config index 415345c..bb8d988 100644 --- a/common/config +++ b/common/config @@ -16,7 +16,7 @@ BUILDDIR=/mnt/build_dir REPORT=1 #=== Getting packages === -# Files will be retrieved from the local archive SRC_ARCHIVE +# Files will be retrieved from the local archive SRC_ARCHIVE # (if defined) or the 'net and will be stored in $BUILDDIR/sources #--- Download the source packages 0(no)/1(yes) GETPKG=0 @@ -48,7 +48,7 @@ OPTIMIZE=0 # 1 = only chapter06 Glibc, GCC and Binutils testsuites # 2 = all chapter06 testsuites # 3 = all chapter05 and chapter06 testsuites -# (in CLFS, alias to 2) +# (in CLFS and HLFS, alias to 2) TEST=1 #--- Run the stripping phases 0(no)/1(yes)