Filter the firmware list (Closes: 1035382)

The firmware packages that do not match the requested architecture(s)
are filtered out.
This commit is contained in:
Roland Clobus 2023-07-09 11:44:28 +02:00
parent 4086f078d9
commit 8eaf20daf1
No known key found for this signature in database
GPG Key ID: 62C57C6AA61495BD
1 changed files with 44 additions and 1 deletions

View File

@ -1,7 +1,7 @@
#!/bin/sh
## live-build(7) - System Build Scripts
## Copyright (C) 2016-2020 The Debian Live team
## Copyright (C) 2016-2023 The Debian Live team
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
@ -18,6 +18,8 @@ Firmware_List_From_Contents () {
local MIRROR_CHROOT="${1}"
local DISTRO_CHROOT="${2}"
local ARCHIVE_AREAS="${3}"
local HAS_X86_ARCH=0
local HAS_ARM_ARCH=0
local _ARCHIVE_AREA
for _ARCHIVE_AREA in ${ARCHIVE_AREAS}
@ -56,6 +58,15 @@ Firmware_List_From_Contents () {
then
rm -f "${CONTENTS_FILE}"
fi
case "${_ARCH}" in
arm64 | armel | armhf)
HAS_ARM_ARCH=1
;;
amd64 | i386)
HAS_X86_ARCH=1
;;
esac
done
# Clean up the cache directory, if no files are present
@ -63,4 +74,36 @@ Firmware_List_From_Contents () {
rmdir --ignore-fail-on-non-empty "cache/contents.chroot/${DISTRO_CHROOT}"
rmdir --ignore-fail-on-non-empty "cache/contents.chroot"
done
# Blocklist firmware which does not match the requested architectures #1035382
# See https://salsa.debian.org/images-team/debian-cd/-/blob/master/tasks/bookworm/exclude-firmware
# Filter out firmware packages that are only useful with non-free drivers
BLOCKLIST_FIRMWARE="firmware-nvidia-gsp firmware-nvidia-tesla-gsp"
# Exclude ARM firmware when no ARM is requested
if [ ${HAS_ARM_ARCH} -eq 0 ]
then
BLOCKLIST_FIRMWARE="${BLOCKLIST_FIRMWARE} arm-trusted-firmware-tools crust-firmware firmware-qcom-soc firmware-samsung firmware-ti-connectivity raspi-firmware"
fi
# Exclude x86 firmware when no x86 is requested
if [ ${HAS_X86_ARCH} -eq 0 ]
then
BLOCKLIST_FIRMWARE="${BLOCKLIST_FIRMWARE} amd64-microcode firmware-intel-sound firmware-sof-signed intel-microcode"
fi
# Deduplicate the list and prepare for easier manipulation by having each package on its own line
local _FIRMWARE_PACKAGES_FILE=tmp_firmware_packages.txt
echo ${FIRMWARE_PACKAGES} | tr " " "\n" | sort -u > ${_FIRMWARE_PACKAGES_FILE}
# Remove the blocklisted firmware packages
# FIRMWARE_PACKAGES has section names and BLOCKLIST_FIRMWARE (intentionally) does not
local _REMOVEME
for _REMOVEME in ${BLOCKLIST_FIRMWARE}
do
sed -i -e "/\/${_REMOVEME}$/d" ${_FIRMWARE_PACKAGES_FILE}
done
# Reassemble the filtered list
FIRMWARE_PACKAGES=$(cat ${_FIRMWARE_PACKAGES_FILE})
rm -f ${_FIRMWARE_PACKAGES_FILE}
}