From 14d266445921875328c4a0fa57ba74cadd461504 Mon Sep 17 00:00:00 2001 From: Cyril Brulebois Date: Thu, 26 Jan 2023 23:22:40 +0100 Subject: [PATCH] generate_firmware_task: pick and choose components We have a few fully-free firmware packages in main, and a few downloaders (e.g. b43-installer and b43legacy-installer) in contrib; the latter might not be really interesting without an alternative connectivity during the installation process. Regarding non-free vs. non-free-firmware, we started moving packages[1] from the former to the latter so that we could build official installation images based on main and non-free-firmware only. 1. https://lists.debian.org/debian-boot/2023/01/msg00150.html At the moment, NON_FREE_COMPONENTS still lists both, but the plan is to move to non-free-firmware only once all the packages we want are available there. The relevant variables regarding components include: - CONTRIB - NONFREE - EXTRANONFREE - FORCE_FIRMWARE This commit implements: - using main all the time; - using contrib if CONTRIB=1; - using NONFREE_COMPONENTS if NONFREE=1 or EXTRANONFREE=1 or FORCE_FIRMWARE=1. At the moment it seems the only existing caller is the top-level Makefile, only when FORCE_FIRMWARE is set. But it seems to make sense to match what tools/apt-selection does, to avoid any surprises. --- tools/generate_firmware_task | 55 ++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/tools/generate_firmware_task b/tools/generate_firmware_task index 40c4ddd3..00aa4aca 100755 --- a/tools/generate_firmware_task +++ b/tools/generate_firmware_task @@ -10,6 +10,7 @@ # 3. For those that do, output the package name into the firmware task # # Copyright Steve McIntyre <93sam@debian.org> 2011 +# Copyright Cyril Brulebois 2023 # # GPL 2 # @@ -22,6 +23,34 @@ my $pkgfiles = ""; my $bp_pkgfiles = ""; my ($pkg, $filename, $arch); my %seen; +my @components; + +# Either the caller tells us explicitly which components to use, or we make this +# determination on our own, based on various environment variables: +sub read_env { + my $env_var = shift; + my $default = shift; + + if (exists($ENV{$env_var})) { + return $ENV{$env_var}; + } + # else + return $default; +} + +# Either the caller tells us explicitly which components to use, or we make this +# determination on our own, based on various environment variables, just like +# tools/apt-selection does: +@components = split /\ /, read_env('FIRMWARE_COMPONENTS', ''); +if (!@components) { + @components = qw(main); + if (read_env('CONTRIB', 0) == 1) { + push @components, qw(contrib); + } + if (read_env('NONFREE', 0) == 1 or read_env('EXTRANONFREE', 0) == 1 or read_env('FORCE_FIRMWARE', 0) == 1) { + push @components, (split / /, read_env('NONFREE_COMPONENTS', '')); + } +} $codename = $ENV{'CODENAME'}; $mirror = $ENV{'MIRROR'}; @@ -36,22 +65,26 @@ if (!defined($codename) || !defined($mirror) || } 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"; + for my $component (@components) { + if (defined($backports)) { + $bp_pkgfiles = "$pkgfiles $mirror/dists/$codename-backports/$component/binary-$arch/Packages.gz"; + $bp_pkgfiles = "$pkgfiles $mirror/dists/$codename-backports/$component/binary-$arch/Packages.xz"; + } + $pkgfiles = "$pkgfiles $mirror/dists/$codename/$component/binary-$arch/Packages.gz"; + $pkgfiles = "$pkgfiles $mirror/dists/$codename/$component/binary-$arch/Packages.xz"; } - $pkgfiles = "$pkgfiles $mirror/dists/$codename/*/binary-$arch/Packages.gz"; - $pkgfiles = "$pkgfiles $mirror/dists/$codename/*/binary-$arch/Packages.xz"; } if (defined($localdebs)) { - 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"; + for my $component (@components) { + foreach $arch (split(' ', $archlist)) { + if (defined($backports)) { + $bp_pkgfiles = "$pkgfiles $localdebs/dists/$codename-backports/$component/binary-$arch/Packages.gz"; + $bp_pkgfiles = "$pkgfiles $localdebs/dists/$codename-backports/$component/binary-$arch/Packages.xz"; + } + $pkgfiles = "$pkgfiles $localdebs/dists/$codename/$component/binary-$arch/Packages.gz"; + $pkgfiles = "$pkgfiles $localdebs/dists/$codename/$component/binary-$arch/Packages.xz"; } - $pkgfiles = "$pkgfiles $localdebs/dists/$codename/*/binary-$arch/Packages.gz"; - $pkgfiles = "$pkgfiles $localdebs/dists/$codename/*/binary-$arch/Packages.xz"; } }