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
This commit is contained in:
parent
88e5cbc258
commit
dc53def3ee
1 changed files with 37 additions and 42 deletions
|
@ -5,10 +5,9 @@ get_sources() { # Download file, write name to MISSING_FILES.DMP if
|
||||||
#----------------------------#
|
#----------------------------#
|
||||||
|
|
||||||
# Test if the packages must be downloaded
|
# Test if the packages must be downloaded
|
||||||
[ ! "$GETPKG" = "y" ] && return
|
[ "$GETPKG" = y ] || return
|
||||||
|
|
||||||
local saveIFS=$IFS
|
local URL FILE BOOKMD5 MD5 HAVEMD5 fromARCHIVE WGETPARAM MAYBEMORE
|
||||||
local IFS line URL1 URL2 FILE BOOKMD5 MD5 HAVEMD5 fromARCHIVE WGETPARAM
|
|
||||||
|
|
||||||
WGETPARAM=""
|
WGETPARAM=""
|
||||||
if [[ "${RETRYSRCDOWNLOAD}" = "y" ]] ; then
|
if [[ "${RETRYSRCDOWNLOAD}" = "y" ]] ; then
|
||||||
|
@ -31,40 +30,37 @@ get_sources() { # Download file, write name to MISSING_FILES.DMP if
|
||||||
# Clean up leftovers from preceding attempts
|
# Clean up leftovers from preceding attempts
|
||||||
>MISSING_FILES.DMP
|
>MISSING_FILES.DMP
|
||||||
|
|
||||||
IFS=$'\x0A' # Modify the 'internal field separator' to break on 'LF' only
|
# Normally, urls.lst contains lines with two fields:
|
||||||
for line in `cat urls.lst`; do
|
# <package url> <book md5>, but
|
||||||
IFS=$saveIFS # Restore the system defaults
|
# if a custom patch has an md5, there is a third field
|
||||||
|
# on the line, due to the way add_CustomToolsURLS works.
|
||||||
# Locations
|
cat urls.lst | while read URL BOOKMD5 MAYBEMORE; do
|
||||||
URL1=`echo $line | cut -d" " -f2` # Preferred URL
|
FILE=$(basename "$URL") # File name
|
||||||
URL2=`echo $line | cut -d" " -f1` # Fallback Upstream URL
|
|
||||||
FILE=`basename $URL1` # File name
|
|
||||||
BOOKMD5=`echo $line | cut -d" " -f3` # MD5 book value
|
|
||||||
|
|
||||||
# Validation pair
|
# Validation pair
|
||||||
MD5="$BOOKMD5 $FILE"
|
MD5="$BOOKMD5 $FILE"
|
||||||
HAVEMD5=1
|
HAVEMD5=1
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
# If the file exists in the archive copy it to the
|
# If the file exists in the archive, copy it to the
|
||||||
# $BUILDDIR/sources dir. MD5SUM will be validated later.
|
# $BUILDDIR/sources dir. MD5SUM will be validated later.
|
||||||
if [ ! -z ${SRC_ARCHIVE} ] &&
|
if [ -n "${SRC_ARCHIVE}" ] &&
|
||||||
[ -d ${SRC_ARCHIVE} ] &&
|
[ -d "${SRC_ARCHIVE}" ] &&
|
||||||
[ -f ${SRC_ARCHIVE}/$FILE ]; then
|
[ -f "${SRC_ARCHIVE}/$FILE" ]; then
|
||||||
cp ${SRC_ARCHIVE}/$FILE .
|
cp "${SRC_ARCHIVE}/$FILE" .
|
||||||
echo "$FILE: -- copied from $SRC_ARCHIVE"
|
echo "$FILE: -- copied from $SRC_ARCHIVE"
|
||||||
fromARCHIVE=1
|
fromARCHIVE=1
|
||||||
else
|
else
|
||||||
fromARCHIVE=0
|
fromARCHIVE=0
|
||||||
# If the file does not exist yet in /sources download a fresh one
|
# If the file does not exist yet in /sources, download a fresh one
|
||||||
if [ ! -f $FILE ] ; then
|
if [ ! -f "$FILE" ] ; then
|
||||||
if [[ ! ("$SRC_ARCHIVE" = "") ]] ; then
|
if [ -n "$SRC_ARCHIVE" ] ; then
|
||||||
echo "${BOLD}${YELLOW}$FILE: not found in ${SRC_ARCHIVE} or ${BUILDDIR}/sources${OFF}"
|
echo "${BOLD}${YELLOW}$FILE: not found in ${SRC_ARCHIVE} nor in ${BUILDDIR}/sources${OFF}"
|
||||||
else
|
else
|
||||||
echo "${BOLD}${YELLOW}$FILE: not found in ${BUILDDIR}/sources${OFF}"
|
echo "${BOLD}${YELLOW}$FILE: not found in ${BUILDDIR}/sources${OFF}"
|
||||||
fi
|
fi
|
||||||
if ! wget $URL1 $WGETPARAM && ! wget $URL2 $WGETPARAM ; then
|
if ! wget "$URL" "$WGETPARAM"; then
|
||||||
gs_wrt_message "$FILE not found in the SRC_ARCHIVE or on any server..SKIPPING"
|
gs_wrt_message "$FILE not found on any server..SKIPPING"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
@ -72,23 +68,22 @@ get_sources() { # Download file, write name to MISSING_FILES.DMP if
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Deal with udev and bootscripts m5sum issue
|
# Deal with bootscripts md5sum issue,
|
||||||
[[ $BOOKMD5 = "BOOTSCRIPTS-MD5SUM" ]] && continue
|
# or skip if it is a custom patch without md5
|
||||||
[[ $BOOKMD5 = "UDEV-MD5SUM" ]] && continue
|
[ $BOOKMD5 = "BOOTSCRIPTS-MD5SUM" ] && continue
|
||||||
[[ $BOOKMD5 = "LFS-NETSCRIPTS-MD5SUM" ]] && continue
|
[ $BOOKMD5 = "CUSTOM-PATCH-MD5SUM" ] && continue
|
||||||
[[ $BOOKMD5 = "CUSTOM-PATCH-MD5SUM" ]] && continue
|
|
||||||
|
|
||||||
# IF the md5sum does not match the existing files
|
# IF the md5sum does not match
|
||||||
if ! echo "$MD5" | md5sum -c - >/dev/null ; then
|
if ! echo "$MD5" | md5sum -c - >/dev/null ; then
|
||||||
[[ $fromARCHIVE = "1" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match SRC_ARCHIVE copy${OFF}"
|
[ "$fromARCHIVE" = 1 ] && echo "${BOLD}${YELLOW}MD5SUM did not match $SRC_ARCHIVE copy${OFF}"
|
||||||
[[ $fromARCHIVE = "0" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match REMOTE copy${OFF}"
|
[ "$fromARCHIVE" = 0 ] && echo "${BOLD}${YELLOW}MD5SUM did not match REMOTE copy${OFF}"
|
||||||
# Remove the old file and download a new one
|
# Remove the old file and download a new one
|
||||||
rm -fv $FILE
|
rm -fv "$FILE"
|
||||||
# Force storage in SRC_ARCHIVE
|
# Force storage in SRC_ARCHIVE
|
||||||
fromARCHIVE=0;
|
fromARCHIVE=0;
|
||||||
# Try to retrieve again the file. Servers in reverse order.
|
# Try to retrieve again the file.
|
||||||
if ! wget $URL2 $WGETPARAM && ! wget $URL1 $WGETPARAM ; then
|
if ! wget "$URL" "$WGETPARAM"; then
|
||||||
gs_wrt_message "$FILE not found on the servers.. SKIPPING"
|
gs_wrt_message "$FILE not found on the server... SKIPPING"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -101,7 +96,7 @@ get_sources() { # Download file, write name to MISSING_FILES.DMP if
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Generate a fresh MD5SUM for this file
|
# Generate a fresh MD5SUM for this file
|
||||||
if [[ "$HAVEMD5" = "0" ]] ; then
|
if [ "$HAVEMD5" = "0" ] ; then
|
||||||
echo "${BOLD}${YELLOW}Generating a new MD5SUM for ${OFF}$FILE"
|
echo "${BOLD}${YELLOW}Generating a new MD5SUM for ${OFF}$FILE"
|
||||||
echo "NEW MD5SUM: $(md5sum $FILE)" >> MISSING_FILES.DMP
|
echo "NEW MD5SUM: $(md5sum $FILE)" >> MISSING_FILES.DMP
|
||||||
fi
|
fi
|
||||||
|
@ -111,13 +106,13 @@ get_sources() { # Download file, write name to MISSING_FILES.DMP if
|
||||||
|
|
||||||
# Copy the freshly downloaded file
|
# Copy the freshly downloaded file
|
||||||
# to the source archive.
|
# to the source archive.
|
||||||
if [ ! -z ${SRC_ARCHIVE} ] &&
|
if [ -n "${SRC_ARCHIVE}" ] &&
|
||||||
[ -d ${SRC_ARCHIVE} ] &&
|
[ -d "${SRC_ARCHIVE}" ] &&
|
||||||
[ -w ${SRC_ARCHIVE} ] &&
|
[ -w "${SRC_ARCHIVE}" ] &&
|
||||||
[ ! -f ${SRC_ARCHIVE}/$FILE ] &&
|
[ ! -f "${SRC_ARCHIVE}/$FILE" ] &&
|
||||||
[ "$fromARCHIVE" = "0" ] ; then
|
[ "$fromARCHIVE" = 0 ] ; then
|
||||||
echo "Storing file:<$FILE> in the package archive"
|
echo "Storing file:<$FILE> in the package archive"
|
||||||
cp -f $FILE ${SRC_ARCHIVE}
|
cp -f "$FILE" "${SRC_ARCHIVE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
Reference in a new issue