Changeset fe30c61


Ignore:
Timestamp:
11/11/2006 07:06:46 PM (17 years ago)
Author:
Manuel Canales Esparcia <manuel@…>
Branches:
2.3, 2.3.x, 2.4, ablfs, ablfs-more, legacy, new_features, trunk
Children:
195ed9f
Parents:
47b363c
Message:

Splitted common-functions.

Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • README

    r47b363c rfe30c61  
    130130               /progress_bar.sh
    131131               /blfs-tool-deps/9xx-*
    132                /libs/*
     132               /libs/func_*
    133133
    134134        /contrib/jhalfs-paco.patch
  • common/common-functions

    r47b363c rfe30c61  
    2424
    2525
    26 HEADER="# This file is automatically generated by jhalfs
    27 # DO NOT EDIT THIS FILE MANUALLY
    28 #
    29 # Generated on `date \"+%F %X %Z\"`"
    30 
    31 
    32 #------------------------------------------------------#
    33 #        NEW Makefile scripting functions              #
    34 #------------------------------------------------------#
    35 
    36 
    37 unset get_package_tarball_name
    38 #----------------------------------#
    39 get_package_tarball_name() {       #
    40 #----------------------------------#
    41   local script_name=`echo ${1} | sed -e 's@[0-9]\{1\}-@@'`
    42 
    43    # The use of 'head' is necessary to limit the return value to the FIRST match..
    44    # hopefully this will not cause problems.
    45    #
    46    case $script_name in
    47      tcl) echo $(grep "^tcl" $JHALFSDIR/pkg_tarball_list | head -n1 )
    48          ;;
    49      linux-headers)
    50          if [ "${PROGNAME}" = "lfs" ]; then
    51            # Uses kernel headers directly
    52            echo $(grep "^linux-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
    53          else
    54            # CLFS/HLFS use massaged headers package
    55            echo $(grep "^linux-headers-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
    56          fi
    57          ;;
    58      *)  echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
    59          ;;
    60    esac
    61 
    62 }
    63 
    64 
    65 unset wrt_RunaAsRoot
    66 #----------------------------------#
    67 wrt_RunAsRoot() {                  # Some scripts must be run as root..
    68 #----------------------------------#
    69   local MOUNT_ENV
    70   local this_script=$1
    71   local file=$2
    72 
    73   case ${PROGNAME} in
    74     lfs   ) MOUNT_ENV="LFS" ;;
    75     blfs  ) MOUNT_ENV="BLFS" ;;
    76     clfs  ) MOUNT_ENV="CLFS" ;;
    77     clfs2 ) MOUNT_ENV="CLFS" ;;
    78     clfs3 ) MOUNT_ENV="CLFS" ;;
    79     hlfs  ) MOUNT_ENV="HLFS" ;;
    80     *) echo "undefined progname $PROGNAME"; exit 1 ;;
    81   esac
    82 
    83 (
    84 cat << EOF
    85         @( time { export ${MOUNT_ENV}=\$(MOUNT_PT) && ${PROGNAME}-commands/`dirname $file`/\$@ >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\
    86         \$(PRT_DU) >>logs/\$@
    87 EOF
    88 ) >> $MKFILE.tmp
    89 }
    90 
    91 
    92 #------------------------------------------------------#
    93 #------------------------------------------------------#
    94 
    95 #----------------------------------#
    96 ROOT_RunAsRoot() {                 #
    97 #----------------------------------#
    98   local file=$1
    99 (
    100 cat << EOF
    101         @( time { source envars && \$(CMDSDIR)/$file >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\
    102         \$(PRT_DU_CR) >>logs/\$@
    103 EOF
    104 ) >> $MKFILE.tmp
    105 }
    106 
    107 #----------------------------------#
    108 ROOT_Unpack() {                    #  An alias, for clairity
    109 #----------------------------------#
    110   local FILE=$1
    111   local optSAVE_PREVIOUS=$2
    112 
    113   if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then
    114 (
    115 cat << EOF
    116         @\$(call remove_existing_dirs,$FILE)
    117 EOF
    118 ) >> $MKFILE.tmp
    119   fi
    120 
    121 (
    122 cat << EOF
    123         @\$(call unpack,$FILE)
    124         @\$(call get_pkg_root_LUSER)
    125 EOF
    126 ) >> $MKFILE.tmp
    127 }
    128 
    129 #------------------------------------------------------#
    130 #------------------------------------------------------#
    131 
    132 #----------------------------------#
    133 LUSER_wrt_target() {               # Create target and initialize log file
    134 #----------------------------------#
    135   local i=$1
    136   local PREV=$2
    137 (
    138 cat << EOF
    139 
    140 $i:  $PREV
    141         @\$(call echo_message, Building)
    142         @./progress_bar.sh \$@ \$\$PPID &
    143         @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@
    144         @\$(PRT_DU) >>logs/\$@
    145 EOF
    146 ) >> $MKFILE.tmp
    147 }
    148 
    149 
    150 #----------------------------------#
    151 LUSER_wrt_RunAsUser() {            # Execute script inside time { }, footer to log file
    152 #----------------------------------#
    153   local file=$1
    154 
    155 (
    156 cat << EOF
    157         @( time { source ~/.bashrc && \$(CMDSDIR)/`dirname $file`/\$@ >> logs/\$@ 2>&1; } ) 2>> logs/\$@ && \\
    158         \$(PRT_DU) >> logs/\$@
    159 EOF
    160 ) >> $MKFILE.tmp
    161 }
    162 
    163 
    164 #----------------------------------#
    165 LUSER_wrt_unpack() {               # Unpack and set 'ROOT' var
    166 #----------------------------------#
    167   local FILE=$1
    168   local optSAVE_PREVIOUS=$2
    169 
    170   if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then
    171 (
    172 cat << EOF
    173         @\$(call remove_existing_dirs,$FILE)
    174 EOF
    175 ) >> $MKFILE.tmp
    176   fi
    177 
    178 (
    179 cat << EOF
    180         @\$(call unpack,$FILE)
    181         @\$(call get_pkg_root_LUSER)
    182 EOF
    183 ) >> $MKFILE.tmp
    184 
    185 }
    186 
    187 
    188 #----------------------------------#
    189 LUSER_wrt_CopyFstab() {            #
    190 #----------------------------------#
    191 (
    192 cat << EOF
    193         @( time { cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@
    194 EOF
    195 ) >> $MKFILE.tmp
    196 }
    197 
    198 
    199 #----------------------------------#
    200 LUSER_wrt_test_log() {             # Initialize testsuite log file
    201 #----------------------------------#
    202   local TESTLOGFILE=$1
    203 (
    204 cat  << EOF
    205         @echo "export  TEST_LOG=$TESTLOGDIR/$TESTLOGFILE" >> envars && \\
    206         echo '\$(nl_)\`date\`\$(nl_)' >$TESTLOGDIR/$TESTLOGFILE
    207 EOF
    208 ) >> $MKFILE.tmp
    209 }
    210 
    211 
    212 #----------------------------------#
    213 LUSER_RemoveBuildDirs() {          #
    214 #----------------------------------#
    215   local name=$1
    216 (
    217 cat << EOF
    218         @\$(call remove_build_dirs,$name)
    219 EOF
    220 ) >> $MKFILE.tmp
    221 }
    222 
    223 #-----------------------------------------------------------------#
    224 #-----------------------------------------------------------------#
    225 
    226 #----------------------------------#
    227 CHROOT_wrt_target() {              # Create target and initialize log file
    228 #----------------------------------#
    229   local i=$1
    230   local PREV=$2
    231   case $i in
    232     iteration* ) local LOGFILE="${this_script}.log" ;;
    233              * ) local LOGFILE="\$@"      ;;
    234   esac
    235 (
    236 cat << EOF
    237 
    238 $i:  $PREV
    239         @\$(call echo_message, Building)
    240         @./progress_bar.sh \$@ \$\$PPID &
    241         @echo "\$(nl_)\`date\`\$(nl_)" >logs/$LOGFILE
    242         @\$(PRT_DU_CR) >>logs/$LOGFILE
    243 EOF
    244 ) >> $MKFILE.tmp
    245 }
    246 
    247 
    248 #----------------------------------#
    249 CHROOT_Unpack() {                  #
    250 #----------------------------------#
    251   local FILE=$1
    252   local optSAVE_PREVIOUS=$2
    253 
    254   if [ "${optSAVE_PREVIOUS}" != "1" ]; then
    255 (
    256 cat << EOF
    257         @\$(call remove_existing_dirs2,$FILE)
    258 EOF
    259 ) >> $MKFILE.tmp
    260   fi
    261 (
    262 cat  << EOF
    263         @\$(call unpack3,$FILE)
    264         @\$(call get_pkg_root2)
    265 EOF
    266 ) >> $MKFILE.tmp
    267 }
    268 
    269 
    270 #----------------------------------#
    271 CHROOT_wrt_test_log() {            #
    272 #----------------------------------#
    273   local TESTLOGFILE=$1
    274 (
    275 cat  << EOF
    276         @echo "export TEST_LOG=/\$(SCRIPT_ROOT)/test-logs/$TESTLOGFILE" >> envars && \\
    277         echo "\$(nl_)\`date\`\$(nl_)" >test-logs/$TESTLOGFILE
    278 EOF
    279 ) >> $MKFILE.tmp
    280 }
    281 
    282 
    283 #----------------------------------#
    284 CHROOT_wrt_RunAsRoot() {           #
    285 #----------------------------------#
    286   local file=$1
    287 (
    288 cat << EOF
    289         @( time { source envars && \$(crCMDSDIR)/$file >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\
    290         \$(PRT_DU_CR) >>logs/\$@
    291 EOF
    292 ) >> $MKFILE.tmp
    293 
    294 }
    295 
    296 
    297 #----------------------------------#
    298 CHROOT_wrt_CopyFstab() {           #
    299 #----------------------------------#
    300 (
    301 cat << EOF
    302         @( time { cp -v /sources/fstab /etc/fstab >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@
    303 EOF
    304 ) >> $MKFILE.tmp
    305 }
    306 
    307 
    308 #----------------------------------#
    309 CHROOT_wrt_RemoveBuildDirs() {     #
    310 #----------------------------------#
    311   local name=$1
    312 (
    313 cat << EOF
    314         @\$(call remove_build_dirs2,$name)
    315 EOF
    316 ) >> $MKFILE.tmp
    317 }
    318 
    319 
    320 unset wrt_touch
    321 #----------------------------------#
    322 wrt_touch() {                      #
    323 #----------------------------------#
    324 (
    325 cat << EOF
    326         @\$(call housekeeping)
    327 EOF
    328 ) >> $MKFILE.tmp
    329 }
    330 
    331 
    332 #----------------------------------#
    333 wrt_blfs_tool_targets() {          #
    334 #----------------------------------#
    335 
    336   echo "${tab_}${GREEN}Processing... ${L_arrow}BLFS_TOOL ${R_arrow}"
    337 
    338   for file in blfs-tool-deps/* ; do
    339     # Keep the script file name
    340     this_script=`basename $file`
    341 
    342     # Grab the name of the target
    343     name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@'`
    344 
    345     # Find the package.
    346     case $name in
    347       tidy )  pkg_tarball=${TIDY_PKG} ;;
    348       unzip ) pkg_tarball=${UNZIP_PKG} ;;
    349       * )     pkg_tarball=$(get_package_tarball_name $name) ;;
    350     esac
    351 
    352     # Append each name of the script files to a list (this will become
    353     # the names of the targets in the Makefile)
    354     blfs_tool="$blfs_tool ${this_script}"
    355 
    356     #--------------------------------------------------------------------#
    357     #         >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<<          #
    358     #--------------------------------------------------------------------#
    359     #
    360     # Drop in the name of the target on a new line, and the previous target
    361     # as a dependency. Also call the echo_message function.
    362     CHROOT_wrt_target "${this_script}" "$PREV"
    363 
    364     # Insert instructions for unpacking the package and changing directories
    365     # DocBook-XML is a zip, the build script will handle that.
    366     [[ ! "$name" = "docbook-xml" ]] && CHROOT_Unpack "$pkg_tarball"
    367 
    368     # Run the script.
    369     CHROOT_wrt_RunAsRoot "$file"
    370 
    371     # Remove the build directory(ies) except if the package build fails.
    372     [[ ! "$name" = "docbook-xml" ]] && CHROOT_wrt_RemoveBuildDirs "$name"
    373 
    374     # Touch the tracking file.
    375     case $name in
    376       tidy )  pkg_ver=tidy-051026 ;;
    377       unzip ) pkg_ver=unzip-5.52 ;;
    378       * )     pkg_ver=$(echo $pkg_tarball | sed -e 's/.tar.*//;s/.tgz//;s/.zip//') ;;
    379     esac
    380     echo  "\$(tab_)@touch $TRACKING_DIR/$pkg_ver" >>  $MKFILE.tmp
    381 
    382     # Include a touch of the target name so make can check
    383     # if it's already been made.
    384     wrt_touch
    385     #
    386     #--------------------------------------------------------------------#
    387     #              >>>>>>>> END OF Makefile ENTRY <<<<<<<<               #
    388     #--------------------------------------------------------------------#
    389 
    390     # Keep the script file name for Makefile dependencies.
    391     PREV=${this_script}
    392   done
    393 }
    394 
    395 #------------------------------------------------------#
    396 #        END Makefile scripting functions              #
    397 #------------------------------------------------------#
    398 
    399 
    400 
    40126#----------------------------#
    40227run_make() {                 #
     
    40429  # Test if make must be run.
    40530  if [ "$RUNMAKE" = "y" ] ; then
    406     # Test to make sure we're running the build as root
     31    # Test to make sure we're not running the build as root
    40732    if [ "$UID" = "0" ] ; then
    40833      echo "You must not be logged in as root to build the system."
     
    44368}
    44469
    445 #----------------------------#
    446 get_book() {                 #
    447 #----------------------------#
    448   cd $JHALFSDIR
     70VERBOSITY2=$VERBOSITY
    44971
    450   if [ -z $WORKING_COPY ] ; then
    451     # Check for Subversion instead of just letting the script hit 'svn' and fail.
    452     test `type -p svn` || eval "echo \"This feature requires Subversion.\"
    453     exit 1"
    454     echo -n "Downloading the $PROGNAME document, $LFSVRS version... "
     72[[ $VERBOSITY2 > 0 ]] && echo ""
    45573
    456     case $PROGNAME in
    457       lfs) svn_root="LFS" ;;
    458       hlfs) svn_root="HLFS" ;;
    459       clfs) svn_root="cross-lfs" ;;
    460       clfs2) svn_root="cross-lfs" ;;
    461       clfs3) svn_root="cross-lfs" ;;
    462       *) echo "BOOK not defined in function <get_book>"
    463           exit 1 ;;
    464     esac
    465     # Grab a fresh book if it's missing, otherwise, update it from the
    466     # repo. If we've already extracted the commands, move on to getting the
    467     # sources.
    468     if [ -d ${PROGNAME}-$LFSVRS ] ; then
    469       cd ${PROGNAME}-$LFSVRS
    470       if LC_ALL=C svn up | grep -q At && \
    471          test -d $JHALFSDIR/${PROGNAME}-commands && \
    472          test -f $JHALFSDIR/pkg_tarball_list ; then
    473         # Set the canonical book version
    474         echo -ne "done\n"
    475         cd $JHALFSDIR
    476         case $PROGNAME in
    477           clfs | clfs2 | clfs3 )
    478             VERSION=$(xmllint --noent $BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //'  -e 's/<\/.*//') ;;
    479           *)
    480             VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //'  -e 's/<\/.*//')  ;;
    481         esac
    482         get_sources
    483       else
    484         echo -ne "done\n"
    485         extract_commands
    486       fi
    487     else
    488       svn co $SVN/${svn_root}/${TREE} ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
    489       echo -ne "done\n"
    490       extract_commands
    491     fi
    492 
    493   else
    494     echo -ne "Using $BOOK as book's sources ...\n"
    495     extract_commands
    496   fi
    497   echo -ne " Document version ${L_arrow}${BOLD}${VERSION}${R_arrow}\n"
    498 }
    499 
    500 #----------------------------#
    501 extract_commands() {         #
    502 #----------------------------#
    503 
    504   # Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
    505   test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
    506   exit 1"
    507 
    508   cd $JHALFSDIR
    509   case $PROGNAME in
    510     clfs | clfs2 )
    511       VERSION=$(xmllint --noent $BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //'  -e 's/<\/.*//') ;;
    512     *)
    513       VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //'  -e 's/<\/.*//')  ;;
    514   esac
    515 
    516   # Start clean
    517   if [ -d ${PROGNAME}-commands ]; then
    518     rm -rf ${PROGNAME}-commands
    519     mkdir -v ${PROGNAME}-commands
    520   fi
    521   echo -n "Extracting commands for"
    522 
    523   # Dump the commands in shell script form from the HLFS book.
    524   case ${PROGNAME} in
    525     clfs)
    526         echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
    527         xsltproc --nonet \
    528                  --xinclude \
    529                  --stringparam method $METHOD \
    530                  --stringparam testsuite $TEST \
    531                  --stringparam bomb-testsuite $BOMB_TEST \
    532                  --stringparam vim-lang $VIMLANG \
    533                  --stringparam timezone $TIMEZONE \
    534                  --stringparam page $PAGE \
    535                  --stringparam lang $LANG \
    536                  -o ./${PROGNAME}-commands/ $XSL $BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
    537       ;;
    538 
    539     clfs2)
    540         echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
    541         xsltproc --nonet \
    542                  --xinclude \
    543                  --stringparam vim-lang $VIMLANG \
    544                  --stringparam timezone $TIMEZONE \
    545                  --stringparam page $PAGE \
    546                  --stringparam lang $LANG \
    547                  -o ./${PROGNAME}-commands/ $XSL $BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
    548       ;;
    549 
    550     clfs3)
    551         echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
    552         xsltproc --nonet \
    553                  --xinclude \
    554                  --stringparam vim-lang $VIMLANG \
    555                  --stringparam timezone $TIMEZONE \
    556                  --stringparam page $PAGE \
    557                  --stringparam lang $LANG \
    558                  -o ./${PROGNAME}-commands/ $XSL $BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
    559       ;;
    560 
    561     hlfs)
    562         echo -n " ${L_arrow}${BOLD}$MODEL${R_arrow} HLFS libc implementation"
    563         xsltproc --nonet \
    564                  --xinclude \
    565                  --stringparam model $MODEL \
    566                  --stringparam testsuite $TEST \
    567                  --stringparam bomb-testsuite $BOMB_TEST \
    568                  --stringparam timezone $TIMEZONE \
    569                  --stringparam page $PAGE \
    570                  --stringparam lang $LANG \
    571                  --stringparam lc_all $LC_ALL \
    572                  --stringparam grsecurity_host $GRSECURITY_HOST \
    573                  -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
    574       ;;
    575     lfs)
    576         echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build"
    577         xsltproc --nonet \
    578                  --xinclude \
    579                  --stringparam testsuite $TEST \
    580                  --stringparam bomb-testsuite $BOMB_TEST \
    581                  --stringparam vim-lang $VIMLANG \
    582                  --stringparam timezone $TIMEZONE \
    583                  --stringparam page $PAGE \
    584                  --stringparam lang $LANG \
    585                  -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
    586       ;;
    587     *)  echo -n " ${L_arrow}${BOLD}${PROGNAME}${R_arrow} book invalid, terminate build"
    588         exit 1 ;;
    589   esac
    590 
    591   [[ "${BLFS_TOOL}" = "y" ]] && copy_blfs_deps_scripts
    592 
    593   echo " ...OK"
    594 
    595   # Make the scripts executable.
    596   chmod -R +x $JHALFSDIR/${PROGNAME}-commands
    597 
    598   # Create the packages file. We need it for proper Makefile creation
    599   create_package_list
    600 
    601   # Done. Moving on...
    602   get_sources
    603 
    604 }
    605 
    606 #----------------------------#
    607 create_package_list() {      #
    608 #----------------------------#
    609 
    610   # Create the packages file. We need it for proper Makefile creation
    611   rm -f pkg_tarball_list
    612   echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK $ARCH"
    613   case ${PROGNAME} in
    614     clfs | clfs2 | clfs3 )
    615         xsltproc --nonet --xinclude -o pkg_tarball_list packages.xsl \
    616                  $BOOK/materials/${ARCH}-chapter.xml >>$LOGDIR/$LOG 2>&1
    617       ;;
    618     hlfs)
    619         xsltproc --nonet --xinclude -o pkg_tarball_list packages.xsl \
    620                  $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
    621       ;;
    622     lfs)
    623         xsltproc --nonet --xinclude -o pkg_tarball_list packages.xsl \
    624                  $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
    625       ;;
    626   esac
    627 
    628   if [[ "${BLFS_TOOL}" = "y" ]] ; then
    629 (
    630 cat << EOF
    631 $LIBXML_PKG
    632 $LIBXSLT_PKG
    633 $TIDY_PKG
    634 $UNZIP_PKG
    635 $DBXML_PKG
    636 $DBXSL_PKG
    637 $LINKS_PKG
    638 $SUDO_PKG
    639 $WGET_PKG
    640 $SVN_PKG
    641 $GPM_PKG
    642 EOF
    643 ) >> pkg_tarball_list
    644   fi
    645 
    646   echo " ...OK"
    647 
    648 }
     74[[ $VERBOSITY2 > 0 ]] && echo -n "Loading <func_book_parser>..."
     75source $COMMON_DIR/libs/func_book_parser
     76[[ $? > 0 ]] && echo "file libs/func_book_parser did not load.." && exit 1
     77[[ $VERBOSITY2 > 0 ]] && echo "OK"
    64978
    65079
    651 #----------------------------#
    652 get_sources() {              # Download file, write name to MISSING_FILES.DMP if an error
    653 #----------------------------#
    654   local saveIFS=$IFS
    655   local IFS line URL1 URL2 FILE BOOKMD5 MD5 HAVEMD5 fromARCHIVE
     80[[ $VERBOSITY2 > 0 ]] && echo -n "Loading <func_download_pkgs>..."
     81source $COMMON_DIR/libs/func_download_pkgs
     82[[ $? > 0 ]] && echo "file libs/func_download_pkgs did not load.." && exit 1
     83[[ $VERBOSITY2 > 0 ]] && echo "OK"
    65684
    657     # Test if the packages must be downloaded
    658   [ ! "$GETPKG" = "y" ] && return
    65985
    660   gs_wrt_message(){
    661     echo "${RED}$1${OFF}"
    662     echo "$1" >> MISSING_FILES.DMP
    663   }
    664     # Housekeeping
    665   [[ ! -d $BUILDDIR/sources ]] && mkdir $BUILDDIR/sources
    666   cd $BUILDDIR/sources
    667   [[ -f MD5SUMS ]] && rm MD5SUMS
    668   [[ -f MISSING_FILES.DMP ]] && rm MISSING_FILES.DMP
    669   [[ -f urls.lst ]] && rm urls.lst
     86[[ $VERBOSITY2 > 0 ]] && echo -n "Loading <func_wrt_Makefile>..."
     87source $COMMON_DIR/libs/func_wrt_Makefile
     88[[ $? > 0 ]] && echo "file libs/func_wrt_Makefile did not load.." && exit 1
     89[[ $VERBOSITY2 > 0 ]] && echo "OK"
    67090
    671     # Generate URLs file
    672   create_urls
    67391
    674   IFS=$'\x0A'  # Modify the 'internal field separator' to break on 'LF' only
    675   for line in `cat urls.lst`; do
    676     IFS=$saveIFS  # Restore the system defaults
     92[[ $VERBOSITY2 > 0 ]] && echo -n "Loading <func_blfs_deps>..."
     93source $COMMON_DIR/libs/func_blfs_deps
     94[[ $? > 0 ]] && echo "file libs/func_blfs_deps did not load.." && exit 1
     95[[ $VERBOSITY2 > 0 ]] && echo "OK"
    67796
    678       # Skip some packages if they aren't needed
    679     case $line in
    680         */tcl* | */expect* | */dejagnu* | */tree* | */gcc-testsuite* )
    681             [[ "$TEST" = "0" ]] && continue
    682           ;;
    683         */vim-*-lang* )
    684             [[ "$VIMLANG" = "0" ]] && continue
    685           ;;
    686         *linux/linux-* )
    687             [[ -z "$CONFIG" ]] && [[ -z "$BOOT_CONFIG" ]] && \
    688             [[ "$GETKERNEL" = "n" ]] && continue
    689           ;;
    690     esac
    691 
    692       # Locations
    693     URL1=`echo $line | cut -d" " -f2` # Preferred URL
    694     URL2=`echo $line | cut -d" " -f1` # Fallback Upstream URL
    695     FILE=`basename $URL1` # File name
    696     BOOKMD5=`echo $line | cut -d" " -f3` # MD5 book value
    697 
    698       # Validation pair
    699     MD5="$BOOKMD5  $FILE"
    700     HAVEMD5=1
    701 
    702     set -e
    703       # If the file exists in the archive copy it to the
    704       # $BUILDDIR/sources dir. MD5SUM will be validated later.
    705     if [ ! -z ${SRC_ARCHIVE} ] &&
    706        [   -d ${SRC_ARCHIVE} ] &&
    707        [   -f ${SRC_ARCHIVE}/$FILE ]; then
    708       cp ${SRC_ARCHIVE}/$FILE .
    709       echo "$FILE: -- copied from $SRC_ARCHIVE"
    710       fromARCHIVE=1
    711     else
    712       echo "${BOLD}${YELLOW}$FILE: not found in ${SRC_ARCHIVE}${OFF}"
    713       fromARCHIVE=0
    714       # If the file does not exist yet in /sources download a fresh one
    715       if [ ! -f $FILE ] ; then
    716         if ! wget $URL1 && ! wget $URL2 ; then
    717           gs_wrt_message "$FILE not found in the SRC_ARCHIVE or on any server..SKIPPING"
    718           continue
    719         fi
    720       fi
    721     fi
    722 
    723       # IF the md5sum does not match the existing files
    724     if ! echo "$MD5" | md5sum -c - >/dev/null ; then
    725       [[ $fromARCHIVE = "1" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match SRC_ARCHIVE copy${OFF}"
    726       [[ $fromARCHIVE = "0" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match REMOTE copy${OFF}"
    727         # Remove the old file and download a new one
    728       rm -fv $FILE
    729         # Force storage in SRC_ARCHIVE
    730       fromARCHIVE=0;
    731         # Try to retrieve again the file. Servers in reverse order.
    732       if ! wget $URL2 && ! wget $URL1 ; then
    733         gs_wrt_message "$FILE not found on the servers.. SKIPPING"
    734         continue
    735       fi
    736     fi
    737 
    738       # Validate the MD5SUM one last time
    739     if ! echo "$MD5" | md5sum -c - >/dev/null ; then
    740       gs_wrt_message "$FILE does not match MD5SUMS value"
    741       # Force generation of MD5SUM
    742       HAVEMD5=0
    743     fi
    744 
    745       # Generate a fresh MD5SUM for this file
    746     if [[ "$HAVEMD5" = "0" ]] ; then
    747       echo "${BOLD}${YELLOW}Generating a new MD5SUM for ${OFF}$FILE"
    748       echo "NEW MD5SUM: $(md5sum $FILE)" >> MISSING_FILES.DMP
    749     fi
    750 
    751       # Good or bad we write the original md5sum to a file
    752     echo "$MD5" >> MD5SUMS
    753 
    754      # Copy the freshly downloaded file
    755      # to the source archive.
    756    if [ ! -z ${SRC_ARCHIVE}  ] &&
    757       [   -d ${SRC_ARCHIVE}  ] &&
    758       [   -w ${SRC_ARCHIVE}  ] &&
    759       [ "$fromARCHIVE" = "0" ] ; then
    760         echo "Storing file:<$FILE> in the package archive"
    761         cp -f $FILE ${SRC_ARCHIVE}
    762    fi
    763 
    764   done
    765 
    766   if [[ -s MISSING_FILES.DMP ]]; then
    767     echo  -e "\n\n${tab_}${RED} One or more files were not retrieved or have bad MD5SUMS.\n${tab_} Check ${L_arrow}$BUILDDIR/sources/MISSING_FILES.DMP${R_arrow} for names ${OFF}\n"
    768       # Do not allow the automatic execution of the Makefile.
    769     echo "${tab_}${BOLD}${RED}*** ${YELLOW}Automatic execution of the generated makefile has been inhibited. ${RED}***${OFF}${nl_}"
    770     RUNMAKE="n"
    771   fi
    772 }
    773 
    774 #----------------------------#
    775 create_urls() {              #
    776 #----------------------------#
    777   cd $JHALFSDIR
    778 
    779   case ${PROGNAME} in
    780     clfs)
    781         echo -n "Creating CLFS <${ARCH}> specific URLs file"
    782         xsltproc --nonet --xinclude \
    783                  --stringparam server $SERVER \
    784                  -o $BUILDDIR/sources/urls.lst urls.xsl \
    785                  $BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
    786         echo " ...OK"
    787       ;;
    788     clfs2)
    789         echo -n "Creating CLFS2 <${ARCH}> specific URLs file"
    790         xsltproc --nonet --xinclude \
    791                  --stringparam server $SERVER \
    792                  -o $BUILDDIR/sources/urls.lst urls.xsl \
    793                  $BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
    794         echo " ...OK"
    795       ;;
    796     clfs3)
    797         echo -n "Creating CLFS3 <${ARCH}> specific URLs file"
    798         xsltproc --nonet --xinclude \
    799                  --stringparam server $SERVER \
    800                  -o $BUILDDIR/sources/urls.lst urls.xsl \
    801                  $BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
    802         echo " ...OK"
    803       ;;
    804     hlfs)
    805         echo -n "Creating HLFS <${MODEL}> specific URLs file"
    806         xsltproc --nonet --xinclude \
    807                  --stringparam server $SERVER \
    808                  --stringparam model $MODEL \
    809                  -o $BUILDDIR/sources/urls.lst urls.xsl \
    810                  $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
    811         echo " ...OK"
    812       ;;
    813     lfs)
    814         echo -n "Creating LFS specific URLs file"
    815         xsltproc --nonet --xinclude \
    816                  --stringparam server $SERVER \
    817                  -o ../sources/urls.lst urls.xsl \
    818                  $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
    819         echo " ...OK"
    820       ;;
    821   esac
    822 
    823   cd $BUILDDIR/sources
    824 
    825   if [[ "${BLFS_TOOL}" = "y" ]]; then
    826     add_blfs_deps_urls
    827   fi
    828 
    829   if [[ "${CUSTOM_TOOLS}" = "y" ]]; then
    830     add_CustomToolsURLS
    831   fi
    832 
    833 }
    834 
    835 #----------------------------# Hardcoded URLs and MD5.
    836 add_blfs_deps_urls() {       # No easy way to extract it.
    837 #----------------------------# Some FTP mirrors may not work
    838 
    839   local BLFS_SERVER="${SERVER}/pub/blfs/conglomeration/"
    840 
    841   if [[ "${DEP_LIBXML}" = "y" ]] ; then
    842     echo "${LIBXML_URL} ${BLFS_SERVER}libxml2/${LIBXML_PKG} ${LIBXML_MD5}" >> urls.lst
    843   fi
    844 
    845   if [[ "${DEP_LIBXSLT}" = "y" ]] ; then
    846     echo "${LIBXSLT_URL} ${BLFS_SERVER}libxslt/${LIBXSLT_PKG} ${LIBXSLT_MD5}" >> urls.lst
    847   fi
    848 
    849   if [[ "${DEP_TIDY}" = "y" ]] ; then
    850     echo "${TIDY_URL} ${BLFS_SERVER}tidy/${TIDY_PKG} ${TIDY_MD5}" >> urls.lst
    851     echo "${TIDY_PATCH_URL} ${BLFS_SERVER}tidy/${TIDY_PATCH} ${TIDY_PATCH_MD5}" >> urls.lst
    852     echo "${TIDY_DOCS_URL} ${BLFS_SERVER}tidy/${TIDY_DOCS} ${TIDY_DOCS_MD5}" >> urls.lst
    853   fi
    854 
    855   if [[ "${DEP_UNZIP}" = "y" ]] ; then
    856     echo "${UNZIP_URL} ${BLFS_SERVER}unzip/${UNZIP_PKG} ${UNZIP_MD5}" >> urls.lst
    857   fi
    858 
    859   if [[ "${DEP_DBXML}" = "y" ]] ; then
    860     echo "${DBXML_URL} ${BLFS_SERVER}docbook-xml/${DBXML_PKG} ${DBXML_MD5}" >> urls.lst
    861   fi
    862 
    863   if [[ "${DEP_DBXSL}" = "y" ]] ; then
    864     echo "${DBXSL_URL} ${BLFS_SERVER}docbook-xsl/${DBXSL_PKG} ${DBXSL_MD5}" >> urls.lst
    865   fi
    866 
    867   if [[ "${DEP_LINKS}" = "y" ]] ; then
    868     echo "${LINKS_URL} ${BLFS_SERVER}links/${LINKS_PKG} ${LINKS_MD5}" >> urls.lst
    869   fi
    870 
    871   if [[ "${DEP_SUDO}" = "y" ]] ; then
    872     echo "${SUDO_URL} ${BLFS_SERVER}sudo/${SUDO_PKG} ${SUDO_MD5}" >> urls.lst
    873     echo "${SUDO_PATCH_URL} ${BLFS_SERVER}sudo/${SUDO_PATCH} ${SUDO_PATCH_MD5}" >> urls.lst
    874   fi
    875 
    876   if [[ "${DEP_WGET}" = "y" ]] ; then
    877     echo "${WGET_URL} ${BLFS_SERVER}wget/${WGET_PKG} ${WGET_MD5}" >> urls.lst
    878   fi
    879 
    880   if [[ "${DEP_SVN}" = "y" ]] ; then
    881     echo "${SVN_URL} ${BLFS_SERVER}subversion/${SVN_PKG} ${SVN_MD5}" >> urls.lst
    882   fi
    883 
    884   if [[ "${DEP_GPM}" = "y" ]] ; then
    885     echo "${GPM_URL} ${BLFS_SERVER}gpm/${GPM_PKG} ${GPM_MD5}" >> urls.lst
    886     echo "${GPM_PATCH_1_URL} ${BLFS_SERVER}gpm/${GPM_PATCH_1} ${GPM_PATCH_1_MD5}" >> urls.lst
    887     echo "${GPM_PATCH_2_URL} ${BLFS_SERVER}gpm/${GPM_PATCH_2} ${GPM_PATCH_2_MD5}" >> urls.lst
    888   fi
    889 
    890 }
    891 
    892 #----------------------------# Maybe there is a better way to do this, but this
    893 copy_blfs_deps_scripts() {   # method avoid to place the test on all
    894 #----------------------------# $PROGNAME/master.sh scripts.
    895 
    896   mkdir -p ${PROGNAME}-commands/blfs-tool-deps
    897 
    898   if [[ "${DEP_LIBXML}" = "y" ]] ; then
    899     mv blfs-tool-deps/901-libxml2 ${PROGNAME}-commands/blfs-tool-deps
    900   fi
    901 
    902   if [[ "${DEP_LIBXSLT}" = "y" ]] ; then
    903     mv blfs-tool-deps/902-libxslt ${PROGNAME}-commands/blfs-tool-deps
    904   fi
    905 
    906   if [[ "${DEP_TIDY}" = "y" ]] ; then
    907     mv blfs-tool-deps/903-tidy ${PROGNAME}-commands/blfs-tool-deps
    908   fi
    909 
    910   if [[ "${DEP_UNZIP}" = "y" ]] ; then
    911     mv blfs-tool-deps/904-unzip ${PROGNAME}-commands/blfs-tool-deps
    912   fi
    913 
    914   if [[ "${DEP_DBXML}" = "y" ]] ; then
    915     mv blfs-tool-deps/905-docbook-xml ${PROGNAME}-commands/blfs-tool-deps
    916   fi
    917 
    918   if [[ "${DEP_DBXSL}" = "y" ]] ; then
    919     mv blfs-tool-deps/906-docbook-xsl ${PROGNAME}-commands/blfs-tool-deps
    920   fi
    921 
    922   if [[ "${DEP_LINKS}" = "y" ]] ; then
    923     mv blfs-tool-deps/908-links ${PROGNAME}-commands/blfs-tool-deps
    924   fi
    925 
    926   if [[ "${DEP_SUDO}" = "y" ]] ; then
    927     mv blfs-tool-deps/909-sudo ${PROGNAME}-commands/blfs-tool-deps
    928   fi
    929 
    930   if [[ "${DEP_WGET}" = "y" ]] ; then
    931     mv blfs-tool-deps/910-wget ${PROGNAME}-commands/blfs-tool-deps
    932   fi
    933 
    934   if [[ "${DEP_SVN}" = "y" ]] ; then
    935     mv blfs-tool-deps/911-subversion ${PROGNAME}-commands/blfs-tool-deps
    936   fi
    937 
    938   if [[ "${DEP_GPM}" = "y" ]] ; then
    939     mv blfs-tool-deps/907-gpm ${PROGNAME}-commands/blfs-tool-deps
    940   fi
    941 
    942   rm -rf blfs-tool-deps
    943 
    944 }
     97[[ $VERBOSITY2 > 0 ]] && echo -n "    ..."
  • jhalfs

    r47b363c rfe30c61  
    265265[[ $VERBOSITY > 0 ]] && echo "OK"
    266266
    267 [[ $VERBOSITY > 0 ]] && echo -n "Loading function <custom_pkgs>..."
    268 source $COMMON_DIR/libs/custom_pkgs
     267[[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_custom_pkgs>..."
     268source $COMMON_DIR/libs/func_custom_pkgs
    269269[[ $? > 0 ]] && echo " function module did not load.." && exit 2
    270270[[ $VERBOSITY > 0 ]] && echo "OK"
Note: See TracChangeset for help on using the changeset viewer.