[fe30c61] | 1 | #!/bin/bash
|
---|
| 2 |
|
---|
| 3 | # $Id$
|
---|
| 4 |
|
---|
| 5 |
|
---|
| 6 | #----------------------------#
|
---|
| 7 | get_sources() { # Download file, write name to MISSING_FILES.DMP if an error
|
---|
| 8 | #----------------------------#
|
---|
| 9 | local saveIFS=$IFS
|
---|
| 10 | local IFS line URL1 URL2 FILE BOOKMD5 MD5 HAVEMD5 fromARCHIVE
|
---|
| 11 |
|
---|
| 12 | # Test if the packages must be downloaded
|
---|
| 13 | [ ! "$GETPKG" = "y" ] && return
|
---|
| 14 |
|
---|
| 15 | gs_wrt_message(){
|
---|
| 16 | echo "${RED}$1${OFF}"
|
---|
| 17 | echo "$1" >> MISSING_FILES.DMP
|
---|
| 18 | }
|
---|
| 19 | # Housekeeping
|
---|
| 20 | [[ ! -d $BUILDDIR/sources ]] && mkdir $BUILDDIR/sources
|
---|
| 21 | cd $BUILDDIR/sources
|
---|
| 22 | [[ -f MD5SUMS ]] && rm MD5SUMS
|
---|
| 23 | [[ -f MISSING_FILES.DMP ]] && rm MISSING_FILES.DMP
|
---|
| 24 | [[ -f urls.lst ]] && rm urls.lst
|
---|
| 25 |
|
---|
| 26 | # Generate URLs file
|
---|
| 27 | create_urls
|
---|
| 28 |
|
---|
| 29 | IFS=$'\x0A' # Modify the 'internal field separator' to break on 'LF' only
|
---|
| 30 | for line in `cat urls.lst`; do
|
---|
| 31 | IFS=$saveIFS # Restore the system defaults
|
---|
| 32 |
|
---|
| 33 | # Skip some packages if they aren't needed
|
---|
| 34 | case $line in
|
---|
| 35 | */tcl* | */expect* | */dejagnu* | */tree* | */gcc-testsuite* )
|
---|
| 36 | [[ "$TEST" = "0" ]] && continue
|
---|
| 37 | ;;
|
---|
| 38 | */vim-*-lang* )
|
---|
| 39 | [[ "$VIMLANG" = "0" ]] && continue
|
---|
| 40 | ;;
|
---|
| 41 | *linux/linux-* )
|
---|
| 42 | [[ -z "$CONFIG" ]] && [[ -z "$BOOT_CONFIG" ]] && \
|
---|
| 43 | [[ "$GETKERNEL" = "n" ]] && continue
|
---|
| 44 | ;;
|
---|
| 45 | esac
|
---|
| 46 |
|
---|
| 47 | # Locations
|
---|
| 48 | URL1=`echo $line | cut -d" " -f2` # Preferred URL
|
---|
| 49 | URL2=`echo $line | cut -d" " -f1` # Fallback Upstream URL
|
---|
| 50 | FILE=`basename $URL1` # File name
|
---|
| 51 | BOOKMD5=`echo $line | cut -d" " -f3` # MD5 book value
|
---|
| 52 |
|
---|
| 53 | # Validation pair
|
---|
| 54 | MD5="$BOOKMD5 $FILE"
|
---|
| 55 | HAVEMD5=1
|
---|
| 56 |
|
---|
| 57 | set -e
|
---|
| 58 | # If the file exists in the archive copy it to the
|
---|
| 59 | # $BUILDDIR/sources dir. MD5SUM will be validated later.
|
---|
| 60 | if [ ! -z ${SRC_ARCHIVE} ] &&
|
---|
| 61 | [ -d ${SRC_ARCHIVE} ] &&
|
---|
| 62 | [ -f ${SRC_ARCHIVE}/$FILE ]; then
|
---|
| 63 | cp ${SRC_ARCHIVE}/$FILE .
|
---|
| 64 | echo "$FILE: -- copied from $SRC_ARCHIVE"
|
---|
| 65 | fromARCHIVE=1
|
---|
| 66 | else
|
---|
| 67 | echo "${BOLD}${YELLOW}$FILE: not found in ${SRC_ARCHIVE}${OFF}"
|
---|
| 68 | fromARCHIVE=0
|
---|
| 69 | # If the file does not exist yet in /sources download a fresh one
|
---|
| 70 | if [ ! -f $FILE ] ; then
|
---|
| 71 | if ! wget $URL1 && ! wget $URL2 ; then
|
---|
| 72 | gs_wrt_message "$FILE not found in the SRC_ARCHIVE or on any server..SKIPPING"
|
---|
| 73 | continue
|
---|
| 74 | fi
|
---|
| 75 | fi
|
---|
| 76 | fi
|
---|
| 77 |
|
---|
| 78 | # IF the md5sum does not match the existing files
|
---|
| 79 | if ! echo "$MD5" | md5sum -c - >/dev/null ; then
|
---|
| 80 | [[ $fromARCHIVE = "1" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match SRC_ARCHIVE copy${OFF}"
|
---|
| 81 | [[ $fromARCHIVE = "0" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match REMOTE copy${OFF}"
|
---|
| 82 | # Remove the old file and download a new one
|
---|
| 83 | rm -fv $FILE
|
---|
| 84 | # Force storage in SRC_ARCHIVE
|
---|
| 85 | fromARCHIVE=0;
|
---|
| 86 | # Try to retrieve again the file. Servers in reverse order.
|
---|
| 87 | if ! wget $URL2 && ! wget $URL1 ; then
|
---|
| 88 | gs_wrt_message "$FILE not found on the servers.. SKIPPING"
|
---|
| 89 | continue
|
---|
| 90 | fi
|
---|
| 91 | fi
|
---|
| 92 |
|
---|
| 93 | # Validate the MD5SUM one last time
|
---|
| 94 | if ! echo "$MD5" | md5sum -c - >/dev/null ; then
|
---|
| 95 | gs_wrt_message "$FILE does not match MD5SUMS value"
|
---|
| 96 | # Force generation of MD5SUM
|
---|
| 97 | HAVEMD5=0
|
---|
| 98 | fi
|
---|
| 99 |
|
---|
| 100 | # Generate a fresh MD5SUM for this file
|
---|
| 101 | if [[ "$HAVEMD5" = "0" ]] ; then
|
---|
| 102 | echo "${BOLD}${YELLOW}Generating a new MD5SUM for ${OFF}$FILE"
|
---|
| 103 | echo "NEW MD5SUM: $(md5sum $FILE)" >> MISSING_FILES.DMP
|
---|
| 104 | fi
|
---|
| 105 |
|
---|
| 106 | # Good or bad we write the original md5sum to a file
|
---|
| 107 | echo "$MD5" >> MD5SUMS
|
---|
| 108 |
|
---|
| 109 | # Copy the freshly downloaded file
|
---|
| 110 | # to the source archive.
|
---|
| 111 | if [ ! -z ${SRC_ARCHIVE} ] &&
|
---|
| 112 | [ -d ${SRC_ARCHIVE} ] &&
|
---|
| 113 | [ -w ${SRC_ARCHIVE} ] &&
|
---|
| 114 | [ "$fromARCHIVE" = "0" ] ; then
|
---|
| 115 | echo "Storing file:<$FILE> in the package archive"
|
---|
| 116 | cp -f $FILE ${SRC_ARCHIVE}
|
---|
| 117 | fi
|
---|
| 118 |
|
---|
| 119 | done
|
---|
| 120 |
|
---|
| 121 | if [[ -s MISSING_FILES.DMP ]]; then
|
---|
| 122 | 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"
|
---|
| 123 | # Do not allow the automatic execution of the Makefile.
|
---|
| 124 | echo "${tab_}${BOLD}${RED}*** ${YELLOW}Automatic execution of the generated makefile has been inhibited. ${RED}***${OFF}${nl_}"
|
---|
| 125 | RUNMAKE="n"
|
---|
| 126 | fi
|
---|
| 127 | }
|
---|
| 128 |
|
---|
| 129 | #----------------------------#
|
---|
| 130 | create_urls() { #
|
---|
| 131 | #----------------------------#
|
---|
| 132 | cd $JHALFSDIR
|
---|
| 133 |
|
---|
| 134 | case ${PROGNAME} in
|
---|
| 135 | clfs)
|
---|
| 136 | echo -n "Creating CLFS <${ARCH}> specific URLs file"
|
---|
| 137 | xsltproc --nonet --xinclude \
|
---|
| 138 | --stringparam server $SERVER \
|
---|
[a9ca77f] | 139 | --stringparam family clfs \
|
---|
[fe30c61] | 140 | -o $BUILDDIR/sources/urls.lst urls.xsl \
|
---|
| 141 | $BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 142 | echo " ...OK"
|
---|
| 143 | ;;
|
---|
| 144 | clfs2)
|
---|
| 145 | echo -n "Creating CLFS2 <${ARCH}> specific URLs file"
|
---|
| 146 | xsltproc --nonet --xinclude \
|
---|
| 147 | --stringparam server $SERVER \
|
---|
[a9ca77f] | 148 | --stringparam family clfs \
|
---|
[fe30c61] | 149 | -o $BUILDDIR/sources/urls.lst urls.xsl \
|
---|
| 150 | $BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 151 | echo " ...OK"
|
---|
| 152 | ;;
|
---|
| 153 | clfs3)
|
---|
| 154 | echo -n "Creating CLFS3 <${ARCH}> specific URLs file"
|
---|
| 155 | xsltproc --nonet --xinclude \
|
---|
| 156 | --stringparam server $SERVER \
|
---|
[a9ca77f] | 157 | --stringparam family clfs \
|
---|
[fe30c61] | 158 | -o $BUILDDIR/sources/urls.lst urls.xsl \
|
---|
| 159 | $BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 160 | echo " ...OK"
|
---|
| 161 | ;;
|
---|
| 162 | hlfs)
|
---|
| 163 | echo -n "Creating HLFS <${MODEL}> specific URLs file"
|
---|
| 164 | xsltproc --nonet --xinclude \
|
---|
| 165 | --stringparam server $SERVER \
|
---|
[a9ca77f] | 166 | --stringparam family lfs \
|
---|
[fe30c61] | 167 | --stringparam model $MODEL \
|
---|
| 168 | -o $BUILDDIR/sources/urls.lst urls.xsl \
|
---|
| 169 | $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 170 | echo " ...OK"
|
---|
| 171 | ;;
|
---|
| 172 | lfs)
|
---|
| 173 | echo -n "Creating LFS specific URLs file"
|
---|
| 174 | xsltproc --nonet --xinclude \
|
---|
| 175 | --stringparam server $SERVER \
|
---|
[a9ca77f] | 176 | --stringparam family lfs \
|
---|
[fe30c61] | 177 | -o ../sources/urls.lst urls.xsl \
|
---|
| 178 | $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 179 | echo " ...OK"
|
---|
| 180 | ;;
|
---|
| 181 | esac
|
---|
| 182 |
|
---|
| 183 | cd $BUILDDIR/sources
|
---|
| 184 |
|
---|
| 185 | if [[ "${BLFS_TOOL}" = "y" ]]; then
|
---|
| 186 | add_blfs_deps_urls
|
---|
| 187 | fi
|
---|
| 188 |
|
---|
| 189 | if [[ "${CUSTOM_TOOLS}" = "y" ]]; then
|
---|
| 190 | add_CustomToolsURLS
|
---|
| 191 | fi
|
---|
| 192 |
|
---|
| 193 | }
|
---|
| 194 |
|
---|