forked from josch/mmdebstrap
test.sh: cache debootstrap results
This commit is contained in:
parent
c6099857e2
commit
4e663a12f0
2 changed files with 31 additions and 13 deletions
|
@ -3,6 +3,7 @@
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
mirrordir="./mirror"
|
mirrordir="./mirror"
|
||||||
|
cachedir="./cache"
|
||||||
|
|
||||||
mirror="http://deb.debian.org/debian"
|
mirror="http://deb.debian.org/debian"
|
||||||
nativearch=$(dpkg --print-architecture)
|
nativearch=$(dpkg --print-architecture)
|
||||||
|
@ -17,6 +18,12 @@ if [ -e "$mirrordir/dists/unstable/Release" ]; then
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
for dist in stable testing unstable; do
|
||||||
|
for variant in minbase buildd -; do
|
||||||
|
rm -f "$cachedir/debian-$dist-$variant.tar"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
for dist in stable testing unstable; do
|
for dist in stable testing unstable; do
|
||||||
rootdir=$(mktemp --directory)
|
rootdir=$(mktemp --directory)
|
||||||
|
|
||||||
|
|
37
test.sh
37
test.sh
|
@ -3,11 +3,15 @@
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
mirrordir="./mirror"
|
mirrordir="./mirror"
|
||||||
|
cachedir="./cache"
|
||||||
|
|
||||||
# by default, use the mmdebstrap executable in the current directory but allow
|
# by default, use the mmdebstrap executable in the current directory but allow
|
||||||
# overwriting the location
|
# overwriting the location
|
||||||
: "${mmdebstrap:=./mmdebstrap}"
|
: "${mmdebstrap:=./mmdebstrap}"
|
||||||
|
|
||||||
|
# by default a cache of debootstrap results is maintained
|
||||||
|
: "${docache:=true}"
|
||||||
|
|
||||||
mirror="http://deb.debian.org/debian"
|
mirror="http://deb.debian.org/debian"
|
||||||
rootdir=$(mktemp --directory)
|
rootdir=$(mktemp --directory)
|
||||||
nativearch=$(dpkg --print-architecture)
|
nativearch=$(dpkg --print-architecture)
|
||||||
|
@ -46,7 +50,11 @@ trap 'kill $pid' INT QUIT TERM EXIT
|
||||||
|
|
||||||
echo "running http server with pid $pid"
|
echo "running http server with pid $pid"
|
||||||
|
|
||||||
export SOURCE_DATE_EPOCH=$(date +%s)
|
# choose the timestamp of the unstable Release file, so that we get
|
||||||
|
# reproducible results for the same mirror timestamp
|
||||||
|
export SOURCE_DATE_EPOCH=$(date --date="$(grep-dctrl -s Date -n '' mirror/dists/unstable/Release)" +%s)
|
||||||
|
|
||||||
|
mkdir -p "$cachedir"
|
||||||
|
|
||||||
for dist in stable testing unstable; do
|
for dist in stable testing unstable; do
|
||||||
> timings
|
> timings
|
||||||
|
@ -65,20 +73,20 @@ for dist in stable testing unstable; do
|
||||||
|
|
||||||
stat --format=%s debian-$dist-mm.tar >> sizes
|
stat --format=%s debian-$dist-mm.tar >> sizes
|
||||||
mkdir ./debian-$dist-mm
|
mkdir ./debian-$dist-mm
|
||||||
cd ./debian-$dist-mm
|
sudo tar -C ./debian-$dist-mm -xf ./debian-$dist-mm.tar
|
||||||
sudo tar -xf ../debian-$dist-mm.tar
|
|
||||||
cd -
|
|
||||||
|
|
||||||
echo running debootstrap --merged-usr --variant=$variant $dist ./debian-$dist-debootstrap "http://localhost:8000/"
|
if [ "$docache" != "true" ] || [ ! -e "$cachedir/debian-$dist-$variant.tar" ]; then
|
||||||
/usr/bin/time --output=timings --append --format=%e sudo debootstrap --merged-usr --variant=$variant $dist ./debian-$dist-debootstrap "http://localhost:8000/"
|
echo running debootstrap --merged-usr --variant=$variant $dist ./debian-$dist-debootstrap "http://localhost:8000/"
|
||||||
sudo tar --sort=name --mtime=@$SOURCE_DATE_EPOCH --clamp-mtime --numeric-owner --one-file-system -C ./debian-$dist-debootstrap -cf debian-$dist-debootstrap.tar .
|
/usr/bin/time --output=timings --append --format=%e sudo debootstrap --merged-usr --variant=$variant $dist ./debian-$dist-debootstrap "http://localhost:8000/"
|
||||||
sudo rm -r ./debian-$dist-debootstrap
|
sudo tar --sort=name --mtime=@$SOURCE_DATE_EPOCH --clamp-mtime --numeric-owner --one-file-system -C ./debian-$dist-debootstrap -c . > "$cachedir/debian-$dist-$variant.tar"
|
||||||
|
sudo rm -r ./debian-$dist-debootstrap
|
||||||
|
else
|
||||||
|
echo cached >> timings
|
||||||
|
fi
|
||||||
|
|
||||||
stat --format=%s debian-$dist-debootstrap.tar >> sizes
|
stat --format=%s "$cachedir/debian-$dist-$variant.tar" >> sizes
|
||||||
mkdir ./debian-$dist-debootstrap
|
mkdir ./debian-$dist-debootstrap
|
||||||
cd ./debian-$dist-debootstrap
|
sudo tar -C ./debian-$dist-debootstrap -xf "$cachedir/debian-$dist-$variant.tar"
|
||||||
sudo tar -xf ../debian-$dist-debootstrap.tar
|
|
||||||
cd -
|
|
||||||
|
|
||||||
# diff cannot compare device nodes, so we use tar to do that for us and then
|
# diff cannot compare device nodes, so we use tar to do that for us and then
|
||||||
# delete the directory
|
# delete the directory
|
||||||
|
@ -149,7 +157,10 @@ for dist in stable testing unstable; do
|
||||||
sudo diff --no-dereference --brief --recursive debian-$dist-debootstrap debian-$dist-mm
|
sudo diff --no-dereference --brief --recursive debian-$dist-debootstrap debian-$dist-mm
|
||||||
|
|
||||||
sudo rm -rf ./debian-$dist-debootstrap ./debian-$dist-mm \
|
sudo rm -rf ./debian-$dist-debootstrap ./debian-$dist-mm \
|
||||||
./debian-$dist-debootstrap.tar ./debian-$dist-mm.tar
|
./debian-$dist-mm.tar
|
||||||
|
if [ "$docache" != "true" ]; then
|
||||||
|
rm "$cachedir/debian-$dist-$variant.tar"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
eval $(awk '{print "var"NR"="$1}' timings)
|
eval $(awk '{print "var"NR"="$1}' timings)
|
||||||
|
|
Loading…
Reference in a new issue