summaryrefslogtreecommitdiff
path: root/sys-kernel/linux-firmware/files/linux-firmware-copy-firmware-r3.patch
blob: 0801b60f5ffa4125a1e2c09b1b1cb03feff63752 (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
58
59
From 4eee756fa1e02c3e8ea168ac0efa16b30dae3b25 Mon Sep 17 00:00:00 2001
From: Mike Pagano <mpagano@gentoo.org>
Date: Sat, 23 Dec 2023 13:14:58 -0500
Subject: [PATCH] [PATCH] copy-firmware.sh: Support passing in firmware files
 to install
Cc: mpagano@gentoo.org

This change adds support to copy-firmware.sh to accept a space separated
list of firmware files to install.

This allows our users to define a small subset of needed firmware files
their system requires without installing every firmware file included
from the repository.

Signed-off-by: Mike Pagano <mpagano@gentoo.org>
---
 copy-firmware.sh | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/copy-firmware.sh b/copy-firmware.sh
index 6757c6ce..d954230d 100755
--- a/copy-firmware.sh
+++ b/copy-firmware.sh
@@ -50,6 +50,16 @@ while test $# -gt 0; do
             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 "$compress" = "cat"; then
                 echo "ERROR: unknown command-line option: $1"
@@ -85,6 +95,7 @@ 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
     test -f "$f" || continue
+	   [ -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
@@ -107,6 +118,7 @@ fi
 
 # shellcheck disable=SC2162 # file/folder name can include escaped symbols
 grep -E '^Link:' WHENCE | sed -e 's/^Link: *//g;s/-> //g' | while read f d; do
+	   [ -n "${FIRMWARE_LIST}" ]  && if ! echo "${FIRMWARE_LIST}" | grep -q "${f}"; then continue; fi
     if test -L "$f$compext"; then
         test -f "$destdir/$f$compext" && continue
         $verbose "copying link $f$compext"
-- 
2.41.0