Changeset 9c9775f for CLFS2/master.sh
- Timestamp:
- 09/19/2007 04:50:48 PM (17 years ago)
- Branches:
- experimental
- Children:
- 3778352
- Parents:
- 0510381
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CLFS2/master.sh
-
Property mode
changed from
100755
to100644
r0510381 r9c9775f 1 #!/bin/ sh1 #!/bin/bash 2 2 # $Id$ 3 3 … … 18 18 ( 19 19 cat << EOF 20 023-creatingtoolsdir: 20 21 025-addinguser: 21 22 @\$(call echo_message, Building) 22 @if [ ! -d \$(MOUNT_PT)/sources ]; then \\ 23 mkdir \$(MOUNT_PT)/sources; \\ 24 fi; 25 @chmod a+wt \$(MOUNT_PT)/sources 26 @touch \$@ && \\ 27 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\ 28 echo --------------------------------------------------------------------------------\$(WHITE) 29 30 025-addinguser: 023-creatingtoolsdir 31 @\$(call echo_message, Building) 32 @if [ ! -d /home/\$(LUSER) ]; then \\ 23 @if [ ! -d \$(LUSER_HOME) ]; then \\ 33 24 groupadd \$(LGROUP); \\ 34 25 useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\ … … 36 27 touch luser-exist; \\ 37 28 fi; 38 @chown -R \$(LUSER) \$(MOUNT_PT) && \\ 39 chown \$(LUSER) \$(MOUNT_PT)/sources 40 @touch \$@ && \\ 41 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\ 42 echo --------------------------------------------------------------------------------\$(WHITE) 29 @\$(call housekeeping) 43 30 44 31 026-settingenvironment: 025-addinguser 45 32 @\$(call echo_message, Building) 46 @if [ -f /home/\$(LUSER)/.bashrc -a ! -f /home/\$(LUSER)/.bashrc.XXX ]; then \\ 47 mv /home/\$(LUSER)/.bashrc /home/\$(LUSER)/.bashrc.XXX; \\ 48 fi; 49 @if [ -f /home/\$(LUSER)/.bash_profile -a ! -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\ 50 mv /home/\$(LUSER)/.bash_profile /home/\$(LUSER)/.bash_profile.XXX; \\ 51 fi; 52 @echo "set +h" > /home/\$(LUSER)/.bashrc && \\ 53 echo "umask 022" >> /home/\$(LUSER)/.bashrc && \\ 54 echo "CLFS=\$(MOUNT_PT)" >> /home/\$(LUSER)/.bashrc && \\ 55 echo "LC_ALL=POSIX" >> /home/\$(LUSER)/.bashrc && \\ 56 echo "PATH=\$(MOUNT_PT)/cross-tools/bin:/bin:/usr/bin" >> /home/\$(LUSER)/.bashrc && \\ 57 echo "export CLFS LC_ALL PATH" >> /home/\$(LUSER)/.bashrc && \\ 58 echo "" >> /home/\$(LUSER)/.bashrc && \\ 59 echo "unset CFLAGS" >> /home/\$(LUSER)/.bashrc && \\ 60 echo "unset CXXFLAGS" >> /home/\$(LUSER)/.bashrc && \\ 61 echo "" >> /home/\$(LUSER)/.bashrc && \\ 62 echo "export CLFS_HOST=\"${CLFS_HOST}\"" >> /home/\$(LUSER)/.bashrc && \\ 63 echo "export CLFS_TARGET=\"${TARGET}\"" >> /home/\$(LUSER)/.bashrc && \\ 64 echo "export CLFS_TARGET32=\"${TARGET32}\"" >> /home/\$(LUSER)/.bashrc && \\ 65 echo "source $JHALFSDIR/envars" >> /home/\$(LUSER)/.bashrc 66 @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bashrc && \\ 33 @if [ -f \$(LUSER_HOME)/.bashrc -a ! -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\ 34 mv \$(LUSER_HOME)/.bashrc \$(LUSER_HOME)/.bashrc.XXX; \\ 35 fi; 36 @if [ -f \$(LUSER_HOME)/.bash_profile -a ! -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\ 37 mv \$(LUSER_HOME)/.bash_profile \$(LUSER_HOME)/.bash_profile.XXX; \\ 38 fi; 39 @echo "set +h" > \$(LUSER_HOME)/.bashrc && \\ 40 echo "umask 022" >> \$(LUSER_HOME)/.bashrc && \\ 41 echo "CLFS=\$(MOUNT_PT)" >> \$(LUSER_HOME)/.bashrc && \\ 42 echo "LC_ALL=POSIX" >> \$(LUSER_HOME)/.bashrc && \\ 43 echo "PATH=\$(MOUNT_PT)/cross-tools/bin:/bin:/usr/bin" >> \$(LUSER_HOME)/.bashrc && \\ 44 echo "export CLFS LC_ALL PATH" >> \$(LUSER_HOME)/.bashrc && \\ 45 echo "" >> \$(LUSER_HOME)/.bashrc && \\ 46 echo "unset CFLAGS" >> \$(LUSER_HOME)/.bashrc && \\ 47 echo "unset CXXFLAGS" >> \$(LUSER_HOME)/.bashrc && \\ 48 echo "" >> \$(LUSER_HOME)/.bashrc && \\ 49 echo "export CLFS_HOST=\"${CLFS_HOST}\"" >> \$(LUSER_HOME)/.bashrc && \\ 50 echo "export CLFS_TARGET=\"${TARGET}\"" >> \$(LUSER_HOME)/.bashrc && \\ 51 echo "source $JHALFSDIR/envars" >> \$(LUSER_HOME)/.bashrc 52 @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bashrc && \\ 67 53 touch envars && \\ 68 chown \$(LUSER):\$(LGROUP) envars && \\ 69 chmod -R a+wt \$(MOUNT_PT) 70 @touch \$@ && \\ 71 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\ 72 echo --------------------------------------------------------------------------------\$(WHITE) 54 chown \$(LUSER):\$(LGROUP) envars 55 @\$(call housekeeping) 73 56 74 57 027-create-directories: 026-settingenvironment … … 88 71 ln -s share/{man,doc,info} \$\$dir ; \\ 89 72 done 90 91 @touch \$@ && \\ 92 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\ 93 echo --------------------------------------------------------------------------------\$(WHITE) 73 @\$(call housekeeping) 94 74 95 75 028-creating-sysfile: 027-create-directories … … 117 97 @touch \$(MOUNT_PT)/var/run/utmp \$(MOUNT_PT)/var/log/{btmp,lastlog,wtmp} 118 98 @chmod 664 \$(MOUNT_PT)/var/run/utmp \$(MOUNT_PT)/var/log/lastlog 119 @chown -R \$(LUSER) \$(MOUNT_PT) 120 121 @touch \$@ && \\ 122 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\ 123 echo --------------------------------------------------------------------------------\$(WHITE) 99 @chown -R \$(LUSER) \$(MOUNT_PT) && \\ 100 chmod -R a+w \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\ 101 chmod -R a+w \$(SRCSDIR) 102 @\$(call housekeeping) 124 103 125 104 EOF 126 105 ) >> $MKFILE.tmp 127 106 128 host_prep=" 02 3-creatingtoolsdir 025-addinguser 026-settingenvironment 027-create-directories 028-creating-sysfile"107 host_prep=" 025-addinguser 026-settingenvironment 027-create-directories 028-creating-sysfile" 129 108 } 130 109 … … 140 119 # 141 120 # Skip this script... 142 # NOTE.. the book indicated you only needed to install groff or file if the host143 # had older versions. The packages would be installed in the target directory144 # and not the host.145 121 case $this_script in 146 122 *cflags* | *variables* ) # work done in host_prep_Makefiles 147 123 continue ;; 148 *file ) FileVer=`file --version | head -n1 | cut -d " " -f1`149 [[ "$FileVer" = "file-4.17" ]] && continue150 ;;151 *groff) GroffVer=`groff --version | head -n1 | cut -d " " -f4`152 [[ "$GroffVer" = "1.19.2" ]] && continue153 ;;154 124 *) ;; 155 125 esac … … 249 219 # If $pkg_tarball isn't empty, we've got a package... 250 220 if [ "$pkg_tarball" != "" ] ; then 221 # Touch timestamp file if installed files logs will be created. 222 # But only for the firt build when running iterative builds. 223 if [ "${INSTALL_LOG}" = "y" ] ; then 224 LUSER_wrt_TouchTimestamp 225 fi 251 226 LUSER_wrt_unpack "$pkg_tarball" 252 227 # If using optimizations, write the instructions … … 256 231 LUSER_wrt_RunAsUser "${file}" 257 232 # 258 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}" 233 # Write installed files log and remove the build directory(ies) 234 # except if the package build fails. 235 if [ "$pkg_tarball" != "" ] ; then 236 LUSER_RemoveBuildDirs "${name}" 237 if [ "${INSTALL_LOG}" = "y" ] ; then 238 LUSER_wrt_LogNewFiles "$name" 239 fi 240 fi 259 241 # 260 242 # Include a touch of the target name so make can check if it's already been made. … … 314 296 # 315 297 # If $pkg_tarball isn't empty, we've got a package... 316 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball" 298 if [ "$pkg_tarball" != "" ] ; then 299 LUSER_wrt_unpack "$pkg_tarball" 300 if [ "${INSTALL_LOG}" = "y" ] ; then 301 LUSER_wrt_TouchTimestamp 302 fi 303 fi 317 304 # 318 305 LUSER_wrt_RunAsUser "${file}" 319 306 # 320 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}" 307 if [ "$pkg_tarball" != "" ] ; then 308 LUSER_RemoveBuildDirs "${name}" 309 if [ "${INSTALL_LOG}" = "y" ] ; then 310 LUSER_wrt_LogNewFiles "$name" 311 fi 312 fi 321 313 # 322 314 # Include a touch of the target name so make can check if it's already been made. … … 360 352 # phase. 361 353 case ${this_script} in 362 *chowning) chowning= ${this_script};;354 *chowning) chowning=" ${this_script}" ;; 363 355 *) bootable="$bootable $this_script" ;; 364 356 esac … … 382 374 # 383 375 # If $pkg_tarball isn't empty, we've got a package... 384 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball" 376 if [ "$pkg_tarball" != "" ] ; then 377 LUSER_wrt_unpack "$pkg_tarball" 378 if [ "${INSTALL_LOG}" = "y" ] ; then 379 LUSER_wrt_TouchTimestamp 380 fi 381 fi 385 382 # 386 383 # Select a script execution method … … 392 389 fi 393 390 ;; 394 *chowning) wrt_RunAsRoot "${ this_script}" "${file}"391 *chowning) wrt_RunAsRoot "${file}" 395 392 ;; 396 393 *) LUSER_wrt_RunAsUser "${file}" … … 399 396 # 400 397 # Housekeeping...remove any build directory(ies) except if the package build fails. 401 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}" 398 if [ "$pkg_tarball" != "" ] ; then 399 LUSER_RemoveBuildDirs "${name}" 400 if [ "${INSTALL_LOG}" = "y" ] ; then 401 LUSER_wrt_LogNewFiles "$name" 402 fi 403 fi 402 404 # 403 405 # Include a touch of the target name so make can check if it's already been made. … … 430 432 bootscripts_Makefiles # $bootscripttools 431 433 bootable_Makefiles # $bootable 434 # Add the CUSTOM_TOOLS targets, if needed 435 [[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target 436 # Add the BLFS_TOOL targets, if needed. 437 [[ "$BLFS_TOOL" = "y" ]] && wrt_blfs_tool_targets 432 438 433 439 # Add a header, some variables and include the function file 434 440 # to the top of the real Makefile. 435 ( 436 cat << EOF 437 $HEADER 438 439 SRC = /sources 440 MOUNT_PT = $BUILDDIR 441 PKG_LST = $PKG_LST 442 LUSER = $LUSER 443 LGROUP = $LGROUP 444 SCRIPT_ROOT = $SCRIPT_ROOT 445 446 BASEDIR = \$(MOUNT_PT) 447 SRCSDIR = \$(BASEDIR)/sources 448 CMDSDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$PROGNAME-commands 449 LOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/logs 450 TESTLOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/test-logs 451 452 SU_LUSER = su - \$(LUSER) -c 453 PRT_DU = echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" 454 LUSER_HOME = /home/\$(LUSER) 455 456 export PATH := \${PATH}:/usr/sbin 457 458 include makefile-functions 459 460 EOF 461 ) > $MKFILE 441 wrt_Makefile_header 462 442 463 443 # Drop in the main target 'all:' and the chapter targets with each sub-target … … 466 446 cat << EOF 467 447 468 all: ck_UID mk_SETUP mk_LUSER mk_ROOT create-sbu_du-report 448 all: ck_UID mk_SETUP mk_LUSER create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL mk_ROOT 449 @sudo make restore-luser-env 469 450 @sudo make do-housekeeping 470 451 @\$(call echo_finished,$VERSION) … … 480 461 mk_SETUP: 481 462 @\$(call echo_SU_request) 482 @sudo make SETUP463 @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP 483 464 @touch \$@ 484 465 485 466 mk_LUSER: mk_SETUP 486 467 @\$(call echo_SULUSER_request) 487 @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make LUSER" ) 488 @sudo make restore-luser-env 468 @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) LUSER" ) 489 469 @touch \$@ 490 470 491 mk_ROOT: 492 @sudo make ROOT 471 mk_CUSTOM_TOOLS: create-sbu_du-report 472 @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\ 473 \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\ 474 (sudo \$(SU_LUSER) "mkdir -p $BUILDDIR$TRACKING_DIR"); \\ 475 (sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\ 476 fi; 493 477 @touch \$@ 494 478 495 SETUP: $host_prep 496 497 LUSER: $cross_tools $basicsystem $bootscripttools $bootable 498 499 ROOT: $chowning 500 479 mk_BLFS_TOOL: mk_CUSTOM_TOOLS 480 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\ 481 \$(call sh_echo_PHASE,Building BLFS_TOOL); \\ 482 (sudo \$(SU_LUSER) "mkdir -p $BUILDDIR$TRACKING_DIR"); \\ 483 (sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BLFS_TOOL"); \\ 484 fi; 485 @touch \$@ 486 487 mk_ROOT: create-sbu_du-report 488 @\$(call echo_SU_request) 489 @echo "$VERSION-sysroot - jhalfs build" > clfs-release && \\ 490 sudo mv clfs-release \$(MOUNT_PT)/etc 491 @sudo make BREAKPOINT=\$(BREAKPOINT) ROOT 492 @touch \$@ 493 494 SETUP: $host_prep 495 LUSER: $cross_tools $basicsystem $bootscripttools $bootable 496 CUSTOM_TOOLS: $custom_list 497 BLFS_TOOL: $blfs_tool 498 ROOT: $chowning 499 500 501 create-sbu_du-report: mk_LUSER 502 @\$(call echo_message, Building) 503 @if [ "\$(ADD_REPORT)" = "y" ]; then \\ 504 ./create-sbu_du-report.sh logs $VERSION; \\ 505 \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\ 506 fi; 507 @touch \$@ 501 508 502 509 restore-luser-env: 503 510 @\$(call echo_message, Building) 504 @if [ -f /home/\$(LUSER)/.bashrc.XXX ]; then \\505 mv -f /home/\$(LUSER)/.bashrc.XXX /home/\$(LUSER)/.bashrc; \\506 fi; 507 @if [ -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\508 mv /home/\$(LUSER)/.bash_profile.XXX /home/\$(LUSER)/.bash_profile; \\509 fi; 510 @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bash* && \\511 @if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\ 512 mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\ 513 fi; 514 @if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\ 515 mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\ 516 fi; 517 @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash* && \\ 511 518 touch \$@ && \\ 512 519 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\ … … 516 523 @-if [ ! -f luser-exist ]; then \\ 517 524 userdel \$(LUSER); \\ 518 rm -rf /home/\$(LUSER); \\525 rm -rf \$(LUSER_HOME); \\ 519 526 fi; 520 527 521 528 EOF 522 529 ) >> $MKFILE 523 524 # Add SBU-disk_usage report target525 echo "create-sbu_du-report:" >> $MKFILE526 if [[ "$REPORT" = "y" ]] ; then527 (528 cat << EOF529 @\$(call echo_message, Building)530 @./create-sbu_du-report.sh logs $VERSION531 @\$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report)532 @touch \$@533 534 535 EOF536 ) >> $MKFILE537 else echo -e "\t@true\n\n" >> $MKFILE; fi538 530 539 531 # Bring over the items from the Makefile.tmp … … 543 535 544 536 } 545 -
Property mode
changed from
Note:
See TracChangeset
for help on using the changeset viewer.