From a2cd0e984393f132e33421c2cf3ebb1b375026bc Mon Sep 17 00:00:00 2001 From: Johannes 'josch' Schauer Date: Mon, 28 Oct 2019 16:29:38 +0100 Subject: [PATCH] add --keyring option as a shorthand for --aptopt='Dir::Etc::Trusted... --- coverage.sh | 21 ++++++++++++++++++++- mmdebstrap | 27 +++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/coverage.sh b/coverage.sh index 286feed..ed5e841 100755 --- a/coverage.sh +++ b/coverage.sh @@ -52,7 +52,7 @@ if [ ! -e shared/mmdebstrap ] || [ mmdebstrap -nt shared/mmdebstrap ]; then fi starttime= -total=108 +total=109 i=1 print_header() { @@ -910,6 +910,25 @@ else ./run_null.sh SUDO fi +print_header "mode=root,variant=apt: test --keyring" +cat << END > shared/test.sh +#!/bin/sh +set -eu +export LC_ALL=C.UTF-8 +echo 'Acquire::Languages "none";' > config +$CMD --mode=root --variant=apt --aptopt='Acquire::Check-Valid-Until "false"' --keyring=/usr/share/keyrings/debian-archive-keyring.gpg --keyring=/usr/share/keyrings/ --aptopt=config $DEFAULT_DIST /tmp/debian-chroot $mirror +cat /tmp/debian-chroot/etc/apt/apt.conf.d/99mmdebstrap +printf 'Acquire::Check-Valid-Until "false";\nDir::Etc::Trusted "/usr/share/keyrings/debian-archive-keyring.gpg";\nDir::Etc::TrustedParts "/usr/share/keyrings/";\nAcquire::Languages "none";\n' | cmp /tmp/debian-chroot/etc/apt/apt.conf.d/99mmdebstrap - +rm /tmp/debian-chroot/etc/apt/apt.conf.d/99mmdebstrap +tar -C /tmp/debian-chroot --one-file-system -c . | tar -t | sort | diff -u tar1.txt - +rm -r /tmp/debian-chroot +END +if [ "$HAVE_QEMU" = "yes" ]; then + ./run_qemu.sh +else + ./run_null.sh SUDO +fi + print_header "mode=root,variant=apt: test --dpkgopt" cat << END > shared/test.sh #!/bin/sh diff --git a/mmdebstrap b/mmdebstrap index 621192e..c8dbbe5 100755 --- a/mmdebstrap +++ b/mmdebstrap @@ -1819,6 +1819,20 @@ sub main() { 'mode=s' => \$options->{mode}, 'dpkgopt=s@' => \$options->{dpkgopts}, 'aptopt=s@' => \$options->{aptopts}, + 'keyring=s' => sub { + my ($opt_name, $opt_value) = @_; + if ($opt_value =~ /"/) { + error "apt cannot handle paths with double quotes"; + } + if (! -e $opt_value) { + error "keyring \"$opt_value\" does not exist"; + } + if (-d $opt_value) { + push @{$options->{aptopts}}, "Dir::Etc::TrustedParts \"$opt_value\""; + } else { + push @{$options->{aptopts}}, "Dir::Etc::Trusted \"$opt_value\""; + } + }, 's|silent' => sub { $verbosity_level = 0; }, 'q|quiet' => sub { $verbosity_level = 0; }, 'v|verbose' => sub { $verbosity_level = 2; }, @@ -2745,6 +2759,19 @@ Example: Minimizing the number of packages installed from experimental --aptopt='APT::Solver "aspcud"' --aptopt='APT::Solver::aspcud::Preferences "-count(solution,APT-Release:=/a=experimental/),-removed,-changed,-new"' +=item B<--keyring>=I|I + +A shorthand for using C<--aptopt='Dir::Etc::Trusted "file"'> or +C<-aptopt='Dir::Etc::TrustedParts "directory"'> when passing a file or +directory to the B<--keyring> option, respectively. B will add the +right keyring for the given I if it knows about the distribution and if +the keyring is installed in a path known by B, usually +F. If B does not know or cannot find the +right keyring for the given I it will only know about the keys that apt +on the host system knows about. If you want to prevent B from +choosing the right keyring for you for known values of I, choose an +arbitrary value for I and specify the right apt line manually. + =item B<--dpkgopt>=I