Merge pull request #30 from bittorf/wget_cache

add download cache
This commit is contained in:
fosslinux 2021-02-10 18:40:34 +11:00 committed by GitHub
commit 839f7c763c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 0 deletions

View file

@ -11,6 +11,12 @@ set -ex
QEMU_CMD="${1:-qemu-system-x86_64}" # or 'chroot' or 'minikernel'
QEMU_RAM="${2:-8G}"
GITDIR="$PWD/$(dirname "$0")"
if [ ! -f 'rootfs.sh' ]; then
echo 'must be run from base of repo'
exit 1
fi
pushd sysa
# SYSTEM A
@ -21,6 +27,35 @@ sudo mount -t tmpfs -o size=8G tmpfs tmp
LOGFILE="$PWD/tmp/bootstrap.log"
wget()
{
local url="$1"
local dir="${CACHEDIR:-$GITDIR/sources}"
local file
file=$(basename "$url")
mkdir -p "$dir"
test -s "$dir/$file" || command wget -O "$dir/$file" "$url"
cp -v "$dir/$file" .
checksum_do "$dir" "$file"
}
checksum_do()
{
local dir="$1"
local file="$2"
local line
local store="$GITDIR/SHA256SUMS.sources"
if line=$(grep "[[:space:]][[:space:]]$file"$ "$store"); then
(cd "$dir" && echo "$line" | sha256sum -c)
else
echo 'Checksum mismatch or not found!'
exit 1
fi
}
# base: mescc-tools-seed
# copy in all the mescc-tools-seed stuff
cp -r mescc-tools-seed/src/mescc-tools-seed/x86/* tmp