]> git.ipfire.org Git - ipfire-2.x.git/blob - src/patches/0001-Add-support-for-compressing-firmware-in-copy-firmwar.patch
zlib: Update to 1.2.12
[ipfire-2.x.git] / src / patches / 0001-Add-support-for-compressing-firmware-in-copy-firmwar.patch
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
5
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.
9
10 Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
11 ---
12
13 v2: quote filename for xz command
14
15 Makefile | 4 ++++
16 copy-firmware.sh | 47 +++++++++++++++++++++++++++++++----------------
17 2 files changed, 35 insertions(+), 16 deletions(-)
18
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)
27 +
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 @@
36
37 verbose=:
38 prune=no
39 +compress=no
40
41 while test $# -gt 0; do
42 case $1 in
43 @@ -19,6 +20,11 @@ while test $# -gt 0; do
44 shift
45 ;;
46
47 + -C | --compress)
48 + compress=yes
49 + shift
50 + ;;
51 +
52 *)
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
58
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
67 +
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 - mkdir -p $destdir/$(dirname "$f")
72 - cp -d "$f" $destdir/"$f"
73 + test -f "$f$cmpxtn" || continue
74 + $verbose "copying file $f$cmpxtn"
75 + mkdir -p $destdir/$(dirname "$f$cmpxtn")
76 + cp -d "$f$cmpxtn" $destdir/"$f$cmpxtn"
77 done
78
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 - mkdir -p $destdir/$(dirname "$f")
84 + if test -L "$f$cmpxtn"; then
85 + test -f "$destdir/$f$cmpxtn" && continue
86 + $verbose "copying link $f$cmpxtn"
87 + mkdir -p $destdir/$(dirname "$f$cmpxtn")
88 cp -d "$f" $destdir/"$f"
89
90 if test "x$d" != "x"; then
91 - target=`readlink "$f"`
92 + target=`readlink "$f$cmpxtn"`
93
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"
105 fi
106 fi
107 else
108 - $verbose "WARNING: missing target for symlink $f"
109 + $verbose "WARNING: missing target for symlink $f$cmpxtn"
110 fi
111 else
112 - $verbose "creating link $f -> $d"
113 - mkdir -p $destdir/$(dirname "$f")
114 - ln -sf "$d" "$destdir/$f"
115 + $verbose "creating link $f$cmpxtn -> $d$cmpxtn"
116 + mkdir -p $destdir/$(dirname "$f$cmpxtn")
117 + ln -sf "$d$cmpxtn" "$destdir/$f$cmpxtn"
118 fi
119 done
120
121 --
122 2.29.2
123