diff --git a/coverage.txt b/coverage.txt index 80be7ec..c4900ab 100644 --- a/coverage.txt +++ b/coverage.txt @@ -358,3 +358,7 @@ Needs-QEMU: true Test: jessie-or-older Needs-QEMU: true Variants: essential apt minbase + +Test: apt-patterns + +Test: apt-patterns-custom diff --git a/mmdebstrap b/mmdebstrap index 4db8976..7d6c3dd 100755 --- a/mmdebstrap +++ b/mmdebstrap @@ -2374,18 +2374,7 @@ sub run_download() { info "nothing to download -- skipping..."; return ([], \@cached_debs); } - my @apt_argv = ('install'); - for my $incl (@{ $options->{include} }) { - for my $pkg (split /[,\s]+/, $incl) { - # strip leading and trailing whitespace - $pkg =~ s/^\s+|\s+$//g; - # skip if the remainder is an empty string - if ($pkg eq '') { - next; - } - push @apt_argv, $pkg; - } - } + my @apt_argv = ('install', @{ $options->{include} }); @dl_debs = run_apt_download_progress({ APT_ARGV => [@apt_argv], @@ -2913,20 +2902,9 @@ sub run_essential() { sub run_install() { my $options = shift; - my %pkgs_to_install; - for my $incl (@{ $options->{include} }) { - for my $pkg (split /[,\s]+/, $incl) { - # strip leading and trailing whitespace - $pkg =~ s/^\s+|\s+$//g; - # skip if the remainder is an empty string - if ($pkg eq '') { - next; - } - $pkgs_to_install{$pkg} = (); - } - } + my @pkgs_to_install = (@{ $options->{include} }); if ($options->{variant} eq 'buildd') { - $pkgs_to_install{'build-essential'} = (); + push @pkgs_to_install, 'build-essential'; } if (any { $_ eq $options->{variant} } ('required', 'important', 'standard', 'buildd')) { @@ -2943,7 +2921,8 @@ sub run_install() { $priority = '?and(?or(~prequired,~pimportant,~pstandard),' . '?not(?essential))'; } - $pkgs_to_install{ + push @pkgs_to_install, + ( "?narrow(" . ( length($options->{suite}) @@ -2955,9 +2934,8 @@ sub run_install() { ) . "?architecture($options->{nativearch})," . "$priority)" - } = (); + ); } - my @pkgs_to_install = keys %pkgs_to_install; if ($options->{mode} eq 'chrootless') { if (scalar @pkgs_to_install > 0) { diff --git a/tests/apt-patterns b/tests/apt-patterns new file mode 100644 index 0000000..c87e932 --- /dev/null +++ b/tests/apt-patterns @@ -0,0 +1,8 @@ +#!/bin/sh +set -eu +export LC_ALL=C.UTF-8 +trap "rm -f /tmp/debian-chroot.tar" EXIT INT TERM +{{ CMD }} --mode={{ MODE }} --variant=essential \ + --include '?or(?exact-name(dummy-does-not-exist),?exact-name(apt))' \ + {{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }} +tar -tf /tmp/debian-chroot.tar | sort | grep -v ./var/lib/apt/extended_states | diff -u tar1.txt - diff --git a/tests/apt-patterns-custom b/tests/apt-patterns-custom new file mode 100644 index 0000000..2348a76 --- /dev/null +++ b/tests/apt-patterns-custom @@ -0,0 +1,9 @@ +#!/bin/sh +set -eu +export LC_ALL=C.UTF-8 +trap "rm -f /tmp/debian-chroot.tar" EXIT INT TERM +{{ CMD }} --mode={{ MODE }} --variant=custom \ + --include '?narrow(?archive(^{{ DIST }}$),?essential)' \ + --include apt \ + {{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }} +tar -tf /tmp/debian-chroot.tar | sort | diff -u tar1.txt -