Compare commits
8 commits
158956e213
...
b46149b851
Author | SHA1 | Date | |
---|---|---|---|
b46149b851 | |||
7198ad50f6 | |||
5ea760920d | |||
86f616996d | |||
1b5d87c7cf | |||
d96e85fddd | |||
c1c6297db7 | |||
e4ef326b59 |
9 changed files with 122 additions and 94 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
1.0.1 (2022-05-29)
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- bugfix release
|
||||||
|
|
||||||
1.0.0 (2022-05-28)
|
1.0.0 (2022-05-28)
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
|
37
coverage.py
37
coverage.py
|
@ -74,8 +74,37 @@ def main():
|
||||||
default=0,
|
default=0,
|
||||||
help="exit after first num failures or errors.",
|
help="exit after first num failures or errors.",
|
||||||
)
|
)
|
||||||
|
parser.add_argument("--mode", metavar="mode", help="only run tests with this mode")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# copy over files from git or as distributed
|
||||||
|
for (git, dist, target) in [
|
||||||
|
("./mmdebstrap", "/usr/bin/mmdebstrap", "mmdebstrap"),
|
||||||
|
("./taridshift", "/usr/bin/mmtaridshift", "taridshift"),
|
||||||
|
("./tarfilter", "/usr/bin/mmtarfilter", "tarfilter"),
|
||||||
|
(
|
||||||
|
"./proxysolver",
|
||||||
|
"/usr/lib/apt/solvers/mmdebstrap-dump-solution",
|
||||||
|
"proxysolver",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"./ldconfig.fakechroot",
|
||||||
|
"/usr/libexec/mmdebstrap/ldconfig.fakechroot",
|
||||||
|
"ldconfig.fakechroot",
|
||||||
|
),
|
||||||
|
]:
|
||||||
|
if os.path.exists(git):
|
||||||
|
shutil.copy(git, f"shared/{target}")
|
||||||
|
else:
|
||||||
|
shutil.copy(dist, f"shared/{target}")
|
||||||
|
# copy over hooks from git or as distributed
|
||||||
|
if os.path.exists("hooks"):
|
||||||
|
shutil.copytree("hooks", "shared/hooks", dirs_exist_ok=True)
|
||||||
|
else:
|
||||||
|
shutil.copytree(
|
||||||
|
"/usr/share/mmdebstrap/hooks", "shared/hooks", dirs_exist_ok=True
|
||||||
|
)
|
||||||
|
|
||||||
onlyrun = None
|
onlyrun = None
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
onlyrun = sys.argv[1]
|
onlyrun = sys.argv[1]
|
||||||
|
@ -118,6 +147,8 @@ def main():
|
||||||
if only_dists and dist not in only_dists:
|
if only_dists and dist not in only_dists:
|
||||||
continue
|
continue
|
||||||
for mode in modes:
|
for mode in modes:
|
||||||
|
if args.mode and args.mode != mode:
|
||||||
|
continue
|
||||||
for variant in variants:
|
for variant in variants:
|
||||||
for fmt in formats:
|
for fmt in formats:
|
||||||
skipreason = skip(
|
skipreason = skip(
|
||||||
|
@ -144,6 +175,7 @@ def main():
|
||||||
starttime = time.time()
|
starttime = time.time()
|
||||||
skipped = defaultdict(list)
|
skipped = defaultdict(list)
|
||||||
failed = []
|
failed = []
|
||||||
|
num_success = 0
|
||||||
for i, (test, name, dist, mode, variant, fmt) in enumerate(tests):
|
for i, (test, name, dist, mode, variant, fmt) in enumerate(tests):
|
||||||
print(separator, file=sys.stderr)
|
print(separator, file=sys.stderr)
|
||||||
print("(%d/%d) %s" % (i + 1, len(tests), name), file=sys.stderr)
|
print("(%d/%d) %s" % (i + 1, len(tests), name), file=sys.stderr)
|
||||||
|
@ -154,7 +186,7 @@ def main():
|
||||||
if i > 0:
|
if i > 0:
|
||||||
currenttime = time.time()
|
currenttime = time.time()
|
||||||
timeleft = timedelta(
|
timeleft = timedelta(
|
||||||
seconds=(len(tests) - i) * (currenttime - starttime) / i
|
seconds=int((len(tests) - i) * (currenttime - starttime) / i)
|
||||||
)
|
)
|
||||||
print("time left: %s" % timeleft, file=sys.stderr)
|
print("time left: %s" % timeleft, file=sys.stderr)
|
||||||
with open("tests/" + name) as fin, open("shared/test.sh", "w") as fout:
|
with open("tests/" + name) as fin, open("shared/test.sh", "w") as fout:
|
||||||
|
@ -197,10 +229,11 @@ def main():
|
||||||
print("result: FAILURE", file=sys.stderr)
|
print("result: FAILURE", file=sys.stderr)
|
||||||
else:
|
else:
|
||||||
print("result: SUCCESS", file=sys.stderr)
|
print("result: SUCCESS", file=sys.stderr)
|
||||||
|
num_success += 1
|
||||||
if args.maxfail and len(failed) >= args.maxfail:
|
if args.maxfail and len(failed) >= args.maxfail:
|
||||||
break
|
break
|
||||||
print(
|
print(
|
||||||
"successully ran %d tests" % (len(tests) - len(skipped) - len(failed)),
|
"successfully ran %d tests" % num_success,
|
||||||
file=sys.stderr,
|
file=sys.stderr,
|
||||||
)
|
)
|
||||||
if skipped:
|
if skipped:
|
||||||
|
|
75
coverage.sh
75
coverage.sh
|
@ -63,81 +63,6 @@ if [ "$notfound" -ne 0 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# only copy if necessary
|
|
||||||
if [ ! -e shared/mmdebstrap ] || [ mmdebstrap -nt shared/mmdebstrap ]; then
|
|
||||||
if [ -e ./mmdebstrap ]; then
|
|
||||||
cp -a mmdebstrap shared
|
|
||||||
else
|
|
||||||
cp -a /usr/bin/mmdebstrap shared
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [ ! -e shared/taridshift ] || [ taridshift -nt shared/taridshift ]; then
|
|
||||||
if [ -e ./taridshift ]; then
|
|
||||||
cp -a ./taridshift shared
|
|
||||||
else
|
|
||||||
cp -a /usr/bin/mmtaridshift shared/taridshift
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [ ! -e shared/tarfilter ] || [ tarfilter -nt shared/tarfilter ]; then
|
|
||||||
if [ -e ./tarfilter ]; then
|
|
||||||
cp -a tarfilter shared
|
|
||||||
else
|
|
||||||
cp -a /usr/bin/mmtarfilter shared/tarfilter
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
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
|
|
||||||
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
|
|
||||||
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/
|
|
||||||
else
|
|
||||||
cp -a /usr/share/mmdebstrap/hooks/merged-usr/setup00.sh shared/hooks/merged-usr/
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
mkdir -p shared/hooks/eatmydata
|
|
||||||
if [ ! -e shared/hooks/eatmydata/extract.sh ] || [ hooks/eatmydata/extract.sh -nt shared/hooks/eatmydata/extract.sh ]; then
|
|
||||||
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
|
|
||||||
fi
|
|
||||||
if [ ! -e shared/hooks/eatmydata/customize.sh ] || [ hooks/eatmydata/customize.sh -nt shared/hooks/eatmydata/customize.sh ]; then
|
|
||||||
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
|
|
||||||
fi
|
|
||||||
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
|
|
||||||
|
|
||||||
# choose the timestamp of the unstable Release file, so that we get
|
# choose the timestamp of the unstable Release file, so that we get
|
||||||
# reproducible results for the same mirror timestamp
|
# reproducible results for the same mirror timestamp
|
||||||
SOURCE_DATE_EPOCH=$(date --date="$(grep-dctrl -s Date -n '' "$mirrordir/dists/$DEFAULT_DIST/Release")" +%s)
|
SOURCE_DATE_EPOCH=$(date --date="$(grep-dctrl -s Date -n '' "$mirrordir/dists/$DEFAULT_DIST/Release")" +%s)
|
||||||
|
|
|
@ -127,6 +127,7 @@ Test: file-mirror
|
||||||
Needs-QEMU: true
|
Needs-QEMU: true
|
||||||
|
|
||||||
Test: file-mirror-automount-hook
|
Test: file-mirror-automount-hook
|
||||||
|
Modes: root unshare fakechroot
|
||||||
Needs-QEMU: true
|
Needs-QEMU: true
|
||||||
|
|
||||||
Test: mirror-is-deb
|
Test: mirror-is-deb
|
||||||
|
@ -312,3 +313,6 @@ Skip-If:
|
||||||
hostarch != "amd64"
|
hostarch != "amd64"
|
||||||
mode == "fakechroot" and not run_ma_same_tests
|
mode == "fakechroot" and not run_ma_same_tests
|
||||||
not have_binfmt
|
not have_binfmt
|
||||||
|
|
||||||
|
Test: no-sbin-in-path
|
||||||
|
Modes: fakechroot
|
||||||
|
|
|
@ -14,13 +14,26 @@ fi
|
||||||
|
|
||||||
xargsopts="--null --no-run-if-empty -I {} --max-args=1"
|
xargsopts="--null --no-run-if-empty -I {} --max-args=1"
|
||||||
|
|
||||||
echo "unmounting the following mountpoints:" >&2
|
case $MMDEBSTRAP_MODE in
|
||||||
|
root|unshare)
|
||||||
|
echo "unmounting the following mountpoints:" >&2 ;;
|
||||||
|
*)
|
||||||
|
echo "removing the following directories:" >&2 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
cat "$rootdir/run/mmdebstrap/file-mirror-automount" \
|
cat "$rootdir/run/mmdebstrap/file-mirror-automount" \
|
||||||
| xargs $xargsopts echo " $rootdir/{}"
|
| xargs $xargsopts echo " $rootdir/{}"
|
||||||
|
|
||||||
cat "$rootdir/run/mmdebstrap/file-mirror-automount" \
|
case $MMDEBSTRAP_MODE in
|
||||||
|
root|unshare)
|
||||||
|
cat "$rootdir/run/mmdebstrap/file-mirror-automount" \
|
||||||
| xargs $xargsopts umount "$rootdir/{}"
|
| xargs $xargsopts umount "$rootdir/{}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
cat "$rootdir/run/mmdebstrap/file-mirror-automount" \
|
||||||
|
| xargs $xargsopts rm -r "$rootdir/{}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
rm "$rootdir/run/mmdebstrap/file-mirror-automount"
|
rm "$rootdir/run/mmdebstrap/file-mirror-automount"
|
||||||
rmdir --ignore-fail-on-non-empty "$rootdir/run/mmdebstrap"
|
rmdir --ignore-fail-on-non-empty "$rootdir/run/mmdebstrap"
|
||||||
|
|
|
@ -12,9 +12,18 @@ env APT_CONFIG=$MMDEBSTRAP_APT_CONFIG apt-get indextargets --no-release-info \
|
||||||
| sed -ne 's/^Repo-URI: file:\/\+//p' \
|
| sed -ne 's/^Repo-URI: file:\/\+//p' \
|
||||||
| sort -u \
|
| sort -u \
|
||||||
| while read path; do
|
| while read path; do
|
||||||
echo "bind-mounting /$path into the chroot" >&2
|
|
||||||
mkdir -p "$rootdir/run/mmdebstrap"
|
mkdir -p "$rootdir/run/mmdebstrap"
|
||||||
|
case $MMDEBSTRAP_MODE in
|
||||||
|
root|unshare)
|
||||||
|
echo "bind-mounting /$path into the chroot" >&2
|
||||||
mkdir -p "$rootdir/$path"
|
mkdir -p "$rootdir/$path"
|
||||||
mount -o ro,bind "/$path" "$rootdir/$path"
|
mount -o ro,bind "/$path" "$rootdir/$path"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "copying /$path into the chroot" >&2
|
||||||
|
mkdir -p "$rootdir/$(dirname $path)"
|
||||||
|
cp -av "/$path" "$rootdir/$(dirname $path)"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
printf '/%s\0' "$path" >> "$rootdir/run/mmdebstrap/file-mirror-automount"
|
printf '/%s\0' "$path" >> "$rootdir/run/mmdebstrap/file-mirror-automount"
|
||||||
done
|
done
|
||||||
|
|
27
mmdebstrap
27
mmdebstrap
|
@ -23,7 +23,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
our $VERSION = '1.0.0';
|
our $VERSION = '1.0.1';
|
||||||
|
|
||||||
use English;
|
use English;
|
||||||
use Getopt::Long;
|
use Getopt::Long;
|
||||||
|
@ -2346,17 +2346,24 @@ sub run_prepare {
|
||||||
# /etc/fakechroot/debootstrap.env and
|
# /etc/fakechroot/debootstrap.env and
|
||||||
# /etc/fakechroot/chroot.env
|
# /etc/fakechroot/chroot.env
|
||||||
{
|
{
|
||||||
my $ldconfig = getcwd() . '/ldconfig.fakechroot';
|
my %subst = (
|
||||||
if (!-x $ldconfig) {
|
chroot => "/usr/sbin/chroot.fakechroot",
|
||||||
$ldconfig = '/usr/libexec/mmdebstrap/ldconfig.fakechroot';
|
mkfifo => "/bin/true",
|
||||||
|
ldconfig => (getcwd() . '/ldconfig.fakechroot'),
|
||||||
|
ldd => "/usr/bin/ldd.fakechroot",
|
||||||
|
ischroot => "/bin/true"
|
||||||
|
);
|
||||||
|
if (!-x $subst{ldconfig}) {
|
||||||
|
$subst{ldconfig}
|
||||||
|
= '/usr/libexec/mmdebstrap/ldconfig.fakechroot';
|
||||||
}
|
}
|
||||||
my @fakechrootsubst = ();
|
my @fakechrootsubst = ();
|
||||||
foreach my $d ('/usr/sbin', '/usr/bin', '/sbin', '/bin') {
|
foreach my $d (split ':', $ENV{PATH}) {
|
||||||
push @fakechrootsubst, "$d/chroot=/usr/sbin/chroot.fakechroot";
|
foreach my $k (sort keys %subst) {
|
||||||
push @fakechrootsubst, "$d/mkfifo=/bin/true";
|
if (-e "$d/$k") {
|
||||||
push @fakechrootsubst, "$d/ldconfig=$ldconfig";
|
push @fakechrootsubst, "$d/$k=$subst{$k}";
|
||||||
push @fakechrootsubst, "$d/ldd=/usr/bin/ldd.fakechroot";
|
}
|
||||||
push @fakechrootsubst, "$d/ischroot=/bin/true";
|
}
|
||||||
}
|
}
|
||||||
if (defined $ENV{FAKECHROOT_CMD_SUBST}
|
if (defined $ENV{FAKECHROOT_CMD_SUBST}
|
||||||
&& $ENV{FAKECHROOT_CMD_SUBST} ne "") {
|
&& $ENV{FAKECHROOT_CMD_SUBST} ne "") {
|
||||||
|
|
|
@ -5,6 +5,16 @@ if [ ! -e /mmdebstrap-testenv ]; then
|
||||||
echo "this test requires the cache directory to be mounted on /mnt and should only be run inside a container" >&2
|
echo "this test requires the cache directory to be mounted on /mnt and should only be run inside a container" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
{{ CMD }} --mode={{ MODE }} --variant=apt --hook-dir=./hooks/file-mirror-automount --customize-hook='rmdir "$1"/mnt/cache/debian/ "$1"/mnt/cache' {{ DIST }} /tmp/debian-chroot.tar "deb file:///mnt/cache/debian {{ DIST }} main"
|
if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then
|
||||||
|
adduser --gecos user --disabled-password user
|
||||||
|
fi
|
||||||
|
prefix=
|
||||||
|
[ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && prefix="runuser -u user --"
|
||||||
|
[ "{{ MODE }}" = "fakechroot" ] && prefix="$prefix fakechroot fakeroot"
|
||||||
|
$prefix {{ CMD }} --mode={{ MODE }} --variant=apt \
|
||||||
|
--hook-dir=./hooks/file-mirror-automount \
|
||||||
|
--customize-hook='[ ! -e "$1"/mnt/cache/debian/ ] || rmdir "$1"/mnt/cache/debian/' \
|
||||||
|
--customize-hook='rmdir "$1"/mnt/cache' \
|
||||||
|
{{ DIST }} /tmp/debian-chroot.tar "deb file:///mnt/cache/debian {{ DIST }} main"
|
||||||
tar -tf /tmp/debian-chroot.tar | sort | diff -u tar1.txt -
|
tar -tf /tmp/debian-chroot.tar | sort | diff -u tar1.txt -
|
||||||
rm /tmp/debian-chroot.tar
|
rm /tmp/debian-chroot.tar
|
||||||
|
|
22
tests/no-sbin-in-path
Normal file
22
tests/no-sbin-in-path
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# If FAKECHROOT_CMD_SUBST sets up wrong substitutions, then binaries cannot be
|
||||||
|
# found. For example if /usr/bin/chroot is listed in FAKECHROOT_CMD_SUBST but
|
||||||
|
# /usr/sbin (the actual location of the chroot binary) is not in PATH, the
|
||||||
|
# command fails
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
export LC_ALL=C.UTF-8
|
||||||
|
[ "{{ MODE }}" = "fakechroot" ]
|
||||||
|
trap "rm -f /tmp/debian-chroot.tar" EXIT INT TERM
|
||||||
|
if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then
|
||||||
|
if [ ! -e /mmdebstrap-testenv ]; then
|
||||||
|
echo "this test modifies the system and should only be run inside a container" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
adduser --gecos user --disabled-password user
|
||||||
|
fi
|
||||||
|
prefix=
|
||||||
|
[ "$(id -u)" -eq 0 ] && prefix="runuser -u user --"
|
||||||
|
$prefix env PATH=/usr/bin:/bin fakechroot fakeroot {{ CMD }} --mode=fakechroot --variant=apt {{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }}
|
||||||
|
tar -tf /tmp/debian-chroot.tar | sort | diff -u tar1.txt -
|
Loading…
Reference in a new issue