]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
linux-firmware: Fix removing unlicensed firmware if compression is used
authorZoltan Boszormenyi <zboszor@gmail.com>
Fri, 17 Oct 2025 09:12:37 +0000 (11:12 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 27 Oct 2025 11:37:38 +0000 (11:37 +0000)
If FIRMWARE_COMPRESSION is set, the newly added code to remove
unlicensed firmware fails with:

| Remove unlicensed firmware: acenic/tg1.bin
| rm: cannot remove '.../work/all-oe-linux/linux-firmware/20250917/image/usr/lib/firmware/acenic/tg1.bin': No such file or directory

This is because the code does not consider that the file may be
compressed.

Fix it by factoring out the code to construct the compressed file
name suffix from do_install:append() into a python function and
also use it for the actual file names listed in REMOVE_UNLICENSED.

(From OE-Core rev: 79fc52e2d729bf30a901055a9864280d3055bbeb)

Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-kernel/linux-firmware/linux-firmware_20251011.bb

index a9e8935f930bde15dd59db6d2ac74ad92dd1e6cf..bb40c68670788268ee3f6ddf69ad3f19f33272c5 100644 (file)
@@ -472,6 +472,14 @@ def fw_compr_suffix(d):
         compr = 'zst'
     return '-' + compr
 
+def fw_compr_file_suffix(d):
+    compr = d.getVar('FIRMWARE_COMPRESSION')
+    if compr == '':
+        return ''
+    if compr == 'zstd':
+        compr = 'zst'
+    return '.' + compr
+
 do_compile() {
        :
 }
@@ -489,7 +497,7 @@ do_install() {
         # Remove all unlicensed firmware
         for file in ${REMOVE_UNLICENSED}; do
                 echo "Remove unlicensed firmware: $file"
-                rm ${D}${nonarch_base_libdir}/firmware/$file
+                rm ${D}${nonarch_base_libdir}/firmware/$file${@fw_compr_file_suffix(d)}
                 path_to_file=$(dirname $file)
                 while [ "${path_to_file}" != "." ]; do
                         num_files=$(ls -A1 ${D}${nonarch_base_libdir}/firmware/$path_to_file | wc -l)
@@ -1386,11 +1394,7 @@ FILES:${PN}-sd8897 = " \
 do_install:append() {
     # The kernel 5.6.x driver still uses the old name, provide a symlink for
     # older kernels
-    COMPR=$(echo ${@fw_compr_suffix(d)} | tr -d '-')
-    if [ -n "$COMPR" ]; then
-        COMPR=".$COMPR"
-    fi
-    ln -fs sdsd8997_combo_v4.bin$COMPR ${D}${nonarch_base_libdir}/firmware/mrvl/sd8997_uapsta.bin$COMPR
+    ln -fs sdsd8997_combo_v4.bin${@fw_compr_file_suffix(d)} ${D}${nonarch_base_libdir}/firmware/mrvl/sd8997_uapsta.bin${@fw_compr_file_suffix(d)}
 }
 FILES:${PN}-sd8997 = " \
   ${nonarch_base_libdir}/firmware/mrvl/sd8997_uapsta.bin* \