Also check just downloaded copies
This commit is contained in:
parent
44e9f5e369
commit
5f3686facb
@ -17,29 +17,42 @@ die() {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fetch_file() {
|
fetch_file() {
|
||||||
local URL=$1
|
local URL=$1
|
||||||
local DIGESTS=$2
|
local DIGEST=$2
|
||||||
|
|
||||||
FILE_NAME=$(basename ${URL})
|
FILE_NAME=$(basename ${URL})
|
||||||
# Check local cache
|
MD5=$(curl -s -S ${DIGEST} | grep -o -E -e "^[0-9a-f]{32}\s*${FILE_NAME}$" | awk '{print $1}')
|
||||||
|
|
||||||
|
if [ -z ${MD5} ]; then
|
||||||
|
die "Unable to get checksum for ${FILE_NAME}, abort"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Do we have local copy
|
||||||
if [ -f ${LOCAL_CACHE}/${FILE_NAME} ]; then
|
if [ -f ${LOCAL_CACHE}/${FILE_NAME} ]; then
|
||||||
# DIGISTS available ?
|
# if we have local, correct copy use it
|
||||||
if [ -n ${DIGESTS} ]; then
|
|
||||||
MD5=$(curl -s ${DIGESTS} | grep -o -E -e "^[0-9a-f]{32}\s*${FILE_NAME}$" | awk '{print $1}')
|
|
||||||
if [ $(md5sum ${LOCAL_CACHE}/${FILE_NAME} | awk '{print $1}') = ${MD5} ]; then
|
if [ $(md5sum ${LOCAL_CACHE}/${FILE_NAME} | awk '{print $1}') = ${MD5} ]; then
|
||||||
cp ${LOCAL_CACHE}/${FILE_NAME} .
|
cp ${LOCAL_CACHE}/${FILE_NAME} .
|
||||||
return
|
return
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
cp ${LOCAL_CACHE}/${FILE_NAME} .
|
echo "Invalid checksum for ${LOCAL_CACHE}/${FILE_NAME}, downloading new copy..."
|
||||||
return
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
wget -nc ${URL} || die "Cannot download ${URL}!"
|
wget -nc ${URL} || die "Cannot download ${URL}!"
|
||||||
|
if [ $(md5sum ${FILE_NAME} | awk '{print $1}') != ${MD5} ]; then
|
||||||
|
die "Invalid checksum for ${FILE_NAME}!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if local cache is usable
|
||||||
|
if [ -d ${LOCAL_CACHE} ] && [ -w ${LOCAL_CACHE} ]; then
|
||||||
cp ${FILE_NAME} ${LOCAL_CACHE}
|
cp ${FILE_NAME} ${LOCAL_CACHE}
|
||||||
|
echo "Stored ${FILE_NAME} in local cache."
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# bootstrap ROOT_FS PROFILE ARCH
|
# bootstrap ROOT_FS PROFILE ARCH
|
||||||
bootstrap() {
|
bootstrap() {
|
||||||
local ROOT_FS=$1
|
local ROOT_FS=$1
|
||||||
|
Loading…
Reference in New Issue
Block a user