- Timestamp:
- 09/02/2006 03:04:03 AM (18 years ago)
- Branches:
- experimental
- Children:
- 1ba5024
- Parents:
- b179a81
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CLFS/master.sh
rb179a81 rd14903f 1 1 #!/bin/sh 2 2 # $Id$ 3 4 5 orphan_scripts="" # 2 scripts do not fit BOOT_Makefiles LUSER environment 3 6 4 7 ################################### … … 6 9 ################################### 7 10 8 9 #----------------------------# 10 host_prep_Makefiles() { # Initialization of the system 11 #----------------------------# 11 #--------------------------------------# 12 BOOT_wrt_target() { # "${this_script}" "$PREV" 13 #--------------------------------------# 14 local i=$1 15 local PREV=$2 16 case $i in 17 iteration* ) local LOGFILE=$this_script.log ;; 18 * ) local LOGFILE=$this_script ;; 19 esac 20 ( 21 cat << EOF 22 23 $i: $PREV 24 @\$(call echo_message, Building) 25 @./progress_bar.sh \$@ \$\$PPID & 26 @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=${SCRIPT_ROOT}\`\n" >logs/$LOGFILE 27 EOF 28 ) >> $MKFILE.tmp 29 } 30 31 #--------------------------------------# 32 BOOT_wrt_Unpack() { # "$pkg_tarball" 33 #--------------------------------------# 34 local FILE=$1 35 local optSAVE_PREVIOUS=$2 36 37 if [ "${optSAVE_PREVIOUS}" != "1" ]; then 38 ( 39 cat << EOF 40 @\$(call remove_existing_dirs2,$FILE) 41 EOF 42 ) >> $MKFILE.tmp 43 fi 44 ( 45 cat << EOF 46 @\$(call unpack3,$FILE) 47 @\$(call get_pkg_root2) 48 EOF 49 ) >> $MKFILE.tmp 50 } 51 52 #----------------------------------# 53 BOOT_wrt_RunAsRoot() { # "${this_script}" "${file}" 54 #----------------------------------# 55 local this_script=$1 56 local file=$2 57 ( 58 cat << EOF 59 @( time { source envars && ${PROGNAME}-commands/`dirname $file`/\$@ >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\ 60 echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \`\n" >>logs/\$@ 61 EOF 62 ) >> $MKFILE.tmp 63 } 64 65 #--------------------------------------# 66 BOOT_wrt_RemoveBuildDirs() { # "${name}" 67 #--------------------------------------# 68 local name=$1 69 ( 70 cat << EOF 71 @\$(call remove_build_dirs2,$name) 72 EOF 73 ) >> $MKFILE.tmp 74 } 75 76 #----------------------------------# 77 BOOT_wrt_test_log() { # 78 #----------------------------------# 79 local TESTLOGFILE=$1 80 ( 81 cat << EOF 82 @echo "export TEST_LOG=/\$(SCRIPT_ROOT)/test-logs/$TESTLOGFILE" >> envars && \\ 83 echo -e "\n\`date\`\n" >test-logs/$TESTLOGFILE 84 EOF 85 ) >> $MKFILE.tmp 86 } 87 88 #----------------------------------# 89 BOOT_wrt_CopyFstab() { # 90 #----------------------------------# 91 ( 92 cat << EOF 93 @( time { cp -v /sources/fstab /etc/fstab >>logs/${this_script} 2>&1 ; } ) 2>>logs/${this_script} 94 EOF 95 ) >> $MKFILE.tmp 96 } 97 98 99 ######################################## 100 101 102 #--------------------------------------# 103 host_prep_Makefiles() { # 104 #--------------------------------------# 12 105 local CLFS_HOST 13 106 14 echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files ${R_arrow}"107 echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files ( SETUP ) ${R_arrow}" 15 108 16 109 # defined here, only for ease of reading … … 79 172 @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bashrc && \\ 80 173 touch envars && \\ 174 chown -R \$(LUSER) \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\ 81 175 touch \$@ && \\ 82 176 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\ … … 84 178 EOF 85 179 ) >> $MKFILE.tmp 86 87 } 88 89 90 91 #-----------------------------# 92 cross_tools_Makefiles() { # 93 #-----------------------------# 94 echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools${R_arrow}" 180 host_prep=" 023-creatingtoolsdir 024-creatingcrossdir 026-settingenvironment" 181 182 } 183 184 #--------------------------------------# 185 cross_tools_Makefiles() { # 186 #--------------------------------------# 187 echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools ( LUSER ) ${R_arrow}" 95 188 96 189 for file in cross-tools/* ; do … … 127 220 # Drop in the name of the target on a new line, and the previous target 128 221 # as a dependency. Also call the echo_message function. 129 wrt_target "${this_script}" "$PREV"222 LUSER_wrt_target "${this_script}" "$PREV" 130 223 # 131 224 # If $pkg_tarball isn't empty, we've got a package... 132 225 # 133 [[ "$pkg_tarball" != "" ]] && wrt_unpack "$pkg_tarball"134 # 135 wrt_RunAsUser "${this_script}""${file}"136 # 137 [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"226 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball" 227 # 228 LUSER_wrt_RunAsUser "${file}" 229 # 230 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}" 138 231 # 139 232 # Include a touch of the target name so make can check if it's already been made. … … 150 243 } 151 244 152 153 #-----------------------------# 154 temptools_Makefiles() { # 155 #-----------------------------# 156 echo "${tab_}${GREEN}Processing... ${L_arrow}temp system${R_arrow}" 245 #--------------------------------------# 246 temptools_Makefiles() { # 247 #--------------------------------------# 248 echo "${tab_}${GREEN}Processing... ${L_arrow}temp system ( LUSER ) ${R_arrow}" 157 249 158 250 for file in temp-system/* ; do … … 185 277 # Drop in the name of the target on a new line, and the previous target 186 278 # as a dependency. Also call the echo_message function. 187 wrt_target "${this_script}" "$PREV"279 LUSER_wrt_target "${this_script}" "$PREV" 188 280 # 189 281 # If $pkg_tarball isn't empty, we've got a package... 190 282 # Insert instructions for unpacking the package and to set the PKGDIR variable. 191 283 # 192 [[ "$pkg_tarball" != "" ]] && wrt_unpack "$pkg_tarball"284 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball" 193 285 [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name" 194 286 # 195 wrt_RunAsUser "${this_script}""${file}"196 # 197 [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"287 LUSER_wrt_RunAsUser "${file}" 288 # 289 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}" 198 290 # 199 291 # Include a touch of the target name so make can check if it's already been made. … … 210 302 211 303 212 #-----------------------------# 213 boot_Makefiles() { # 214 #-----------------------------# 215 echo "${tab_}${GREEN}Processing... ${L_arrow}boot${R_arrow}" 216 304 #--------------------------------------# 305 chroot_Makefiles() { # 306 #--------------------------------------# 307 echo "${tab_}${GREEN}Processing... ${L_arrow}tmptools CHROOT ( CHROOT ) ${R_arrow}" 308 309 for file in chroot/* ; do 310 # Keep the script file name 311 this_script=`basename $file` 312 # 313 # Skipping scripts is done now and not included in the build tree. 314 case $this_script in 315 *chroot*) continue ;; 316 esac 317 318 # 319 # First append each name of the script files to a list (this will become 320 # the names of the targets in the Makefile 321 case "${this_script}" in 322 *util-linux) : ;; 323 *kernfs) orphan_scripts="${orphan_scripts} ${this_script}" ;; 324 *) chroottools="$chroottools $this_script" ;; 325 esac 326 327 # Grab the name of the target, strip id number, XXX-script 328 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'` 329 330 pkg_tarball=$(get_package_tarball_name $name) 331 332 # This is very ugly:: util-linux is in /chroot but should be run under LUSER 333 # A custom collection of routines. 334 case "${this_script}" in 335 *util-linux) 336 LUSER_wrt_target "${this_script}" "$PREV" 337 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball" 338 [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name" 339 LUSER_wrt_RunAsUser "${file}" 340 LUSER_RemoveBuildDirs "${name}" 341 wrt_touch 342 temptools="$temptools $this_script" 343 continue ;; 344 esac 345 346 347 #--------------------------------------------------------------------# 348 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< # 349 #--------------------------------------------------------------------# 350 # 351 # Drop in the name of the target on a new line, and the previous target 352 # as a dependency. Also call the echo_message function. 353 CHROOT_wrt_target "${this_script}" "$PREV" 354 # 355 # If $pkg_tarball isn't empty, we've got a package... 356 # Insert instructions for unpacking the package and changing directories 357 # 358 if [ "$pkg_tarball" != "" ] ; then 359 case $this_script in 360 *util-linux) ROOT_Unpack "$pkg_tarball" ;; 361 *) CHROOT_Unpack "$pkg_tarball" ;; 362 esac 363 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name" 364 fi 365 # 366 # Select a script execution method 367 case $this_script in 368 *kernfs) wrt_RunAsRoot "${this_script}" "${file}" ;; 369 *util-linux) ROOT_RunAsRoot "${file}" ;; 370 *) CHROOT_wrt_RunAsRoot "${file}" ;; 371 esac 372 # 373 # Housekeeping...remove the build directory(ies), except if the package build fails. 374 [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}" 375 # 376 # Include a touch of the target name so make can check if it's already been made. 377 wrt_touch 378 # 379 #--------------------------------------------------------------------# 380 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< # 381 #--------------------------------------------------------------------# 382 # 383 # Keep the script file name for Makefile dependencies. 384 PREV=$this_script 385 386 done # for file in... 387 } 388 389 390 #--------------------------------------# 391 boot_Makefiles() { # 392 #--------------------------------------# 393 394 echo "${tab_}${GREEN}Processing... ${L_arrow}tmptools BOOT ( LUSER ) ${R_arrow}" 395 # 396 # Create a target bootable partition containing a compile environment. Later 397 # on we boot into this environment and contine the build. 398 # 217 399 for file in boot/* ; do 218 400 # Keep the script file name … … 223 405 *grub | *aboot | *colo | *silo | *arcload | *lilo ) continue ;; 224 406 *whatnext*) continue ;; 225 *kernel) # if there is no kernel config file do not build the kernel 407 *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;; 408 *kernel) # if there is no kernel config file do not build the kernel 226 409 [[ -z $CONFIG ]] && continue 227 410 # Copy the config file to /sources with a standardized name … … 232 415 # First append each name of the script files to a list (this will become 233 416 # the names of the targets in the Makefile 234 boottools="$boottools $this_script" 417 case "${this_script}" in 418 *changingowner) orphan_scripts="${orphan_scripts} ${this_script}" ;; 419 *devices) orphan_scripts="${orphan_scripts} ${this_script}" ;; 420 *) boottools="$boottools $this_script" ;; 421 esac 235 422 # 236 423 # Grab the name of the target, strip id number and misc words. … … 257 444 # Drop in the name of the target on a new line, and the previous target 258 445 # as a dependency. Also call the echo_message function. 259 wrt_target "${this_script}" "$PREV"446 LUSER_wrt_target "${this_script}" "$PREV" 260 447 # 261 448 # If $pkg_tarball isn't empty, we've got a package... 262 449 # Insert instructions for unpacking the package and changing directories 263 450 # 264 [[ "$pkg_tarball" != "" ]] && wrt_unpack "$pkg_tarball"451 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball" 265 452 [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name" 266 453 # 267 454 # Select a script execution method 268 455 case $this_script in 456 # The following 2 scripts are defined in the /boot directory but need 457 # to be run as a root user. Set them up here but run them in another phase 269 458 *changingowner*) wrt_RunAsRoot "${this_script}" "${file}" ;; 270 459 *devices*) wrt_RunAsRoot "${this_script}" "${file}" ;; 271 460 *fstab*) if [[ -n "$FSTAB" ]]; then 272 wrt_copy_fstab "${this_script}"461 LUSER_wrt_CopyFstab 273 462 else 274 wrt_RunAsUser "${this_script}""${file}"463 LUSER_wrt_RunAsUser "${file}" 275 464 fi 276 465 ;; 277 *) wrt_RunAsUser "${this_script}""${file}" ;;466 *) LUSER_wrt_RunAsUser "${file}" ;; 278 467 esac 279 468 # 280 469 # Housekeeping...remove any build directory(ies) except if the package build fails. 281 [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"470 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}" 282 471 # 283 472 # Include a touch of the target name so make can check if it's already been made. … … 295 484 296 485 297 #-----------------------------# 298 chroot_Makefiles() { # 299 #-----------------------------# 300 echo "${tab_}${GREEN}Processing... ${L_arrow}chroot${R_arrow}" 301 302 for file in chroot/* ; do 303 # Keep the script file name 304 this_script=`basename $file` 305 # 306 # Skipping scripts is done now and not included in the build tree. 307 case $this_script in 308 *chroot*) continue ;; 309 esac 310 311 # 312 # First append each name of the script files to a list (this will become 313 # the names of the targets in the Makefile 314 chroottools="$chroottools $this_script" 315 316 # Grab the name of the target, strip id number, XXX-script 317 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'` 318 319 pkg_tarball=$(get_package_tarball_name $name) 320 321 #--------------------------------------------------------------------# 322 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< # 323 #--------------------------------------------------------------------# 324 # 325 # Drop in the name of the target on a new line, and the previous target 326 # as a dependency. Also call the echo_message function. 327 wrt_target "${this_script}" "$PREV" 328 # 329 # If $pkg_tarball isn't empty, we've got a package... 330 # Insert instructions for unpacking the package and changing directories 331 # 332 if [ "$pkg_tarball" != "" ] ; then 333 case $this_script in 334 *util-linux) wrt_unpack "$pkg_tarball" ;; 335 *) wrt_unpack2 "$pkg_tarball" ;; 336 esac 337 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name" 338 fi 339 # 340 # Select a script execution method 341 case $this_script in 342 *kernfs) wrt_RunAsRoot "${this_script}" "${file}" ;; 343 *util-linux) wrt_RunAsUser "${this_script}" "${file}" ;; 344 *) wrt_run_as_chroot1 "${this_script}" "${file}" ;; 345 esac 346 # 347 # Housekeeping...remove the build directory(ies), except if the package build fails. 348 [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}" 349 # 350 # Include a touch of the target name so make can check if it's already been made. 351 wrt_touch 352 # 353 #--------------------------------------------------------------------# 354 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< # 355 #--------------------------------------------------------------------# 356 # 357 # Keep the script file name for Makefile dependencies. 358 PREV=$this_script 359 360 done # for file in... 361 } 362 363 364 #-----------------------------# 365 testsuite_tools_Makefiles() { # 366 #-----------------------------# 367 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) testsuite tools${R_arrow}" 486 #--------------------------------------# 487 chroot_testsuite_tools_Makefiles() { # 488 #--------------------------------------# 489 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) testsuite tools ( CHROOT ) ${R_arrow}" 368 490 369 491 for file in testsuite-tools/* ; do … … 390 512 # Drop in the name of the target on a new line, and the previous target 391 513 # as a dependency. Also call the echo_message function. 392 wrt_target "${this_script}" "$PREV"393 # 394 wrt_unpack2"$pkg_tarball"514 CHROOT_wrt_target "${this_script}" "$PREV" 515 # 516 CHROOT_Unpack "$pkg_tarball" 395 517 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name" 396 518 # 397 wrt_run_as_chroot1 "${this_script}""${file}"398 # 399 wrt_remove_build_dirs "${name}"519 CHROOT_wrt_RunAsRoot "${file}" 520 # 521 CHROOT_wrt_RemoveBuildDirs "${name}" 400 522 # 401 523 # Include a touch of the target name so make can check if it's already been made. … … 412 534 } 413 535 414 415 #--------------------------------# 416 bm_testsuite_tools_Makefiles() { # 417 #--------------------------------# 418 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) testsuite tools${R_arrow}" 419 536 #--------------------------------------# 537 boot_testsuite_tools_Makefiles() { # 538 #--------------------------------------# 539 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) testsuite tools ( ROOT ) ${R_arrow}" 420 540 for file in testsuite-tools/* ; do 421 541 # Keep the script file name … … 442 562 # Drop in the name of the target on a new line, and the previous target 443 563 # as a dependency. Also call the echo_message function. 444 wrt_target_boot "${this_script}" "$PREV"445 # 446 wrt_unpack3"$pkg_tarball"564 BOOT_wrt_target "${this_script}" "$PREV" 565 # 566 BOOT_wrt_Unpack "$pkg_tarball" 447 567 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name" 448 568 # 449 wrt_run_as_root2"${this_script}" "${file}"450 # 451 wrt_remove_build_dirs2"${name}"569 BOOT_wrt_RunAsRoot "${this_script}" "${file}" 570 # 571 BOOT_wrt_RemoveBuildDirs "${name}" 452 572 # 453 573 # Include a touch of the target name so make can check if it's already been made. … … 462 582 463 583 done 464 } 465 466 467 #-----------------------------# 468 final_system_Makefiles() { # 469 #-----------------------------# 584 585 } 586 587 588 #--------------------------------------# 589 chroot_final_system_Makefiles() { # 590 #--------------------------------------# 470 591 # Set envars and scripts for iteration targets 471 592 LOGS="" # Start with an empty global LOGS envar … … 489 610 fi 490 611 491 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system$N ${R_arrow}"612 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system$N ( CHROOT ) ${R_arrow}" 492 613 493 614 for file in final-system$N/* ; do … … 536 657 # Drop in the name of the target on a new line, and the previous target 537 658 # as a dependency. Also call the echo_message function. 538 wrt_target "${this_script}${N}" "$PREV"659 CHROOT_wrt_target "${this_script}${N}" "$PREV" 539 660 540 661 # If $pkg_tarball isn't empty, we've got a package... 541 662 if [ "$pkg_tarball" != "" ] ; then 542 wrt_unpack2"$pkg_tarball"663 CHROOT_Unpack "$pkg_tarball" 543 664 # If the testsuites must be run, initialize the log file 544 665 case $name in 545 666 binutils | gcc | glibc ) 546 [[ "$TEST" != "0" ]] && wrt_test_log2"${this_script}"667 [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}" 547 668 ;; 548 669 * ) 549 [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && wrt_test_log2"${this_script}"670 [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && CHROOT_wrt_test_log "${this_script}" 550 671 ;; 551 672 esac … … 554 675 fi 555 676 # 556 wrt_run_as_chroot1 "${this_script}""${file}"557 # 558 [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"677 CHROOT_wrt_RunAsRoot "${file}" 678 # 679 [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}" 559 680 # 560 681 # Include a touch of the target name so make can check if it's already been made. … … 572 693 } 573 694 574 575 #-----------------------------# 576 bm_final_system_Makefiles() { # 577 #-----------------------------# 695 #--------------------------------------# 696 boot_final_system_Makefiles() { # 697 #--------------------------------------# 578 698 # Set envars and scripts for iteration targets 579 699 LOGS="" # Start with an empty global LOGS envar … … 599 719 fi 600 720 601 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system$N ${R_arrow}"721 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system$N ( ROOT ) ${R_arrow}" 602 722 603 723 for file in final-system$N/* ; do … … 647 767 # Drop in the name of the target on a new line, and the previous target 648 768 # as a dependency. Also call the echo_message function. 649 wrt_target_boot "${this_script}${N}" "$PREV"769 BOOT_wrt_target "${this_script}${N}" "$PREV" 650 770 651 771 # If $pkg_tarball isn't empty, we've got a package... 652 772 if [ "$pkg_tarball" != "" ] ; then 653 773 FILE="$pkg_tarball" 654 wrt_unpack3"$FILE"774 BOOT_wrt_Unpack "$FILE" 655 775 # If the testsuites must be run, initialize the log file 656 776 case $name in 657 777 binutils | gcc | glibc ) 658 [[ "$TEST" != "0" ]] && wrt_test_log2"${this_script}"778 [[ "$TEST" != "0" ]] && BOOT_wrt_test_log "${this_script}" 659 779 ;; 660 780 * ) 661 [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && wrt_test_log2"${this_script}"781 [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && BOOT_wrt_test_log "${this_script}" 662 782 ;; 663 783 esac … … 666 786 fi 667 787 # 668 wrt_run_as_root2"${this_script}" "${file}"669 # 670 [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs2"${name}"788 BOOT_wrt_RunAsRoot "${this_script}" "${file}" 789 # 790 [[ "$pkg_tarball" != "" ]] && BOOT_wrt_RemoveBuildDirs "${name}" 671 791 # 672 792 # Include a touch of the target name so make can check if it's already been made. … … 682 802 system_build=$basicsystem 683 803 done # for file in final-system/* ... 684 } 685 686 687 #----------------------------- #688 bootscripts_Makefiles() {#689 #----------------------------- #690 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) bootscripts${R_arrow}"804 805 } 806 807 #--------------------------------------# 808 chroot_bootscripts_Makefiles() { # 809 #--------------------------------------# 810 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) bootscripts ( CHROOT ) ${R_arrow}" 691 811 692 812 for file in bootscripts/* ; do … … 723 843 # Drop in the name of the target on a new line, and the previous target 724 844 # as a dependency. Also call the echo_message function. 725 wrt_target "${this_script}" "$PREV"845 CHROOT_wrt_target "${this_script}" "$PREV" 726 846 # 727 847 # If $pkg_tarball isn't empty, we've got a package... 728 848 # 729 [[ "$pkg_tarball" != "" ]] && wrt_unpack2"$pkg_tarball"730 # 731 wrt_run_as_chroot1 "${this_script}""${file}"732 # 733 [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"849 [[ "$pkg_tarball" != "" ]] && CHROOT_Unpack "$pkg_tarball" 850 # 851 CHROOT_wrt_RunAsRoot "${file}" 852 # 853 [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}" 734 854 # 735 855 # Include a touch of the target name so make can check if it's already been made. … … 744 864 745 865 done # for file in bootscripts/* ... 746 747 } 748 749 #-----------------------------# 750 bm_bootscripts_Makefiles() { # 751 #-----------------------------# 752 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) bootscripts${R_arrow}" 866 } 867 868 #--------------------------------------# 869 boot_bootscripts_Makefiles() { # 870 #--------------------------------------# 871 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) bootscripts ( ROOT ) ${R_arrow}" 753 872 754 873 for file in bootscripts/* ; do … … 785 904 # Drop in the name of the target on a new line, and the previous target 786 905 # as a dependency. Also call the echo_message function. 787 wrt_target_boot "${this_script}" "$PREV"906 BOOT_wrt_target "${this_script}" "$PREV" 788 907 # 789 908 # If $pkg_tarball isn't empty, we've got a package... 790 909 # 791 [[ "$pkg_tarball" != "" ]] && wrt_unpack3"$pkg_tarball"792 # 793 wrt_run_as_root2"${this_script}" "${file}"794 # 795 [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs2"${name}"910 [[ "$pkg_tarball" != "" ]] && BOOT_wrt_Unpack "$pkg_tarball" 911 # 912 BOOT_wrt_RunAsRoot "${this_script}" "${file}" 913 # 914 [[ "$pkg_tarball" != "" ]] && BOOT_wrt_RemoveBuildDirs "${name}" 796 915 # 797 916 # Include a touch of the target name so make can check if it's already been made. … … 806 925 807 926 done # for file in bootscripts/* ... 808 809 } 810 811 812 813 #-----------------------------# 814 bootable_Makefiles() { # 815 #-----------------------------# 816 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable${R_arrow}" 927 } 928 929 #--------------------------------------# 930 chroot_bootable_Makefiles() { # 931 #--------------------------------------# 932 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable ( CHROOT ) ${R_arrow}" 817 933 818 934 for file in {bootable,the-end}/* ; do … … 823 939 case $this_script in 824 940 *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;; 941 *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;; 825 942 *kernel) # if there is no kernel config file do not build the kernel 826 943 [[ -z $CONFIG ]] && continue … … 849 966 # Drop in the name of the target on a new line, and the previous target 850 967 # as a dependency. Also call the echo_message function. 851 wrt_target "${this_script}" "$PREV"968 CHROOT_wrt_target "${this_script}" "$PREV" 852 969 # 853 970 # If $pkg_tarball isn't empty, we've got a package... 854 971 # Insert instructions for unpacking the package and changing directories 855 972 # 856 [[ "$pkg_tarball" != "" ]] && wrt_unpack2"$pkg_tarball"973 [[ "$pkg_tarball" != "" ]] && CHROOT_Unpack "$pkg_tarball" 857 974 # 858 975 # Select a script execution method 859 976 case $this_script in 860 *fstab*) if [[ -n "$FSTAB" ]]; then 861 wrt_copy_fstab "${this_script}" 862 else 863 wrt_run_as_chroot1 "${this_script}" "${file}" 864 fi 865 ;; 866 *) wrt_run_as_chroot1 "${this_script}" "${file}" ;; 977 *fstab*) if [[ -n "$FSTAB" ]]; then 978 CHROOT_wrt_CopyFstab 979 else 980 CHROOT_wrt_RunAsRoot "${file}" 981 fi 982 ;; 983 *) CHROOT_wrt_RunAsRoot "${file}" 984 ;; 867 985 esac 868 986 # 869 987 # Housekeeping...remove any build directory(ies) except if the package build fails. 870 [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"988 [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}" 871 989 # 872 990 # Include a touch of the target name so make can check if it's already been made. … … 887 1005 } 888 1006 889 890 891 #-----------------------------# 892 bm_bootable_Makefiles() { # 893 #-----------------------------# 894 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) make bootable${R_arrow}" 1007 #--------------------------------------# 1008 boot_bootable_Makefiles() { # 1009 #--------------------------------------# 1010 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) make bootable ( ROOT ) ${R_arrow}" 895 1011 896 1012 for file in {bootable,the-end}/* ; do … … 926 1042 # Drop in the name of the target on a new line, and the previous target 927 1043 # as a dependency. Also call the echo_message function. 928 wrt_target_boot "${this_script}" "$PREV"1044 BOOT_wrt_target "${this_script}" "$PREV" 929 1045 # 930 1046 # If $pkg_tarball isn't empty, we've got a package... 931 1047 # Insert instructions for unpacking the package and changing directories 932 1048 # 933 [[ "$pkg_tarball" != "" ]] && wrt_unpack3"$pkg_tarball"1049 [[ "$pkg_tarball" != "" ]] && BOOT_wrt_Unpack "$pkg_tarball" 934 1050 # 935 1051 # Select a script execution method … … 938 1054 # Minimal boot mode has no access to original file, store in /sources 939 1055 cp $FSTAB $BUILDDIR/sources/fstab 940 wrt_copy_fstab2"${this_script}"1056 BOOT_wrt_CopyFstab "${this_script}" 941 1057 else 942 wrt_run_as_root2"${this_script}" "${file}"1058 BOOT_wrt_RunAsRoot "${this_script}" "${file}" 943 1059 fi 944 1060 ;; 945 *) wrt_run_as_root2"${this_script}" "${file}" ;;1061 *) BOOT_wrt_RunAsRoot "${this_script}" "${file}" ;; 946 1062 esac 947 1063 # 948 1064 # Housekeeping...remove any build directory(ies) except if the package build fails. 949 [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs2"${name}"1065 [[ "$pkg_tarball" != "" ]] && BOOT_wrt_RemoveBuildDirs "${name}" 950 1066 # 951 1067 # Include a touch of the target name so make can check if it's already been made. … … 958 1074 # Keep the script file name for Makefile dependencies. 959 1075 PREV=$this_script 960 961 1076 done 962 1077 … … 964 1079 if [[ "$REPORT" = "y" ]] ; then wrt_report ; fi 965 1080 966 } 967 968 969 #-----------------------------# 970 build_Makefile() { # Construct a Makefile from the book scripts 971 #-----------------------------# 972 echo "Creating Makefile... ${BOLD}START${OFF}" 1081 1082 } 1083 1084 1085 #--------------------------------------# 1086 build_Makefile() { # Construct a Makefile from the book scripts 1087 #--------------------------------------# 1088 # 1089 # Script crashes if error trapping is on 1090 # 1091 set +e 1092 declare -f method_cmds 1093 declare -f testsuite_cmds 1094 declare -f final_sys_cmds 1095 declare -f bootscripts_cmds 1096 declare -f bootable_cmds 1097 set -e 1098 1099 echo "...Creating Makefile... ${BOLD}START${OFF}" 973 1100 974 1101 cd $JHALFSDIR/${PROGNAME}-commands 975 # Start with a clean Makefile.tmp file 1102 # Start with a clean files 1103 >$MKFILE 976 1104 >$MKFILE.tmp 977 1105 978 host_prep_Makefiles 979 cross_tools_Makefiles # $cross_tools 980 temptools_Makefiles # $temptools 981 if [[ $METHOD = "chroot" ]]; then 982 chroot_Makefiles # $chroottools 983 if [[ ! $TEST = "0" ]]; then 984 testsuite_tools_Makefiles # $testsuitetools 985 fi 986 final_system_Makefiles # $basicsystem 1106 method_cmds=${METHOD}_Makefiles 1107 testsuite_cmds=${METHOD}_testsuite_tools_Makefiles 1108 final_sys_cmds=${METHOD}_final_system_Makefiles 1109 bootscripts_cmds=${METHOD}_bootscripts_Makefiles 1110 bootable_cmds=${METHOD}_bootable_Makefiles 1111 1112 host_prep_Makefiles # mk_SETUP (SETUP) $host_prep 1113 cross_tools_Makefiles # mk_CROSS (LUSER) $cross_tools 1114 temptools_Makefiles # mk_TEMP (LUSER) $temptools 1115 $method_cmds # mk_SYSTOOLS (CHROOT) $chroottools/$boottools 1116 if [[ ! $TEST = "0" ]]; then 1117 $testsuite_cmds # mk_SYSTOOLS (CHROOT) $testsuitetools 1118 fi 1119 $final_sys_cmds # mk_FINAL (CHROOT) $basicsystem 987 1120 # Add the iterations targets, if needed 988 [[ "$COMPARE" = "y" ]] && wrt_compare_targets 989 bootscripts_Makefiles # $bootscripttools 990 bootable_Makefiles # $bootabletools 991 else 992 boot_Makefiles # $boottools 993 if [[ ! $TEST = "0" ]]; then 994 bm_testsuite_tools_Makefiles # $testsuitetools 995 fi 996 bm_final_system_Makefiles # $basicsystem 997 # Add the iterations targets, if needed 998 [[ "$COMPARE" = "y" ]] && wrt_compare_targets 999 bm_bootscripts_Makefiles # $bootscipttools 1000 bm_bootable_Makefiles # $bootabletoosl 1001 fi 1002 # the_end_Makefiles 1003 1121 [[ "$COMPARE" = "y" ]] && wrt_compare_targets 1122 $bootscripts_cmds # mk_BOOTSCRIPT (CHROOT) $bootscripttools 1123 $bootable_cmds # mk_BOOTABLE (CHROOT) $bootabletools 1004 1124 1005 1125 # Add a header, some variables and include the function file … … 1030 1150 LUSER_HOME = /home/\$(LUSER) 1031 1151 PRT_DU = echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" 1032 PRT_DU_CR = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) \$(MOUNT_PT)\`\n" 1033 1152 PRT_DU_CR = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) / \`\n" 1034 1153 1035 1154 include makefile-functions … … 1057 1176 fi 1058 1177 1059 # Drop in the main target 'all:' and the chapter targets with each sub-target 1060 # as a dependency. 1178 ################## CHROOT #################### 1179 1061 1180 if [[ "${METHOD}" = "chroot" ]]; then 1062 1181 ( 1063 cat << EOF 1064 all: chapter2 chapter3 chapter4 chapter5 chapter6 chapter7 chapter8 do-housekeeping 1182 cat << EOF 1183 1184 all: mk_SETUP mk_CROSS mk_TEMP mk_SYSTOOLS mk_FINAL mk_BOOTSCRIPT mk_BOOTABLE do-housekeeping 1065 1185 @\$(call echo_finished,$VERSION) 1066 1186 1067 chapter2: 023-creatingtoolsdir 024-creatingcrossdir 025-addinguser 026-settingenvironment 1068 1069 chapter3: chapter2 $cross_tools 1070 1071 chapter4: chapter3 $temptools 1072 1073 chapter5: chapter4 $chroottools restore-luser-env $testsuitetools 1074 1075 chapter6: chapter5 $basicsystem 1076 1077 chapter7: chapter6 $bootscripttools 1078 1079 chapter8: chapter7 $bootabletools 1080 1081 clean-all: clean 1082 rm -rf ./{clfs-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches} 1083 1084 clean: clean-chapter4 clean-chapter3 clean-chapter2 1187 #---------------AS ROOT 1188 mk_SETUP: 1189 @\$(call echo_SU_request) 1190 @sudo make SETUP 1191 @touch \$@ 1192 1193 #---------------AS LUSER 1194 mk_CROSS: mk_SETUP 1195 @\$(call echo_PHASE,Cross Tool) 1196 @( \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make CROSS" ) 1197 @touch \$@ 1198 1199 mk_TEMP: mk_CROSS 1200 @\$(call echo_PHASE,Temporary Tools) 1201 @( \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make TEMP" ) 1202 @touch \$@ 1203 1204 # 1205 # The convoluted piece of code below is necessary to provide 'make' with a valid shell in the 1206 # chroot environment. (Unless someone knows a different way) 1207 # Manually create the /bin directory and provide link to the /tools dir. 1208 # Also change the original symlink creation to include (f)orce to prevent failure due to 1209 # pre-existing links. 1210 1211 #---------------CHROOT JAIL 1212 mk_SYSTOOLS: mk_TEMP $orphan_scripts 1213 @mkdir \$(MOUNT_PT)/bin && \\ 1214 cd \$(MOUNT_PT)/bin && \\ 1215 ln -sf /tools/bin/bash bash; ln -sf bash sh 1216 @sed -e 's|^ln -sv|ln -svf|' -i \$(CMDSDIR)/chroot/082-createfiles 1217 @\$(call echo_CHROOT_request) 1218 @\$(call echo_PHASE, Chroot systools) 1219 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make SYSTOOLS") 1220 @touch \$@ 1221 1222 mk_FINAL: mk_SYSTOOLS 1223 @\$(call echo_PHASE,Final System) 1224 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make FINAL") 1225 @touch \$@ 1226 1227 mk_BOOTSCRIPT: mk_FINAL 1228 @\$(call echo_PHASE,Bootscript) 1229 @\$(call echo_CHROOT_request) 1230 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BOOTSCRIPT") 1231 @touch \$@ 1232 1233 mk_BOOTABLE: mk_BOOTSCRIPT 1234 @\$(call echo_PHASE, Make bootable ) 1235 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BOOTABLE") 1236 @touch \$@ 1237 1238 EOF 1239 ) >> $MKFILE 1240 fi 1241 1242 ################### BOOT ##################### 1243 1244 if [[ "${METHOD}" = "boot" ]]; then 1245 ( 1246 cat << EOF 1247 1248 all: mk_SETUP mk_CROSS mk_TEMP mk_SYSTOOLS $orphan_scripts restore-luser-env 1249 @\$(call echo_boot_finished,$VERSION) 1250 1251 makesys: mk_FINAL mk_BOOTSCRIPT mk_BOOTABLE 1252 @\$(call echo_finished,$VERSION) 1253 1254 #---------------AS ROOT 1255 1256 mk_SETUP: 1257 @\$(call echo_SU_request) 1258 @sudo make SETUP 1259 @touch \$@ 1260 1261 #---------------AS LUSER 1262 1263 mk_CROSS: mk_SETUP 1264 @\$(call echo_PHASE,Cross Tool) 1265 @( \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make CROSS" ) 1266 @touch \$@ 1267 1268 mk_TEMP: mk_CROSS 1269 @\$(call echo_PHASE,Temporary Tools) 1270 @( \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make TEMP" ) 1271 @touch \$@ 1272 1273 mk_SYSTOOLS: mk_TEMP 1274 @\$(call echo_PHASE,Minimal Boot system) 1275 @( \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make SYSTOOLS" ) 1276 @touch \$@ 1277 1278 #---------------AS ROOT 1279 1280 mk_FINAL: 1281 @\$(call echo_PHASE,Final System) 1282 @( make FINAL ) 1283 @touch \$@ 1284 1285 mk_BOOTSCRIPT: mk_FINAL 1286 @\$(call echo_PHASE,Bootscript) 1287 @( make BOOTSCRIPT ) 1288 @touch \$@ 1289 1290 mk_BOOTABLE: mk_BOOTSCRIPT 1291 @\$(call echo_PHASE,Making Bootable) 1292 @( make BOOTABLE ) 1293 @touch \$@ 1294 1295 EOF 1296 ) >> $MKFILE 1297 fi 1298 1299 ( 1300 cat << EOF 1301 1302 SETUP: $host_prep 1303 CROSS: $cross_tools 1304 TEMP: $temptools 1305 SYSTOOLS: ${chroottools}${boottools} 1306 FINAL: $testsuitetools $basicsystem 1307 BOOTSCRIPT: $bootscripttools 1308 BOOTABLE: $bootabletools 1085 1309 1086 1310 restart: 1087 1311 @echo "This feature does not exist for the CLFS makefile. (yet)" 1088 1089 clean-chapter2:1090 -if [ ! -f luser-exist ]; then \\1091 userdel \$(LUSER); \\1092 rm -rf /home/\$(LUSER); \\1093 fi;1094 rm -rf \$(MOUNT_PT)/tools1095 rm -f /tools1096 rm -rf \$(MOUNT_PT)/cross-tools1097 rm -f /cross-tools1098 rm -f envars luser-exist1099 rm -f 02* logs/02*.log1100 1101 clean-chapter3:1102 rm -rf \$(MOUNT_PT)/tools/*1103 rm -f $cross_tools sources-dir1104 cd logs && rm -f $cross_tools && cd ..1105 1106 clean-chapter4:1107 -umount \$(MOUNT_PT)/sys1108 -umount \$(MOUNT_PT)/proc1109 -umount \$(MOUNT_PT)/dev/shm1110 -umount \$(MOUNT_PT)/dev/pts1111 -umount \$(MOUNT_PT)/dev1112 rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,lib64,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}1113 rm -f $temptools1114 cd logs && rm -f $temptools && cd ..1115 1116 1312 1117 1313 restore-luser-env: … … 1139 1335 fi; 1140 1336 1337 ######################################################## 1338 1339 1141 1340 EOF 1142 1341 ) >> $MKFILE 1143 fi1144 1145 1146 if [[ "${METHOD}" = "boot" ]]; then1147 (1148 cat << EOF1149 1150 all: makeboot1151 1152 makeboot: 023-creatingtoolsdir 024-creatingcrossdir 025-addinguser 026-settingenvironment \1153 $cross_tools\1154 $temptools \1155 $chroottools \1156 $boottools restore-luser-env1157 @\$(call echo_boot_finished,$VERSION)1158 1159 makesys: $testsuitetools $basicsystem $bootscripttools $bootabletools1160 @\$(call echo_finished,$VERSION)1161 1162 1163 clean-all: clean1164 rm -rf ./{clfs-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}1165 1166 clean: clean-makesys clean-makeboot clean-jhalfs1167 1168 restart:1169 @echo "This feature does not exist for the CLFS makefile. (yet)"1170 1171 clean-jhalfs:1172 -if [ ! -f luser-exist ]; then \\1173 userdel \$(LUSER); \\1174 rm -rf /home/\$(LUSER); \\1175 fi;1176 rm -rf \$(MOUNT_PT)/tools1177 rm -f /tools1178 rm -rf \$(MOUNT_PT)/cross-tools1179 rm -f /cross-tools1180 rm -f envars luser-exist1181 rm -f 02* logs/02*.log1182 1183 clean-makeboot:1184 rm -rf /tools/*1185 rm -f $cross_tools && rm -f $temptools && rm -f $chroottools && rm -f $boottools1186 rm -f restore-luser-env sources-dir1187 cd logs && rm -f $cross_tools && rm -f $temptools && rm -f $chroottools && rm -f $boottools && cd ..1188 1189 clean-makesys:1190 -umount \$(MOUNT_PT)/sys1191 -umount \$(MOUNT_PT)/proc1192 -umount \$(MOUNT_PT)/dev/shm1193 -umount \$(MOUNT_PT)/dev/pts1194 -umount \$(MOUNT_PT)/dev1195 rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,lib64,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}1196 rm -f $basicsystem1197 rm -f $bootscripttools1198 rm -f $bootabletools1199 cd logs && rm -f $basicsystem && rm -f $bootscripttools && rm -f $bootabletools && cd ..1200 1201 1202 restore-luser-env:1203 @\$(call echo_message, Building)1204 @if [ -f /home/\$(LUSER)/.bashrc.XXX ]; then \\1205 mv -fv /home/\$(LUSER)/.bashrc.XXX /home/\$(LUSER)/.bashrc; \\1206 fi;1207 @if [ -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\1208 mv -v /home/\$(LUSER)/.bash_profile.XXX /home/\$(LUSER)/.bash_profile; \\1209 fi;1210 @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bash* && \\1211 touch \$@ && \\1212 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\1213 echo --------------------------------------------------------------------------------\$(WHITE)1214 1215 1216 EOF1217 ) >> $MKFILE1218 fi1219 1342 1220 1343 # Bring over the items from the Makefile.tmp 1221 1344 cat $MKFILE.tmp >> $MKFILE 1222 1345 rm $MKFILE.tmp 1346 1223 1347 echo "Creating Makefile... ${BOLD}DONE${OFF}" 1224 1225 } 1226 1348 }
Note:
See TracChangeset
for help on using the changeset viewer.