From 1824a6693304cd8923da288610c378b6b18ed62a Mon Sep 17 00:00:00 2001 From: Steve McIntyre Date: Tue, 4 Jul 2023 16:53:30 +0100 Subject: [PATCH] Add a way to exclude named firmware packages from media So we can control which packages are included - see tasks/$codename/firmware-exclude --- Makefile | 2 +- debian/changelog | 3 +++ tasks/bookworm/exclude-firmware | 26 ++++++++++++++++++++++++++ tasks/trixie/exclude-firmware | 26 ++++++++++++++++++++++++++ tools/generate_firmware_task | 28 ++++++++++++++++++++++++++-- tools/make-firmware-image | 2 +- 6 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 tasks/bookworm/exclude-firmware create mode 100644 tasks/trixie/exclude-firmware diff --git a/Makefile b/Makefile index 31fb8ea7..838e479e 100755 --- a/Makefile +++ b/Makefile @@ -170,7 +170,7 @@ ifneq ($(ARCHES),source) $(BASEDIR)/tools/generate_di+k_list ifeq ($(FORCE_FIRMWARE),1) # Generate firmware task file using the contents of the archive - $(Q)$(BASEDIR)/tools/generate_firmware_task "$(ARCHES)" $(TASKDIR)/firmware + $(Q)$(BASEDIR)/tools/generate_firmware_task "$(ARCHES)" $(TASKDIR)/exclude-firmware $(TASKDIR)/firmware endif ifeq ($(DEBIAN_EDU),1) # Generate Debian Edu task file containing (almost) all of Debian Edu's packages diff --git a/debian/changelog b/debian/changelog index 88586056..52f95382 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,9 @@ debian-cd (3.2.2) UNRELEASED; urgency=medium [ Steve McIntyre ] * Start development for trixie * Remove old config and data for jessie and stretch + * Add a way to exclude named firmware packages from media, so we can + control which packages are included - see + tasks/$codename/firmware-exclude -- Steve McIntyre <93sam@debian.org> Mon, 12 Jun 2023 08:36:50 +0100 diff --git a/tasks/bookworm/exclude-firmware b/tasks/bookworm/exclude-firmware new file mode 100644 index 00000000..98963014 --- /dev/null +++ b/tasks/bookworm/exclude-firmware @@ -0,0 +1,26 @@ +/* + * List the n-f-f packages that we do *not* want to include on media. + * Parsed using cpp, so C-style comments will work here. + */ + +/* Always exclude these packages: only useful with non-free drivers + that we can't and won't ship */ +firmware-nvidia-gsp +firmware-nvidia-tesla-gsp + +/* If we don't have an arm* architecture, exclude these */ +#if !defined(ARCHarm64) && !defined(ARCHarmel) && !defined(ARCHarmhf) +arm-trusted-firmware-tools +crust-firmware +firmware-qcom-soc +firmware-samsung +raspi-firmware +#endif + +/* If we don't have an x86 architecture, exclude these */ +#if !defined(ARCHamd64) && !defined(ARCHi386) +amd64-microcode +firmware-intel-sound +firmware-sof-signed +intel-microcode +#endif diff --git a/tasks/trixie/exclude-firmware b/tasks/trixie/exclude-firmware new file mode 100644 index 00000000..98963014 --- /dev/null +++ b/tasks/trixie/exclude-firmware @@ -0,0 +1,26 @@ +/* + * List the n-f-f packages that we do *not* want to include on media. + * Parsed using cpp, so C-style comments will work here. + */ + +/* Always exclude these packages: only useful with non-free drivers + that we can't and won't ship */ +firmware-nvidia-gsp +firmware-nvidia-tesla-gsp + +/* If we don't have an arm* architecture, exclude these */ +#if !defined(ARCHarm64) && !defined(ARCHarmel) && !defined(ARCHarmhf) +arm-trusted-firmware-tools +crust-firmware +firmware-qcom-soc +firmware-samsung +raspi-firmware +#endif + +/* If we don't have an x86 architecture, exclude these */ +#if !defined(ARCHamd64) && !defined(ARCHi386) +amd64-microcode +firmware-intel-sound +firmware-sof-signed +intel-microcode +#endif diff --git a/tools/generate_firmware_task b/tools/generate_firmware_task index 32bfe647..999912c9 100755 --- a/tools/generate_firmware_task +++ b/tools/generate_firmware_task @@ -16,14 +16,17 @@ # use strict; +use File::Basename; -my ($mirror, $codename, $archlist, $outfile, $localdebs, $backports); +my ($mirror, $codename, $archlist, $excludelist, $outfile, $localdebs, $backports); my $date; +my $tasksdir; my (@pkgfiles, @bp_pkgfiles); my ($pkg, $filename, $arch); my %seen; my @components; - +my $cpp_command; +my %excluded; sub contains_firmware($$) { my $count = 0; @@ -54,6 +57,12 @@ sub check_packages($$@) { next; } + # Don't include packages that we're told to exclude + if ($excluded{$pkg}) { + print STDERR " Ignoring $pkg\n"; + next; + } + if (!exists $seen{$filename}) { $seen{$filename} = 1; if (contains_firmware($mirror, $filename)) { @@ -106,13 +115,18 @@ $mirror = $ENV{'MIRROR'}; $localdebs = $ENV{'LOCALDEBS'}; $backports = $ENV{'BACKPORTS'}; $archlist = shift; +$excludelist = shift; $outfile = shift; if (!defined($codename) || !defined($mirror) || + !defined($excludelist) || !defined($archlist) || !defined($outfile)) { die "Error in arguments\n"; } +$tasksdir = dirname($outfile); +$cpp_command = "cpp -traditional -undef -P -C -Wall -nostdinc -I$tasksdir"; + foreach $arch (split(' ', $archlist)) { for my $component (@components) { if (defined($backports)) { @@ -122,6 +136,7 @@ foreach $arch (split(' ', $archlist)) { push @pkgfiles, "$mirror/dists/$codename/$component/binary-$arch/Packages.gz"; push @pkgfiles, "$mirror/dists/$codename/$component/binary-$arch/Packages.xz"; } + $cpp_command .= " -DARCH$arch"; } if (defined($localdebs)) { @@ -137,6 +152,15 @@ if (defined($localdebs)) { } } +# Build the hash of excluded packages +open (EXLIST, "$cpp_command $excludelist |") or + die "Can't parse exclude list: $!\n"; +while (defined (my $exc = )) { + chomp $exc; + $excluded{$exc} = 1; +} +close EXLIST; + # This special filename is an crude but easy way to distinguish the historical # caller (top-level Makefile) from tools/make-firmware-image which should use # the same logic, but is interested in the Filename for interesting firmware diff --git a/tools/make-firmware-image b/tools/make-firmware-image index a812ff15..3200bcd2 100755 --- a/tools/make-firmware-image +++ b/tools/make-firmware-image @@ -47,7 +47,7 @@ fi # This tool requires environment variables (exported earlier) and two parameters; the second one has # a special value for us to use. Deduplication should happen there, but uniquify to make sure: -$BASEDIR/tools/generate_firmware_task '*' --list-filenames-and-indices | sort -u | while read FILE INDICES; do +$BASEDIR/tools/generate_firmware_task '*' /dev/null --list-filenames-and-indices | sort -u | while read FILE INDICES; do cp ${MIRROR}/$FILE $TMPDIR/firmware # Adding metadata for bullseye might be helpful but disruptive, be careful: