From e9fa78c43810fd2a6134db9d028defd1e0fa1ac0 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 24 Apr 2022 03:09:03 +0200 Subject: [PATCH] Support file:// mirrors the same way copy:// is supported As long as you can make it so that the same path to the deb file works inside and outside of the chroot using file:// as a mirror is no longer a problem with the previous work. --- coverage.sh | 10 +++------- mmdebstrap | 15 +++++++-------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/coverage.sh b/coverage.sh index dbcf26f..23bf716 100755 --- a/coverage.sh +++ b/coverage.sh @@ -1526,7 +1526,7 @@ else skipped=$((skipped+1)) fi -print_header "mode=$defaultmode,variant=apt: fail with file:// mirror" +print_header "mode=$defaultmode,variant=apt: file:// mirror" cat << END > shared/test.sh #!/bin/sh set -eu @@ -1535,13 +1535,9 @@ 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 -ret=0 -$CMD --mode=$defaultmode --variant=apt $DEFAULT_DIST /tmp/debian-chroot.tar "deb file:///mnt/cache/debian unstable main" || ret=\$? +$CMD --mode=$defaultmode --variant=apt $DEFAULT_DIST /tmp/debian-chroot.tar "deb file:///mnt/cache/debian $DEFAULT_DIST main" +tar -tf /tmp/debian-chroot.tar | sort | diff -u tar1.txt - rm /tmp/debian-chroot.tar -if [ "\$ret" = 0 ]; then - echo expected failure but got exit \$ret >&2 - exit 1 -fi END if [ "$HAVE_QEMU" = "yes" ]; then ./run_qemu.sh diff --git a/mmdebstrap b/mmdebstrap index ea85a77..2b87918 100755 --- a/mmdebstrap +++ b/mmdebstrap @@ -2135,8 +2135,13 @@ sub run_download() { # strip the the chroot directory from the filenames foreach my $deb (@dl_debs) { if (rindex $deb, $options->{root}, 0) { - error "package file $deb not in chroot directory" - . " -- use copy:// instead of file://"; + if (-e "$options->{root}/$deb") { + push @essential_pkgs, $deb; + } else { + error "package file $deb not accessible from chroot directory" + . " -- use copy:// instead of file:// or a bind-mount"; + } + next; } if (-e $deb) { push @essential_pkgs, substr($deb, length($options->{root})); @@ -6952,12 +6957,6 @@ as the non-root user, then as a workaround you could run C so that the config files are only accessible by the root user. See Debian bug #808203. -The C URI type cannot be used to install the essential packages. This -is because B uses dpkg to install the packages that apt places into -F but with C apt will not copy the files even -with C<--download-only>. Use C instead, which is equivalent to -C but copies the archives into F. - With apt versions before 2.1.16, setting C<[trusted=yes]> or C to allow signed archives without a known public key or unsigned archives will fail because of a gpg warning in the