Changeset c103baa


Ignore:
Timestamp:
01/23/2006 08:11:45 PM (18 years ago)
Author:
Manuel Canales Esparcia <manuel@…>
Branches:
1.0, 2.3, 2.3.x, 2.4, ablfs, ablfs-more, legacy, new_features, trunk
Children:
b7da946
Parents:
aa71d75
Message:

Sending the proper jhahlfs script.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • HLFS/jhahlfs

    raa71d75 rc103baa  
    11#!/bin/sh
    2 set -e  # Enable error trapping
    3 set -u  # Trap undefined variables.. Forces the programmer
    4     # to define a variable before using it
     2set -e  # Enable error trapping
     3set -u  # Trap undefined variables.. Forces the programmer
     4                # to define a variable before using it
    55
    66#
     
    4444WC=${BOOK:+1}
    4545
    46 CLEAN=0   # Clean out build dir?
    47 DL=     # The download app to use
    48 PREV=   # name of previous script processed
     46CLEAN=0         # Clean out build dir?
     47DL=                     # The download app to use
     48PREV=           # name of previous script processed
    4949chapter5=
    5050chapter6=
     
    8080
    8181version="
    82 jhahlfs development \$Date: 2005-12-20 20:39:13 +0000 (Tue, 20 Dec 2005) $
     82jhahlfs development \$Date$
    8383
    8484Written by George Boudreau
     
    128128${DD_BORDER}
    129129-EOF-
    130   exit
     130        exit
    131131}
    132132
     
    136136
    137137no_empty_builddir() {
    138   'clear'
     138        'clear'
    139139cat <<- -EOF-
    140140${DD_BORDER}
     
    150150${DD_BORDER}
    151151-EOF-
    152   exit
     152        exit
    153153}
    154154
     
    173173    # If +e then disable text output
    174174    if [[ "$-" =~ "e" ]]; then
    175   echo -e "\n${RED}ERROR:${GREEN} basic error trapped!${OFF}\n" >&2
     175        echo -e "\n${RED}ERROR:${GREEN} basic error trapped!${OFF}\n" >&2
    176176    fi
    177177}
     
    180180    echo -e "\n\t${BOLD}${WHITE}Goodbye and thank you for choosing ${YELLOW}JHAHLFS\n${OFF}"
    181181}
    182 ##### Simple error TRAPS
    183 # ctrl-c   SIGINT
    184 # ctrl-y
    185 # ctrl-z   SIGTSTP
    186 # SIGHUP   1 HANGUP
    187 # SIGINT   2 INTRERRUPT FROM KEYBOARD Ctrl-C
    188 # SIGQUIT  3
    189 # SIGKILL  9 KILL
    190 # SIGTERM 15 TERMINATION
    191 # SIGSTOP 17,18,23 STOP THE PROCESS
     182#####   Simple error TRAPS
     183#       ctrl-c   SIGINT
     184#       ctrl-y
     185#       ctrl-z   SIGTSTP
     186#       SIGHUP   1 HANGUP
     187#       SIGINT   2 INTRERRUPT FROM KEYBOARD Ctrl-C
     188#       SIGQUIT  3
     189#       SIGKILL  9 KILL
     190#       SIGTERM 15 TERMINATION
     191#       SIGSTOP 17,18,23 STOP THE PROCESS
    192192#####
    193193set -e
     
    205205check_requirements() {       # Simple routine to validate gcc and kernel versions against requirements
    206206#----------------------------#
    207   # Minimum values acceptable
    208   #   bash  3.0>
    209   #    gcc  3.0>
    210   # kernel  2.6.2>
    211 
    212   [[ $1 = "1" ]] && echo "${nl_}BASH: ${L_arrow}${GREEN}${BASH_VERSION}${R_arrow}"
    213   case $BASH_VERSION in
    214     [3-9].*) ;;
    215     *) 'clear'
    216       echo -e "
     207        # Minimum values acceptable
     208        #   bash        3.0>
     209        #    gcc        3.0>
     210        # kernel        2.6.2>
     211
     212        [[ $1 = "1" ]] && echo "${nl_}BASH: ${L_arrow}${GREEN}${BASH_VERSION}${R_arrow}"
     213        case $BASH_VERSION in
     214                [3-9].*) ;;
     215                *) 'clear'
     216                        echo -e "
    217217$DD_BORDER
    218218\t\t${OFF}${RED}BASH version ${BOLD}${YELLOW}-->${WHITE} $BASH_VERSION ${YELLOW}<--${OFF}${RED} is too old.
    219219\t\t    This script requires 3.0${OFF}${RED} or greater
    220220$DD_BORDER"
    221       exit 1
    222       ;;
    223   esac
    224 
    225   [[ $1 = "1" ]] && echo "GCC: ${L_arrow}${GREEN}`gcc -dumpversion`${R_arrow}"
     221                        exit 1
     222                        ;;
     223        esac
     224
     225        [[ $1 = "1" ]] && echo "GCC: ${L_arrow}${GREEN}`gcc -dumpversion`${R_arrow}"
    226226    case `gcc -dumpversion` in
    227     [3-9].[0-9].* ) ;;
    228     *)  'clear'
    229       echo -e "
     227                [3-9].[0-9].* ) ;;
     228                *)  'clear'
     229                        echo -e "
    230230$DD_BORDER
    231231\t\t${OFF}${RED}GCC version ${BOLD}${YELLOW}-->${WHITE} $(gcc -dumpversion) ${YELLOW}<--${OFF}${RED} is too old.
    232232\t\t This script requires ${BOLD}${WHITE}3.0${OFF}${RED} or greater
    233233$DD_BORDER"
    234       exit 1
    235     ;;
     234                        exit 1
     235                ;;
    236236    esac
    237237
    238   #
    239   # >>>> Check kernel version against the minimum acceptable level <<<<
    240   #
    241   [[ $1 = "1" ]] && echo "LINUX: ${L_arrow}${GREEN}`uname -r`${R_arrow}"
    242 
    243   local IFS
    244   declare -i major minor revision change
    245   min_kernel_vers=2.6.2
    246 
    247   IFS=".-"   # Split up w.x.y.z as well as w.x.y-rc  (catch release candidates)
    248   set -- $min_kernel_vers # set postional parameters to minimum ver values
    249   major=$1; minor=$2; revision=$3
    250   #
    251   set -- `uname -r` # Set postional parameters to user kernel version
    252   #Compare against minimum acceptable kernel version..
    253   (( $1  > major )) && return
    254   (( $1 == major )) && (((  $2 >  minor )) ||
    255             ((( $2 == minor )) && (( $3 >= revision )))) && return
    256 
    257   # oops.. write error msg and die
    258   echo -e "
     238        #
     239        # >>>> Check kernel version against the minimum acceptable level <<<<
     240        #
     241        [[ $1 = "1" ]] && echo "LINUX: ${L_arrow}${GREEN}`uname -r`${R_arrow}"
     242
     243        local IFS
     244        declare -i major minor revision change
     245        min_kernel_vers=2.6.2
     246
     247        IFS=".-"   # Split up w.x.y.z as well as w.x.y-rc  (catch release candidates)
     248        set -- $min_kernel_vers # set postional parameters to minimum ver values
     249        major=$1; minor=$2; revision=$3
     250        #
     251        set -- `uname -r` # Set postional parameters to user kernel version
     252        #Compare against minimum acceptable kernel version..
     253        (( $1  > major )) && return
     254        (( $1 == major )) && (((  $2 >  minor )) ||
     255                                                ((( $2 == minor )) && (( $3 >= revision )))) && return
     256
     257        # oops.. write error msg and die
     258        echo -e "
    259259$DD_BORDER
    260260\t\t${OFF}${RED}The kernel version ${BOLD}${YELLOW}-->${WHITE} $(uname -r) ${YELLOW}<--${OFF}${RED} is too old.
    261261\t\tThis script requires version ${BOLD}${WHITE}$min_kernel_vers${OFF}${RED} or greater
    262262$DD_BORDER"
    263   exit 1
     263        exit 1
    264264}
    265265
     
    268268validate_config()    {       # Are the config values sane (within reason)
    269269#----------------------------#
    270   local -r PARAM_LIST="BUILDDIR HPKG MODEL TEST TOOLCHAINTEST STRIP VIMLANG PAGE GRSECURITY_HOST RUNMAKE"
    271   local -r ERROR_MSG='${OFF}${RED}The variable \"${GREEN}${config_param}${RED}\" value ${BOLD}${YELLOW}--\>${WHITE}${!config_param}${YELLOW}\<--${OFF}${RED} is invalid, check the config file ${GREEN}\<jhahlfs.conf\>${OFF}'
    272   local -r PARAM_VALS='${WHITE}${config_param}: ${L_arrow}${GREEN}${!config_param}${R_arrow}'
    273   local config_param
    274   local validation_str
    275 
    276   write_error_and_die() {
    277     echo -e "\n${DD_BORDER}"
    278        echo "`eval echo ${ERROR_MSG}`" >&2
    279     echo -e "${DD_BORDER}\n"
    280     exit 1
    281   }
    282   set +e
    283   for config_param in $PARAM_LIST; do
    284     [[ $1 = "1" ]] && echo -e "`eval echo $PARAM_VALS`"
    285     case $config_param in
    286       BUILDDIR) # We cannot have an <empty> or </> root mount point
    287             if [[ "xx x/x" =~ "x${!config_param}x" ]]; then
    288               write_error_and_die
    289             fi
    290             continue  ;;
    291       HPKG)     validation_str="x0x x1x"  ;;
    292       RUNMAKE)    validation_str="x0x x1x"  ;;
    293       TEST)     validation_str="x0x x1x"  ;;
    294       STRIP)      validation_str="x0x x1x"  ;;
    295       VIMLANG)    validation_str="x0x x1x"  ;;
    296       TOOLCHAINTEST)  validation_str="x0x x1x"  ;;
    297       GRSECURITY_HOST)  validation_str="x0x x1x"  ;;
    298 
    299       MODEL)    validation_str="xglibcx xuclibcx" ;;
    300       PAGE)   validation_str="xletterx xA4x"  ;;
    301       *)
    302         echo "WHAT PARAMETER IS THIS.. <<${config_param}>>"
    303         exit
    304       ;;
    305     esac
    306     # This is the 'regexp' test available in bash-3.0..
    307     # using it as a poor man's test for substring
    308     if [[ ! "${validation_str}" =~ "x${!config_param}x" ]] ; then
    309       # parameter value entered is no good
    310       write_error_and_die
    311     fi
    312   done # for loop
    313 
    314   for config_param in LC_ALL LANG; do
    315     [[ $1 = "1" ]] && echo "`eval echo $PARAM_VALS`"
    316     [[ -z "${!config_param}" ]] && continue
    317     # See it the locale values exist on this machine
    318     [[ "`locale -a | grep -c ${!config_param}`" > 0 ]] && continue
    319 
    320     # If you make it this far then there is a problem
    321     write_error_and_die
    322   done
    323 
    324   for config_param in FSTAB CONFIG KEYMAP BOOK; do
    325     [[ $1 = "1" ]] && echo "`eval echo $PARAM_VALS`"
    326     # If this is not a working copy, ie the default book, then skip
    327     [[ -z $WC ]] && continue
    328     [[ -z "${!config_param}" ]] && continue
    329     [[ -e "${!config_param}" ]] && [[ -s "${!config_param}" ]] && continue
    330 
    331     # If you make it this far then there is a problem
    332     write_error_and_die
    333   done
    334 
    335   set -e
    336   echo "$tab_${BOLD}${YELLOW} Config parameters look good${OFF}${nl_}"
     270        local -r PARAM_LIST="BUILDDIR HPKG MODEL TEST TOOLCHAINTEST STRIP VIMLANG PAGE GRSECURITY_HOST RUNMAKE"
     271        local -r ERROR_MSG='${OFF}${RED}The variable \"${GREEN}${config_param}${RED}\" value ${BOLD}${YELLOW}--\>${WHITE}${!config_param}${YELLOW}\<--${OFF}${RED} is invalid, check the config file ${GREEN}\<jhahlfs.conf\>${OFF}'
     272        local -r PARAM_VALS='${WHITE}${config_param}: ${L_arrow}${GREEN}${!config_param}${R_arrow}'
     273        local config_param
     274        local validation_str
     275
     276        write_error_and_die() {
     277                echo -e "\n${DD_BORDER}"
     278                   echo "`eval echo ${ERROR_MSG}`" >&2
     279                echo -e "${DD_BORDER}\n"
     280                exit 1
     281        }
     282        set +e
     283        for config_param in $PARAM_LIST; do
     284                [[ $1 = "1" ]] && echo -e "`eval echo $PARAM_VALS`"
     285                case $config_param in
     286                        BUILDDIR)       # We cannot have an <empty> or </> root mount point
     287                                                if [[ "xx x/x" =~ "x${!config_param}x" ]]; then
     288                                                        write_error_and_die
     289                                                fi
     290                                                continue        ;;
     291                        HPKG)                   validation_str="x0x x1x"        ;;
     292                        RUNMAKE)                validation_str="x0x x1x"        ;;
     293                        TEST)                   validation_str="x0x x1x"        ;;
     294                        STRIP)                  validation_str="x0x x1x"        ;;
     295                        VIMLANG)                validation_str="x0x x1x"        ;;
     296                        TOOLCHAINTEST)  validation_str="x0x x1x"        ;;
     297                        GRSECURITY_HOST)        validation_str="x0x x1x"        ;;
     298
     299                        MODEL)          validation_str="xglibcx xuclibcx"       ;;
     300                        PAGE)           validation_str="xletterx xA4x"  ;;
     301                        *)
     302                                echo "WHAT PARAMETER IS THIS.. <<${config_param}>>"
     303                                exit
     304                        ;;
     305                esac
     306                # This is the 'regexp' test available in bash-3.0..
     307                # using it as a poor man's test for substring
     308                if [[ ! "${validation_str}" =~ "x${!config_param}x" ]] ; then
     309                        # parameter value entered is no good
     310                        write_error_and_die
     311                fi
     312        done # for loop
     313
     314        for config_param in LC_ALL LANG; do
     315                [[ $1 = "1" ]] && echo "`eval echo $PARAM_VALS`"
     316                [[ -z "${!config_param}" ]] && continue
     317                # See it the locale values exist on this machine
     318                [[ "`locale -a | grep -c ${!config_param}`" > 0 ]] && continue
     319
     320                # If you make it this far then there is a problem
     321                write_error_and_die
     322        done
     323
     324        for config_param in FSTAB CONFIG KEYMAP BOOK; do
     325                [[ $1 = "1" ]] && echo "`eval echo $PARAM_VALS`"
     326                # If this is not a working copy, ie the default book, then skip
     327                [[ -z $WC ]] && continue
     328                [[ -z "${!config_param}" ]] && continue
     329                [[ -e "${!config_param}" ]] && [[ -s "${!config_param}" ]] && continue
     330
     331                # If you make it this far then there is a problem
     332                write_error_and_die
     333        done
     334
     335        set -e
     336        echo "$tab_${BOLD}${YELLOW} Config parameters look good${OFF}${nl_}"
    337337}
    338338
     
    344344
    345345    LOC_add_patches_entry() {
    346   for f in `grep "/$1-" patcheslist_.wget`; do
    347       basename $f | sed "s|${2}|\&${1}-version;|" >> patches
    348   done
     346        for f in `grep "/$1-" patcheslist_.wget`; do
     347            basename $f | sed "s|${2}|\&${1}-version;|" >> patches
     348        done
    349349    }
    350350
    351351    xsltproc --nonet \
    352       --xinclude \
    353       -o patcheslist_.wget \
    354       hlfs-patcheslist_.xsl \
    355       $BOOK/index.xml > /dev/null 2>&1
     352                        --xinclude \
     353                        -o patcheslist_.wget \
     354                        hlfs-patcheslist_.xsl \
     355                        $BOOK/index.xml > /dev/null 2>&1
    356356
    357357    rm -f patches
     
    359359    IFS=$'\x0A'  # Modify the 'internal field separator' to break on 'LF' only
    360360    for f in `cat packages`; do
    361   IFS=$saveIFS
    362   LOC_add_patches_entry \
    363     `echo $f | sed -e 's/-version//' \
    364              -e 's/-file.*//' \
    365              -e 's/"//g' \
    366              -e 's/uclibc/uClibc/'`
     361        IFS=$saveIFS
     362        LOC_add_patches_entry \
     363                `echo $f | sed -e 's/-version//' \
     364                                           -e 's/-file.*//' \
     365                                           -e 's/"//g' \
     366                                           -e 's/uclibc/uClibc/'`
    367367    done
    368368
    369   # .... U G L Y .... what to do with the grsecurity patch to the kernel..
    370   for f in `grep "/grsecurity-" patcheslist_.wget`; do
    371       basename $f >> patches
    372   done
     369        # .... U G L Y .... what to do with the grsecurity patch to the kernel..
     370        for f in `grep "/grsecurity-" patcheslist_.wget`; do
     371            basename $f >> patches
     372        done
    373373
    374374    IFS=$saveIFS
     
    415415
    416416    echo -n "Downloading the HLFS Book, version $HLFSVRS... "
    417   # Grab a fresh HLFS book if it's missing, otherwise, update it from the
    418   # repo. If we've already extracted the commands, move on to getting the
    419   # sources.
    420   if [ -d hlfs-$HLFSVRS ] ; then
    421       cd hlfs-$HLFSVRS
    422       if LC_ALL=C svn up | grep -q At && \
    423     test -d $JHAHLFSDIR/commands && \
    424     test -f $JHAHLFSDIR/packages && \
    425     test -f $JHAHLFSDIR/patches ; then
    426     echo -ne "done\n"
    427         # Set the canonical book version
    428     cd $JHAHLFSDIR
    429     VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
    430     get_sources
    431       else
    432         echo -ne "done\n"
    433         extract_commands
    434       fi
     417        # Grab a fresh HLFS book if it's missing, otherwise, update it from the
     418        # repo. If we've already extracted the commands, move on to getting the
     419        # sources.
     420        if [ -d hlfs-$HLFSVRS ] ; then
     421            cd hlfs-$HLFSVRS
     422            if LC_ALL=C svn up | grep -q At && \
     423                test -d $JHAHLFSDIR/commands && \
     424                test -f $JHAHLFSDIR/packages && \
     425                test -f $JHAHLFSDIR/patches ; then
     426                echo -ne "done\n"
     427                # Set the canonical book version
     428                cd $JHAHLFSDIR
     429                VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
     430                get_sources
     431            else
     432                echo -ne "done\n"
     433                extract_commands
     434            fi
     435        else
     436            case $HLFSVRS in
     437                development)
     438                   svn co $SVN/HLFS/trunk/BOOK hlfs-$HLFSVRS >>$LOGDIR/$LOG 2>&1
     439                    ;;
     440                *) echo -e "${RED}Invalid document version selected${OFF}"
     441                    ;;
     442            esac
     443            echo -ne "done\n"
     444            extract_commands
     445        fi
    435446  else
    436       case $HLFSVRS in
    437     development)
    438              svn co $SVN/HLFS/trunk/BOOK hlfs-$HLFSVRS >>$LOGDIR/$LOG 2>&1
    439         ;;
    440     *) echo -e "${RED}Invalid document version selected${OFF}"
    441         ;;
    442       esac
    443       echo -ne "done\n"
    444       extract_commands
    445   fi
    446   else
    447   echo -ne "Using $BOOK as book's sources ...\n"
     447        echo -ne "Using $BOOK as book's sources ...\n"
    448448        extract_commands
    449449  fi
     
    453453extract_commands() {         #
    454454#----------------------------#
    455   # Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
    456   test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
    457   exit 1"
    458 
    459   cd $JHAHLFSDIR
    460   VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
    461 
    462   # Start clean
    463   if [ -d commands ]; then
    464     rm -rf commands
    465     mkdir -v commands
    466   fi
    467   echo -n "Extracting commands..."
    468 
    469   # Dump the commands in shell script form from the HLFS book.
    470   xsltproc  --nonet \
    471         --xinclude \
    472         --stringparam model $MODEL \
    473         --stringparam testsuite $TEST \
    474         --stringparam toolchaintest $TOOLCHAINTEST \
    475         --stringparam vim-lang $VIMLANG \
    476         -o ./commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
    477 
    478   # Make the scripts executable.
    479   chmod -R +x $JHAHLFSDIR/commands
    480 
    481   # Grab the patches and package names.
    482   cd $JHAHLFSDIR
    483   for i in patches packages ; do rm -f $i ; done
    484   grep "\-version" $BOOK/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@' \
    485   -e '/generic/d' >> packages
    486 
    487   # Download the vim-lang package if it must be installed
    488   if [ "$VIMLANG" = "1" ] ; then
    489     echo `grep "vim" packages | sed 's@vim@&-lang@'` >> packages
    490   fi
    491   echo `grep "udev-config-file" $BOOK/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@'` >> packages
    492 
    493   # There is no HLFS patches.ent file so we will create one.
    494   build_patches_file
     455        # Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
     456        test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
     457        exit 1"
     458
     459        cd $JHAHLFSDIR
     460        VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
     461
     462        # Start clean
     463        if [ -d commands ]; then
     464                rm -rf commands
     465                mkdir -v commands
     466        fi
     467        echo -n "Extracting commands..."
     468
     469        # Dump the commands in shell script form from the HLFS book.
     470        xsltproc  --nonet \
     471                          --xinclude \
     472                          --stringparam model $MODEL \
     473                          --stringparam testsuite $TEST \
     474                          --stringparam toolchaintest $TOOLCHAINTEST \
     475                          --stringparam vim-lang $VIMLANG \
     476                          -o ./commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
     477
     478        # Make the scripts executable.
     479        chmod -R +x $JHAHLFSDIR/commands
     480
     481        # Grab the patches and package names.
     482        cd $JHAHLFSDIR
     483        for i in patches packages ; do rm -f $i ; done
     484        grep "\-version" $BOOK/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@' \
     485        -e '/generic/d' >> packages
     486
     487        # Download the vim-lang package if it must be installed
     488        if [ "$VIMLANG" = "1" ] ; then
     489                echo `grep "vim" packages | sed 's@vim@&-lang@'` >> packages
     490        fi
     491        echo `grep "udev-config-file" $BOOK/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@'` >> packages
     492
     493        # There is no HLFS patches.ent file so we will create one.
     494        build_patches_file
    495495#  grep "ENTITY" $BOOK/patches.ent | sed -e 's/.* "//' -e 's/">//' >> patches
    496496
    497   # Done. Moving on...
    498   echo -ne "done\n"
    499   get_sources
     497        # Done. Moving on...
     498        echo -ne "done\n"
     499        get_sources
    500500}
    501501
     
    505505  cd $BUILDDIR/sources
    506506
    507   # Hackish fix for the bash-doc, glibc-{linuxthreads,libidn} and
    508   # module-init-tools-testsuite packages that don't conform to
    509   # norms in the URL scheme.
    510   DIR=`echo $1 | sed 's@-doc@@;s@-linuxthreads@@;s@-libidn@@;s@-testsuite@@'`
    511 
    512   # Find the md5 sum for this package.
    513   if [ $2 != MD5SUMS ] ; then
    514     set +e
    515     MD5=`grep "  $2" MD5SUMS`
    516     if [ $? -ne 0 ]; then
    517       set -e
    518       echo "${RED}$2 not found in MD5SUMS${OFF}"
    519       echo "$2 not found in MD5SUMS" >> MISSING_FILES.DMP
    520       return
    521       fi
    522       set -e
    523   fi
    524 
    525   if [ ! -f $2 ] ; then
    526     case $DL in
    527       wget )  wget $HTTP/$DIR/$2            ;;
    528       curl )  `curl -# $HTTP/$DIR/$2 -o $2`     ;;
    529       * )     echo "$DL not supported at this time."  ;;
    530     esac
    531   elif ! echo "$MD5" | md5sum -c - >/dev/null 2>/dev/null ; then
    532     case $DL in
    533       wget )  wget -c $HTTP/$DIR/$2         ;;
    534       curl )  `curl -# -C - $HTTP/$DIR/$2 -o $2`    ;;
    535       * )   echo "$DL not supported at this time."  ;;
    536     esac
    537   fi
    538 
    539   if [ $2 != MD5SUMS ] && ! echo "$MD5" | md5sum -c - ; then
    540     exit 1
    541   fi
    542   if [ $2 != MD5SUMS ] ; then
    543     echo `grep "$MD5" MD5SUMS` >> MD5SUMS-$VERSION
    544   fi
     507        # Hackish fix for the bash-doc, glibc-{linuxthreads,libidn} and
     508        # module-init-tools-testsuite packages that don't conform to
     509        # norms in the URL scheme.
     510        DIR=`echo $1 | sed 's@-doc@@;s@-linuxthreads@@;s@-libidn@@;s@-testsuite@@'`
     511
     512        # Find the md5 sum for this package.
     513        if [ $2 != MD5SUMS ] ; then
     514                set +e
     515                MD5=`grep "  $2" MD5SUMS`
     516                if [ $? -ne 0 ]; then
     517                        set -e
     518                        echo "${RED}$2 not found in MD5SUMS${OFF}"
     519                        echo "$2 not found in MD5SUMS" >> MISSING_FILES.DMP
     520                        return
     521            fi
     522        set -e
     523        fi
     524
     525        if [ ! -f $2 ] ; then
     526                case $DL in
     527                        wget )  wget $HTTP/$DIR/$2                                              ;;
     528                        curl )  `curl -# $HTTP/$DIR/$2 -o $2`                   ;;
     529                        * )     echo "$DL not supported at this time."  ;;
     530                esac
     531        elif ! echo "$MD5" | md5sum -c - >/dev/null 2>/dev/null ; then
     532                case $DL in
     533                        wget )  wget -c $HTTP/$DIR/$2                                   ;;
     534                        curl )  `curl -# -C - $HTTP/$DIR/$2 -o $2`              ;;
     535                        * )             echo "$DL not supported at this time."  ;;
     536                esac
     537        fi
     538
     539        if [ $2 != MD5SUMS ] && ! echo "$MD5" | md5sum -c - ; then
     540                exit 1
     541        fi
     542        if [ $2 != MD5SUMS ] ; then
     543                echo `grep "$MD5" MD5SUMS` >> MD5SUMS-$VERSION
     544        fi
    545545}
    546546
     
    551551    local IFS
    552552
    553   # Test if the packages must be downloaded
    554   if [ ! "$HPKG" = "1" ] ; then
    555       return
    556   fi
     553        # Test if the packages must be downloaded
     554        if [ ! "$HPKG" = "1" ] ; then
     555                return
     556        fi
    557557
    558558    # Modify the 'internal field separator' to break on 'LF' only
    559   IFS=$'\x0A'
    560 
    561   if [ ! -d $BUILDDIR/sources ] ; then mkdir $BUILDDIR/sources ; fi
    562   cd $BUILDDIR/sources
    563 
    564   > MISSING_FILES.DMP  # Files not in md5sum end up here
    565 
    566   if [ -f MD5SUMS ] ; then rm MD5SUMS ; fi
    567   if [ -f MD5SUMS-$VERSION ] ; then rm MD5SUMS-$VERSION ; fi
    568 
    569   # Retrieve the master md5sum file
    570   download "" MD5SUMS
    571 
    572   # Iterate through each package and grab it, along with any patches it needs.
    573   for i in `cat $JHAHLFSDIR/packages` ; do
     559        IFS=$'\x0A'
     560
     561        if [ ! -d $BUILDDIR/sources ] ; then mkdir $BUILDDIR/sources ; fi
     562        cd $BUILDDIR/sources
     563
     564        > MISSING_FILES.DMP  # Files not in md5sum end up here
     565
     566        if [ -f MD5SUMS ] ; then rm MD5SUMS ; fi
     567        if [ -f MD5SUMS-$VERSION ] ; then rm MD5SUMS-$VERSION ; fi
     568
     569        # Retrieve the master md5sum file
     570        download "" MD5SUMS
     571
     572        # Iterate through each package and grab it, along with any patches it needs.
     573        for i in `cat $JHAHLFSDIR/packages` ; do
    574574      PKG=`echo $i | sed -e 's/-version.*//' \
    575             -e 's/-file.*//' \
    576             -e 's/uclibc/uClibc/' `
    577 
    578     # Needed for Groff patchlevel patch on UTF-8 branch
    579     GROFFLEVEL=`grep "groff-patchlevel" $JHAHLFSDIR/packages | sed -e 's/groff-patchlevel //' -e 's/"//g'`
    580 
    581     #
    582     # How to deal with orphan packages..??
    583     #
    584     VRS=`echo $i | sed -e 's/.* //' -e 's/"//g'`
    585     case "$PKG" in
    586     "expect-lib" )      continue ;; # not valid packages
    587     "linux-dl" )      continue ;;
    588     "groff-patchlevel" )  continue ;;
    589     "uClibc-patch" )    continue ;;
    590 
    591     "tcl" )     FILE="$PKG$VRS-src.tar.bz2"       ; download $PKG $FILE ;;
    592     "vim-lang" )  FILE="vim-$VRS-lang.tar.bz2"; PKG="vim" ; download $PKG $FILE ;;
    593     "udev-config" ) FILE="$VRS" ; PKG="udev"        ; download $PKG $FILE ;;
    594 
    595     "uClibc-locale" ) FILE="$PKG-$VRS.tar.bz2" ; PKG="uClibc"
    596               download $PKG $FILE
    597               # There can be no patches for this file
    598               continue ;;
    599 
    600     "gcc" )   download $PKG "gcc-core-$VRS.tar.bz2"
    601           download $PKG "gcc-g++-$VRS.tar.bz2"
    602       ;;
    603     "glibc")  download $PKG "$PKG-$VRS.tar.bz2"
    604           download $PKG "$PKG-libidn-$VRS.tar.bz2"
    605       ;;
    606     * )     FILE="$PKG-$VRS.tar.bz2"
    607           download $PKG $FILE
    608       ;;
     575                                                -e 's/-file.*//' \
     576                                                -e 's/uclibc/uClibc/' `
     577
     578          # Needed for Groff patchlevel patch on UTF-8 branch
     579          GROFFLEVEL=`grep "groff-patchlevel" $JHAHLFSDIR/packages | sed -e 's/groff-patchlevel //' -e 's/"//g'`
     580
     581          #
     582          # How to deal with orphan packages..??
     583          #
     584          VRS=`echo $i | sed -e 's/.* //' -e 's/"//g'`
     585          case "$PKG" in
     586                "expect-lib" )                  continue ;; # not valid packages
     587                "linux-dl" )                    continue ;;
     588                "groff-patchlevel" )    continue ;;
     589                "uClibc-patch" )                continue ;;
     590
     591                "tcl" )                 FILE="$PKG$VRS-src.tar.bz2"                     ; download $PKG $FILE   ;;
     592                "vim-lang" )    FILE="vim-$VRS-lang.tar.bz2"; PKG="vim" ; download $PKG $FILE   ;;
     593                "udev-config" ) FILE="$VRS" ; PKG="udev"                                ; download $PKG $FILE   ;;
     594
     595                "uClibc-locale" ) FILE="$PKG-$VRS.tar.bz2" ; PKG="uClibc"
     596                                                  download $PKG $FILE
     597                                                  # There can be no patches for this file
     598                                                  continue ;;
     599
     600                "gcc" )         download $PKG "gcc-core-$VRS.tar.bz2"
     601                                        download $PKG "gcc-g++-$VRS.tar.bz2"
     602                        ;;
     603                "glibc")        download $PKG "$PKG-$VRS.tar.bz2"
     604                                        download $PKG "$PKG-libidn-$VRS.tar.bz2"
     605                        ;;
     606                * )                     FILE="$PKG-$VRS.tar.bz2"
     607                                        download $PKG $FILE
     608                        ;;
    609609      esac
    610610
     
    616616    done
    617617
    618   # .... U G L Y .... what to do with the grsecurity patch to the kernel..
    619   download grsecurity `grep grsecurity $JHAHLFSDIR/patches`
    620 
    621   # .... U G L Y .... deal with uClibc-locale-xxxxx.tar.bz2 format issue.
    622   bzcat uClibc-locale-030818.tar.bz2 | gzip > uClibc-locale-030818.tgz
    623 
    624   if [[ -s $BUILDDIR/sources/MISSING_FILES.DMP ]]; then
    625     echo  -e "\n\n${tab_}${RED} One or more files were not retrieved.\n${tab_} Check <MISSING_FILES.DMP> for names ${OFF}\n\n"
    626   fi
     618        # .... U G L Y .... what to do with the grsecurity patch to the kernel..
     619        download grsecurity `grep grsecurity $JHAHLFSDIR/patches`
     620
     621        # .... U G L Y .... deal with uClibc-locale-xxxxx.tar.bz2 format issue.
     622        bzcat uClibc-locale-030818.tar.bz2 | gzip > uClibc-locale-030818.tgz
     623
     624        if [[ -s $BUILDDIR/sources/MISSING_FILES.DMP ]]; then
     625                echo  -e "\n\n${tab_}${RED} One or more files were not retrieved.\n${tab_} Check <MISSING_FILES.DMP> for names ${OFF}\n\n"
     626        fi
    627627}
    628628
     
    644644    local TARGET LOADER
    645645
    646     echo  "${YELLOW}  Processing Chapter-4 scripts ${OFF}"
    647 
    648   # Define a few model dependant variables
    649   if [[ ${MODEL} = "uclibc" ]]; then
    650     TARGET="tools-linux-uclibc"; LOADER="ld-uClibc.so.0"
    651   else
    652     TARGET="tools-linux-gnu";    LOADER="ld-linux.so.2"
     646    echo  "${YELLOW}    Processing Chapter-4 scripts ${OFF}"
     647
     648        # Define a few model dependant variables
     649        if [[ ${MODEL} = "uclibc" ]]; then
     650          TARGET="tools-linux-uclibc"; LOADER="ld-uClibc.so.0"
     651        else
     652          TARGET="tools-linux-gnu";    LOADER="ld-linux.so.2"
    653653    fi
    654654
    655   # 022-
    656   # If /home/hlfs is already present in the host, we asume that the
    657   # hlfs user and group are also presents in the host, and a backup
    658   # of their bash init files is made.
     655        # 022-
     656        # If /home/hlfs is already present in the host, we asume that the
     657        # hlfs user and group are also presents in the host, and a backup
     658        # of their bash init files is made.
    659659(
    660660cat << EOF
    661661020-creatingtoolsdir:
    662   @\$(call echo_message, Building)
    663   @mkdir -v \$(HLFS)/tools && \\
    664   rm -fv /tools && \\
    665   ln -sv \$(HLFS)/tools /
    666   @if [ ! -d \$(HLFS)/sources ]; then \\
    667     mkdir \$(HLFS)/sources; \\
    668   fi;
    669   @chmod a+wt \$(HLFS)/sources && \\
    670   touch \$@
     662        @\$(call echo_message, Building)
     663        @mkdir -v \$(HLFS)/tools && \\
     664        rm -fv /tools && \\
     665        ln -sv \$(HLFS)/tools /
     666        @if [ ! -d \$(HLFS)/sources ]; then \\
     667                mkdir \$(HLFS)/sources; \\
     668        fi;
     669        @chmod a+wt \$(HLFS)/sources && \\
     670        touch \$@
    671671
    672672021-addinguser:  020-creatingtoolsdir
    673   @\$(call echo_message, Building)
    674   @if [ ! -d /home/hlfs ]; then \\
    675     groupadd hlfs; \\
    676     useradd -s /bin/bash -g hlfs -m -k /dev/null hlfs; \\
    677   else \\
    678     touch user-hlfs-exist; \\
    679   fi;
    680   @chown hlfs \$(HLFS)/tools && \\
    681   chown hlfs \$(HLFS)/sources && \\
    682   touch \$@
     673        @\$(call echo_message, Building)
     674        @if [ ! -d /home/hlfs ]; then \\
     675                groupadd hlfs; \\
     676                useradd -s /bin/bash -g hlfs -m -k /dev/null hlfs; \\
     677        else \\
     678                touch user-hlfs-exist; \\
     679        fi;
     680        @chown hlfs \$(HLFS)/tools && \\
     681        chown hlfs \$(HLFS)/sources && \\
     682        touch \$@
    683683
    684684022-settingenvironment:  021-addinguser
    685   @\$(call echo_message, Building)
    686   @if [ -f /home/hlfs/.bashrc -a ! -f /home/hlfs/.bashrc.XXX ]; then \\
    687     mv -v /home/hlfs/.bashrc /home/hlfs/.bashrc.XXX; \\
    688   fi;
    689   @if [ -f /home/hlfs/.bash_profile  -a ! -f /home/hlfs/.bash_profile.XXX ]; then \\
    690     mv -v /home/hlfs/.bash_profile /home/hlfs/.bash_profile.XXX; \\
    691   fi;
    692   @echo "set +h" > /home/hlfs/.bashrc && \\
    693   echo "umask 022" >> /home/hlfs/.bashrc && \\
    694   echo "HLFS=/mnt/hlfs" >> /home/hlfs/.bashrc && \\
    695   echo "LC_ALL=POSIX" >> /home/hlfs/.bashrc && \\
    696   echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/hlfs/.bashrc && \\
    697   echo "export HLFS LC_ALL PATH" >> /home/hlfs/.bashrc && \\
    698   echo "" >> /home/hlfs/.bashrc && \\
    699   echo "target=$(uname -m)-${TARGET}" >> /home/hlfs/.bashrc && \\
    700   echo "ldso=/tools/lib/${LOADER}" >> /home/hlfs/.bashrc && \\
    701   echo "export target ldso" >> /home/hlfs/.bashrc && \\
    702   echo "source $JHAHLFSDIR/envars" >> /home/hlfs/.bashrc && \\
    703   chown hlfs:hlfs /home/hlfs/.bashrc && \\
    704   touch envars && \\
    705   touch \$@
     685        @\$(call echo_message, Building)
     686        @if [ -f /home/hlfs/.bashrc -a ! -f /home/hlfs/.bashrc.XXX ]; then \\
     687                mv -v /home/hlfs/.bashrc /home/hlfs/.bashrc.XXX; \\
     688        fi;
     689        @if [ -f /home/hlfs/.bash_profile  -a ! -f /home/hlfs/.bash_profile.XXX ]; then \\
     690                mv -v /home/hlfs/.bash_profile /home/hlfs/.bash_profile.XXX; \\
     691        fi;
     692        @echo "set +h" > /home/hlfs/.bashrc && \\
     693        echo "umask 022" >> /home/hlfs/.bashrc && \\
     694        echo "HLFS=/mnt/hlfs" >> /home/hlfs/.bashrc && \\
     695        echo "LC_ALL=POSIX" >> /home/hlfs/.bashrc && \\
     696        echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/hlfs/.bashrc && \\
     697        echo "export HLFS LC_ALL PATH" >> /home/hlfs/.bashrc && \\
     698        echo "" >> /home/hlfs/.bashrc && \\
     699        echo "target=$(uname -m)-${TARGET}" >> /home/hlfs/.bashrc && \\
     700        echo "ldso=/tools/lib/${LOADER}" >> /home/hlfs/.bashrc && \\
     701        echo "export target ldso" >> /home/hlfs/.bashrc && \\
     702        echo "source $JHAHLFSDIR/envars" >> /home/hlfs/.bashrc && \\
     703        chown hlfs:hlfs /home/hlfs/.bashrc && \\
     704        touch envars && \\
     705        touch \$@
    706706EOF
    707707) >> $MKFILE.tmp
     
    713713#----------------------------#
    714714
    715   echo "${YELLOW} Processing Chapter-5 scripts${OFF}"
     715        echo "${YELLOW} Processing Chapter-5 scripts${OFF}"
    716716
    717717  for file in chapter05/* ; do
     
    720720
    721721    # Skip this script depending on jhahlfs.conf flags set.
    722   case $this_script in
    723         # If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed
    724     *tcl* )   [[ "$TOOLCHAINTEST" = "0" ]] && continue; ;;
    725     *expect* )  [[ "$TOOLCHAINTEST" = "0" ]] && continue; ;;
    726     *dejagnu* ) [[ "$TOOLCHAINTEST" = "0" ]] && continue; ;;
    727       # Test if the stripping phase must be skipped
    728     *stripping* ) [[ "$STRIP" = "0" ]] && continue ;;
    729       # Select the appropriate library
    730     *glibc*)    [[ ${MODEL} = "uclibc" ]] && continue ;;
    731     *uclibc*)   [[ ${MODEL} = "glibc" ]]  && continue ;;
    732     *) ;;
    733   esac
    734 
    735   # First append each name of the script files to a list (this will become
    736   # the names of the targets in the Makefile
    737   chapter5="$chapter5 $this_script"
    738 
    739   # Grab the name of the target (minus the -headers or -cross in the case of gcc
    740   # and binutils in chapter 5)
    741   name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-cross@@' -e 's@-headers@@'`
    742 
    743   # >>>>>>>>>> U G L Y <<<<<<<<<
    744   # Adjust 'name' and patch a few scripts on the fly..
    745   case $name in
    746   linux-libc) name=linux-libc-headers
    747     ;;
    748   uclibc) # this sucks as method to deal with gettext/libint inside uClibc
    749     sed 's@^cd gettext-runtime@cd ../gettext-*/gettext-runtime@' -i chapter05/$this_script
    750     ;;
    751   gcc) # to compensate for the compiler test inside gcc (which fails), disable error trap
    752     sed 's@^gcc -o test test.c@set +e; gcc -o test test.c@' -i chapter05/$this_script
    753     ;;
    754   esac
    755 
    756   # Set the dependency for the first target.
    757   if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
    758 
    759 
    760   #--------------------------------------------------------------------#
    761   #         >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<<          #
    762   #--------------------------------------------------------------------#
    763   #
    764   # Drop in the name of the target on a new line, and the previous target
    765   # as a dependency. Also call the echo_message function.
    766   echo -e "\n$this_script:  $PREV
    767   @\$(call echo_message, Building)" >> $MKFILE.tmp
    768 
    769   # Find the version of the command files, if it corresponds with the building of
    770   # a specific package
    771   vrs=`grep "^$name-version" $JHAHLFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
    772   # If $vrs isn't empty, we've got a package...
    773   if [ "$vrs" != "" ] ; then
    774     # Deal with non-standard names
    775     case $name in
    776       tcl)  FILE="$name$vrs-src.tar"  ;;
    777         uclibc) FILE="uClibc-$vrs.tar"    ;;
    778       gcc)  FILE=gcc-core-$vrs.tar    ;;
    779         *)    FILE="$name-$vrs.tar"   ;;
     722        case $this_script in
     723                # If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed
     724                *tcl* )         [[ "$TOOLCHAINTEST" = "0" ]] && continue; ;;
     725                *expect* )      [[ "$TOOLCHAINTEST" = "0" ]] && continue; ;;
     726                *dejagnu* )     [[ "$TOOLCHAINTEST" = "0" ]] && continue; ;;
     727                        # Test if the stripping phase must be skipped
     728                *stripping* )   [[ "$STRIP" = "0" ]] && continue ;;
     729                        # Select the appropriate library
     730                *glibc*)                [[ ${MODEL} = "uclibc" ]] && continue ;;
     731                *uclibc*)               [[ ${MODEL} = "glibc" ]]  && continue ;;
     732                *) ;;
     733        esac
     734
     735        # First append each name of the script files to a list (this will become
     736        # the names of the targets in the Makefile
     737        chapter5="$chapter5 $this_script"
     738
     739        # Grab the name of the target (minus the -headers or -cross in the case of gcc
     740        # and binutils in chapter 5)
     741        name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-cross@@' -e 's@-headers@@'`
     742
     743        # >>>>>>>>>> U G L Y <<<<<<<<<
     744        # Adjust 'name' and patch a few scripts on the fly..
     745        case $name in
     746        linux-libc) name=linux-libc-headers
     747                ;;
     748        uclibc) # this sucks as method to deal with gettext/libint inside uClibc
     749                sed 's@^cd gettext-runtime@cd ../gettext-*/gettext-runtime@' -i chapter05/$this_script
     750                ;;
     751        gcc) # to compensate for the compiler test inside gcc (which fails), disable error trap
     752                sed 's@^gcc -o test test.c@set +e; gcc -o test test.c@' -i chapter05/$this_script
     753                ;;
     754        esac
     755
     756        # Set the dependency for the first target.
     757        if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
     758
     759
     760        #--------------------------------------------------------------------#
     761        #         >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<<          #
     762        #--------------------------------------------------------------------#
     763        #
     764        # Drop in the name of the target on a new line, and the previous target
     765        # as a dependency. Also call the echo_message function.
     766        echo -e "\n$this_script:  $PREV
     767        @\$(call echo_message, Building)" >> $MKFILE.tmp
     768
     769        # Find the version of the command files, if it corresponds with the building of
     770        # a specific package
     771        vrs=`grep "^$name-version" $JHAHLFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
     772        # If $vrs isn't empty, we've got a package...
     773        if [ "$vrs" != "" ] ; then
     774                # Deal with non-standard names
     775                case $name in
     776                        tcl)    FILE="$name$vrs-src.tar"        ;;
     777                    uclibc)     FILE="uClibc-$vrs.tar"          ;;
     778                        gcc)    FILE=gcc-core-$vrs.tar          ;;
     779                *)              FILE="$name-$vrs.tar"           ;;
     780                esac
     781                # Insert instructions for unpacking the package and to set the PKGDIR variable.
     782(
     783cat << EOF
     784        @\$(call unpack,$FILE)
     785        @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
     786        chown -R hlfs \$(HLFS)\$(SRC)/\$\$ROOT && \\
     787        echo "export PKGDIR=\$(HLFS)\$(SRC)/\$\$ROOT" > envars && \\
     788EOF
     789) >> $MKFILE.tmp
     790        fi
     791
     792    case $this_script in
     793                *binutils* )  # Dump the path to sources directory for later removal
     794                        echo -e '\techo "$(HLFS)$(SRC)/$$ROOT" >> sources-dir' >> $MKFILE.tmp
     795                        ;;
     796                *adjusting* )  # For the Adjusting phase we must to cd to the binutils-build directory.
     797                        echo -e '\t@echo "export PKGDIR=$(HLFS)$(SRC)/binutils-build" > envars' >> $MKFILE.tmp
     798                        ;;
     799                * )  # Everything else, add a true statment so we don't confuse make
     800                        echo -e '\ttrue' >> $MKFILE.tmp
     801                        ;;
    780802    esac
    781     # Insert instructions for unpacking the package and to set the PKGDIR variable.
     803
     804        # Insert date and disk usage at the top of the log file, the script run
     805        # and date and disk usage again at the bottom of the log file.
    782806(
    783807cat << EOF
    784   @\$(call unpack,$FILE)
    785   @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
    786   chown -R hlfs \$(HLFS)\$(SRC)/\$\$ROOT && \\
    787   echo "export PKGDIR=\$(HLFS)\$(SRC)/\$\$ROOT" > envars && \\
     808        @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(HLFS)\`\n" >logs/$this_script && \\
     809        su - hlfs -c "source /home/hlfs/.bashrc && $JHAHLFSDIR/commands/$file" >>logs/$this_script 2>&1 && \\
     810        echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(HLFS)\`\n" >>logs/$this_script
    788811EOF
    789812) >> $MKFILE.tmp
    790   fi
    791 
    792     case $this_script in
    793     *binutils* )  # Dump the path to sources directory for later removal
    794       echo -e '\techo "$(HLFS)$(SRC)/$$ROOT" >> sources-dir' >> $MKFILE.tmp
    795       ;;
    796     *adjusting* )  # For the Adjusting phase we must to cd to the binutils-build directory.
    797       echo -e '\t@echo "export PKGDIR=$(HLFS)$(SRC)/binutils-build" > envars' >> $MKFILE.tmp
    798       ;;
    799     * )  # Everything else, add a true statment so we don't confuse make
    800       echo -e '\ttrue' >> $MKFILE.tmp
    801       ;;
    802     esac
    803 
    804   # Insert date and disk usage at the top of the log file, the script run
    805   # and date and disk usage again at the bottom of the log file.
     813
     814        # Remove the build directory(ies) except if the package build fails
     815        # (so we can review config.cache, config.log, etc.)
     816        # For Binutils the sources must be retained for some time.
     817        if [ "$vrs" != "" ] ; then
     818                if [[ ! `_IS_ $this_script binutils` ]]; then
    806819(
    807820cat << EOF
    808   @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(HLFS)\`\n" >logs/$this_script && \\
    809   su - hlfs -c "source /home/hlfs/.bashrc && $JHAHLFSDIR/commands/$file" >>logs/$this_script 2>&1 && \\
    810   echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(HLFS)\`\n" >>logs/$this_script
     821        @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
     822        rm -r \$(HLFS)\$(SRC)/\$\$ROOT && \\
     823        if [ -e \$(HLFS)\$(SRC)/$name-build ]; then \\
     824                rm -r \$(HLFS)\$(SRC)/$name-build; \\
     825        fi;
    811826EOF
    812827) >> $MKFILE.tmp
    813 
    814   # Remove the build directory(ies) except if the package build fails
    815   # (so we can review config.cache, config.log, etc.)
    816   # For Binutils the sources must be retained for some time.
    817   if [ "$vrs" != "" ] ; then
    818     if [[ ! `_IS_ $this_script binutils` ]]; then
     828                fi
     829        fi
     830
     831    # Remove the Binutils pass 1 sources after a successful Adjusting phase.
     832        if [[ `_IS_ $this_script adjusting` ]] ; then
    819833(
    820834cat << EOF
    821   @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
    822   rm -r \$(HLFS)\$(SRC)/\$\$ROOT && \\
    823   if [ -e \$(HLFS)\$(SRC)/$name-build ]; then \\
    824     rm -r \$(HLFS)\$(SRC)/$name-build; \\
    825   fi;
    826 EOF
    827 ) >> $MKFILE.tmp
    828     fi
    829   fi
    830 
    831     # Remove the Binutils pass 1 sources after a successful Adjusting phase.
    832   if [[ `_IS_ $this_script adjusting` ]] ; then
    833 (
    834 cat << EOF
    835   @rm -r \`cat sources-dir\` && \\
    836   rm -r \$(HLFS)\$(SRC)/binutils-build && \\
    837   rm sources-dir
     835        @rm -r \`cat sources-dir\` && \\
     836        rm -r \$(HLFS)\$(SRC)/binutils-build && \\
     837        rm sources-dir
    838838EOF
    839839) >> $MKFILE.tmp
     
    867867    fi
    868868
    869   echo -e "${YELLOW}  Processing Chapter-6 scripts ${OFF}"
     869        echo -e "${YELLOW}      Processing Chapter-6 scripts ${OFF}"
    870870  for file in chapter06/* ; do
    871871    # Keep the script file name
     
    873873
    874874    # Skip this script depending on jhahlfs.conf flags set.
    875   case $this_script in
    876       # We'll run the chroot commands differently than the others, so skip them in the
    877       # dependencies and target creation.
    878     *chroot* )  continue ;;
    879         # Test if the stripping phase must be skipped
    880     *-stripping* )  [[ "$STRIP" = "0" ]] && continue ;;
    881       # Select the appropriate library
    882     *glibc*)    [[ ${MODEL} = "uclibc" ]] && continue ;;
    883     *uclibc*)   [[ ${MODEL} = "glibc" ]]  && continue ;;
    884     *) ;;
     875        case $this_script in
     876                        # We'll run the chroot commands differently than the others, so skip them in the
     877                        # dependencies and target creation.
     878                *chroot* )      continue ;;
     879                    # Test if the stripping phase must be skipped
     880                *-stripping* )  [[ "$STRIP" = "0" ]] && continue ;;
     881                        # Select the appropriate library
     882                *glibc*)                [[ ${MODEL} = "uclibc" ]] && continue ;;
     883                *uclibc*)               [[ ${MODEL} = "glibc" ]]  && continue ;;
     884                *) ;;
    885885    esac
    886886
     
    892892    name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
    893893
    894   #
    895   # Sed replacement for 'nodump' tag in xml scripts until Manuel has a chance to fix them
    896   #
     894        #
     895        # Sed replacement for 'nodump' tag in xml scripts until Manuel has a chance to fix them
     896        #
    897897    case $name in
    898     kernfs) # Remove sysctl code if host does not have grsecurity enabled
    899       if [[ "$GRSECURITY_HOST" = "0" ]]; then
    900           sed '/sysctl/d' -i chapter06/$this_script
    901       fi
    902       ;;
    903     module-init-tools)
    904         if [[ "$TEST" = "0" ]]; then  # This needs rework....
    905           sed '/make distclean/d' -i chapter06/$this_script
    906         fi
    907       ;;
    908     glibc)  # PATCH.. Turn off error trapping for the remainder of the script.
    909         sed 's|^make install|make install; set +e|'  -i chapter06/$this_script
    910       ;;
    911     uclibc) # PATCH..
    912         sed 's/EST5EDT/${TIMEZONE}/' -i chapter06/$this_script
    913         # PATCH.. Cannot use interactive programs/scripts.
    914         sed 's/make menuconfig/make oldconfig/' -i chapter06/$this_script
    915         sed 's@^cd gettext-runtime@cd ../gettext-*/gettext-runtime@' -i chapter06/$this_script
    916       ;;
    917     gcc)  # PATCH..
    918         sed 's/rm /rm -f /' -i chapter06/$this_script
    919       ;;
     898                kernfs) # Remove sysctl code if host does not have grsecurity enabled
     899                        if [[ "$GRSECURITY_HOST" = "0" ]]; then
     900                            sed '/sysctl/d' -i chapter06/$this_script
     901                        fi
     902                        ;;
     903                module-init-tools)
     904                                if [[ "$TEST" = "0" ]]; then  # This needs rework....
     905                                  sed '/make distclean/d' -i chapter06/$this_script
     906                                fi
     907                        ;;
     908                glibc)  # PATCH.. Turn off error trapping for the remainder of the script.
     909                                sed 's|^make install|make install; set +e|'  -i chapter06/$this_script
     910                        ;;
     911                uclibc) # PATCH..
     912                                sed 's/EST5EDT/${TIMEZONE}/' -i chapter06/$this_script
     913                                # PATCH.. Cannot use interactive programs/scripts.
     914                                sed 's/make menuconfig/make oldconfig/' -i chapter06/$this_script
     915                                sed 's@^cd gettext-runtime@cd ../gettext-*/gettext-runtime@' -i chapter06/$this_script
     916                        ;;
     917                gcc)    # PATCH..
     918                                sed 's/rm /rm -f /' -i chapter06/$this_script
     919                        ;;
    920920    esac
    921921
    922   #--------------------------------------------------------------------#
    923   #         >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<<          #
    924   #--------------------------------------------------------------------#
    925   #
    926   # Drop in the name of the target on a new line, and the previous target
    927   # as a dependency. Also call the echo_message function.
    928   echo -e "\n$this_script:  $PREV
    929   @\$(call echo_message, Building)" >> $MKFILE.tmp
     922        #--------------------------------------------------------------------#
     923        #         >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<<          #
     924        #--------------------------------------------------------------------#
     925        #
     926        # Drop in the name of the target on a new line, and the previous target
     927        # as a dependency. Also call the echo_message function.
     928        echo -e "\n$this_script:  $PREV
     929        @\$(call echo_message, Building)" >> $MKFILE.tmp
    930930
    931931    # Find the version of the command files, if it corresponds with the building of
     
    933933    vrs=`grep "^$name-version" $JHAHLFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
    934934
    935   # If $vrs isn't empty, we've got a package...
    936   # Insert instructions for unpacking the package and changing directories
    937   if [ "$vrs" != "" ] ; then
    938   # Deal with non-standard names
    939   case $name in
    940     tcl)  FILE="$name$vrs-src.tar.*" ;;
    941     uclibc) FILE="uClibc-$vrs.tar.*" ;;
    942     gcc)  FILE="gcc-core-$vrs.tar.*" ;;
    943     *)    FILE="$name-$vrs.tar.*" ;;
    944   esac
     935        # If $vrs isn't empty, we've got a package...
     936        # Insert instructions for unpacking the package and changing directories
     937        if [ "$vrs" != "" ] ; then
     938        # Deal with non-standard names
     939        case $name in
     940                tcl)    FILE="$name$vrs-src.tar.*" ;;
     941                uclibc) FILE="uClibc-$vrs.tar.*" ;;
     942                gcc)    FILE="gcc-core-$vrs.tar.*" ;;
     943                *)              FILE="$name-$vrs.tar.*" ;;
     944        esac
    945945(
    946946cat  << EOF
    947   @\$(call unpack2,$FILE)
    948   @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
    949   echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars && \\
    950   echo "export target=$(uname -m)-${TARGET}" >> envars && \\
    951   echo "export ldso=/lib/${LOADER}" >> envars
     947        @\$(call unpack2,$FILE)
     948        @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
     949        echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars && \\
     950        echo "export target=$(uname -m)-${TARGET}" >> envars && \\
     951        echo "export ldso=/lib/${LOADER}" >> envars
    952952EOF
    953953) >> $MKFILE.tmp
     
    955955
    956956    case $this_script in
    957     *readjusting*) # For the Re-Adjusting phase we must to cd to the binutils-build directory.
    958       echo -e '\t@echo "export PKGDIR=$(SRC)/binutils-build" > envars' >> $MKFILE.tmp
    959       ;;
    960     *glibc* | *uclibc* ) # For glibc and uClibc we need to set TIMEZONE envar.
    961       echo -e '\t@echo "export TIMEZONE=$(TIMEZONE)" >> envars' >> $MKFILE.tmp
    962       ;;
    963     *groff* ) # For Groff we need to set PAGE envar.
    964       echo -e '\t@echo "export PAGE=$(PAGE)" >> envars' >> $MKFILE.tmp
    965       ;;
    966   esac
     957                *readjusting*) # For the Re-Adjusting phase we must to cd to the binutils-build directory.
     958                        echo -e '\t@echo "export PKGDIR=$(SRC)/binutils-build" > envars' >> $MKFILE.tmp
     959                        ;;
     960                *glibc* | *uclibc* ) # For glibc and uClibc we need to set TIMEZONE envar.
     961                        echo -e '\t@echo "export TIMEZONE=$(TIMEZONE)" >> envars' >> $MKFILE.tmp
     962                        ;;
     963                *groff* ) # For Groff we need to set PAGE envar.
     964                        echo -e '\t@echo "export PAGE=$(PAGE)" >> envars' >> $MKFILE.tmp
     965                        ;;
     966        esac
    967967
    968968
     
    971971(
    972972cat << EOF
    973   @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(HLFS)\`\n" >logs/$this_script && \\
    974   export HLFS=\$(HLFS) && commands/$file >>logs/$this_script 2>&1 && \\
    975   echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(HLFS)\`\n" >>logs/$this_script
     973        @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(HLFS)\`\n" >logs/$this_script && \\
     974        export HLFS=\$(HLFS) && commands/$file >>logs/$this_script 2>&1 && \\
     975        echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(HLFS)\`\n" >>logs/$this_script
    976976EOF
    977977) >> $MKFILE.tmp
     
    981981(
    982982cat << EOF
    983   @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(HLFS)\`\n" >logs/$this_script && \\
    984   \$(CHROOT1) 'cd /jhahlfs && source envars && /jhahlfs/commands/$file >>/jhahlfs/logs/$this_script 2>&1' && \\
    985   echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(HLFS)\`\n" >>logs/$this_script
     983        @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(HLFS)\`\n" >logs/$this_script && \\
     984        \$(CHROOT1) 'cd /jhahlfs && source envars && /jhahlfs/commands/$file >>/jhahlfs/logs/$this_script 2>&1' && \\
     985        echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(HLFS)\`\n" >>logs/$this_script
    986986EOF
    987987) >> $MKFILE.tmp
     
    992992(
    993993cat << EOF
    994   @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
    995   rm -r \$(HLFS)\$(SRC)/\$\$ROOT && \\
    996   if [ -e \$(HLFS)\$(SRC)/$name-build ]; then \\
    997     rm -r \$(HLFS)\$(SRC)/$name-build; \\
    998   fi;
     994        @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
     995        rm -r \$(HLFS)\$(SRC)/\$\$ROOT && \\
     996        if [ -e \$(HLFS)\$(SRC)/$name-build ]; then \\
     997                rm -r \$(HLFS)\$(SRC)/$name-build; \\
     998        fi;
    999999EOF
    10001000) >> $MKFILE.tmp
     
    10051005(
    10061006cat << EOF
    1007   @rm -r \`cat sources-dir\` && \\
    1008   rm -r \$(HLFS)\$(SRC)/binutils-build && \\
    1009   rm sources-dir
     1007        @rm -r \`cat sources-dir\` && \\
     1008        rm -r \$(HLFS)\$(SRC)/binutils-build && \\
     1009        rm sources-dir
    10101010EOF
    10111011) >> $MKFILE.tmp
     
    10291029#----------------------------#
    10301030
    1031     echo  "${YELLOW}  Processing Chapter-7 scripts ${OFF}"
     1031    echo  "${YELLOW}    Processing Chapter-7 scripts ${OFF}"
    10321032  for file in chapter07/*; do
    10331033    # Keep the script file name
     
    10391039    # password, edit several files and setup Grub.
    10401040    case $this_script in
    1041   *grub)    continue  ;;
    1042   *reboot)  continue  ;;
    1043   *console) continue  ;; # Use the file generated by lfs-bootscripts
    1044 
    1045   *kernel)  # How does Manuel add this string to the file..
    1046         sed 's|cd \$PKGDIR.*||'         -i chapter07/$this_script
    1047         # You cannot run menuconfig from within the makefile
    1048           sed 's|make menuconfig|make oldconfig|' -i chapter07/$this_script
    1049         # The files in the conglomeration dir are xxx.bz2
    1050         sed 's|.patch.gz|.patch.bz2|'       -i chapter07/$this_script
    1051         sed 's|gunzip|bunzip2|'         -i chapter07/$this_script
    1052         # If defined include the keymap in the kernel
    1053         if [[ -n "$KEYMAP" ]]; then
    1054         sed "s|^loadkeys -m.*>|loadkeys -m $KEYMAP >|" -i chapter07/$this_script
    1055         else
    1056         sed '/loadkeys -m/d'          -i chapter07/$this_script
    1057         sed '/drivers\/char/d'          -i chapter07/$this_script
    1058         fi
    1059         # If no .config file is supplied, the kernel build is skipped
    1060         [[ -z $CONFIG ]] && continue
    1061     ;;
    1062   *usage)   # The script bombs, disable error trapping
    1063         sed 's|set -e|set +e|'  -i chapter07/$this_script
    1064     ;;
    1065   *profile) # Add the config values to the script
    1066         sed "s|LC_ALL=\*\*EDITME.*EDITME\*\*|LC_ALL=$LC_ALL|" -i chapter07/$this_script
    1067         sed "s|LANG=\*\*EDITME.*EDITME\*\*|LANG=$LANG|"       -i chapter07/$this_script
    1068     ;;
     1041        *grub)    continue      ;;
     1042        *reboot)  continue      ;;
     1043        *console) continue      ;; # Use the file generated by lfs-bootscripts
     1044
     1045        *kernel)        # How does Manuel add this string to the file..
     1046                          sed 's|cd \$PKGDIR.*||'                                       -i chapter07/$this_script
     1047                                # You cannot run menuconfig from within the makefile
     1048                  sed 's|make menuconfig|make oldconfig|'       -i chapter07/$this_script
     1049                                # The files in the conglomeration dir are xxx.bz2
     1050                          sed 's|.patch.gz|.patch.bz2|'                         -i chapter07/$this_script
     1051                          sed 's|gunzip|bunzip2|'                                       -i chapter07/$this_script
     1052                                # If defined include the keymap in the kernel
     1053                          if [[ -n "$KEYMAP" ]]; then
     1054                                sed "s|^loadkeys -m.*>|loadkeys -m $KEYMAP >|" -i chapter07/$this_script
     1055                          else
     1056                                sed '/loadkeys -m/d'                                    -i chapter07/$this_script
     1057                                sed '/drivers\/char/d'                                  -i chapter07/$this_script
     1058                          fi
     1059                                # If no .config file is supplied, the kernel build is skipped
     1060                          [[ -z $CONFIG ]] && continue
     1061                ;;
     1062        *usage)   # The script bombs, disable error trapping
     1063                          sed 's|set -e|set +e|'  -i chapter07/$this_script
     1064                ;;
     1065        *profile) # Add the config values to the script
     1066                          sed "s|LC_ALL=\*\*EDITME.*EDITME\*\*|LC_ALL=$LC_ALL|" -i chapter07/$this_script
     1067                          sed "s|LANG=\*\*EDITME.*EDITME\*\*|LANG=$LANG|"       -i chapter07/$this_script
     1068                ;;
    10691069    esac
    10701070
    1071   # First append then name of the script file to a list (this will become
    1072   # the names of the targets in the Makefile
    1073   chapter7="$chapter7 $this_script"
    1074 
    1075   #--------------------------------------------------------------------#
    1076   #         >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<<          #
    1077   #--------------------------------------------------------------------#
    1078   #
    1079   # Drop in the name of the target on a new line, and the previous target
    1080   # as a dependency. Also call the echo_message function.
    1081   echo -e "\n$this_script:  $PREV
    1082   @\$(call echo_message, Building)" >> $MKFILE.tmp
    1083 
    1084   if [[ `_IS_ $this_script bootscripts` ]] ; then
    1085       vrs=`grep "^lfs-bootscripts-version" $JHAHLFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
     1071        # First append then name of the script file to a list (this will become
     1072        # the names of the targets in the Makefile
     1073        chapter7="$chapter7 $this_script"
     1074
     1075        #--------------------------------------------------------------------#
     1076        #         >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<<          #
     1077        #--------------------------------------------------------------------#
     1078        #
     1079        # Drop in the name of the target on a new line, and the previous target
     1080        # as a dependency. Also call the echo_message function.
     1081        echo -e "\n$this_script:  $PREV
     1082        @\$(call echo_message, Building)" >> $MKFILE.tmp
     1083
     1084        if [[ `_IS_ $this_script bootscripts` ]] ; then
     1085        vrs=`grep "^lfs-bootscripts-version" $JHAHLFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
    10861086        FILE="lfs-bootscripts-$vrs.tar.*"
    1087     # The bootscript pkg references both lfs AND blfs bootscripts...
    1088     #  see XML script for other additions to bootscripts file
    1089     # PATCH
     1087                # The bootscript pkg references both lfs AND blfs bootscripts...
     1088                #  see XML script for other additions to bootscripts file
     1089                # PATCH
    10901090        vrs=`grep "^blfs-bootscripts-version" $JHAHLFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
    1091     sed "s|make install$|make install; cd ../blfs-bootscripts-$vrs|" -i chapter07/$this_script
     1091                sed "s|make install$|make install; cd ../blfs-bootscripts-$vrs|" -i chapter07/$this_script
    10921092(
    10931093cat  << EOF
    1094   @\$(call unpack2,$FILE)
    1095   @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
    1096   echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars && \\
    1097   echo "\$(HLFS)\$(SRC)/blfs-bootscripts-$vrs" > sources-dir
     1094        @\$(call unpack2,$FILE)
     1095        @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
     1096        echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars && \\
     1097        echo "\$(HLFS)\$(SRC)/blfs-bootscripts-$vrs" > sources-dir
    10981098EOF
    10991099) >> $MKFILE.tmp
    1100   fi
    1101 
    1102   if [[ `_IS_ $this_script kernel` ]] ; then
    1103     # not much really, script does everything..
    1104     echo -e "\t@cp -f $CONFIG \$(HLFS)/sources/kernel-config" >> $MKFILE.tmp
     1100        fi
     1101
     1102        if [[ `_IS_ $this_script kernel` ]] ; then
     1103                # not much really, script does everything..
     1104                echo -e "\t@cp -f $CONFIG \$(HLFS)/sources/kernel-config" >> $MKFILE.tmp
    11051105          fi
    11061106
     
    11091109(
    11101110cat << EOF
    1111   @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(HLFS)\`\n" >logs/$this_script && \\
    1112   cp -v $FSTAB \$(HLFS)/etc/fstab >>logs/$this_script 2>&1 && \\
    1113   echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(HLFS)\`\n" >>logs/$this_script
     1111        @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(HLFS)\`\n" >logs/$this_script && \\
     1112        cp -v $FSTAB \$(HLFS)/etc/fstab >>logs/$this_script 2>&1 && \\
     1113        echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(HLFS)\`\n" >>logs/$this_script
    11141114EOF
    11151115) >> $MKFILE.tmp
     
    11181118(
    11191119cat << EOF
    1120   @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(HLFS)\`\n" >logs/$this_script && \\
    1121   \$(CHROOT2) 'cd /jhahlfs && source envars && /jhahlfs/commands/$file >>/jhahlfs/logs/$this_script 2>&1' && \\
    1122   echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(HLFS)\`\n" >>logs/$this_script
     1120        @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(HLFS)\`\n" >logs/$this_script && \\
     1121        \$(CHROOT2) 'cd /jhahlfs && source envars && /jhahlfs/commands/$file >>/jhahlfs/logs/$this_script 2>&1' && \\
     1122        echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(HLFS)\`\n" >>logs/$this_script
    11231123EOF
    11241124) >> $MKFILE.tmp
     
    11291129(
    11301130cat << EOF
    1131   @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
    1132   rm -r \$(HLFS)\$(SRC)/\$\$ROOT
    1133   @rm -r \`cat sources-dir\` && \\
    1134   rm sources-dir
     1131        @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
     1132        rm -r \$(HLFS)\$(SRC)/\$\$ROOT
     1133        @rm -r \`cat sources-dir\` && \\
     1134        rm sources-dir
    11351135
    11361136EOF
     
    11861186  for file in chapter06/*chroot* ; do
    11871187    chroot=`cat $file | sed -e '/#!\/bin\/sh/d' \
    1188           -e '/^export/d' \
    1189           -e '/^logout/d' \
    1190           -e 's@ \\\@ @g' | tr -d '\n' |  sed -e 's/  */ /g' \
    1191                           -e 's|\\$|&&|g' \
    1192                           -e 's|exit||g' \
    1193                           -e 's|$| -c|' \
    1194                           -e 's|"$$HLFS"|$(HLFS)|'\
    1195                           -e 's|set -e||'`
     1188                            -e '/^export/d' \
     1189                            -e '/^logout/d' \
     1190                            -e 's@ \\\@ @g' | tr -d '\n' |  sed -e 's/  */ /g' \
     1191                                                                                                        -e 's|\\$|&&|g' \
     1192                                                                                                        -e 's|exit||g' \
     1193                                                                                                        -e 's|$| -c|' \
     1194                                                                                                        -e 's|"$$HLFS"|$(HLFS)|'\
     1195                                                                                                        -e 's|set -e||'`
    11961196    echo -e "CHROOT$i= $chroot\n" >> $MKFILE
    11971197    i=`expr $i + 1`
     
    12011201  # as a dependency.
    12021202(
    1203   cat << EOF
     1203        cat << EOF
    12041204all:  chapter4 chapter5 chapter6 chapter7
    1205   @\$(call echo_finished,$VERSION)
     1205        @\$(call echo_finished,$VERSION)
    12061206
    12071207chapter4:  020-creatingtoolsdir 021-addinguser 022-settingenvironment
     
    12141214
    12151215clean-all:  clean
    1216   rm -rf ./{commands,logs,Makefile,dump-hlfs-scripts.xsl,functions,packages,patches}
     1216        rm -rf ./{commands,logs,Makefile,dump-hlfs-scripts.xsl,functions,packages,patches}
    12171217
    12181218clean:  clean-chapter7 clean-chapter6 clean-chapter5 clean-chapter4
    12191219
    12201220clean-chapter4:
    1221   -if [ ! -f user-hlfs-exist ]; then \\
    1222     userdel hlfs; \\
    1223     rm -rf /home/hlfs; \\
    1224   fi;
    1225   rm -rf \$(HLFS)/tools
    1226   rm -f /tools
    1227   rm -f envars user-hlfs-exist
    1228   rm -f 02* logs/02*.log
     1221        -if [ ! -f user-hlfs-exist ]; then \\
     1222                userdel hlfs; \\
     1223                rm -rf /home/hlfs; \\
     1224        fi;
     1225        rm -rf \$(HLFS)/tools
     1226        rm -f /tools
     1227        rm -f envars user-hlfs-exist
     1228        rm -f 02* logs/02*.log
    12291229
    12301230clean-chapter5:
    1231   rm -rf \$(HLFS)/tools/*
    1232   rm -f $chapter5 restore-hlfs-env sources-dir
    1233   cd logs && rm -f $chapter5 && cd ..
     1231        rm -rf \$(HLFS)/tools/*
     1232        rm -f $chapter5 restore-hlfs-env sources-dir
     1233        cd logs && rm -f $chapter5 && cd ..
    12341234
    12351235clean-chapter6:
    1236   -umount \$(HLFS)/sys
    1237   -umount \$(HLFS)/proc
    1238   -umount \$(HLFS)/dev/shm
    1239   -umount \$(HLFS)/dev/pts
    1240   -umount \$(HLFS)/dev
    1241   rm -rf \$(HLFS)/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
    1242   rm -f $chapter6
    1243   cd logs && rm -f $chapter6 && cd ..
     1236        -umount \$(HLFS)/sys
     1237        -umount \$(HLFS)/proc
     1238        -umount \$(HLFS)/dev/shm
     1239        -umount \$(HLFS)/dev/pts
     1240        -umount \$(HLFS)/dev
     1241        rm -rf \$(HLFS)/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
     1242        rm -f $chapter6
     1243        cd logs && rm -f $chapter6 && cd ..
    12441244
    12451245clean-chapter7:
    1246   rm -f $chapter7
    1247   cd logs && rm -f $chapter7 && cd ..
     1246        rm -f $chapter7
     1247        cd logs && rm -f $chapter7 && cd ..
    12481248
    12491249restore-hlfs-env:
    1250   @\$(call echo_message, Building)
    1251   @if [ -f /home/hlfs/.bashrc.XXX ]; then \\
    1252     mv -fv /home/hlfs/.bashrc.XXX /home/hlfs/.bashrc; \\
    1253   fi;
    1254   @if [ -f /home/hlfs/.bash_profile.XXX ]; then \\
    1255     mv -v /home/hlfs/.bash_profile.XXX /home/hlfs/.bash_profile; \\
    1256   fi;
    1257   @chown hlfs:hlfs /home/hlfs/.bash* && \\
    1258   touch \$@
     1250        @\$(call echo_message, Building)
     1251        @if [ -f /home/hlfs/.bashrc.XXX ]; then \\
     1252                mv -fv /home/hlfs/.bashrc.XXX /home/hlfs/.bashrc; \\
     1253        fi;
     1254        @if [ -f /home/hlfs/.bash_profile.XXX ]; then \\
     1255                mv -v /home/hlfs/.bash_profile.XXX /home/hlfs/.bash_profile; \\
     1256        fi;
     1257        @chown hlfs:hlfs /home/hlfs/.bash* && \\
     1258        touch \$@
    12591259
    12601260EOF
    12611261) >> $MKFILE
    12621262
    1263   # Bring over the items from the Makefile.tmp
    1264   cat $MKFILE.tmp >> $MKFILE
    1265   rm $MKFILE.tmp
    1266   echo -ne "${GREEN}done\n${OFF}"
     1263        # Bring over the items from the Makefile.tmp
     1264        cat $MKFILE.tmp >> $MKFILE
     1265        rm $MKFILE.tmp
     1266        echo -ne "${GREEN}done\n${OFF}"
    12671267}
    12681268
     
    12701270run_make() {                 # Execute the newly constructed Makefile
    12711271#----------------------------#
    1272   # Test if make must be run.
    1273   if [ "$RUNMAKE" = "1" ] ; then
    1274     # Test to make sure we're running the build as root
    1275     if [ "$UID" != "0" ] ; then
    1276       echo "You must be logged in as root to successfully build HLFS."
    1277       exit 1
    1278     fi
    1279     # Build the system
    1280     if [ -e $MKFILE ] ; then
    1281       echo -ne "Building the HLFS system...\n"
    1282       cd $JHAHLFSDIR && make
    1283       echo -ne "done\n"
    1284     fi
    1285   fi
     1272        # Test if make must be run.
     1273        if [ "$RUNMAKE" = "1" ] ; then
     1274                # Test to make sure we're running the build as root
     1275                if [ "$UID" != "0" ] ; then
     1276                        echo "You must be logged in as root to successfully build HLFS."
     1277                        exit 1
     1278                fi
     1279                # Build the system
     1280                if [ -e $MKFILE ] ; then
     1281                        echo -ne "Building the HLFS system...\n"
     1282                        cd $JHAHLFSDIR && make
     1283                        echo -ne "done\n"
     1284                fi
     1285        fi
    12861286}
    12871287
     
    12981298    --version | -V ) 'clear'; echo "$version" ; exit 0; ;;
    12991299    --help | -h )  usage | less
    1300           'clear' ; exit 0
    1301     ;;
     1300                                  'clear' ; exit 0
     1301                ;;
    13021302
    13031303    --HLFS-version | -L )
     
    13061306      case $1 in
    13071307        dev* | SVN | trunk )
    1308       BOOK="" # necessary to overide any value set inside jhahlfs.conf
    1309       WC=
     1308                  BOOK=""       # necessary to overide any value set inside jhahlfs.conf
     1309                  WC=
    13101310          HLFSVRS=development
    13111311          ;;
     
    13391339      ;;
    13401340
    1341     --get-packages | -P ) HPKG=1 ;;
    1342     --run-make | -M )   RUNMAKE=1 ;;
    1343     --rebuild )       CLEAN=1 ;;
     1341    --get-packages | -P )       HPKG=1 ;;
     1342    --run-make | -M )           RUNMAKE=1 ;;
     1343    --rebuild )                         CLEAN=1 ;;
    13441344
    13451345    --readme )
    1346     'clear'
    1347     echo "$_inline_doc" | less
    1348     'clear'; exit
    1349     ;;
     1346                'clear'
     1347                echo "$_inline_doc" | less
     1348                'clear'; exit
     1349                ;;
    13501350
    13511351    --fstab )
     
    13871387# and notify the user about that.
    13881388if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] && [ -z $CLEAN ] ; then
    1389   no_empty_builddir
     1389        no_empty_builddir
    13901390fi
    13911391
     
    14081408BOOK=${BOOK:=hlfs-$HLFSVRS}
    14091409
    1410 [[ ! -d $JHAHLFSDIR ]]  && mkdir -pv $JHAHLFSDIR
    1411 [[ ! -d $LOGDIR ]]    && mkdir -v $LOGDIR
     1410[[ ! -d $JHAHLFSDIR ]]  && mkdir -pv $JHAHLFSDIR
     1411[[ ! -d $LOGDIR ]]              && mkdir -v $LOGDIR
    14121412if [[ "$PWD" != "$JHAHLFSDIR" ]]; then
    1413   cp -v $FILES $JHAHLFSDIR/
    1414   sed 's,FAKEDIR,'$BOOK',' $XSL > $JHAHLFSDIR/dump-hlfs-scripts.xsl
    1415   export XSL=$JHAHLFSDIR/dump-hlfs-scripts.xsl
     1413        cp -v $FILES $JHAHLFSDIR/
     1414        sed 's,FAKEDIR,'$BOOK',' $XSL > $JHAHLFSDIR/dump-hlfs-scripts.xsl
     1415        export XSL=$JHAHLFSDIR/dump-hlfs-scripts.xsl
    14161416fi
    14171417
     
    14201420
    14211421# Check for minumum gcc and kernel versions
    1422 check_requirements  1 # 0/1  0-do not display values.
    1423 validate_config   1 # 0/1  0-do not display values
     1422check_requirements      1       # 0/1  0-do not display values.
     1423validate_config         1       # 0/1  0-do not display values
    14241424get_book
    14251425build_Makefile
Note: See TracChangeset for help on using the changeset viewer.