Add a Contents-firmware file

to help with looking up firmware packages in d-i
This commit is contained in:
Steve McIntyre 2022-10-09 01:43:12 +01:00 committed by Steve McIntyre
parent e57aa6fa72
commit 32291d88a3
2 changed files with 51 additions and 2 deletions

2
debian/changelog vendored
View File

@ -11,6 +11,8 @@ debian-cd (3.1.36) UNRELEASED; urgency=medium
* Add non-free-firmware support
+ Add an extra config variable NONFREE_COMPONENTS to declare where
to look for non-free packages.
* Add a Contents-firmware file to help with looking up firmware
packages in d-i.
[ Cyril Brulebois ]
* generate_firmware_patterns: Drop support for the temporary --test

View File

@ -1188,6 +1188,8 @@ sub add_firmware_stuff {
m/^Section: (\S+)/m and $section = $1;
m/^Filename: (\S+)/mi and $file = $1;
my $base_file = basename($file);
if ($file =~ /\/main\//) {
$dist = "main";
} elsif ($file =~ /\/contrib\//) {
@ -1206,7 +1208,7 @@ sub add_firmware_stuff {
}
msg_ap(0, "Symlink fw package $p into /firmware\n");
symlink("../$file", "$dir/firmware/" . basename($file));
symlink("../$file", "$dir/firmware/$base_file");
msg_ap(0, "Symlink ../$file $dir/firmware/.\n");
if (! -d "$dir/firmware") {
mkdir "$dir/firmware" or die "mkdir $dir/firmware failed $!\n";
@ -1228,6 +1230,28 @@ sub add_firmware_stuff {
$blocks_added += get_file_blocks("$dir/firmware/dep11/$p.patterns");
}
# Find the current size of the firmware Contents file
my $contents_blocks_old = 0;
my $cont_file = "$dir/firmware/Contents-firmware";
if (-f "$cont_file") {
$contents_blocks_old = get_file_blocks("$cont_file");
}
# Add new contents stuff, and count it
open(OFILE, ">> $cont_file");
open(DPKGC, "dpkg --contents $dir/firmware/$base_file |")
or die "Can't find contents of $dir/firmware/$base_file: $!";
while (defined(my $line = <DPKGC>)) {
chomp $line;
if ($line =~ m,^[-|l]\S+\s+\S+\s+\d+\s+\S+\s+\S+\s+./(\S+/firmware/\S+)$,) {
printf OFILE "%-55s %s\n", $1, $base_file;
}
}
close DPKGC;
close OFILE;
my $contents_blocks_new = get_file_blocks($cont_file);
$blocks_added += $contents_blocks_new - $contents_blocks_old;
return $blocks_added;
}
@ -1441,8 +1465,10 @@ sub remove_firmware_stuff {
m/^Package: (\S+)/mi and $p = $1;
m/^Filename: (\S+)/mi and $file = $1;
my $base_file = basename($file);
msg_ap(0, "Remove symlink for fw package $p in /firmware\n");
unlink("$dir/firmware/" . basename($file));
unlink("$dir/firmware/$base_file");
if (-f "$dir/firmware/dep11/$p.patterns") {
$blocks_removed += get_file_blocks("$dir/firmware/dep11/$p.patterns");
@ -1450,6 +1476,27 @@ sub remove_firmware_stuff {
unlink("$dir/firmware/dep11/$p.patterns");
}
# Find the current size of the firmware Contents file, and grep
# out from the current data
my $contents_blocks_old = 0;
my $cont_file = "$dir/firmware/Contents-firmware";
open(OFILE, "> $cont_file.1");
if (-f $cont_file) {
$contents_blocks_old = get_file_blocks($cont_file);
open(IFILE, "< $cont_file");
while (defined(my $line = <IFILE>)) {
chomp $line;
if ($line !~ /\b$base_file$/) {
print OFILE "$line\n";
}
}
close IFILE;
}
close OFILE;
rename "$cont_file.1", "$cont_file";
my $contents_blocks_new = get_file_blocks($cont_file);
$blocks_removed += $contents_blocks_new - $contents_blocks_old;
return $blocks_removed;
}