Changeset 9c9775f for CLFS2/master.sh


Ignore:
Timestamp:
09/19/2007 04:50:48 PM (17 years ago)
Author:
Manuel Canales Esparcia <manuel@…>
Branches:
experimental
Children:
3778352
Parents:
0510381
Message:

Updated experimental branch to current trunk code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CLFS2/master.sh

    • Property mode changed from 100755 to 100644
    r0510381 r9c9775f  
    1 #!/bin/sh
     1#!/bin/bash
    22# $Id$
    33
     
    1818(
    1919cat << EOF
    20 023-creatingtoolsdir:
     20
     21025-addinguser:
    2122        @\$(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 \\
    3324                groupadd \$(LGROUP); \\
    3425                useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
     
    3627                touch luser-exist; \\
    3728        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)
    4330
    4431026-settingenvironment:  025-addinguser
    4532        @\$(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 && \\
    6753        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)
    7356
    7457027-create-directories: 026-settingenvironment
     
    8871          ln -s share/{man,doc,info} \$\$dir ; \\
    8972        done
    90 
    91         @touch \$@ && \\
    92         echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
    93         echo --------------------------------------------------------------------------------\$(WHITE)
     73        @\$(call housekeeping)
    9474
    9575028-creating-sysfile: 027-create-directories
     
    11797        @touch \$(MOUNT_PT)/var/run/utmp \$(MOUNT_PT)/var/log/{btmp,lastlog,wtmp}
    11898        @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)
    124103
    125104EOF
    126105) >> $MKFILE.tmp
    127106
    128   host_prep=" 023-creatingtoolsdir 025-addinguser 026-settingenvironment 027-create-directories 028-creating-sysfile"
     107  host_prep=" 025-addinguser 026-settingenvironment 027-create-directories 028-creating-sysfile"
    129108}
    130109
     
    140119    #
    141120    # Skip this script...
    142     # NOTE.. the book indicated you only needed to install groff or file if the host
    143     #   had older versions. The packages would be installed in the target directory
    144     #   and not the host.
    145121    case $this_script in
    146122      *cflags* | *variables* )  # work done in host_prep_Makefiles
    147123              continue ;;
    148       *file ) FileVer=`file --version | head -n1 | cut -d " " -f1`
    149               [[ "$FileVer" = "file-4.17" ]] && continue
    150         ;;
    151       *groff) GroffVer=`groff --version | head -n1 | cut -d " " -f4`
    152               [[ "$GroffVer" = "1.19.2" ]] && continue
    153         ;;
    154124      *) ;;
    155125    esac
     
    249219    # If $pkg_tarball isn't empty, we've got a package...
    250220    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
    251226      LUSER_wrt_unpack "$pkg_tarball"
    252227      # If using optimizations, write the instructions
     
    256231    LUSER_wrt_RunAsUser "${file}"
    257232    #
    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
    259241    #
    260242    # Include a touch of the target name so make can check if it's already been made.
     
    314296    #
    315297    # 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
    317304    #
    318305    LUSER_wrt_RunAsUser "${file}"
    319306    #
    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
    321313    #
    322314    # Include a touch of the target name so make can check if it's already been made.
     
    360352    #  phase.
    361353    case ${this_script} in
    362       *chowning) chowning=${this_script}   ;;
     354      *chowning) chowning=" ${this_script}"   ;;
    363355              *) bootable="$bootable $this_script"  ;;
    364356    esac
     
    382374    #
    383375    # 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
    385382    #
    386383    # Select a script execution method
     
    392389                fi
    393390          ;;
    394       *chowning)  wrt_RunAsRoot "${this_script}" "${file}"
     391      *chowning)  wrt_RunAsRoot "${file}"
    395392          ;;
    396393              *)  LUSER_wrt_RunAsUser "${file}"
     
    399396    #
    400397    # 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
    402404    #
    403405    # Include a touch of the target name so make can check if it's already been made.
     
    430432  bootscripts_Makefiles            # $bootscripttools
    431433  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
    432438
    433439  # Add a header, some variables and include the function file
    434440  # 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
    462442
    463443  # Drop in the main target 'all:' and the chapter targets with each sub-target
     
    466446cat << EOF
    467447
    468 all:    ck_UID mk_SETUP mk_LUSER mk_ROOT create-sbu_du-report
     448all:    ck_UID mk_SETUP mk_LUSER create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL mk_ROOT
     449        @sudo make restore-luser-env
    469450        @sudo make do-housekeeping
    470451        @\$(call echo_finished,$VERSION)
     
    480461mk_SETUP:
    481462        @\$(call echo_SU_request)
    482         @sudo make SETUP
     463        @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
    483464        @touch \$@
    484465
    485466mk_LUSER: mk_SETUP
    486467        @\$(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" )
    489469        @touch \$@
    490470
    491 mk_ROOT:
    492         @sudo make ROOT
     471mk_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;
    493477        @touch \$@
    494478
    495 SETUP:  $host_prep
    496 
    497 LUSER:  $cross_tools $basicsystem $bootscripttools $bootable
    498 
    499 ROOT:   $chowning
    500 
     479mk_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
     487mk_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
     494SETUP:        $host_prep
     495LUSER:        $cross_tools $basicsystem $bootscripttools $bootable
     496CUSTOM_TOOLS: $custom_list
     497BLFS_TOOL:    $blfs_tool
     498ROOT:         $chowning
     499
     500
     501create-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  \$@
    501508
    502509restore-luser-env:
    503510        @\$(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* && \\
    511518        touch \$@ && \\
    512519        echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
     
    516523        @-if [ ! -f luser-exist ]; then \\
    517524                userdel \$(LUSER); \\
    518                 rm -rf /home/\$(LUSER); \\
     525                rm -rf \$(LUSER_HOME); \\
    519526        fi;
    520527
    521528EOF
    522529) >> $MKFILE
    523 
    524   # Add SBU-disk_usage report target
    525   echo "create-sbu_du-report:" >> $MKFILE
    526   if [[ "$REPORT" = "y" ]] ; then
    527 (
    528     cat << EOF
    529         @\$(call echo_message, Building)
    530         @./create-sbu_du-report.sh logs $VERSION
    531         @\$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report)
    532         @touch  \$@
    533 
    534 
    535 EOF
    536 ) >> $MKFILE
    537   else echo -e "\t@true\n\n" >> $MKFILE; fi
    538530
    539531  # Bring over the items from the Makefile.tmp
     
    543535
    544536}
    545 
Note: See TracChangeset for help on using the changeset viewer.