summaryrefslogtreecommitdiff
path: root/sys-kernel/linux-firmware/files/linux-firmware-copy-firmware-r7.patch
blob: a27c9521815edafa8d38d9fdae0cf059b39cbde5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
--- a/copy-firmware.sh	2024-11-11 03:15:42.000000000 +0100
+++ b/copy-firmware.sh	2024-12-11 07:45:50.451166572 +0100
@@ -46,6 +46,16 @@
             shift
             ;;
 
+        --firmware-list)
+            if [ -n "$2" ]; then
+                FIRMWARE_LIST=$2
+                shift 2
+            else
+                echo "ERROR: '--firmware-list' requires a non-empty option argument of firmware files to install"
+                exit 1
+            fi
+            ;;
+
         *)
             if test -n "$destdir"; then
                 err "unknown command-line options: $*"
@@ -70,8 +80,18 @@
     ./check_whence.py || err "check_whence.py has detected errors."
 fi
 
+if test -n "${FIRMWARE_LIST}"; then
+    grep -E '^Link:' WHENCE | sed -e 's/^Link: *//g;s/-> //g' | while read l t; do
+        if ! cat "${FIRMWARE_LIST}" | grep -q "${l}"; then continue; fi
+        target="$(realpath --relative-to="$(pwd)" -m -s "$(dirname "$l")/$t")"
+        echo "${target}" >> "${FIRMWARE_LIST}"
+    done
+    FIRMWARE_LIST=$(cat "${FIRMWARE_LIST}")
+fi
+
 # shellcheck disable=SC2162 # file/folder name can include escaped symbols
 grep -E '^(RawFile|File):' WHENCE | sed -E -e 's/^(RawFile|File): */\1 /;s/"//g' | while read k f; do
+    [ -n "${FIRMWARE_LIST}" ]  && if ! echo "${FIRMWARE_LIST}" | grep -q "${f}"; then continue; fi
     install -d "$destdir/$(dirname "$f")"
     $verbose "copying/compressing file $f$compext"
     if test "$compress" != "cat" && test "$k" = "RawFile"; then
@@ -84,6 +104,7 @@
 
 # shellcheck disable=SC2162 # file/folder name can include escaped symbols
 grep -E '^Link:' WHENCE | sed -e 's/^Link: *//g;s/-> //g' | while read l t; do
+    [ -n "${FIRMWARE_LIST}" ]  && if ! echo "${FIRMWARE_LIST}" | grep -q "${l}"; then continue; fi
     directory="$destdir/$(dirname "$l")"
     install -d "$directory"
     target="$(cd "$directory" && realpath -m -s "$t")"
@@ -98,7 +119,9 @@
 
 # Verify no broken symlinks
 if test "$(find "$destdir" -xtype l | wc -l)" -ne 0 ; then
-    err "Broken symlinks found:\\n$(find "$destdir" -xtype l)"
+    if  [ -z "${FIRMWARE_LIST}" ]; then
+        err "Broken symlinks found:\\n$(find "$destdir" -xtype l)"
+    fi
 fi
 
 exit 0