diff --git a/CLFS2/master.sh b/CLFS2/master.sh index d7ec1b9..712c3b2 100755 --- a/CLFS2/master.sh +++ b/CLFS2/master.sh @@ -11,7 +11,7 @@ host_prep_Makefiles() { # Initialization of the system #----------------------------# local CLFS_HOST - echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files${R_arrow}" + echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files ( SETUP ) ${R_arrow}" # defined here, only for ease of reading CLFS_HOST="$(echo $MACHTYPE | sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")" @@ -35,7 +35,7 @@ cat << EOF else \\ touch luser-exist; \\ fi; - @chown \$(LUSER) \$(MOUNT_PT) && \\ + @chown -R \$(LUSER) \$(MOUNT_PT) && \\ chown \$(LUSER) \$(MOUNT_PT)/sources @touch \$@ && \\ echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\ @@ -64,7 +64,8 @@ cat << EOF echo "export CLFS_TARGET32=\"${TARGET32}\"" >> /home/\$(LUSER)/.bashrc && \\ echo "source $JHALFSDIR/envars" >> /home/\$(LUSER)/.bashrc @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bashrc && \\ - touch envars + touch envars && \\ + chown \$(LUSER):\$(LGROUP) envars @touch \$@ && \\ echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\ echo --------------------------------------------------------------------------------\$(WHITE) @@ -122,13 +123,15 @@ cat << EOF EOF ) >> $MKFILE.tmp + + host_prep=" 023-creatingtoolsdir 025-addinguser 026-settingenvironment 027-create-directories 028-creating-sysfile" } #-----------------------------# cross_tools_Makefiles() { # #-----------------------------# - echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools${R_arrow}" + echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools ( LUSER ) ${R_arrow}" for file in cross-tools/* ; do # Keep the script file name @@ -175,18 +178,18 @@ cross_tools_Makefiles() { # # # 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" + LUSER_wrt_target "${this_script}" "$PREV" # # If $pkg_tarball isn't empty, we've got a package... if [ "$pkg_tarball" != "" ] ; then - wrt_unpack "$pkg_tarball" + LUSER_wrt_unpack "$pkg_tarball" # If using optimizations, write the instructions [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name" fi # - wrt_RunAsUser "${this_script}" "${file}" + LUSER_wrt_RunAsUser "${file}" # - [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}" + [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}" # # Include a touch of the target name so make can check if it's already been made. wrt_touch @@ -206,7 +209,7 @@ cross_tools_Makefiles() { # #-----------------------------# final_system_Makefiles() { # #-----------------------------# - echo "${tab_}${GREEN}Processing... ${L_arrow}final system${R_arrow}" + echo "${tab_}${GREEN}Processing... ${L_arrow}final system ( LUSER ) ${R_arrow}" for file in final-system/* ; do # Keep the script file name @@ -240,18 +243,18 @@ final_system_Makefiles() { # # # 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" + LUSER_wrt_target "${this_script}" "$PREV" # # If $pkg_tarball isn't empty, we've got a package... if [ "$pkg_tarball" != "" ] ; then - wrt_unpack "$pkg_tarball" + LUSER_wrt_unpack "$pkg_tarball" # If using optimizations, write the instructions [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name" fi # - wrt_RunAsUser "${this_script}" "${file}" + LUSER_wrt_RunAsUser "${file}" # - [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}" + [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}" # # Include a touch of the target name so make can check if it's already been made. wrt_touch @@ -270,7 +273,7 @@ final_system_Makefiles() { # #-----------------------------# bootscripts_Makefiles() { # #-----------------------------# - echo "${tab_}${GREEN}Processing... ${L_arrow}bootscripts${R_arrow}" + echo "${tab_}${GREEN}Processing... ${L_arrow}bootscripts ( LUSER ) ${R_arrow}" for file in bootscripts/* ; do # Keep the script file name @@ -306,14 +309,14 @@ bootscripts_Makefiles() { # # # 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" + LUSER_wrt_target "${this_script}" "$PREV" # # If $pkg_tarball isn't empty, we've got a package... - [[ "$pkg_tarball" != "" ]] && wrt_unpack "$pkg_tarball" + [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball" # - wrt_RunAsUser "${this_script}" "${file}" + LUSER_wrt_RunAsUser "${file}" # - [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}" + [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}" # # Include a touch of the target name so make can check if it's already been made. wrt_touch @@ -333,7 +336,7 @@ bootscripts_Makefiles() { # #-----------------------------# bootable_Makefiles() { # #-----------------------------# - echo "${tab_}${GREEN}Processing... ${L_arrow}make bootable${R_arrow}" + echo "${tab_}${GREEN}Processing... ${L_arrow}make bootable ( LUSER ) ${R_arrow}" for file in bootable/* ; do # Keep the script file name @@ -342,6 +345,7 @@ bootable_Makefiles() { # # A little housekeeping on the scripts case $this_script in *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;; + *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;; *kernel) # if there is no kernel config file do not build the kernel [[ -z $CONFIG ]] && continue # Copy the config file to /sources with a standardized name @@ -351,7 +355,12 @@ bootable_Makefiles() { # # # First append each name of the script files to a list (this will become # the names of the targets in the Makefile - bootable="$bootable $this_script" + # NOTE: new makfile format forces the last script, *chowning, into a separate + # phase. + case ${this_script} in + *chowning) chowning=${this_script} ;; + *) bootable="$bootable $this_script" ;; + esac # # 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@@' ` @@ -368,27 +377,27 @@ bootable_Makefiles() { # # # 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" + LUSER_wrt_target "${this_script}" "$PREV" # # If $pkg_tarball isn't empty, we've got a package... - [[ "$pkg_tarball" != "" ]] && wrt_unpack "$pkg_tarball" + [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball" # # Select a script execution method case $this_script in *fstab*) if [[ -n "$FSTAB" ]]; then - wrt_copy_fstab "${this_script}" + LUSER_wrt_CopyFstab else - wrt_RunAsUser "${this_script}" "${file}" + LUSER_wrt_RunAsUser "${file}" fi ;; *chowning) wrt_RunAsRoot "${this_script}" "${file}" ;; - *) wrt_RunAsUser "${this_script}" "${file}" + *) LUSER_wrt_RunAsUser "${file}" ;; esac # # Housekeeping...remove any build directory(ies) except if the package build fails. - [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}" + [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}" # # Include a touch of the target name so make can check if it's already been made. wrt_touch @@ -454,19 +463,30 @@ EOF # 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 restore-luser-env do-housekeeping +cat << EOF + +all: mk_SETUP mk_LUSER mk_ROOT @\$(call echo_finished,$VERSION) -chapter2: 023-creatingtoolsdir 025-addinguser 026-settingenvironment 027-create-directories 028-creating-sysfile +mk_SETUP: + @\$(call echo_SU_request) + @sudo make SETUP + @touch \$@ + +mk_LUSER: mk_SETUP + @\$(call echo_SULUSER_request) + @( \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make LUSER" ) + @touch \$@ -chapter3: chapter2 $cross_tools +mk_ROOT: + @sudo make ROOT + @touch \$@ -chapter4: chapter3 $basicsystem +SETUP: $host_prep -chapter5: chapter4 $bootscripttools +LUSER: $cross_tools $basicsystem $bootscripttools $bootable -chapter6: chapter5 $bootable +ROOT: $chowning clean-all: clean rm -rf ./{clfs2-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches} diff --git a/HLFS/master.sh b/HLFS/master.sh index 67f67bd..4f4e7ef 100755 --- a/HLFS/master.sh +++ b/HLFS/master.sh @@ -7,16 +7,30 @@ set -e # Enable error trapping ### FUNCTIONS ### ################################### + #----------------------------# process_toolchain() { # embryo,cocoon and butterfly need special handling #----------------------------# local toolchain=$1 local this_script=$2 - local tc_phase + local tc_phase local binutil_tarball local gcc_core_tarball + local TC_MountPT + local remove_existing - echo "${tab_}${tab_}${GREEN}toolchain ${L_arrow}${toolchain}${R_arrow}" + tc_phase=`echo $toolchain | sed -e 's@[0-9]\{3\}-@@' -e 's@-toolchain@@'` + case $tc_phase in + embryo | \ + cocoon) # Vars for LUSER phase + remove_existing="remove_existing_dirs" + TC_MountPT="\$(MOUNT_PT)\$(SRC)" + ;; + butterfly) # Vars for CHROOT phase + remove_existing="remove_existing_dirs2" + TC_MountPT="\$(SRC)" + ;; + esac # # Safe method to remove existing toolchain dirs @@ -24,56 +38,49 @@ process_toolchain() { # embryo,cocoon and butterfly need special handling gcc_core_tarball=$(get_package_tarball_name "gcc-core") ( cat << EOF - @\$(call remove_existing_dirs,$binutil_tarball) - @\$(call remove_existing_dirs,$gcc_core_tarball) + @\$(call ${remove_existing},$binutil_tarball) + @\$(call ${remove_existing},$gcc_core_tarball) EOF ) >> $MKFILE.tmp # # Manually remove the toolchain directories.. - tc_phase=`echo $toolchain | sed -e 's@[0-9]\{3\}-@@' -e 's@-toolchain@@'` ( cat << EOF - @rm -rf \$(MOUNT_PT)\$(SRC)/${tc_phase}-toolchain && \\ - rm -rf \$(MOUNT_PT)\$(SRC)/${tc_phase}-build + @rm -rf ${TC_MountPT}/${tc_phase}-toolchain && \\ + rm -rf ${TC_MountPT}/${tc_phase}-build EOF ) >> $MKFILE.tmp - case ${toolchain} in - *butterfly*) + ( cat << EOF - @echo "export PKGDIR=\$(SRC)" > envars + @echo "export PKGDIR=${TC_MountPT}" > envars EOF ) >> $MKFILE.tmp - [[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}" - wrt_run_as_chroot1 "$toolchain" "$this_script" + + case ${tc_phase} in + butterfly) + [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}" + CHROOT_wrt_RunAsRoot "$toolchain" "$this_script" ;; - - *) -( -cat << EOF - @echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)" > envars -EOF -) >> $MKFILE.tmp - wrt_RunAsUser "$toolchain" "$this_script" + *) LUSER_wrt_RunAsUser "$toolchain" "$this_script" ;; esac # ( cat << EOF - @\$(call remove_existing_dirs,$binutil_tarball) - @\$(call remove_existing_dirs,$gcc_core_tarball) + @\$(call ${remove_existing},$binutil_tarball) + @\$(call ${remove_existing},$gcc_core_tarball) EOF ) >> $MKFILE.tmp # # 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 + @rm -rf ${TC_MountPT}/${tc_phase}-toolchain && \\ + rm -rf ${TC_MountPT}/${tc_phase}-build EOF ) >> $MKFILE.tmp @@ -84,13 +91,13 @@ EOF chapter3_Makefiles() { # Initialization of the system #----------------------------# - echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter3${R_arrow}" + echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter3 ( SETUP ) ${R_arrow}" # Define a few model dependant variables if [[ ${MODEL} = "uclibc" ]]; then TARGET="pc-linux-gnu"; LOADER="ld-uClibc.so.0" else - TARGET="pc-linux-gnu"; LOADER="ld-linux.so.2" + TARGET="pc-linux-gnu"; LOADER="ld-linux.so.2" fi # If /home/$LUSER is already present in the host, we asume that the @@ -151,7 +158,7 @@ cat << EOF echo --------------------------------------------------------------------------------\$(WHITE) EOF ) >> $MKFILE.tmp - + chapter3=" 020-creatingtoolsdir 021-addinguser 022-settingenvironment" } #----------------------------# @@ -160,7 +167,7 @@ chapter5_Makefiles() { # Bootstrap or temptools phase local file local this_script - echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5${R_arrow}" + echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5 ( LUSER ) ${R_arrow}" for file in chapter05/* ; do # Keep the script file name @@ -205,32 +212,32 @@ chapter5_Makefiles() { # Bootstrap or temptools phase # NO Optimization allowed if [[ ${name} = "embryo-toolchain" ]] || \ [[ ${name} = "cocoon-toolchain" ]]; then - wrt_target "$this_script" "$PREV" + LUSER_wrt_target "$this_script" "$PREV" process_toolchain "${this_script}" "${file}" wrt_touch PREV=$this_script continue fi # - wrt_target "$this_script" "$PREV" + LUSER_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. - wrt_unpack "$pkg_tarball" + LUSER_wrt_unpack "$pkg_tarball" # If using optimizations, write the instructions [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name" 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_RunAsUser "$this_script" "${file}" + LUSER_wrt_RunAsUser "${file}" # Remove the build directory(ies) except if the package build fails # (so we can review config.cache, config.log, etc.) if [ "$pkg_tarball" != "" ] ; then - wrt_remove_build_dirs "$name" + LUSER_RemoveBuildDirs "$name" fi # Include a touch of the target name so make can check if it's already been made. @@ -275,7 +282,7 @@ chapter6_Makefiles() { # sysroot or chroot build phase sed -e '/groupadd/d' -i chapter06$N/*-udev fi - echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N${R_arrow}" + echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N ( CHROOT ) ${R_arrow}" for file in chapter06$N/* ; do # Keep the script file name @@ -324,25 +331,25 @@ 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. if [[ ${name} = "butterfly-toolchain" ]]; then - wrt_target "${this_script}${N}" "$PREV" + CHROOT_wrt_target "${this_script}${N}" "$PREV" process_toolchain "${this_script}" "${file}" wrt_touch PREV=$this_script continue fi - wrt_target "${this_script}${N}" "$PREV" + CHROOT_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" + CHROOT_Unpack "$pkg_tarball" # If the testsuites must be run, initialize the log file # butterfly-toolchain tests are enabled in 'process_tookchain' function case $name in - glibc ) [[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}" + glibc ) [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}" ;; - * ) [[ "$TEST" > "1" ]] && wrt_test_log2 "${this_script}" + * ) [[ "$TEST" > "1" ]] && CHROOT_wrt_test_log "${this_script}" ;; esac # If using optimizations, write the instructions @@ -355,13 +362,13 @@ chapter6_Makefiles() { # sysroot or chroot build phase wrt_RunAsRoot "${this_script}" "${file}" ;; *) # The rest of Chapter06 - wrt_run_as_chroot1 "${this_script}" "${file}" + CHROOT_wrt_RunAsRoot "${file}" ;; esac # # Remove the build directory(ies) except if the package build fails. if [ "$pkg_tarball" != "" ] ; then - wrt_remove_build_dirs "$name" + CHROOT_wrt_RemoveBuildDirs "$name" fi # # Include a touch of the target name so make can check if it's already been made. @@ -385,7 +392,7 @@ chapter7_Makefiles() { # Create a bootable system.. kernel, bootscripts..e local file local this_script - echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7${R_arrow}" + echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7 ( BOOT ) ${R_arrow}" for file in chapter07/*; do # Keep the script file name this_script=`basename $file` @@ -398,12 +405,12 @@ chapter7_Makefiles() { # Create a bootable system.. kernel, bootscripts..e *usage) continue ;; # Contains example commands *grub) continue ;; *console) continue ;; # Use the file generated by lfs-bootscripts - - *kernel) - # If no .config file is supplied, the kernel build is skipped - [[ -z $CONFIG ]] && continue - cp $CONFIG $BUILDDIR/sources/kernel-config - ;; + *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab + ;; + *kernel) # If no .config file is supplied, the kernel build is skipped + [[ -z $CONFIG ]] && continue + cp $CONFIG $BUILDDIR/sources/kernel-config + ;; esac # First append then name of the script file to a list (this will become @@ -416,11 +423,11 @@ chapter7_Makefiles() { # Create a bootable system.. kernel, bootscripts..e # # 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" + CHROOT_wrt_target "$this_script" "$PREV" case "${this_script}" in *bootscripts*) - wrt_unpack2 $(get_package_tarball_name "lfs-bootscripts") + CHROOT_Unpack $(get_package_tarball_name "lfs-bootscripts") blfs_bootscripts=$(get_package_tarball_name "blfs-bootscripts" | sed -e 's/.tar.*//' ) echo -e "\t@echo \"\$(MOUNT_PT)\$(SRC)/$blfs_bootscripts\" >> sources-dir" >> $MKFILE.tmp ;; @@ -429,13 +436,13 @@ chapter7_Makefiles() { # Create a bootable system.. kernel, bootscripts..e case "${this_script}" in *fstab*) # Check if we have a real /etc/fstab file if [[ -n "$FSTAB" ]] ; then - wrt_copy_fstab "$this_script" - else # Initialize the log and run the script - wrt_run_as_chroot2 "${this_script}" "${file}" + CHROOT_wrt_CopyFstab + else + CHROOT_wrt_RunAsRoot "$file" fi ;; *) # All other scripts - wrt_run_as_chroot2 "${this_script}" "${file}" + CHROOT_wrt_RunAsRoot "${file}" ;; esac @@ -444,8 +451,8 @@ chapter7_Makefiles() { # Create a bootable system.. kernel, bootscripts..e *bootscripts*) ( cat << EOF - @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\ - rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT + @ROOT=\`head -n1 \$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\ + rm -r \$(SRC)/\$\$ROOT @rm -r \`cat sources-dir\` && \\ rm sources-dir EOF @@ -545,6 +552,47 @@ EOF # as a dependency. ( cat << EOF + +all: mk_SETUP mk_LUSER mk_CHROOT mk_BOOT + @\$(call echo_finished,$VERSION) + + +mk_SETUP: + @\$(call echo_SU_request) + @sudo make SETUP + @touch \$@ + +mk_LUSER: mk_SETUP + @\$(call echo_SULUSER_request) + @( \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make LUSER" ) + @touch \$@ + +mk_CHROOT: mk_LUSER 057-changingowner 059-kernfs + @mkdir \$(MOUNT_PT)/bin && \ + cd \$(MOUNT_PT)/bin && \ + ln -sf /tools/bin/bash bash; ln -sf bash sh + @sed -e 's|^ln -sv|ln -svf|' -i \$(CMDSDIR)/chapter06/064-createfiles + @\$(call echo_CHROOT_request) + @( sudo \$(CHROOT1) "env && cd \$(SCRIPT_ROOT) && make CHROOT") + @touch \$@ + +mk_BOOT: mk_CHROOT + @\$(call echo_CHROOT_request) + @( sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BOOT") + @touch \$@ + + +SETUP: $chapter3 + +LUSER: $chapter5 + +CHROOT: $chapter6 + +BOOT: $chapter7 + + + + all: chapter3 chapter5 chapter6 chapter7 do-housekeeping @\$(call echo_finished,$VERSION) diff --git a/LFS/master.sh b/LFS/master.sh index 9a9d9a7..36314db 100755 --- a/LFS/master.sh +++ b/LFS/master.sh @@ -7,10 +7,13 @@ ################################### +############################################################# + + #----------------------------# -chapter4_Makefiles() { +chapter4_Makefiles() { # #----------------------------# - echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter4${R_arrow}" + echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter4 ( SETUP ) ${R_arrow}" # If /home/$LUSER is already present in the host, we asume that the # lfs user and group are also presents in the host, and a backup @@ -35,6 +38,7 @@ chapter4_Makefiles() { touch luser-exist; \\ fi; @chown \$(LUSER) \$(MOUNT_PT)/tools && \\ + chown -R \$(LUSER) \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\ chmod a+wt \$(MOUNT_PT)/sources && \\ touch \$@ && \\ echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\ @@ -57,17 +61,22 @@ chapter4_Makefiles() { echo "source $JHALFSDIR/envars" >> /home/\$(LUSER)/.bashrc && \\ chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bashrc && \\ touch envars && \\ + chown \$(LUSER) envars && \\ touch \$@ && \\ echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\ echo --------------------------------------------------------------------------------\$(WHITE) EOF -) >> $MKFILE.tmp +) > $MKFILE.tmp + + chapter4=" 020-creatingtoolsdir 021-addinguser 022-settingenvironment" } + + #----------------------------# chapter5_Makefiles() { #----------------------------# - echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5${R_arrow}" + echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5 ( LUSER ) ${R_arrow}" for file in chapter05/* ; do # Keep the script file name @@ -86,7 +95,13 @@ chapter5_Makefiles() { # 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}" + # DO NOT append the changingowner script. + # A hack is necessary: create script in chap5 BUT run as a dependency for + # chap6 CHROOT + case "${this_script}" in + *changingowner) : ;; + *) chapter5="$chapter5 ${this_script}" ;; + esac # Grab the name of the target (minus the -pass1 or -pass2 in the case of gcc # and binutils in chapter 5) @@ -101,7 +116,7 @@ chapter5_Makefiles() { # # 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" + LUSER_wrt_target "${this_script}" "$PREV" # Find the version of the command files, if it corresponds with the building of # a specific package @@ -110,9 +125,9 @@ chapter5_Makefiles() { # 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. - wrt_unpack "$pkg_tarball" + LUSER_wrt_unpack "$pkg_tarball" # If the testsuites must be run, initialize the log file - [[ "$TEST" = "3" ]] && wrt_test_log "${this_script}" + [[ "$TEST" = "3" ]] && LUSER_wrt_test_log "${this_script}" # If using optimizations, write the instructions [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name" fi @@ -122,13 +137,13 @@ chapter5_Makefiles() { # The changingowner script must be run as root. case "${this_script}" in *changingowner) wrt_RunAsRoot "${this_script}" "$file" ;; - *) wrt_RunAsUser "${this_script}" "$file" ;; + *) LUSER_wrt_RunAsUser "$file" ;; esac # Remove the build directory(ies) except if the package build fails # (so we can review config.cache, config.log, etc.) if [ "$pkg_tarball" != "" ] ; then - wrt_remove_build_dirs "$name" + LUSER_RemoveBuildDirs "$name" fi # Include a touch of the target name so make can check @@ -144,9 +159,11 @@ chapter5_Makefiles() { done # end for file in chapter05/* } + #----------------------------# chapter6_Makefiles() { #----------------------------# + # Set envars and scripts for iteration targets LOGS="" # Start with an empty global LOGS envar if [[ -z "$1" ]] ; then @@ -166,7 +183,7 @@ chapter6_Makefiles() { sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i chapter06$N/*-bzip2 fi - echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N${R_arrow}" + echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N ( CHROOT ) ${R_arrow}" for file in chapter06$N/* ; do # Keep the script file name @@ -208,19 +225,19 @@ chapter6_Makefiles() { # # 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}${N}" "$PREV" + CHROOT_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" + CHROOT_Unpack "$pkg_tarball" # If the testsuites must be run, initialize the log file case $name in binutils | gcc | glibc ) - [[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}" + [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}" ;; * ) - [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && wrt_test_log2 "${this_script}" + [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && CHROOT_wrt_test_log "${this_script}" ;; esac # If using optimizations, write the instructions @@ -231,12 +248,12 @@ chapter6_Makefiles() { # and not to use chroot. case "${this_script}" in *kernfs) wrt_RunAsRoot "${this_script}" "$file" ;; - *) wrt_run_as_chroot1 "${this_script}" "$file" ;; + *) CHROOT_wrt_RunAsRoot "$file" ;; esac # Remove the build directory(ies) except if the package build fails. if [ "$pkg_tarball" != "" ] ; then - wrt_remove_build_dirs "$name" + CHROOT_wrt_RemoveBuildDirs "$name" fi # Include a touch of the target name so make can check @@ -257,7 +274,7 @@ chapter6_Makefiles() { #----------------------------# chapter789_Makefiles() { #----------------------------# - echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7/8/9${R_arrow}" + echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7/8/9 ( BOOT ) ${R_arrow}" for file in chapter0{7,8,9}/* ; do # Keep the script file name @@ -274,6 +291,7 @@ chapter789_Makefiles() { *grub) continue ;; *reboot) continue ;; *console) continue ;; # Use the file generated by lfs-bootscripts + *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;; *kernel) [[ -z ${CONFIG} ]] && continue cp ${CONFIG} $BUILDDIR/sources/kernel-config ;; esac @@ -288,37 +306,37 @@ chapter789_Makefiles() { # # 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" + CHROOT_wrt_target "${this_script}" "$PREV" # Find the bootscripts and kernel package names case "${this_script}" in *bootscripts) name="lfs-bootscripts" pkg_tarball=$(get_package_tarball_name $name) - wrt_unpack2 "$pkg_tarball" + CHROOT_Unpack "$pkg_tarball" ;; *kernel) name="linux" pkg_tarball=$(get_package_tarball_name $name) - wrt_unpack2 "$pkg_tarball" + CHROOT_Unpack "$pkg_tarball" ;; esac # Check if we have a real /etc/fstab file case "${this_script}" in *fstab) if [[ -n $FSTAB ]]; then - wrt_copy_fstab "${this_script}" + CHROOT_wrt_CopyFstab else - wrt_run_as_chroot2 "$this_script" "$file" + CHROOT_wrt_RunAsRoot "$file" fi ;; - *) wrt_run_as_chroot2 "$this_script" "$file" + *) CHROOT_wrt_RunAsRoot "$file" ;; esac case "${this_script}" in - *bootscripts) wrt_remove_build_dirs "dummy" ;; - *kernel) wrt_remove_build_dirs "dummy" ;; + *bootscripts) CHROOT_wrt_RemoveBuildDirs "dummy" ;; + *kernel) CHROOT_wrt_RemoveBuildDirs "dummy" ;; esac # Include a touch of the target name so make can check @@ -338,15 +356,18 @@ chapter789_Makefiles() { } + #----------------------------# -build_Makefile() { +build_Makefile() { # #----------------------------# + echo "Creating Makefile... ${BOLD}START${OFF}" + cd $JHALFSDIR/${PROGNAME}-commands # Start with a clean Makefile.tmp file - >$MKFILE.tmp - + >$MKFILE + chapter4_Makefiles chapter5_Makefiles chapter6_Makefiles @@ -354,13 +375,13 @@ build_Makefile() { [[ "$COMPARE" = "y" ]] && wrt_compare_targets 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 PKG_LST = $PKG_LST @@ -381,8 +402,8 @@ crTESTLOGDIR = /\$(SCRIPT_ROOT)/test-logs SU_LUSER = su - \$(LUSER) -c LUSER_HOME = /home/\$(LUSER) -PRT_DU = echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" -PRT_DU_CR = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) \$(MOUNT_PT)\`\n" +PRT_DU = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) \$(MOUNT_PT) \`\n" +PRT_DU_CR = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) / \`\n" include makefile-functions @@ -390,7 +411,6 @@ include makefile-functions EOF ) > $MKFILE - # Add chroot commands CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`" i=1 @@ -414,16 +434,51 @@ EOF # as a dependency. ( cat << EOF -all: chapter4 chapter5 chapter6 chapter789 do_housekeeping + +all: mk_SETUP mk_LUSER mk_CHROOT mk_BOOT @\$(call echo_finished,$VERSION) -chapter4: 020-creatingtoolsdir 021-addinguser 022-settingenvironment -chapter5: chapter4 $chapter5 restore-luser-env +mk_SETUP: + @\$(call echo_SU_request) + @sudo make SETUP + @touch \$@ + +mk_LUSER: mk_SETUP + @\$(call echo_SULUSER_request) + @( \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make LUSER" ) + @touch \$@ +# +# The convoluted piece of code below is necessary to provide 'make' with a valid shell in the +# chroot environment. (Unless someone knows a different way) +# Manually create the /bin directory and provide link to the /tools dir. +# Also change the original symlink creation to include (f)orce to prevent failure due to +# pre-existing links. +# +mk_CHROOT: mk_LUSER 057-changingowner 059-kernfs + @mkdir \$(MOUNT_PT)/bin && \\ + cd \$(MOUNT_PT)/bin && \\ + ln -sf /tools/bin/bash bash; ln -sf bash sh + @sed -e 's|^ln -sv|ln -svf|' -i \$(CMDSDIR)/chapter06/063-createfiles + @\$(call echo_CHROOT_request) + @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make CHROOT") + @touch \$@ + +mk_BOOT: mk_CHROOT + @\$(call echo_CHROOT_request) + @( sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BOOT") + @touch \$@ + + +SETUP: $chapter4 + +LUSER: $chapter5 + +CHROOT: $chapter6 + +BOOT: $chapter789 -chapter6: chapter5 $chapter6 -chapter789: chapter6 $chapter789 clean-all: clean rm -rf ./{lfs-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches} @@ -525,13 +580,16 @@ restart_code: fi;\\ fi; + + 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/common/common-functions b/common/common-functions index 4d0071d..99a8765 100644 --- a/common/common-functions +++ b/common/common-functions @@ -29,51 +29,15 @@ HEADER="# This file is automatically generated by jhalfs-X # Generated on `date \"+%F %X %Z\"`" +#------------------------------------------------------# +# NEW Makefile scripting functions # +#------------------------------------------------------# + +unset get_package_tarball_name #----------------------------------# -wrt_target() { # Create target and initialize log file +get_package_tarball_name() { # #----------------------------------# - local i=$1 - local PREV=$2 - case $i in - iteration* ) local LOGFILE=$this_script.log ;; - * ) local LOGFILE=$this_script ;; - esac -( -cat << EOF - -$i: $PREV - @\$(call echo_message, Building) - @./progress_bar.sh \$@ & - @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >logs/$LOGFILE -EOF -) >> $MKFILE.tmp -} - - -#----------------------------------# -wrt_target_boot() { # Create target and initialize log file -#----------------------------------# - local i=$1 - local PREV=$2 - case $i in - iteration* ) local LOGFILE=$this_script.log ;; - * ) local LOGFILE=$this_script ;; - esac -( -cat << EOF - -$i: $PREV - @\$(call echo_message, Building) - @./progress_bar.sh \$@ & - @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=${SCRIPT_ROOT}\`\n" >logs/$LOGFILE -EOF -) >> $MKFILE.tmp -} - -#----------------------------# -get_package_tarball_name() { # -#----------------------------# local script_name=$1 # The use of 'head' is necessary to limit the return value to the FIRST match.. @@ -88,204 +52,7 @@ get_package_tarball_name() { # } -#----------------------------------# -wrt_test_log() { # Initialize testsuite log file -#----------------------------------# - local TESTLOGFILE=$1 -( -cat << EOF - @echo "export TEST_LOG=$TESTLOGDIR/$TESTLOGFILE" >> envars && \\ - su - \$(LUSER) -c "echo -e '\n\`date\`\n' >$TESTLOGDIR/$TESTLOGFILE" -EOF -) >> $MKFILE.tmp -} - -#----------------------------------# -wrt_test_log2() { # -#----------------------------------# - local TESTLOGFILE=$1 -( -cat << EOF - @echo "export TEST_LOG=/$SCRIPT_ROOT/test-logs/$TESTLOGFILE" >> envars && \\ - echo -e "\n\`date\`\n" >test-logs/$TESTLOGFILE -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_copy_fstab() { # -#----------------------------------# - local i=$1 -( - cat << EOF - @cp -v $FSTAB \$(MOUNT_PT)/etc/fstab >>logs/$i 2>&1 -EOF -) >> $MKFILE.tmp -} - - -#----------------------------------# -wrt_copy_fstab2() { # -#----------------------------------# - local i=$1 -( - cat << EOF - @cp -v /sources/fstab /etc/fstab >>logs/$i 2>&1 -EOF -) >> $MKFILE.tmp -} - - -#----------------------------------# -wrt_report() { # -#----------------------------------# -( -cat << EOF - -create-sbu_du-report: $PREV - @\$(call echo_message, Building) - @./create-sbu_du-report.sh logs $VERSION - @\$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report) - @touch \$@ -EOF -) >> $MKFILE.tmp - -chapter789="$chapter789 create-sbu_du-report" -} - -unset wrt_unpack -#----------------------------------# -wrt_unpack() { # Unpack and set 'ROOT' var -#----------------------------------# - local FILE=$1 - local optSAVE_PREVIOUS=$2 - - if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then -( -cat << EOF - @\$(call remove_existing_dirs,$FILE) -EOF -) >> $MKFILE.tmp - fi - -( -cat << EOF - @\$(call unpack,$FILE) - @\$(call get_pkg_root) -EOF -) >> $MKFILE.tmp - -} - -unset wrt_unpack2 -#----------------------------------# -wrt_unpack2() { # -#----------------------------------# - local FILE=$1 - local optSAVE_PREVIOUS=$2 - - if [ "${optSAVE_PREVIOUS}" != "1" ]; then -( -cat << EOF - @\$(call remove_existing_dirs,$FILE) -EOF -) >> $MKFILE.tmp - fi -( -cat << EOF - @\$(call unpack2,$FILE) - @\$(call get_pkg_root,nouser) -EOF -) >> $MKFILE.tmp -} - -#----------------------------------# -wrt_unpack3() { # -#----------------------------------# - local FILE=$1 - local optSAVE_PREVIOUS=$2 - - if [ "${optSAVE_PREVIOUS}" != "1" ]; then -( -cat << EOF - @\$(call remove_existing_dirs2,$FILE) -EOF -) >> $MKFILE.tmp - fi -( -cat << EOF - @\$(call unpack3,$FILE) - @\$(call get_pkg_root2) -EOF -) >> $MKFILE.tmp -} - - -unset wrt_remove_build_dirs -#----------------------------------# -wrt_remove_build_dirs() { # -#----------------------------------# - local name=$1 -( -cat << EOF - @\$(call remove_build_dirs,$name) -EOF -) >> $MKFILE.tmp -} - -#----------------------------------# -wrt_remove_build_dirs2() { # -#----------------------------------# - local name=$1 -( -cat << EOF - @\$(call remove_build_dirs2,$name) -EOF -) >> $MKFILE.tmp -} - - - -unset wrt_touch -#----------------------------------# -wrt_touch() { # -#----------------------------------# -( -cat << EOF - @\$(call housekeeping) -EOF -) >> $MKFILE.tmp -} - -unset wrt_RunAsUser -#----------------------------------# -wrt_RunAsUser() { # Execute script inside time { }, footer to log file -#----------------------------------# - local this_script=$1 - local file=$2 - -( -cat << EOF - @( time { \$(SU_LUSER) "source \$(LUSER_HOME)/.bashrc && \$(CMDSDIR)/`dirname $file`/\$@" >> logs/\$@ 2>&1; } ) 2>> logs/\$@ && \\ - \$(PRT_DU) >> logs/\$@ -EOF -) >> $MKFILE.tmp -} - - +unset wrt_RunaAsRoot #----------------------------------# wrt_RunAsRoot() { # Some scripts must be run as root.. #----------------------------------# @@ -301,7 +68,7 @@ wrt_RunAsRoot() { # Some scripts must be run as root.. hlfs ) MOUNT_ENV="HLFS" ;; *) echo "undefined progname $PROGNAME"; exit 1 esac - + ( cat << EOF @( time { export ${MOUNT_ENV}=\$(MOUNT_PT) && ${PROGNAME}-commands/`dirname $file`/\$@ >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\ @@ -310,68 +77,6 @@ EOF ) >> $MKFILE.tmp } -#----------------------------------# -wrt_run_as_root2() { # -#----------------------------------# - local this_script=$1 - local file=$2 -( -cat << EOF - @( time { source envars && ${PROGNAME}-commands/`dirname $file`/\$@ >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\ - echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \`\n" >>logs/\$@ -EOF -) >> $MKFILE.tmp -} - - -unset wrt_run_as_chroot1 -#----------------------------------# -wrt_run_as_chroot1() { # -#----------------------------------# - local this_script=$1 - local file=$2 -( -cat << EOF - @( time { \$(CHROOT1) 'cd \$(SCRIPT_ROOT) && source envars && \$(crCMDSDIR)/$file >>logs/${this_script} 2>&1' ; } ) 2>>logs/${this_script} && \\ - \$(PRT_DU_CR) >> logs/${this_script} -EOF -) >> $MKFILE.tmp -} - -unset wrt_run_as_chroot2 -#----------------------------------# -wrt_run_as_chroot2() { # -#----------------------------------# - local this_script=$1 - local file=$2 -( -cat << EOF - @( time { \$(CHROOT2) 'cd \$(SCRIPT_ROOT) && source envars && \$(crCMDSDIR)/`dirname $file`/\$@ >>logs/\$@ 2>&1' ; } ) 2>>logs/\$@ && \\ - \$(PRT_DU_CR) >> logs/\$@ -EOF -) >> $MKFILE.tmp -} - -unset wrt_target -#----------------------------------# -wrt_target() { # Create target and initialize log file -#----------------------------------# - local i=$1 - local PREV=$2 - case $i in - iteration* ) local LOGFILE="\$@.log" ;; - * ) local LOGFILE="\$@" ;; - esac -( -cat << EOF - -$i: $PREV - @\$(call echo_message, Building) - @./progress_bar.sh \$@ & - @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >logs/$LOGFILE -EOF -) >> $MKFILE.tmp -} #----------------------------------# wrt_target_boot() { # Create target and initialize log file @@ -394,6 +99,212 @@ EOF } +#------------------------------------------------------# +#------------------------------------------------------# + + +#----------------------------------# +LUSER_wrt_target() { # Create target and initialize log file +#----------------------------------# + local i=$1 + local PREV=$2 +( +cat << EOF + +$i: $PREV + @\$(call echo_message, Building) + @./progress_bar.sh \$@ \$\$PPID & + @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) \$(MOUNT_PT)\`\n" >logs/\$@ +EOF +) >> $MKFILE.tmp +} + + +#----------------------------------# +LUSER_wrt_RunAsUser() { # Execute script inside time { }, footer to log file +#----------------------------------# + local file=$1 + +( +cat << EOF + @( time { source ~/.bashrc && \$(CMDSDIR)/`dirname $file`/\$@ >> logs/\$@ 2>&1; } ) 2>> logs/\$@ && \\ + \$(PRT_DU) >> logs/\$@ +EOF +) >> $MKFILE.tmp +} + + +#----------------------------------# +LUSER_wrt_unpack() { # Unpack and set 'ROOT' var +#----------------------------------# + local FILE=$1 + local optSAVE_PREVIOUS=$2 + + if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then +( +cat << EOF + @\$(call remove_existing_dirs,$FILE) +EOF +) >> $MKFILE.tmp + fi + +( +cat << EOF + @\$(call unpack,$FILE) + @\$(call get_pkg_root_LUSER) +EOF +) >> $MKFILE.tmp + +} + + +#----------------------------------# +LUSER_wrt_CopyFstab() { # +#----------------------------------# +( +cat << EOF + @( time { cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ +EOF +) >> $MKFILE.tmp +} + + +#----------------------------------# +LUSER_wrt_test_log() { # Initialize testsuite log file +#----------------------------------# + local TESTLOGFILE=$1 +( +cat << EOF + @echo "export TEST_LOG=$TESTLOGDIR/$TESTLOGFILE" >> envars && \\ + echo -e '\n\`date\`\n' >$TESTLOGDIR/$TESTLOGFILE +EOF +) >> $MKFILE.tmp +} + + +#----------------------------------# +LUSER_RemoveBuildDirs() { # +#----------------------------------# + local name=$1 +( +cat << EOF + @\$(call remove_build_dirs,$name) +EOF +) >> $MKFILE.tmp +} + +#-----------------------------------------------------------------# +#-----------------------------------------------------------------# + +#----------------------------------# +CHROOT_wrt_target() { # Create target and initialize log file +#----------------------------------# + local i=$1 + local PREV=$2 + case $i in + iteration* ) local LOGFILE="${this_script}.log" ;; + * ) local LOGFILE="${this_script}" ;; + esac +( +cat << EOF + +$i: $PREV + @\$(call echo_message, Building) + @./progress_bar.sh \$@ \$\$PPID & + @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) / \`\n" >logs/$LOGFILE +EOF +) >> $MKFILE.tmp +} + + +#----------------------------------# +CHROOT_Unpack() { # +#----------------------------------# + local FILE=$1 + local optSAVE_PREVIOUS=$2 + + if [ "${optSAVE_PREVIOUS}" != "1" ]; then +( +cat << EOF + @\$(call remove_existing_dirs2,$FILE) +EOF +) >> $MKFILE.tmp + fi +( +cat << EOF + @\$(call unpack3,$FILE) + @\$(call get_pkg_root2) +EOF +) >> $MKFILE.tmp +} + + +#----------------------------------# +CHROOT_wrt_test_log() { # +#----------------------------------# + local TESTLOGFILE=$1 +( +cat << EOF + @echo "export TEST_LOG=/\$(SCRIPT_ROOT)/test-logs/$TESTLOGFILE" >> envars && \\ + echo -e "\n\`date\`\n" >test-logs/$TESTLOGFILE +EOF +) >> $MKFILE.tmp +} + + +#----------------------------------# +CHROOT_wrt_RunAsRoot() { # +#----------------------------------# + local file=$1 +( +cat << EOF + @( time { source envars && \$(crCMDSDIR)/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\ + \$(PRT_DU_CR) >>logs/$this_script +EOF +) >> $MKFILE.tmp + +} + + +#----------------------------------# +CHROOT_wrt_CopyFstab() { # +#----------------------------------# +( +cat << EOF + @( time { cp -v /sources/fstab /etc/fstab >>logs/${this_script} 2>&1 ; } ) 2>>logs/${this_script} +EOF +) >> $MKFILE.tmp +} + + +#----------------------------------# +CHROOT_wrt_RemoveBuildDirs() { # +#----------------------------------# + local name=$1 +( +cat << EOF + @\$(call remove_build_dirs2,$name) +EOF +) >> $MKFILE.tmp +} + + +unset wrt_touch +#----------------------------------# +wrt_touch() { # +#----------------------------------# +( +cat << EOF + @\$(call housekeeping) +EOF +) >> $MKFILE.tmp +} + +#------------------------------------------------------# +# END Makefile scripting functions # +#------------------------------------------------------# + + #----------------------------# run_make() { # @@ -589,6 +500,7 @@ extract_commands() { # # Done. Moving on... get_sources + } #----------------------------# @@ -800,8 +712,9 @@ create_urls() { # cd $BUILDDIR/sources if [[ "${BLFS_TOOL}" = "y" ]]; then - add_blfs_deps_urls + add_blfs_deps_urls fi + } #----------------------------# Hardcoded URLs and MD5. diff --git a/common/func_compare.sh b/common/func_compare.sh index 2a5efe3..a00aba7 100644 --- a/common/func_compare.sh +++ b/common/func_compare.sh @@ -11,7 +11,7 @@ wrt_compare_targets() { # wrt_system_build "$N" "$PREV_IT" fi this_script=$ITERATION - wrt_target "$ITERATION" "$PREV" + CHROOT_wrt_target "$ITERATION" "$PREV" wrt_compare_work "$ITERATION" "$PREV_IT" wrt_logs "$N" PREV_IT=$ITERATION diff --git a/common/makefile-functions b/common/makefile-functions index a566bfb..869f5b8 100644 --- a/common/makefile-functions +++ b/common/makefile-functions @@ -1,18 +1,45 @@ # $Id$ -BOLD= "" -RED= "" -GREEN= "" -ORANGE= "" -BLUE= "" -WHITE= "" +BOLD = "" +RED = "" +GREEN = "" +ORANGE = "" +BLUE = "" +WHITE = "" +YELLOW = "" + +OFF = "" +BOLD = "" +REVERSE = "" + + +define echo_SU_request + @echo $(BOLD)-------------------------------------------------------------------------------- + @echo $(BLUE)$@ + @echo $(WHITE)ROOT privilege is required to perform a number commands + @echo sudo will request a password to all high privelege cmds to execut correctly +endef + +define echo_SULUSER_request + @clear + @echo $(BOLD)-------------------------------------------------------------------------------- + @echo $(BOLD)$(BLUE)$@ + @echo $(WHITE)You are going to log into the user account $(BOLD)$(YELLOW)$(LUSER)$(OFF) + @echo su requires a password +endef + +define echo_CHROOT_request + @clear + @echo $(BOLD)-------------------------------------------------------------------------------- + @echo $(BOLD)$(BLUE)$@ + @echo $(WHITE)You are going to CHROOT into $(MOUNT_PT) $(BOLD)$(YELLOW)$(LUSER)$(OFF) + @echo a password is required +endef define echo_message - @echo $(BOLD) - @echo -------------------------------------------------------------------------------- - @echo $(BOLD)$(1) target $(BLUE)$@$(BOLD) - @echo $(WHITE) + @echo $(BOLD)-------------------------------------------------------------------------------- + @echo $(BOLD)$(1) target $(BLUE)$@$(BOLD)$(WHITE) endef define remove_existing_dirs @@ -23,7 +50,7 @@ define remove_existing_dirs endef define remove_existing_dirs2 - @PKG_PATH=\`ls -t $(SRC)/$(1) | head -n1\` && \ + @PKG_PATH=`ls -t $(SRC)/$(1) | head -n1` && \ ROOT=`tar -tf $$PKG_PATH | head -n1 | sed -e 's@^./@@;s@/.*@@'` && \ rm -rf $(SRC)/$$ROOT && \ rm -rf $(SRC)/$${ROOT%-*}-build @@ -44,7 +71,7 @@ endef define housekeeping @touch $@ && \ sleep .25 && \ - echo -e "\n\n "$(BOLD)Target $(BLUE)$@ $(BOLD)OK && \ + echo -e "\n" $(BOLD)Target $(BLUE)$@ $(WHITE)$(BOLD)OK && \ echo --------------------------------------------------------------------------------$(WHITE) endef @@ -64,6 +91,11 @@ define get_pkg_root2 echo "export PKGDIR=$(SRC)/$$ROOT" > envars endef +define get_pkg_root_LUSER + @ROOT=`head -n1 $(SRCSDIR)/$(PKG_LST) | sed 's@^./@@;s@/.*@@'` && \ + echo "export PKGDIR=$(SRCSDIR)/$$ROOT" > envars +endef + define unpack @cd $(SRCSDIR) && \ tar -xvf `ls -t $(1) | head -n1` > $(PKG_LST) diff --git a/common/progress_bar.sh b/common/progress_bar.sh index fb0dc00..35965fa 100755 --- a/common/progress_bar.sh +++ b/common/progress_bar.sh @@ -7,6 +7,7 @@ set -e # Be sure that we know the taget name [[ -z $1 ]] && exit TARGET=$1 # Remember the target build we are looking for +MAKE_PPID=$2 declare -r CSI=$'\e[' # DEC terminology, Control Sequence Introducer declare -r CURSOR_OFF=${CSI}$'?25l' @@ -21,12 +22,9 @@ declare -a GRAPHIC_STR="| / - \\ + " declare -i SEC=0 # Seconds accumulator declare -i PREV_SEC=0 -makePID=$(fuser -v . 2>&1 | grep make) -makePID=$(echo $makePID | cut -d" " -f2) - write_or_exit() { # make has been killed or failed or run to completion, leave - [[ ! -e /proc/$makePID ]] && echo -n "${CURSOR_ON}" && exit + [[ ! -e /proc/${MAKE_PPID} ]] && echo -n "${CURSOR_ON}" && exit # Target build complete, leave. [[ -f ${TARGET} ]] && echo -n "${CURSOR_ON}" && exit