Skip to contentSkip to conversation

Install only listed firmware files

PATCH In review Takashi Iwai 2 participants 2 messages Jul 31, 2019 – Aug 15, 2019 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Install only listed firmware files

The current make-install procedure leaves lots of garbage files that aren't really firmware files in /lib/firmware.

Instead of copy-all-and-prune approach, copy only the listed files and links in WHENCE by make-install for assuring only the proper firmware files.

---
 Makefile         |  5 +----
 copy-firmware.sh | 30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 4 deletions(-)
 create mode 100755 copy-firmware.sh
Makefile +1 -4
index d1163b871096..16b5b1a02a49 100644
@@ -10,7 +10,4 @@ check:
 
 install:
 	mkdir -p $(DESTDIR)$(FIRMWAREDIR)
-	cp -r * $(DESTDIR)$(FIRMWAREDIR)
-	rm -rf $(DESTDIR)$(FIRMWAREDIR)/usbdux
-	find $(DESTDIR)$(FIRMWAREDIR) \( -name 'WHENCE' -or -name 'LICENSE.*' -or \
-		-name 'LICENCE.*' \) -exec rm -- {} \;
+	./copy-firmware.sh $(DESTDIR)$(FIRMWAREDIR)
copy-firmware.sh new file +30 -0
new file mode 100755
index 000000000000..7b276e271cfa
@@ -0,0 +1,30 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copy firmware files based on WHENCE list
+#
+
+verbose=:
+if [ x"$1" = x"-v" ]; then
+    verbose=echo
+    shift
+fi
+
+destdir="$1"
+
+grep '^File:' WHENCE | sed -e's/^File: *//g' -e's/"//g' | while read f; do
+    test -f "$f" || continue
+    $verbose "copying file $f"
+    mkdir -p $destdir/$(dirname "$f")
+    cp -d "$f" $destdir/"$f"
+done
+
+grep -E '^Link:' WHENCE | sed -e's/^Link: *//g' -e's/-> //g' | while read f d; do
+    test -L "$f" || continue
+    test -f "$destdir/$f" && continue
+    $verbose "copying link $f"
+    mkdir -p $destdir/$(dirname "$f")
+    cp -d "$f" $destdir/"$f"
+done
+
+exit 0
Signature · 1 line
2.16.4
#1 lore raw
Quoted 9 lines · Takashi Iwai

The current make-install procedure leaves lots of garbage files that aren't really firmware files in /lib/firmware.

Instead of copy-all-and-prune approach, copy only the listed files and links in WHENCE by make-install for assuring only the proper firmware files.

Thanks! Applied and pushed out.

josh