Don't rely on Architecture field in indextargets output because it's only filled for non-flat mirrors

This commit is contained in:
Johannes 'josch' Schauer 2018-10-22 11:29:56 +02:00
parent bdbe12fec8
commit 7a25de31db
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -715,7 +715,7 @@ sub setup {
# Same if we want to install priority based variants. # Same if we want to install priority based variants.
if ($options->{variant} ne 'apt') { if ($options->{variant} ne 'apt') {
my %ess_pkgs; my %ess_pkgs;
open(my $pipe_apt, '-|', 'apt-get', 'indextargets', '--format', '$(FILENAME)', 'Created-By: Packages', "Architecture: $options->{nativearch}") or die "cannot start apt-get indextargets: $!"; open(my $pipe_apt, '-|', 'apt-get', 'indextargets', '--format', '$(FILENAME)', 'Created-By: Packages') or die "cannot start apt-get indextargets: $!";
while (my $fname = <$pipe_apt>) { while (my $fname = <$pipe_apt>) {
chomp $fname; chomp $fname;
open (my $pipe_cat, '-|', '/usr/lib/apt/apt-helper', 'cat-file', $fname) or die "cannot start apt-helper cat-file: $!"; open (my $pipe_cat, '-|', '/usr/lib/apt/apt-helper', 'cat-file', $fname) or die "cannot start apt-helper cat-file: $!";
@ -723,6 +723,7 @@ sub setup {
my $pkgname; my $pkgname;
my $ess = ''; my $ess = '';
my $prio = 'optional'; my $prio = 'optional';
my $arch = '';
while (my $line = <$pipe_cat>) { while (my $line = <$pipe_cat>) {
chomp $line; chomp $line;
# Dpkg::Index takes 10 seconds to parse a typical Packages # Dpkg::Index takes 10 seconds to parse a typical Packages
@ -735,41 +736,48 @@ sub setup {
$ess = 'yes' $ess = 'yes'
} elsif ($line =~ /^Priority: (.*)/) { } elsif ($line =~ /^Priority: (.*)/) {
$prio = $1; $prio = $1;
} elsif ($line =~ /^Architecture: (.*)/) {
$arch = $1;
} }
next; next;
} }
# the line is empty, thus a package stanza just finished # we are only interested of packages of native architecture or
# processing and we can handle it now # Architecture:all
if ($ess eq 'yes') { if ($arch eq $options->{nativearch} or $arch eq 'all') {
$ess_pkgs{$pkgname} = (); # the line is empty, thus a package stanza just finished
} elsif ($options->{variant} eq 'essential') { # processing and we can handle it now
# for this variant we are only interested in the if ($ess eq 'yes') {
# essential packages $ess_pkgs{$pkgname} = ();
} elsif (any { $_ eq $options->{variant} } ('standard', 'important', 'required', 'buildd', 'minbase')) { } elsif ($options->{variant} eq 'essential') {
if ($prio eq 'optional' or $prio eq 'extra') { # for this variant we are only interested in the
# always ignore packages of priority optional and extra # essential packages
} elsif ($prio eq 'standard') { } elsif (any { $_ eq $options->{variant} } ('standard', 'important', 'required', 'buildd', 'minbase')) {
if (none { $_ eq $options->{variant} } ('important', 'required', 'buildd', 'minbase')) { if ($prio eq 'optional' or $prio eq 'extra') {
# always ignore packages of priority optional and extra
} elsif ($prio eq 'standard') {
if (none { $_ eq $options->{variant} } ('important', 'required', 'buildd', 'minbase')) {
$pkgs_to_install{$pkgname} = ();
}
} elsif ($prio eq 'important') {
if (none { $_ eq $options->{variant} } ('required', 'buildd', 'minbase')) {
$pkgs_to_install{$pkgname} = ();
}
} elsif ($prio eq 'required') {
# required packages are part of all sets except
# essential and apt
$pkgs_to_install{$pkgname} = (); $pkgs_to_install{$pkgname} = ();
} else {
die "unknown priority: $prio";
} }
} elsif ($prio eq 'important') {
if (none { $_ eq $options->{variant} } ('required', 'buildd', 'minbase')) {
$pkgs_to_install{$pkgname} = ();
}
} elsif ($prio eq 'required') {
# required packages are part of all sets except
# essential and apt
$pkgs_to_install{$pkgname} = ();
} else { } else {
die "unknown priority: $prio"; die "unknown variant: $options->{variant}";
} }
} else {
die "unknown variant: $options->{variant}";
} }
# reset values # reset values
undef $pkgname; undef $pkgname;
$ess = ''; $ess = '';
$prio = 'optional'; $prio = 'optional';
$arch = '';
} }
close $pipe_cat; close $pipe_cat;