Add proper backports support in generate_firmware_task

When BACKPORTS is defined, look for firmware in $codename-backports
first, then in $codename
This commit is contained in:
Steve McIntyre 2018-08-13 14:36:36 +01:00
parent 5dd0d5cc2a
commit 5710321f9e
1 changed files with 42 additions and 17 deletions

View File

@ -16,15 +16,17 @@
use strict; use strict;
my ($mirror, $codename, $archlist, $outfile, $localdebs); my ($mirror, $codename, $archlist, $outfile, $localdebs, $backports);
my $date; my $date;
my $pkgfiles = ""; my $pkgfiles = "";
my $bp_pkgfiles = "";
my ($pkg, $filename, $arch); my ($pkg, $filename, $arch);
my %seen; my %seen;
$codename = $ENV{'CODENAME'}; $codename = $ENV{'CODENAME'};
$mirror = $ENV{'MIRROR'}; $mirror = $ENV{'MIRROR'};
$localdebs = $ENV{'LOCALDEBS'}; $localdebs = $ENV{'LOCALDEBS'};
$backports = $ENV{'BACKPORTS'};
$archlist = shift; $archlist = shift;
$outfile = shift; $outfile = shift;
@ -34,12 +36,20 @@ if (!defined($codename) || !defined($mirror) ||
} }
foreach $arch (split(' ', $archlist)) { foreach $arch (split(' ', $archlist)) {
if (defined($backports)) {
$bp_pkgfiles = "$pkgfiles $mirror/dists/$codename-backports/*/binary-$arch/Packages.gz";
$bp_pkgfiles = "$pkgfiles $mirror/dists/$codename-backports/*/binary-$arch/Packages.xz";
}
$pkgfiles = "$pkgfiles $mirror/dists/$codename/*/binary-$arch/Packages.gz"; $pkgfiles = "$pkgfiles $mirror/dists/$codename/*/binary-$arch/Packages.gz";
$pkgfiles = "$pkgfiles $mirror/dists/$codename/*/binary-$arch/Packages.xz"; $pkgfiles = "$pkgfiles $mirror/dists/$codename/*/binary-$arch/Packages.xz";
} }
if (defined($localdebs)) { if (defined($localdebs)) {
foreach $arch (split(' ', $archlist)) { foreach $arch (split(' ', $archlist)) {
if (defined($backports)) {
$bp_pkgfiles = "$pkgfiles $localdebs/dists/$codename-backports/*/binary-$arch/Packages.gz";
$bp_pkgfiles = "$pkgfiles $localdebs/dists/$codename-backports/*/binary-$arch/Packages.xz";
}
$pkgfiles = "$pkgfiles $localdebs/dists/$codename/*/binary-$arch/Packages.gz"; $pkgfiles = "$pkgfiles $localdebs/dists/$codename/*/binary-$arch/Packages.gz";
$pkgfiles = "$pkgfiles $localdebs/dists/$codename/*/binary-$arch/Packages.xz"; $pkgfiles = "$pkgfiles $localdebs/dists/$codename/*/binary-$arch/Packages.xz";
} }
@ -58,9 +68,6 @@ print OUT " */\n";
print "$0: Checking for firmware packages:\n"; print "$0: Checking for firmware packages:\n";
open (INPKG, "\$BASEDIR/tools/catz $pkgfiles |") or die "Can't read input package files: $!\n";
$/ = ''; # Browse by paragraph
sub contains_firmware($$) { sub contains_firmware($$) {
my $count = 0; my $count = 0;
open (PKGLISTING, "dpkg --contents $mirror/$filename | grep ' ./lib/firmware/' |") or open (PKGLISTING, "dpkg --contents $mirror/$filename | grep ' ./lib/firmware/' |") or
@ -75,22 +82,40 @@ sub contains_firmware($$) {
} }
} }
while (defined($_ = <INPKG>)) { sub check_packages($$) {
m/^Package: (\S+)/m and $pkg = $1; my $use_bp = shift;
m/^Filename: (\S+)/m and $filename = $1; my $packages = shift;
if (! ($pkg =~ /(microcode|firmware)/)) { open (INPKG, "\$BASEDIR/tools/catz $packages |") or die "Can't read input package files: $!\n";
next; $/ = ''; # Browse by paragraph
}
if (!exists $seen{$filename}) { while (defined($_ = <INPKG>)) {
$seen{$filename} = 1; m/^Package: (\S+)/m and $pkg = $1;
if (contains_firmware($mirror, $filename)) { m/^Filename: (\S+)/m and $filename = $1;
print " $pkg ($filename)\n";
print OUT "$pkg\n"; if (! ($pkg =~ /(microcode|firmware)/)) {
} next;
}
if (!exists $seen{$filename}) {
$seen{$filename} = 1;
if (contains_firmware($mirror, $filename)) {
print " $pkg ($filename)\n";
if ($use_bp) {
print OUT "$pkg/$codename-backports\n";
} else {
print OUT "$pkg\n";
}
}
}
} }
close INPKG;
} }
close INPKG; if (defined($backports)) {
check_packages(1, $bp_pkgfiles);
}
check_packages(0, $pkgfiles);
close OUT; close OUT;