Ignore:
Timestamp:
05/01/2006 11:10:53 AM (18 years ago)
Author:
Manuel Canales Esparcia <manuel@…>
Branches:
experimental
Children:
65d83a6
Parents:
c58f330
Message:

Keeping sinchronized experimental branch with trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • common/common-functions

    rc58f330 r3e7af38  
    506506        development)
    507507           svn co $SVN/${svn_root}/trunk/BOOK ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
    508         alphabetical)
    509            svn co $SVN/${svn_root}/branches/$LFSVRS/BOOK ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
    510         udev_update)
    511            svn co $SVN/LFS/branches/$LFSVRS/BOOK lfs-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
    512508      esac
    513509      echo -ne "done\n"
     
    526522}
    527523
    528 
    529 #----------------------------#
    530 build_patches_file() {       # Supply a suitably formated list of patches.
    531 #----------------------------#
    532   local saveIFS=$IFS
    533   local IFS
    534 
    535   rm -f patches
    536 
    537   LOC_add_patches_entry() {
    538     for f in `grep "/$1-" patcheslist_.wget`; do
    539       basename $f | sed "s|${2}|\&${1}-version;|" >> patches
    540     done
    541   }
    542 
    543   case ${PROGNAME} in
    544     hlfs)
    545          echo -n "Creating the HLFS ${L_arrow}${BOLD}$MODEL${R_arrow} specific patches file"
    546          xsltproc --nonet \
    547                   --xinclude \
    548                   --stringparam model $MODEL \
    549                   -o patcheslist_.wget \
    550                   patcheslist.xsl \
    551                   $BOOK/chapter04/patches.xml
    552                   #> /dev/null 2>&1
    553 
    554          # .... U G L Y .... what to do with the grsecurity patch to the kernel..
    555          for f in `grep "/grsecurity-" patcheslist_.wget`; do
    556            basename $f >> patches
    557          done
    558       ;;
    559 
    560     clfs)  # Pull out a list of arch specific patches
    561          echo -n "Creating CLFS ${L_arrow}${BOLD}$ARCH${R_arrow} specific patches file"
    562          xsltproc -xinclude  \
    563                   -o patcheslist_.wget \
    564                   patcheslist.xsl \
    565                   $BOOK/materials/${ARCH}-chapter.xml
    566       ;;
    567     *)  return
    568   esac
    569 
    570 
    571   IFS=$'\x0A'  # Modify the 'internal field separator' to break on 'LF' only
    572   for f in `cat packages`; do
    573     IFS=$saveIFS  # Restore the system defaults
    574     LOC_add_patches_entry \
    575     `echo $f | sed -e 's/-version//' \
    576                    -e 's/-file.*//' \
    577                    -e 's/"//g' \
    578                    -e 's/uclibc/uClibc/'`
    579   done
    580 
    581   rm -f patcheslist_.wget
    582 
    583   echo " ...OK"
    584 }
    585 
    586 
    587524#----------------------------#
    588525extract_commands() {         #
    589526#----------------------------#
    590   local saveIFS=$IFS
    591527
    592528  # Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
     
    652588                 -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
    653589      ;;
    654     *) exit 1
     590    *) exit 1 ;;
    655591  esac
    656592
     
    660596  chmod -R +x $JHALFSDIR/${PROGNAME}-commands
    661597
    662   # Grab the patches and package names.
    663   for i in patches packages ; do
    664     rm -f $i
    665   done
    666   #
     598  # Create the packages file. We need it for proper Makefile creation
     599  rm -f packages
    667600  case "${PROGNAME}" in
    668601    clfs)
    669       ################################
    670       # A LOCAL function
    671       # xx_.wget contains arch specific files but in URL format
    672       # Build a file with only arch specific files.. small ugly..
    673       LOC_add_packages_entry() {
    674         local fileMATCH aFILE
    675 
    676           # Deal with a non-standard format
    677         if [[ "$1" = "clfs-bootscripts" ]]; then
    678           set -- "bootscripts-cross-lfs" $2
    679         fi
    680         fileMATCH="/$1"
    681 
    682         # format.. Filename-Version  or FilenameVersion
    683         for aFILE in `grep ${fileMATCH}-*[[:digit:]] packageslist_.wget`; do
    684          # Block vim-x.x-lang file, will add it later based on config flag
    685          if [[ ! "${aFILE}" =~ "vim-$2-lang" ]]; then
    686            echo "$1-version \"$2\"" >> packages
    687          fi
    688         done
    689       }
    690       #################################
    691 
    692       # We only want a list arch specific files..
    693       # Unfortunately this script produces URL's which must be converted to a std format
    694       echo -n "Creating CLFS ${L_arrow}${BOLD}${ARCH}${R_arrow} specific packages file"
    695       xsltproc -xinclude  \
    696                -o packageslist_.wget \
    697                packageslist.xsl \
    698                $BOOK/materials/${ARCH}-chapter.xml
    699 
    700       # This has the correct format but contains packages from every book
     602      echo -n "Creating <${PROGNAME}> specific packages file"
    701603      grep "\-version " $BOOK/packages.ent | sed -e 's@<!ENTITY @@' \
    702604                                                 -e 's@">@"@' \
    703                                                  -e '/generic/d' > packages.tmp
    704       # This variable is necessary to make sure the `cat $JHALFSDIR/packages`
    705       # separates each iteration by lines.
    706       # Modify the 'internal field separator' to break on 'LF' only
    707       IFS=$'\x0A'
    708       for f in `cat packages.tmp`; do
    709         IFS=$saveIFS  # Restore the system defaults
    710         LOC_add_packages_entry \
    711         `echo $f | sed -e 's/-version//' \
    712                        -e 's/-file.*//' \
    713                        -e 's/"//g'`
    714      done
    715 
    716      rm -f packageslist_.wget packages.tmp
    717 
     605                                                 -e '/generic/d' > packages
    718606     echo " ...OK"
    719607     ;;
     
    732620                                               -e 's@">@"@' \
    733621                                               -e '/generic/d' >> packages
    734       echo `grep "glibc" packages | sed 's@glibc@glibc-libidn@'` >> packages
    735       echo `grep "udev-config-file" $BOOK/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@'` >> packages
    736622      echo " ...OK"
    737623      ;;
    738   esac
    739 
    740   # Download the vim-lang package if it must be installed
    741   if [ "$VIMLANG" = "1" ] && [ ! "$PROGNAME" = "hlfs" ] ; then
    742     echo `grep "vim" packages | sed 's@vim@&-lang@'` >> packages
    743   fi
    744 
    745   # Create the patches file
    746   case "${PROGNAME}" in
    747     hlfs)
    748       build_patches_file ;;
    749     clfs )
    750       build_patches_file ;;
    751     lfs)
    752       grep "^<\!ENTITY" $BOOK/patches.ent | sed -e 's/.* "//' -e 's/">//' >> patches
    753       ;;
    754     blfs) ;;
    755     *) exit 1
    756624  esac
    757625
     
    762630
    763631#----------------------------#
    764 download() {                 # Download file, write name to MISSING_FILES.DMP if an error
    765 #----------------------------#
    766   cd $BUILDDIR/sources
    767 
    768   # Hackish fix for the bash-doc, glibc-{linuxthreads,libidn}
    769   # that don't conform to norms in the URL scheme.
    770   DIR=`echo $1 | sed 's@-doc@@;s@-linuxthreads@@;s@-libidn@@;s@-testsuite@@'`
    771 
    772   # If the file exists in the archive copy it to the $BUILDDIR/sources dir
    773   # MD5SUM is assumed to be correct from previous download
    774   if [ ! -z ${SRC_ARCHIVE} ] &&
    775      [   -d ${SRC_ARCHIVE} ] &&
    776      [   -f ${SRC_ARCHIVE}/$2 ]; then
    777     cp ${SRC_ARCHIVE}/$2 .
    778     echo "$2: -- ok"
    779     return
    780   fi
    781 
    782   # Find the md5 sum for this package.
    783   if [ $2 != MD5SUMS ] ; then
    784     set +e
    785     MD5=`grep "  $2" MD5SUMS`
    786     if [ $? -ne 0 ]; then
    787       set -e
    788       echo "${RED}$2 not found in MD5SUMS${OFF}"
    789       echo "$2 not found in MD5SUMS" >> MISSING_FILES.DMP
    790       return
     632get_sources() {              # Download file, write name to MISSING_FILES.DMP if an error
     633#----------------------------#
     634  local saveIFS=$IFS
     635  local IFS line URL1 URL2 FILE MD5
     636
     637  # Test if the packages must be downloaded
     638  if [ "$GETPKG" = "1" ] ; then
     639
     640    [[ ! -d $BUILDDIR/sources ]] && mkdir $BUILDDIR/sources
     641    cd $BUILDDIR/sources
     642    [[ -f MD5SUMS ]] && rm MD5SUMS
     643    [[ -f MD5SUMS-$VERSION ]] && rm MD5SUMS-$VERSION
     644    [[ -f MISSING_FILES.DMP ]] && rm MISSING_FILES.DMP
     645    [[ -f urls.lst ]] && rm urls.lst
     646
     647    # Download a fresh MD5SUMS file
     648    wget $SERVER/pub/lfs/conglomeration/MD5SUMS
     649
     650    # Generate URLs file
     651    create_urls
     652
     653    IFS=$'\x0A'  # Modify the 'internal field separator' to break on 'LF' only
     654    for line in `cat urls.lst`; do
     655      IFS=$saveIFS  # Restore the system defaults
     656
     657      # Skip some packages if they aren't needed
     658      case $line in
     659        */tcl* | */expect* | */dejagnu* | */tree* | */gcc-testsuite* )
     660            [[ "$TEST" = "0" ]] && continue
     661          ;;
     662        */vim-*-lang* )
     663            [[ "$VIMLANG" = "0" ]] && continue
     664          ;;
     665      esac
     666
     667      URL1=`echo $line | cut -d" " -f1` # Upstream URL
     668      URL2=`echo $line | cut -d" " -f2` # Fallback URL
     669      FILE=`basename $URL2` # File name
     670
     671      # If the file exists in the archive copy it to the $BUILDDIR/sources dir
     672      # MD5SUM is assumed to be correct from previous download
     673      if [ ! -z ${SRC_ARCHIVE} ] &&
     674         [ -d ${SRC_ARCHIVE} ] &&
     675         [ -f ${SRC_ARCHIVE}/$FILE ]; then
     676        cp ${SRC_ARCHIVE}/$FILE .
     677        echo "$FILE: -- copied from $SRC_ARCHIVE"
     678      fi
     679
     680      # Find the md5 sum for this package.
     681      set +e
     682      MD5=`grep "  $FILE" MD5SUMS`
     683      if [ $? -ne 0 ]; then
     684        set -e
     685        echo "${RED}$FILE not found in MD5SUMS${OFF}"
     686        echo "$FILE not found in MD5SUMS" >> MISSING_FILES.DMP
    791687      fi
    792688      set -e
     689
     690      if [ ! -f $FILE ] ; then
     691        wget $URL1 || wget $URL2
     692      elif ! echo "$MD5" | md5sum -c - >/dev/null 2>/dev/null ; then
     693        wget -N $URL1 || wget -N $URL2
     694      fi
     695
     696      if ! echo "$MD5" | md5sum -c - ; then
     697        echo "${RED}$FILE not match MD5SUMS value${OFF}"
     698        echo "$FILE not match MD5SUMS value" >> MISSING_FILES.DMP
     699      fi
     700      echo `grep "$MD5" MD5SUMS` >> MD5SUMS-$VERSION
     701
     702      # Copy the freshly downloaded file
     703      # to the source archive.
     704      if [ ! -z ${SRC_ARCHIVE} ] &&
     705         [ -d ${SRC_ARCHIVE} ] &&
     706         [ -w ${SRC_ARCHIVE} ] &&
     707         [ ! -f ${SRC_ARCHIVE}/$FILE ] ; then
     708        echo "Store file:<$FILE> in package archive"
     709        cp -v $FILE ${SRC_ARCHIVE}
     710      fi
     711
     712    done
     713
     714    if [[ -s MISSING_FILES.DMP ]]; then
     715      echo  -e "\n\n${tab_}${RED} One or more files were not retrieved or have a bad MD5SUMS chechsum.\n${tab_} Check ${L_arrow}$BUILDDIR/sources/MISSING_FILES.DMP${R_arrow} for names ${OFF}\n\n"
     716    fi
     717
    793718  fi
    794 
    795   if [ ! -f $2 ] ; then
    796     case $DL in
    797       wgetFTP )  wget --passive $FTP/$DIR/$2            ;;
    798       wget )  wget $HTTP/$DIR/$2            ;;
    799       curl )  `curl -# $FTP/$DIR/$2 -o $2`     ;;
    800       * )     echo "$DL not supported at this time."  ;;
    801     esac
    802   elif ! echo "$MD5" | md5sum -c - >/dev/null 2>/dev/null ; then
    803     case $DL in
    804       wgetFTP )  wget --passive -c $FTP/$DIR/$2         ;;
    805       wget )   wget -c $HTTP/$DIR/$2            ;;
    806       curl )  `curl -# -C - $FTP/$DIR/$2 -o $2`    ;;
    807       * )     echo "$DL not supported at this time."  ;;
    808     esac
    809   fi
    810 
    811   if [ $2 != MD5SUMS ] && ! echo "$MD5" | md5sum -c - ; then
    812     exit 1
    813   fi
    814   if [ $2 != MD5SUMS ] ; then
    815     echo `grep "$MD5" MD5SUMS` >> MD5SUMS-$VERSION
    816   fi
    817 
    818   # If we make it this far we should copy the freshly downloaded file
    819   # to the source archive.
    820   if [ ! -z ${SRC_ARCHIVE} ] &&
    821      [   -d ${SRC_ARCHIVE} ] &&
    822      [   -w ${SRC_ARCHIVE} ] &&
    823      [ $2 != MD5SUMS ]; then
    824        echo "Store file:<$2> in package archive"
    825        cp -v $2 ${SRC_ARCHIVE}
    826   fi
    827 
    828 }
    829 
    830 
    831 #----------------------------#
    832 get_sources() {
    833 #----------------------------#
    834 
    835   # Test if the packages must be downloaded
    836   if [ "$HPKG" = "1" ] ; then
    837 
    838     # This variable is necessary to make sure the `cat $JHALFSDIR/packages`
    839     # separates each iteration by lines.
    840     # Modify the 'internal field separator' to break on 'LF' only
    841     IFS=$'\x0A'
    842 
    843     if [ ! -d $BUILDDIR/sources ] ; then mkdir $BUILDDIR/sources ; fi
    844     cd $BUILDDIR/sources
    845     if [ -f MD5SUMS ] ; then rm MD5SUMS ; fi
    846     if [ -f MD5SUMS-$VERSION ] ; then rm MD5SUMS-$VERSION ; fi
    847     if [ -f MISSING_FILES.DMP ] ; then rm MISSING_FILES.DMP ; fi
    848 
    849     download "" MD5SUMS
    850 
    851     # Iterate through each package and grab it, along with any patches it needs.
    852     for i in `cat $JHALFSDIR/packages` ; do
    853       PKG=`echo $i | sed -e 's/-version.*//' -e 's/-file.*//'`
    854 
    855       # There are some entities that aren't valid packages.
    856       if [ "$PKG" = "expect-lib" -o "$PKG" = "linux-dl" ] ; then continue ; fi
    857 
    858       VRS=`echo $i | sed -e 's/.* //' -e 's/"//g'`
    859       case $PKG in
    860         tcl)         FILE="$PKG$VRS-src.tar.bz2"  ;;
    861         vim-lang)    PKG="vim"
    862                      FILE="vim-$VRS-lang.tar.bz2" ;;
    863         udev-config) PKG="udev"
    864                      FILE="$VRS"                  ;;
    865         *)           FILE="$PKG-$VRS.tar.bz2"     ;;
    866       esac
    867       download $PKG $FILE
    868 
    869       # Download any associated patches
    870       for patch in `grep "&$PKG-version" $JHALFSDIR/patches` ; do
    871         PATCH=`echo $patch | sed 's@&'$PKG'-version;@'$VRS'@'`
    872         download $PKG $PATCH
    873       done
    874     done
    875     if [[ -s $BUILDDIR/sources/MISSING_FILES.DMP ]]; then
    876       echo  -e "\n\n${tab_}${RED} One or more files were not retrieved.\n${tab_} Check ${L_arrow}$BUILDDIR/sources/MISSING_FILES.DMP${R_arrow} for names ${OFF}\n\n"
    877     fi
    878   fi
    879 }
    880 
     719}
     720
     721
     722#----------------------------#
     723create_urls() {              #
     724#----------------------------#
     725  cd $JHALFSDIR
     726
     727  case ${PROGNAME} in
     728    clfs)
     729        echo -n "Creating CLFS <${ARCH}> specific URLs file"
     730        xsltproc --nonet --xinclude \
     731                 --stringparam server $SERVER \
     732                 -o $BUILDDIR/sources/urls.lst urls.xsl \
     733                 $BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
     734        echo " ...OK"
     735      ;;
     736    hlfs)
     737        echo -n "Creating HLFS <${MODEL}> specific URLs file"
     738        xsltproc --nonet --xinclude \
     739                 --stringparam server $SERVER \
     740                 --stringparam model $MODEL \
     741                 -o $BUILDDIR/sources/urls.lst urls.xsl \
     742                 $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
     743        echo " ...OK"
     744      ;;
     745    lfs)
     746        echo -n "Creating LFS specific URLs file"
     747        xsltproc --nonet --xinclude \
     748                 --stringparam server $SERVER \
     749                 -o ../sources/urls.lst urls.xsl \
     750                 $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
     751        echo " ...OK"
     752      ;;
     753  esac
     754
     755  cd $BUILDDIR/sources
     756}
Note: See TracChangeset for help on using the changeset viewer.