generate_firmware_patterns: rewrite to match caller's expectations
Initially it was interesting to pass “--package ALL” to create *.patterns files for all packages found in the specified Components-* file(s), but make_disc_trees.pl uses a call per package, so drop support for looping. Remember whether modalias information was found for the requested package, and only apply the firmware-sof-signed workaround when that's indeed the requested package and when modalias information wasn't found (in case that gets added to DEP-11 metadata at some point in the future). When using the workaround, include a reminder in the logs.
This commit is contained in:
parent
9d95f65bd9
commit
b56af4dbcc
|
@ -21,10 +21,11 @@ use File::Slurp;
|
|||
use Getopt::Long;
|
||||
use YAML::XS;
|
||||
|
||||
my $SOF = 'firmware-sof-signed';
|
||||
|
||||
my $output_dir = '.';
|
||||
my $verbose;
|
||||
my $pkgname = "ALL";
|
||||
my $pkgname;
|
||||
|
||||
GetOptions( "output-dir=s" => \$output_dir,
|
||||
"verbose" => \$verbose,
|
||||
|
@ -37,7 +38,7 @@ sub format_alias {
|
|||
}
|
||||
|
||||
|
||||
sub process_components {
|
||||
sub generate_patterns_from_components {
|
||||
my $input = shift;
|
||||
my $content;
|
||||
print STDERR "processing $input\n"
|
||||
|
@ -53,7 +54,6 @@ sub process_components {
|
|||
die "only gz and xz suffixes are supported";
|
||||
}
|
||||
|
||||
my @packages;
|
||||
foreach my $array (Load $content) {
|
||||
next if not defined $array->{Provides};
|
||||
next if not defined $array->{Provides}->{modaliases};
|
||||
|
@ -61,9 +61,9 @@ sub process_components {
|
|||
print STDERR "found modaliases entries for firmware package ", $array->{Package}, "\n"
|
||||
if $verbose;
|
||||
|
||||
if ($pkgname eq "ALL" or $pkgname eq $array->{Package}) {
|
||||
next if $pkgname ne $array->{Package};
|
||||
|
||||
my $patterns_file = $output_dir . "/" . $array->{Package} . ".patterns";
|
||||
my $patterns_file = "$output_dir/$pkgname.patterns";
|
||||
printf STDERR "writing %d entries to %s\n",
|
||||
(scalar @{ $array->{Provides}->{modaliases} }),
|
||||
$patterns_file;
|
||||
|
@ -72,44 +72,19 @@ sub process_components {
|
|||
# the right ($), and replace each '*' with '.*':
|
||||
write_file($patterns_file,
|
||||
format_alias( @{ $array->{Provides}->{modaliases} } ));
|
||||
push @packages, $array->{Package};
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return @packages;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
# Make sure the output directory exists:
|
||||
die "missing output directory $output_dir"
|
||||
if ! -d $output_dir;
|
||||
|
||||
write_file("$output_dir/README.txt",
|
||||
"These files help Debian Installer detect helpful firmware packages (via hw-detect).\n");
|
||||
|
||||
# Generate .patterns file to match firmware packages found in
|
||||
# Components-* files:
|
||||
my @all_packages;
|
||||
foreach my $component (@ARGV) {
|
||||
die "missing metadata file $component"
|
||||
if ! -f $component;
|
||||
my @packages = process_components($component);
|
||||
push @all_packages, @packages;
|
||||
}
|
||||
@all_packages = sort @all_packages;
|
||||
print STDERR "firmware packages found across all components: @all_packages\n"
|
||||
if $verbose;
|
||||
|
||||
# Workaround for firmware-sof-signed, which doesn't advertise firmware
|
||||
# files it might need through the MODULE_FIRMWARE() macro (meaning no
|
||||
# chance to generate DEP-11 info from there): alias info manually
|
||||
# extracted on 2023-01-18 (linux-image-6.1.0-1-amd64, 6.1.4-1).
|
||||
#
|
||||
# XXX: To be kept in sync! (#1029175)
|
||||
my $SOF = 'firmware-sof-signed';
|
||||
if (! grep { $_ eq $SOF } @all_packages) {
|
||||
|
||||
if ($pkgname eq 'ALL' or $pkgname eq 'firmware-sof-signed') {
|
||||
|
||||
sub generate_patterns_for_firmware_sof_intel_workaround {
|
||||
# Extract on amd64, from the installed package, with the following
|
||||
# command. Note that descending under intel/ would lead to no
|
||||
# aliases, so stick to the top-level directory for sof:
|
||||
|
@ -174,12 +149,32 @@ if (! grep { $_ eq $SOF } @all_packages) {
|
|||
if $verbose;
|
||||
|
||||
my $sof_file = $output_dir . "/" . $SOF . ".patterns";
|
||||
printf STDERR "writing %d entries to %s\n",
|
||||
printf STDERR "writing %d entries to %s (using the workaround)\n",
|
||||
(scalar @sof_aliases),
|
||||
$sof_file;
|
||||
|
||||
write_file($sof_file,
|
||||
format_alias(@sof_aliases));
|
||||
push @all_packages, $SOF;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Make sure the output directory exists:
|
||||
die "missing output directory $output_dir"
|
||||
if ! -d $output_dir;
|
||||
|
||||
write_file("$output_dir/README.txt",
|
||||
"These files help Debian Installer detect helpful firmware packages (via hw-detect).\n");
|
||||
|
||||
# Search for the specified package in the Components-* files, and
|
||||
# generate patterns when it's found:
|
||||
my $done;
|
||||
foreach my $components (@ARGV) {
|
||||
die "missing metadata file $components"
|
||||
if ! -f $components;
|
||||
$done = generate_patterns_from_components($components);
|
||||
last if $done;
|
||||
}
|
||||
|
||||
# Only apply the workaround when relevant:
|
||||
generate_patterns_for_firmware_sof_intel_workaround()
|
||||
if ! $done and $pkgname eq $SOF;
|
||||
|
|
Loading…
Reference in New Issue