BOOKMD5=`echo $line | cut -d" " -f3` # MD5 book value
# Validation pair
MD5="$BOOKMD5 $FILE"
HAVEMD5=1
set -e
# If the file exists in the archive copy it to the
# $BUILDDIR/sources dir. MD5SUM will be validated later.
if [ ! -z ${SRC_ARCHIVE} ] &&
[ -d ${SRC_ARCHIVE} ] &&
[ -f ${SRC_ARCHIVE}/$FILE ]; then
cp ${SRC_ARCHIVE}/$FILE .
echo "$FILE: -- copied from $SRC_ARCHIVE"
fromARCHIVE=1
else
echo "${BOLD}${YELLOW}$FILE: not found in ${SRC_ARCHIVE}${OFF}"
fromARCHIVE=0
# If the file does not exist yet in /sources download a fresh one
if [ ! -f $FILE ] ; then
if ! wget $URL1 && ! wget $URL2 ; then
gs_wrt_message "$FILE not found in the SRC_ARCHIVE or on any server..SKIPPING"
continue
fi
fi
fi
# IF the md5sum does not match the existing files
if ! echo "$MD5" | md5sum -c - >/dev/null ; then
[[ $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}"
# Remove the old file and download a new one
rm -fv $FILE
# Force storage in SRC_ARCHIVE
fromARCHIVE=0;
# Try to retrieve again the file. Servers in reverse order.
if ! wget $URL2 && ! wget $URL1 ; then
gs_wrt_message "$FILE not found on the servers.. SKIPPING"
continue
fi
fi
# Validate the MD5SUM one last time
if ! echo "$MD5" | md5sum -c - >/dev/null ; then
gs_wrt_message "$FILE does not match MD5SUMS value"
# Force generation of MD5SUM
HAVEMD5=0
fi
# Generate a fresh MD5SUM for this file
if [[ "$HAVEMD5" = "0" ]] ; then
echo "${BOLD}${YELLOW}Generating a new MD5SUM for ${OFF}$FILE"
echo "NEW MD5SUM: $(md5sum $FILE)" >> MISSING_FILES.DMP
fi
# Good or bad we write the original md5sum to a file
echo "$MD5" >> MD5SUMS
# Copy the freshly downloaded file
# to the source archive.
if [ ! -z ${SRC_ARCHIVE} ] &&
[ -d ${SRC_ARCHIVE} ] &&
[ -w ${SRC_ARCHIVE} ] &&
[ "$fromARCHIVE" = "0" ] ; then
echo "Storing file:<$FILE> in the package archive"
cp -f $FILE ${SRC_ARCHIVE}
fi
done
if [[ -s MISSING_FILES.DMP ]]; then
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"
# Do not allow the automatic execution of the Makefile.
echo "${tab_}${BOLD}${RED}*** ${YELLOW}Automatic execution of the generated makefile has been inhibited. ${RED}***${OFF}${nl_}"
RUNMAKE="n"
fi
}
#----------------------------#
create_urls() { #
#----------------------------#
cd $JHALFSDIR
case ${PROGNAME} in
clfs)
echo -n "Creating CLFS <${ARCH}> specific URLs file"