Changeset dc53def


Ignore:
Timestamp:
05/07/2022 09:25:43 AM (2 years ago)
Author:
Pierre Labastie <pierre.labastie@…>
Branches:
ablfs-more, trunk
Children:
6df52e8
Parents:
88e5cbc
Message:

Only use upstream URL when downloading packages

Also fix typos and shell programming. Use "cat file | while read"
instead of a complicated construct for reading only lines and then
breaking lines into their fields... Fix a TODO item

File:
1 edited

Legend:

Unmodified
Added
Removed
  • common/libs/func_download_pkgs

    r88e5cbc rdc53def  
    66
    77    # Test if the packages must be downloaded
    8   [ ! "$GETPKG" = "y" ] && return
     8  [ "$GETPKG" = y ] || return
    99
    10   local saveIFS=$IFS
    11   local IFS line URL1 URL2 FILE BOOKMD5 MD5 HAVEMD5 fromARCHIVE WGETPARAM
     10  local URL FILE BOOKMD5 MD5 HAVEMD5 fromARCHIVE WGETPARAM MAYBEMORE
    1211
    1312  WGETPARAM=""
     
    3231  >MISSING_FILES.DMP
    3332
    34   IFS=$'\x0A'  # Modify the 'internal field separator' to break on 'LF' only
    35   for line in `cat urls.lst`; do
    36     IFS=$saveIFS  # Restore the system defaults
    37 
    38       # Locations
    39     URL1=`echo $line | cut -d" " -f2` # Preferred URL
    40     URL2=`echo $line | cut -d" " -f1` # Fallback Upstream URL
    41     FILE=`basename $URL1` # File name
    42     BOOKMD5=`echo $line | cut -d" " -f3` # MD5 book value
     33    # Normally, urls.lst contains lines with two fields:
     34    # <package url> <book md5>, but
     35    # if a custom patch has an md5, there is a third field
     36    # on the line, due to the way add_CustomToolsURLS works.
     37  cat urls.lst | while read URL BOOKMD5 MAYBEMORE; do
     38    FILE=$(basename "$URL") # File name
    4339
    4440      # Validation pair
     
    4743
    4844    set -e
    49       # If the file exists in the archive copy it to the
     45      # If the file exists in the archive, copy it to the
    5046      # $BUILDDIR/sources dir. MD5SUM will be validated later.
    51     if [ ! -z ${SRC_ARCHIVE} ] &&
    52        [   -d ${SRC_ARCHIVE} ] &&
    53        [   -f ${SRC_ARCHIVE}/$FILE ]; then
    54       cp ${SRC_ARCHIVE}/$FILE .
     47    if [ -n "${SRC_ARCHIVE}" ] &&
     48       [ -d "${SRC_ARCHIVE}" ] &&
     49       [ -f "${SRC_ARCHIVE}/$FILE" ]; then
     50      cp "${SRC_ARCHIVE}/$FILE" .
    5551      echo "$FILE: -- copied from $SRC_ARCHIVE"
    5652      fromARCHIVE=1
    5753    else
    5854      fromARCHIVE=0
    59       # If the file does not exist yet in /sources download a fresh one
    60       if [ ! -f $FILE ] ; then
    61         if [[ ! ("$SRC_ARCHIVE" = "") ]] ; then
    62           echo "${BOLD}${YELLOW}$FILE: not found in ${SRC_ARCHIVE} or ${BUILDDIR}/sources${OFF}"
     55      # If the file does not exist yet in /sources, download a fresh one
     56      if [ ! -f "$FILE" ] ; then
     57        if [ -n "$SRC_ARCHIVE" ] ; then
     58          echo "${BOLD}${YELLOW}$FILE: not found in ${SRC_ARCHIVE} nor in ${BUILDDIR}/sources${OFF}"
    6359        else
    6460          echo "${BOLD}${YELLOW}$FILE: not found in ${BUILDDIR}/sources${OFF}"
    6561        fi
    66         if ! wget $URL1 $WGETPARAM && ! wget $URL2 $WGETPARAM ; then
    67           gs_wrt_message "$FILE not found in the SRC_ARCHIVE or on any server..SKIPPING"
     62        if ! wget "$URL" "$WGETPARAM"; then
     63          gs_wrt_message "$FILE not found on any server..SKIPPING"
    6864          continue
    6965        fi
     
    7369    fi
    7470
    75     # Deal with udev and bootscripts m5sum issue
    76     [[ $BOOKMD5 = "BOOTSCRIPTS-MD5SUM" ]]    && continue
    77     [[ $BOOKMD5 = "UDEV-MD5SUM" ]]           && continue
    78     [[ $BOOKMD5 = "LFS-NETSCRIPTS-MD5SUM" ]] && continue
    79     [[ $BOOKMD5 = "CUSTOM-PATCH-MD5SUM" ]]   && continue
     71    # Deal with bootscripts md5sum issue,
     72    # or skip if it is a custom patch without md5
     73    [ $BOOKMD5 = "BOOTSCRIPTS-MD5SUM"  ] && continue
     74    [ $BOOKMD5 = "CUSTOM-PATCH-MD5SUM" ] && continue
    8075
    81       # IF the md5sum does not match the existing files
     76      # IF the md5sum does not match
    8277    if ! echo "$MD5" | md5sum -c - >/dev/null ; then
    83       [[ $fromARCHIVE = "1" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match SRC_ARCHIVE copy${OFF}"
    84       [[ $fromARCHIVE = "0" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match REMOTE copy${OFF}"
     78      [ "$fromARCHIVE" = 1 ] && echo "${BOLD}${YELLOW}MD5SUM did not match $SRC_ARCHIVE copy${OFF}"
     79      [ "$fromARCHIVE" = 0 ] && echo "${BOLD}${YELLOW}MD5SUM did not match REMOTE copy${OFF}"
    8580        # Remove the old file and download a new one
    86       rm -fv $FILE
     81      rm -fv "$FILE"
    8782        # Force storage in SRC_ARCHIVE
    8883      fromARCHIVE=0;
    89         # Try to retrieve again the file. Servers in reverse order.
    90       if ! wget $URL2 $WGETPARAM && ! wget $URL1 $WGETPARAM ; then
    91         gs_wrt_message "$FILE not found on the servers.. SKIPPING"
     84        # Try to retrieve again the file.
     85      if ! wget "$URL" "$WGETPARAM"; then
     86        gs_wrt_message "$FILE not found on the server... SKIPPING"
    9287        continue
    9388      fi
     
    10297
    10398      # Generate a fresh MD5SUM for this file
    104     if [[ "$HAVEMD5" = "0" ]] ; then
     99    if [ "$HAVEMD5" = "0" ] ; then
    105100      echo "${BOLD}${YELLOW}Generating a new MD5SUM for ${OFF}$FILE"
    106101      echo "NEW MD5SUM: $(md5sum $FILE)" >> MISSING_FILES.DMP
     
    112107     # Copy the freshly downloaded file
    113108     # to the source archive.
    114    if [ ! -z ${SRC_ARCHIVE}  ] &&
    115       [   -d ${SRC_ARCHIVE}  ] &&
    116       [   -w ${SRC_ARCHIVE}  ] &&
    117       [ ! -f ${SRC_ARCHIVE}/$FILE ] &&
    118       [ "$fromARCHIVE" = "0" ] ; then
     109   if [ -n "${SRC_ARCHIVE}"  ] &&
     110      [ -d "${SRC_ARCHIVE}"  ] &&
     111      [ -w "${SRC_ARCHIVE}"  ] &&
     112      [ ! -f "${SRC_ARCHIVE}/$FILE" ] &&
     113      [ "$fromARCHIVE" = 0 ] ; then
    119114        echo "Storing file:<$FILE> in the package archive"
    120         cp -f $FILE ${SRC_ARCHIVE}
     115        cp -f "$FILE" "${SRC_ARCHIVE}"
    121116   fi
    122117
Note: See TracChangeset for help on using the changeset viewer.