Compare commits

..

No commits in common. "b46149b8513c4107f932ea408cdbca725bc74ec1" and "158956e213c713310e1326df35810f95caa8c624" have entirely different histories.

9 changed files with 94 additions and 122 deletions

View file

@ -1,8 +1,3 @@
1.0.1 (2022-05-29)
------------------
- bugfix release
1.0.0 (2022-05-28)
------------------

View file

@ -74,37 +74,8 @@ def main():
default=0,
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()
# 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
if len(sys.argv) > 1:
onlyrun = sys.argv[1]
@ -147,8 +118,6 @@ def main():
if only_dists and dist not in only_dists:
continue
for mode in modes:
if args.mode and args.mode != mode:
continue
for variant in variants:
for fmt in formats:
skipreason = skip(
@ -175,7 +144,6 @@ def main():
starttime = time.time()
skipped = defaultdict(list)
failed = []
num_success = 0
for i, (test, name, dist, mode, variant, fmt) in enumerate(tests):
print(separator, file=sys.stderr)
print("(%d/%d) %s" % (i + 1, len(tests), name), file=sys.stderr)
@ -186,7 +154,7 @@ def main():
if i > 0:
currenttime = time.time()
timeleft = timedelta(
seconds=int((len(tests) - i) * (currenttime - starttime) / i)
seconds=(len(tests) - i) * (currenttime - starttime) / i
)
print("time left: %s" % timeleft, file=sys.stderr)
with open("tests/" + name) as fin, open("shared/test.sh", "w") as fout:
@ -229,11 +197,10 @@ def main():
print("result: FAILURE", file=sys.stderr)
else:
print("result: SUCCESS", file=sys.stderr)
num_success += 1
if args.maxfail and len(failed) >= args.maxfail:
break
print(
"successfully ran %d tests" % num_success,
"successully ran %d tests" % (len(tests) - len(skipped) - len(failed)),
file=sys.stderr,
)
if skipped:

View file

@ -63,6 +63,81 @@ if [ "$notfound" -ne 0 ]; then
exit 1
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
# reproducible results for the same mirror timestamp
SOURCE_DATE_EPOCH=$(date --date="$(grep-dctrl -s Date -n '' "$mirrordir/dists/$DEFAULT_DIST/Release")" +%s)

View file

@ -127,7 +127,6 @@ Test: file-mirror
Needs-QEMU: true
Test: file-mirror-automount-hook
Modes: root unshare fakechroot
Needs-QEMU: true
Test: mirror-is-deb
@ -313,6 +312,3 @@ Skip-If:
hostarch != "amd64"
mode == "fakechroot" and not run_ma_same_tests
not have_binfmt
Test: no-sbin-in-path
Modes: fakechroot

View file

@ -14,26 +14,13 @@ fi
xargsopts="--null --no-run-if-empty -I {} --max-args=1"
case $MMDEBSTRAP_MODE in
root|unshare)
echo "unmounting the following mountpoints:" >&2 ;;
*)
echo "removing the following directories:" >&2 ;;
esac
echo "unmounting the following mountpoints:" >&2
cat "$rootdir/run/mmdebstrap/file-mirror-automount" \
| xargs $xargsopts echo " $rootdir/{}"
case $MMDEBSTRAP_MODE in
root|unshare)
cat "$rootdir/run/mmdebstrap/file-mirror-automount" \
cat "$rootdir/run/mmdebstrap/file-mirror-automount" \
| xargs $xargsopts umount "$rootdir/{}"
;;
*)
cat "$rootdir/run/mmdebstrap/file-mirror-automount" \
| xargs $xargsopts rm -r "$rootdir/{}"
;;
esac
rm "$rootdir/run/mmdebstrap/file-mirror-automount"
rmdir --ignore-fail-on-non-empty "$rootdir/run/mmdebstrap"

View file

@ -12,18 +12,9 @@ env APT_CONFIG=$MMDEBSTRAP_APT_CONFIG apt-get indextargets --no-release-info \
| sed -ne 's/^Repo-URI: file:\/\+//p' \
| sort -u \
| while read path; do
mkdir -p "$rootdir/run/mmdebstrap"
case $MMDEBSTRAP_MODE in
root|unshare)
echo "bind-mounting /$path into the chroot" >&2
mkdir -p "$rootdir/run/mmdebstrap"
mkdir -p "$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"
done

View file

@ -23,7 +23,7 @@
use strict;
use warnings;
our $VERSION = '1.0.1';
our $VERSION = '1.0.0';
use English;
use Getopt::Long;
@ -2346,24 +2346,17 @@ sub run_prepare {
# /etc/fakechroot/debootstrap.env and
# /etc/fakechroot/chroot.env
{
my %subst = (
chroot => "/usr/sbin/chroot.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 $ldconfig = getcwd() . '/ldconfig.fakechroot';
if (!-x $ldconfig) {
$ldconfig = '/usr/libexec/mmdebstrap/ldconfig.fakechroot';
}
my @fakechrootsubst = ();
foreach my $d (split ':', $ENV{PATH}) {
foreach my $k (sort keys %subst) {
if (-e "$d/$k") {
push @fakechrootsubst, "$d/$k=$subst{$k}";
}
}
foreach my $d ('/usr/sbin', '/usr/bin', '/sbin', '/bin') {
push @fakechrootsubst, "$d/chroot=/usr/sbin/chroot.fakechroot";
push @fakechrootsubst, "$d/mkfifo=/bin/true";
push @fakechrootsubst, "$d/ldconfig=$ldconfig";
push @fakechrootsubst, "$d/ldd=/usr/bin/ldd.fakechroot";
push @fakechrootsubst, "$d/ischroot=/bin/true";
}
if (defined $ENV{FAKECHROOT_CMD_SUBST}
&& $ENV{FAKECHROOT_CMD_SUBST} ne "") {

View file

@ -5,16 +5,6 @@ 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
exit 1
fi
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"
{{ 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"
tar -tf /tmp/debian-chroot.tar | sort | diff -u tar1.txt -
rm /tmp/debian-chroot.tar

View file

@ -1,22 +0,0 @@
#!/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 -