OCaml 4.14.0 rebuild
[arch-packages.git] / linux-firmware / repos / core-any / 0001-Add-support-for-compressing-firmware-in-copy-firmware.patch
blob17fb733bb746d32d05eb8e751d94918ea802aa95
1 From 7eec2b56f54c778d5bd6e7aea49ee03e3b76e769 Mon Sep 17 00:00:00 2001
2 From: Peter Robinson <pbrobinson@gmail.com>
3 Date: Fri, 22 Jan 2021 20:36:23 +0000
4 Subject: [PATCH v2] Add support for compressing firmware in copy-firmware.sh
6 As of kernel 5.3 there's initial support for loading compressed firmware.
7 At this stage the only supported compression methis is "xz -C crc32" but
8 this option brings significant benefits.
10 Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
11 ---
13 v2: quote filename for xz command
15 Makefile | 4 ++++
16 copy-firmware.sh | 47 +++++++++++++++++++++++++++++++----------------
17 2 files changed, 35 insertions(+), 16 deletions(-)
19 diff --git a/Makefile b/Makefile
20 index e1c362f..9a48471 100644
21 --- a/Makefile
22 +++ b/Makefile
23 @@ -11,3 +11,7 @@ check:
24 install:
25 mkdir -p $(DESTDIR)$(FIRMWAREDIR)
26 ./copy-firmware.sh $(DESTDIR)$(FIRMWAREDIR)
28 +installcompress:
29 + mkdir -p $(DESTDIR)$(FIRMWAREDIR)
30 + ./copy-firmware.sh -C $(DESTDIR)$(FIRMWAREDIR)
31 diff --git a/copy-firmware.sh b/copy-firmware.sh
32 index 9b46b63..0dd2e5c 100755
33 --- a/copy-firmware.sh
34 +++ b/copy-firmware.sh
35 @@ -6,6 +6,7 @@
37 verbose=:
38 prune=no
39 +compress=no
41 while test $# -gt 0; do
42 case $1 in
43 @@ -19,6 +20,11 @@ while test $# -gt 0; do
44 shift
47 + -C | --compress)
48 + compress=yes
49 + shift
50 + ;;
53 if test "x$destdir" != "x"; then
54 echo "ERROR: unknown command-line options: $@"
55 @@ -31,40 +37,49 @@ while test $# -gt 0; do
56 esac
57 done
59 +if test "x$compress" = "xyes"; then
60 + cmpxtn=.xz
61 + grep '^File:' WHENCE | sed -e's/^File: *//g' -e's/"//g' | while read f; do
62 + test -f "$f" || continue
63 + $verbose "compressing $f"
64 + xz -C crc32 "$f"
65 + done
66 +fi
68 grep '^File:' WHENCE | sed -e's/^File: *//g' -e's/"//g' | while read f; do
69 - test -f "$f" || continue
70 - $verbose "copying file $f"
71 - install -d $destdir/$(dirname "$f")
72 - cp -d "$f" $destdir/"$f"
73 + test -f "$f$cmpxtn" || continue
74 + $verbose "copying file $f$cmpxtn"
75 + install -d $destdir/$(dirname "$f$cmpxtn")
76 + cp -d "$f$cmpxtn" $destdir/"$f$cmpxtn"
77 done
79 grep -E '^Link:' WHENCE | sed -e's/^Link: *//g' -e's/-> //g' | while read f d; do
80 - if test -L "$f"; then
81 - test -f "$destdir/$f" && continue
82 - $verbose "copying link $f"
83 - install -d $destdir/$(dirname "$f")
84 + if test -L "$f$cmpxtn"; then
85 + test -f "$destdir/$f$cmpxtn" && continue
86 + $verbose "copying link $f$cmpxtn"
87 + install -d $destdir/$(dirname "$f$cmpxtn")
88 cp -d "$f" $destdir/"$f"
90 if test "x$d" != "x"; then
91 - target=`readlink "$f"`
92 + target=`readlink "$f$cmpxtn"`
94 if test "x$target" != "x$d"; then
95 $verbose "WARNING: inconsistent symlink target: $target != $d"
96 else
97 if test "x$prune" != "xyes"; then
98 - $verbose "WARNING: unneeded symlink detected: $f"
99 + $verbose "WARNING: unneeded symlink detected: $f$cmpxtn"
100 else
101 - $verbose "WARNING: pruning unneeded symlink $f"
102 - rm -f "$f"
103 + $verbose "WARNING: pruning unneeded symlink $f$cmpxtn"
104 + rm -f "$f$cmpxtn"
107 else
108 - $verbose "WARNING: missing target for symlink $f"
109 + $verbose "WARNING: missing target for symlink $f$cmpxtn"
111 else
112 - $verbose "creating link $f -> $d"
113 - install -d $destdir/$(dirname "$f")
114 - ln -sf "$d" "$destdir/$f"
115 + $verbose "creating link $f$cmpxtn -> $d$cmpxtn"
116 + install -d $destdir/$(dirname "$f$cmpxtn")
117 + ln -sf "$d$cmpxtn" "$destdir/$f$cmpxtn"
119 done
122 2.29.2