2018-10-22 18:37:31 +00:00
#!/bin/sh
set -eu
2022-05-25 14:02:09 +00:00
if [ -e ./mmdebstrap -a -e ./taridshift -a -e ./tarfilter -a -e ./coverage.py ] ; then
2020-11-27 00:00:56 +00:00
TMPFILE = $( mktemp)
perltidy < ./mmdebstrap > " $TMPFILE "
ret = 0
diff -u ./mmdebstrap " $TMPFILE " || ret = $?
if [ " $ret " -ne 0 ] ; then
echo "perltidy failed" >& 2
rm " $TMPFILE "
exit 1
fi
2020-01-21 12:07:18 +00:00
rm " $TMPFILE "
2020-01-08 16:44:07 +00:00
2020-11-27 00:00:56 +00:00
if [ $( sed -e '/^__END__$/,$d' ./mmdebstrap | wc --max-line-length) -gt 79 ] ; then
echo "exceeded maximum line length of 79 characters" >& 2
exit 1
fi
2020-01-09 07:39:40 +00:00
2020-11-27 00:00:56 +00:00
perlcritic --severity 4 --verbose 8 ./mmdebstrap
2020-01-09 07:39:40 +00:00
2022-05-25 14:02:09 +00:00
black --check ./taridshift ./tarfilter ./coverage.py
2020-11-27 00:00:56 +00:00
fi
2020-01-18 22:13:10 +00:00
2018-12-28 06:44:54 +00:00
mirrordir = "./shared/cache/debian"
2018-11-04 19:34:40 +00:00
2019-10-18 20:46:23 +00:00
if [ ! -e " $mirrordir " ] ; then
echo " run ./make_mirror.sh before running $0 " >& 2
exit 1
fi
2018-11-04 19:34:40 +00:00
# we use -f because the file might not exist
rm -f shared/cover_db.img
2019-03-25 13:21:55 +00:00
: " ${ DEFAULT_DIST : =unstable } "
2018-12-05 09:33:03 +00:00
: " ${ HAVE_QEMU : =yes } "
2019-10-05 05:23:25 +00:00
: " ${ RUN_MA_SAME_TESTS : =yes } "
2020-01-06 10:10:31 +00:00
2018-12-05 09:33:03 +00:00
if [ " $HAVE_QEMU " = "yes" ] ; then
# prepare image for cover_db
2020-01-09 11:41:26 +00:00
guestfish -N shared/cover_db.img= disk:64M -- mkfs vfat /dev/sda
2018-12-27 13:38:00 +00:00
2019-03-25 13:21:55 +00:00
if [ ! -e " ./shared/cache/debian- $DEFAULT_DIST .qcow " ] ; then
echo " ./shared/cache/debian- $DEFAULT_DIST .qcow does not exist " >& 2
2018-12-27 13:38:00 +00:00
exit 1
fi
fi
# check if all required debootstrap tarballs exist
notfound = 0
2021-08-16 11:11:42 +00:00
for dist in oldstable stable testing unstable; do
2018-12-27 13:38:00 +00:00
for variant in minbase buildd -; do
if [ ! -e " shared/cache/debian- $dist - $variant .tar " ] ; then
echo " shared/cache/debian- $dist - $variant .tar does not exist " >& 2
notfound = 1
fi
done
done
if [ " $notfound " -ne 0 ] ; then
echo "not all required debootstrap tarballs are present" >& 2
exit 1
2018-12-05 09:33:03 +00:00
fi
2018-11-04 19:34:40 +00:00
2018-11-23 16:27:36 +00:00
# only copy if necessary
if [ ! -e shared/mmdebstrap ] || [ mmdebstrap -nt shared/mmdebstrap ] ; then
2020-11-27 00:00:56 +00:00
if [ -e ./mmdebstrap ] ; then
cp -a mmdebstrap shared
else
cp -a /usr/bin/mmdebstrap shared
fi
2018-11-23 16:27:36 +00:00
fi
2020-01-18 22:13:10 +00:00
if [ ! -e shared/taridshift ] || [ taridshift -nt shared/taridshift ] ; then
2020-11-27 00:00:56 +00:00
if [ -e ./taridshift ] ; then
cp -a ./taridshift shared
else
cp -a /usr/bin/mmtaridshift shared/taridshift
fi
2020-01-18 22:13:10 +00:00
fi
2020-08-25 11:02:33 +00:00
if [ ! -e shared/tarfilter ] || [ tarfilter -nt shared/tarfilter ] ; then
2020-11-27 00:00:56 +00:00
if [ -e ./tarfilter ] ; then
cp -a tarfilter shared
else
cp -a /usr/bin/mmtarfilter shared/tarfilter
fi
2020-11-13 18:02:41 +00:00
fi
2020-11-29 01:30:03 +00:00
if [ ! -e shared/proxysolver ] || [ proxysolver -nt shared/proxysolver ] ; then
if [ -e ./proxysolver ] ; then
cp -a proxysolver shared
else
cp -a /usr/lib/apt/solvers/mmdebstrap-dump-solution shared/proxysolver
fi
fi
2021-09-16 14:23:46 +00:00
if [ ! -e shared/ldconfig.fakechroot ] || [ ldconfig.fakechroot -nt shared/ldconfig.fakechroot ] ; then
if [ -e ./ldconfig.fakechroot ] ; then
cp -a ldconfig.fakechroot shared
else
cp -a /usr/libexec/mmdebstrap/ldconfig.fakechroot shared/ldconfig.fakechroot
fi
fi
2021-09-21 21:01:58 +00:00
mkdir -p shared/hooks/merged-usr
if [ ! -e shared/hooks/merged-usr/setup00.sh ] || [ hooks/merged-usr/setup00.sh -nt shared/hooks/merged-usr/setup00.sh ] ; then
if [ -e hooks/merged-usr/setup00.sh ] ; then
cp -a hooks/merged-usr/setup00.sh shared/hooks/merged-usr/
2020-11-27 00:00:56 +00:00
else
2021-09-21 21:01:58 +00:00
cp -a /usr/share/mmdebstrap/hooks/merged-usr/setup00.sh shared/hooks/merged-usr/
2020-11-27 00:00:56 +00:00
fi
2020-08-25 14:05:10 +00:00
fi
mkdir -p shared/hooks/eatmydata
if [ ! -e shared/hooks/eatmydata/extract.sh ] || [ hooks/eatmydata/extract.sh -nt shared/hooks/eatmydata/extract.sh ] ; then
2020-11-27 00:00:56 +00:00
if [ -e hooks/eatmydata/extract.sh ] ; then
cp -a hooks/eatmydata/extract.sh shared/hooks/eatmydata/
else
cp -a /usr/share/mmdebstrap/hooks/eatmydata/extract.sh shared/hooks/eatmydata/
fi
2020-08-25 14:05:10 +00:00
fi
if [ ! -e shared/hooks/eatmydata/customize.sh ] || [ hooks/eatmydata/customize.sh -nt shared/hooks/eatmydata/customize.sh ] ; then
2020-11-27 00:00:56 +00:00
if [ -e hooks/eatmydata/customize.sh ] ; then
cp -a hooks/eatmydata/customize.sh shared/hooks/eatmydata/
else
cp -a /usr/share/mmdebstrap/hooks/eatmydata/customize.sh shared/hooks/eatmydata/
fi
2020-08-25 14:05:10 +00:00
fi
2022-05-24 11:16:24 +00:00
mkdir -p shared/hooks/file-mirror-automount
if [ ! -e shared/hooks/file-mirror-automount/setup00.sh ] || [ hooks/file-mirror-automount/setup00.sh -nt shared/hooks/file-mirror-automount/setup00.sh ] ; then
if [ -e hooks/file-mirror-automount/setup00.sh ] ; then
cp -a hooks/file-mirror-automount/setup00.sh shared/hooks/file-mirror-automount/
else
cp -a /usr/share/mmdebstrap/hooks/file-mirror-automount/setup00.sh shared/hooks/file-mirror-automount/
fi
fi
if [ ! -e shared/hooks/file-mirror-automount/customize00.sh ] || [ hooks/file-mirror-automount/customize00.sh -nt shared/hooks/file-mirror-automount/customize00.sh ] ; then
if [ -e hooks/file-mirror-automount/customize00.sh ] ; then
cp -a hooks/file-mirror-automount/customize00.sh shared/hooks/file-mirror-automount/
else
cp -a /usr/share/mmdebstrap/hooks/file-mirror-automount/customize00.sh shared/hooks/file-mirror-automount/
fi
fi
2018-11-02 16:24:46 +00:00
2018-11-04 19:34:40 +00:00
# choose the timestamp of the unstable Release file, so that we get
# reproducible results for the same mirror timestamp
2019-03-25 13:21:55 +00:00
SOURCE_DATE_EPOCH = $( date --date= " $( grep-dctrl -s Date -n '' " $mirrordir /dists/ $DEFAULT_DIST /Release " ) " +%s)
2018-10-22 18:37:31 +00:00
2018-11-04 19:34:40 +00:00
# for traditional sort order that uses native byte values
2018-12-27 13:16:23 +00:00
export LC_ALL = C.UTF-8
2018-10-22 18:37:31 +00:00
2018-12-05 09:33:03 +00:00
: " ${ HAVE_UNSHARE : =yes } "
: " ${ HAVE_PROOT : =yes } "
: " ${ HAVE_BINFMT : =yes } "
defaultmode = "auto"
if [ " $HAVE_UNSHARE " != "yes" ] ; then
defaultmode = "root"
fi
2018-11-04 19:34:40 +00:00
# by default, use the mmdebstrap executable in the current directory together
# with perl Devel::Cover but allow to overwrite this
: " ${ CMD : =perl -MDevel : : Cover =-silent,-nogcov ./mmdebstrap } "
mirror = "http://127.0.0.1/debian"
2018-10-22 18:37:31 +00:00
2022-05-25 14:02:09 +00:00
export HAVE_QEMU HAVE_UNSHARE HAVE_BINFMT RUN_MA_SAME_TESTS DEFAULT_DIST SOURCE_DATE_EPOCH CMD mirror
2020-05-03 18:32:50 +00:00
2022-05-25 14:02:09 +00:00
./coverage.py
2020-05-03 18:32:50 +00:00
2022-05-25 14:02:09 +00:00
if [ -e shared/cover_db.img ] ; then
# produce report inside the VM to make sure that the versions match or
# otherwise we might get:
# Can't read shared/cover_db/runs/1598213854.252.64287/cover.14 with Sereal: Sereal: Error: Bad Sereal header: Not a valid Sereal document. at offset 1 of input at srl_decoder.c line 600 at /usr/lib/x86_64-linux-gnu/perl5/5.30/Devel/Cover/DB/IO/Sereal.pm line 34, <$fh> chunk 1.
cat << END > shared/test.sh
cover -nogcov -report html_basic cover_db >& 2
mkdir -p report
for f in common.js coverage.html cover.css css.js mmdebstrap--branch.html mmdebstrap--condition.html mmdebstrap.html mmdebstrap--subroutine.html standardista-table-sorting.js; do
cp -a cover_db/\$ f report
2020-05-03 18:32:50 +00:00
done
2022-05-25 14:02:09 +00:00
cover -delete cover_db >& 2
2022-01-07 11:46:35 +00:00
END
if [ " $HAVE_QEMU " = "yes" ] ; then
./run_qemu.sh
2022-05-25 14:02:09 +00:00
elif [ " $mode " = "root" ] ; then
2020-08-24 13:01:49 +00:00
./run_null.sh SUDO
else
./run_null.sh
fi
echo
echo open file://$( pwd ) /shared/report/coverage.html in a browser
echo
fi
2021-02-04 16:39:50 +00:00
rm shared/test.sh shared/tar1.txt shared/tar2.txt shared/pkglist.txt shared/doc-debian.tar.list shared/mmdebstrap shared/taridshift shared/tarfilter shared/proxysolver