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>
13 v2: quote filename for xz command
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
23 @@ -11,3 +11,7 @@ check:
25 mkdir -p $(DESTDIR)$(FIRMWAREDIR)
26 ./copy-firmware.sh $(DESTDIR)$(FIRMWAREDIR)
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
41 while test $# -gt 0; do
43 @@ -19,6 +20,11 @@ while test $# -gt 0; do
53 if test "x$destdir" != "x"; then
54 echo "ERROR: unknown command-line options: $@"
55 @@ -31,40 +37,49 @@ while test $# -gt 0; do
59 +if test "x$compress" = "xyes"; then
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"
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"
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"
97 if test "x$prune" != "xyes"; then
98 - $verbose "WARNING: unneeded symlink detected: $f"
99 + $verbose "WARNING: unneeded symlink detected: $f$cmpxtn"
101 - $verbose "WARNING: pruning unneeded symlink $f"
103 + $verbose "WARNING: pruning unneeded symlink $f$cmpxtn"
108 - $verbose "WARNING: missing target for symlink $f"
109 + $verbose "WARNING: missing target for symlink $f$cmpxtn"
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"