Changeset 50fb011 for LFS


Ignore:
Timestamp:
08/30/2006 02:01:04 AM (18 years ago)
Author:
George Boudreau <georgeb@…>
Branches:
experimental
Children:
08a4953
Parents:
01b6d52
Message:

First commit of changes to makefile generation. Makefile now does recursive calls to itself for the different phases..SETUP,LUSER,CHROOT,ROOT

File:
1 edited

Legend:

Unmodified
Added
Removed
  • LFS/master.sh

    r01b6d52 r50fb011  
    88
    99
    10 #----------------------------#
    11 chapter4_Makefiles() {
    12 #----------------------------#
    13   echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter4${R_arrow}"
     10#############################################################
     11
     12
     13#----------------------------#
     14chapter4_Makefiles() {       #
     15#----------------------------#
     16  echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter4     ( SETUP ) ${R_arrow}"
    1417
    1518# If /home/$LUSER is already present in the host, we asume that the
     
    3639        fi;
    3740        @chown \$(LUSER) \$(MOUNT_PT)/tools && \\
     41        chown -R \$(LUSER) \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
    3842        chmod a+wt \$(MOUNT_PT)/sources && \\
    3943        touch \$@ && \\
     
    5862        chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bashrc && \\
    5963        touch envars && \\
     64        chown \$(LUSER) envars && \\
    6065        touch \$@ && \\
    6166        echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
    6267        echo --------------------------------------------------------------------------------\$(WHITE)
    6368EOF
    64 ) >> $MKFILE.tmp
     69) > $MKFILE.tmp
     70
     71  chapter4=" 020-creatingtoolsdir 021-addinguser 022-settingenvironment"
    6572}
    6673
     74
     75
    6776#----------------------------#
    6877chapter5_Makefiles() {
    6978#----------------------------#
    70   echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5${R_arrow}"
     79  echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5     ( LUSER ) ${R_arrow}"
    7180
    7281  for file in chapter05/* ; do
     
    8796    # First append each name of the script files to a list (this will become
    8897    # the names of the targets in the Makefile
    89     chapter5="$chapter5 ${this_script}"
     98    # DO NOT append the changingowner script.
     99    # A hack is necessary: create script in chap5 BUT run as a dependency for
     100    #  chap6 CHROOT
     101    case "${this_script}" in
     102      *changingowner) : ;;
     103                   *) chapter5="$chapter5 ${this_script}" ;;
     104    esac
    90105
    91106    # Grab the name of the target (minus the -pass1 or -pass2 in the case of gcc
     
    102117    # Drop in the name of the target on a new line, and the previous target
    103118    # as a dependency. Also call the echo_message function.
    104     wrt_target "${this_script}" "$PREV"
     119    LUSER_wrt_target "${this_script}" "$PREV"
    105120
    106121    # Find the version of the command files, if it corresponds with the building of
     
    111126    if [ "$pkg_tarball" != "" ] ; then
    112127      # Insert instructions for unpacking the package and to set the PKGDIR variable.
    113       wrt_unpack "$pkg_tarball"
     128      LUSER_wrt_unpack "$pkg_tarball"
    114129      # If the testsuites must be run, initialize the log file
    115       [[ "$TEST" = "3" ]] && wrt_test_log "${this_script}"
     130      [[ "$TEST" = "3" ]] && LUSER_wrt_test_log "${this_script}"
    116131      # If using optimizations, write the instructions
    117132      [[ "$OPTIMIZE" = "2" ]] &&  wrt_optimize "$name" && wrt_makeflags "$name"
     
    123138    case "${this_script}" in
    124139      *changingowner)  wrt_RunAsRoot "${this_script}" "$file" ;;
    125       *)               wrt_RunAsUser "${this_script}" "$file" ;;
     140      *)               LUSER_wrt_RunAsUser "$file" ;;
    126141    esac
    127142
     
    129144    # (so we can review config.cache, config.log, etc.)
    130145    if [ "$pkg_tarball" != "" ] ; then
    131       wrt_remove_build_dirs "$name"
     146      LUSER_RemoveBuildDirs "$name"
    132147    fi
    133148
     
    145160}
    146161
     162
    147163#----------------------------#
    148164chapter6_Makefiles() {
    149165#----------------------------#
     166
    150167  # Set envars and scripts for iteration targets
    151168  LOGS="" # Start with an empty global LOGS envar
     
    167184  fi
    168185
    169   echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N${R_arrow}"
     186  echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N     ( CHROOT ) ${R_arrow}"
    170187
    171188  for file in chapter06$N/* ; do
     
    209226    # Drop in the name of the target on a new line, and the previous target
    210227    # as a dependency. Also call the echo_message function.
    211     wrt_target "${this_script}${N}" "$PREV"
     228    CHROOT_wrt_target "${this_script}${N}" "$PREV"
    212229
    213230    # If $pkg_tarball isn't empty, we've got a package...
    214231    # Insert instructions for unpacking the package and changing directories
    215232    if [ "$pkg_tarball" != "" ] ; then
    216       wrt_unpack2 "$pkg_tarball"
     233      CHROOT_Unpack "$pkg_tarball"
    217234      # If the testsuites must be run, initialize the log file
    218235      case $name in
    219236        binutils | gcc | glibc )
    220           [[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}"
     237          [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}"
    221238          ;;
    222239        * )
    223           [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && wrt_test_log2 "${this_script}"
     240          [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && CHROOT_wrt_test_log "${this_script}"
    224241          ;;
    225242      esac
     
    232249    case "${this_script}" in
    233250      *kernfs)  wrt_RunAsRoot    "${this_script}" "$file" ;;
    234       *)        wrt_run_as_chroot1 "${this_script}" "$file" ;;
     251      *)        CHROOT_wrt_RunAsRoot "$file" ;;
    235252    esac
    236253
    237254    # Remove the build directory(ies) except if the package build fails.
    238255    if [ "$pkg_tarball" != "" ] ; then
    239       wrt_remove_build_dirs "$name"
     256      CHROOT_wrt_RemoveBuildDirs "$name"
    240257    fi
    241258
     
    258275chapter789_Makefiles() {
    259276#----------------------------#
    260   echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7/8/9${R_arrow}"
     277  echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7/8/9 ( BOOT ) ${R_arrow}"
    261278
    262279  for file in chapter0{7,8,9}/* ; do
     
    275292      *reboot)  continue ;;
    276293      *console) continue  ;; # Use the file generated by lfs-bootscripts
     294      *fstab)   [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
    277295      *kernel)  [[ -z ${CONFIG} ]] && continue
    278296                cp ${CONFIG} $BUILDDIR/sources/kernel-config  ;;
     
    289307    # Drop in the name of the target on a new line, and the previous target
    290308    # as a dependency. Also call the echo_message function.
    291     wrt_target "${this_script}" "$PREV"
     309    CHROOT_wrt_target "${this_script}" "$PREV"
    292310
    293311    # Find the bootscripts and kernel package names
     
    296314            name="lfs-bootscripts"
    297315            pkg_tarball=$(get_package_tarball_name $name)
    298             wrt_unpack2 "$pkg_tarball"
     316            CHROOT_Unpack "$pkg_tarball"
    299317        ;;
    300318      *kernel)
    301319            name="linux"
    302320            pkg_tarball=$(get_package_tarball_name $name)
    303             wrt_unpack2 "$pkg_tarball"
     321            CHROOT_Unpack "$pkg_tarball"
    304322       ;;
    305323    esac
     
    308326    case "${this_script}" in
    309327      *fstab) if [[ -n $FSTAB ]]; then
    310                 wrt_copy_fstab "${this_script}"
     328                CHROOT_wrt_CopyFstab
    311329              else
    312                 wrt_run_as_chroot2 "$this_script" "$file"
     330                CHROOT_wrt_RunAsRoot "$file"
    313331              fi
    314332        ;;
    315       *)        wrt_run_as_chroot2 "$this_script" "$file"
     333      *)        CHROOT_wrt_RunAsRoot "$file"
    316334        ;;
    317335    esac
    318336
    319337    case "${this_script}" in
    320       *bootscripts)  wrt_remove_build_dirs "dummy" ;;
    321       *kernel)       wrt_remove_build_dirs "dummy" ;;
     338      *bootscripts)  CHROOT_wrt_RemoveBuildDirs "dummy" ;;
     339      *kernel)       CHROOT_wrt_RemoveBuildDirs "dummy" ;;
    322340    esac
    323341
     
    339357
    340358
    341 #----------------------------#
    342 build_Makefile() {
    343 #----------------------------#
     359
     360#----------------------------#
     361build_Makefile() {           #
     362#----------------------------#
     363
    344364  echo "Creating Makefile... ${BOLD}START${OFF}"
     365 
    345366  cd $JHALFSDIR/${PROGNAME}-commands
    346367
    347368  # Start with a clean Makefile.tmp file
    348   >$MKFILE.tmp
    349 
     369  >$MKFILE
     370 
    350371  chapter4_Makefiles
    351372  chapter5_Makefiles
     
    355376  chapter789_Makefiles
    356377
    357 
    358378  # Add a header, some variables and include the function file
    359379  # to the top of the real Makefile.
     
    361381    cat << EOF
    362382$HEADER
     383
    363384
    364385SRC          = /sources
     
    382403SU_LUSER     = su - \$(LUSER) -c
    383404LUSER_HOME   = /home/\$(LUSER)
    384 PRT_DU       = echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n"
    385 PRT_DU_CR    = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) \$(MOUNT_PT)\`\n"
     405PRT_DU       = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) \$(MOUNT_PT) \`\n"
     406PRT_DU_CR    = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) / \`\n"
    386407
    387408
     
    390411EOF
    391412) > $MKFILE
    392 
    393413
    394414  # Add chroot commands
     
    415435(
    416436    cat << EOF
    417 all:  chapter4 chapter5 chapter6 chapter789 do_housekeeping
     437
     438all:    mk_SETUP mk_LUSER mk_CHROOT mk_BOOT
    418439        @\$(call echo_finished,$VERSION)
    419440
    420 chapter4:  020-creatingtoolsdir 021-addinguser 022-settingenvironment
    421 
    422 chapter5:  chapter4 $chapter5 restore-luser-env
    423 
    424 chapter6:  chapter5 $chapter6
    425 
    426 chapter789:  chapter6 $chapter789
     441
     442mk_SETUP:
     443        @\$(call echo_SU_request)
     444        @sudo make SETUP
     445        @touch \$@
     446       
     447mk_LUSER: mk_SETUP
     448        @\$(call echo_SULUSER_request)
     449        @( \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make LUSER" )
     450        @touch \$@
     451#
     452# The convoluted piece of code below is necessary to provide 'make' with a valid shell in the
     453# chroot environment. (Unless someone knows a different way)
     454# Manually create the /bin directory and provide link to the /tools dir.
     455# Also change the original symlink creation to include (f)orce to prevent failure due to
     456#  pre-existing links.
     457#
     458mk_CHROOT: mk_LUSER 057-changingowner 059-kernfs
     459        @mkdir \$(MOUNT_PT)/bin && \\
     460        cd \$(MOUNT_PT)/bin && \\
     461        ln -sf /tools/bin/bash bash; ln -sf bash sh
     462        @sed -e 's|^ln -sv|ln -svf|' -i \$(CMDSDIR)/chapter06/063-createfiles
     463        @\$(call echo_CHROOT_request)
     464        @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make CHROOT")
     465        @touch \$@
     466
     467mk_BOOT: mk_CHROOT
     468        @\$(call echo_CHROOT_request)
     469        @( sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BOOT")
     470        @touch \$@
     471       
     472
     473SETUP:  $chapter4
     474
     475LUSER:  $chapter5
     476
     477CHROOT: $chapter6
     478
     479BOOT:   $chapter789
     480
     481
    427482
    428483clean-all:  clean
     
    526581        fi;
    527582
     583
     584
    528585EOF
    529586) >> $MKFILE
     587
     588
    530589
    531590  # Bring over the items from the Makefile.tmp
     
    533592  rm $MKFILE.tmp
    534593  echo "Creating Makefile... ${BOLD}DONE${OFF}"
    535 
    536594}
    537595
Note: See TracChangeset for help on using the changeset viewer.