|
Peter Robinson |
a0da87 |
From 7eec2b56f54c778d5bd6e7aea49ee03e3b76e769 Mon Sep 17 00:00:00 2001
|
|
Peter Robinson |
a0da87 |
From: Peter Robinson <pbrobinson@gmail.com>
|
|
Peter Robinson |
a0da87 |
Date: Fri, 22 Jan 2021 20:36:23 +0000
|
|
Peter Robinson |
a0da87 |
Subject: [PATCH v2] Add support for compressing firmware in copy-firmware.sh
|
|
Peter Robinson |
a0da87 |
|
|
Peter Robinson |
a0da87 |
As of kernel 5.3 there's initial support for loading compressed firmware.
|
|
Peter Robinson |
a0da87 |
At this stage the only supported compression methis is "xz -C crc32" but
|
|
Peter Robinson |
a0da87 |
this option brings significant benefits.
|
|
Peter Robinson |
a0da87 |
|
|
Peter Robinson |
a0da87 |
Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
|
|
Peter Robinson |
a0da87 |
---
|
|
Peter Robinson |
a0da87 |
|
|
Peter Robinson |
a0da87 |
v2: quote filename for xz command
|
|
Peter Robinson |
a0da87 |
|
|
Peter Robinson |
a0da87 |
Makefile | 4 ++++
|
|
Peter Robinson |
a0da87 |
copy-firmware.sh | 47 +++++++++++++++++++++++++++++++----------------
|
|
Peter Robinson |
a0da87 |
2 files changed, 35 insertions(+), 16 deletions(-)
|
|
Peter Robinson |
a0da87 |
|
|
Peter Robinson |
a0da87 |
diff --git a/Makefile b/Makefile
|
|
Peter Robinson |
a0da87 |
index e1c362f..9a48471 100644
|
|
Peter Robinson |
a0da87 |
--- a/Makefile
|
|
Peter Robinson |
a0da87 |
+++ b/Makefile
|
|
Peter Robinson |
65c684 |
@@ -11,3 +11,7 @@
|
|
Peter Robinson |
a0da87 |
install:
|
|
Peter Robinson |
65c684 |
install -d $(DESTDIR)$(FIRMWAREDIR)
|
|
Peter Robinson |
a0da87 |
./copy-firmware.sh $(DESTDIR)$(FIRMWAREDIR)
|
|
Peter Robinson |
a0da87 |
+
|
|
Peter Robinson |
a0da87 |
+installcompress:
|
|
Peter Robinson |
65c684 |
+ install -d $(DESTDIR)$(FIRMWAREDIR)
|
|
Peter Robinson |
a0da87 |
+ ./copy-firmware.sh -C $(DESTDIR)$(FIRMWAREDIR)
|
|
Peter Robinson |
a0da87 |
diff --git a/copy-firmware.sh b/copy-firmware.sh
|
|
Peter Robinson |
a0da87 |
index 9b46b63..0dd2e5c 100755
|
|
Peter Robinson |
a0da87 |
--- a/copy-firmware.sh
|
|
Peter Robinson |
a0da87 |
+++ b/copy-firmware.sh
|
|
Peter Robinson |
a0da87 |
@@ -6,6 +6,7 @@
|
|
Peter Robinson |
a0da87 |
|
|
Peter Robinson |
a0da87 |
verbose=:
|
|
Peter Robinson |
a0da87 |
prune=no
|
|
Peter Robinson |
a0da87 |
+compress=no
|
|
Peter Robinson |
a0da87 |
|
|
Peter Robinson |
a0da87 |
while test $# -gt 0; do
|
|
Peter Robinson |
a0da87 |
case $1 in
|
|
Peter Robinson |
a0da87 |
@@ -19,6 +20,11 @@ while test $# -gt 0; do
|
|
Peter Robinson |
a0da87 |
shift
|
|
Peter Robinson |
a0da87 |
;;
|
|
Peter Robinson |
a0da87 |
|
|
Peter Robinson |
a0da87 |
+ -C | --compress)
|
|
Peter Robinson |
a0da87 |
+ compress=yes
|
|
Peter Robinson |
a0da87 |
+ shift
|
|
Peter Robinson |
a0da87 |
+ ;;
|
|
Peter Robinson |
a0da87 |
+
|
|
Peter Robinson |
a0da87 |
*)
|
|
Peter Robinson |
a0da87 |
if test "x$destdir" != "x"; then
|
|
Peter Robinson |
a0da87 |
echo "ERROR: unknown command-line options: $@"
|
|
Peter Robinson |
a0da87 |
@@ -31,40 +37,49 @@ while test $# -gt 0; do
|
|
Peter Robinson |
a0da87 |
esac
|
|
Peter Robinson |
a0da87 |
done
|
|
Peter Robinson |
a0da87 |
|
|
Peter Robinson |
a0da87 |
+if test "x$compress" = "xyes"; then
|
|
Peter Robinson |
a0da87 |
+ cmpxtn=.xz
|
|
Peter Robinson |
a0da87 |
+ grep '^File:' WHENCE | sed -e's/^File: *//g' -e's/"//g' | while read f; do
|
|
Peter Robinson |
a0da87 |
+ test -f "$f" || continue
|
|
Peter Robinson |
a0da87 |
+ $verbose "compressing $f"
|
|
Peter Robinson |
a0da87 |
+ xz -C crc32 "$f"
|
|
Peter Robinson |
a0da87 |
+ done
|
|
Peter Robinson |
a0da87 |
+fi
|
|
Peter Robinson |
a0da87 |
+
|
|
Peter Robinson |
a0da87 |
grep '^File:' WHENCE | sed -e's/^File: *//g' -e's/"//g' | while read f; do
|
|
Peter Robinson |
a0da87 |
- test -f "$f" || continue
|
|
Peter Robinson |
a0da87 |
- $verbose "copying file $f"
|
|
Peter Robinson |
65c684 |
- install -d $destdir/$(dirname "$f")
|
|
Peter Robinson |
a0da87 |
- cp -d "$f" $destdir/"$f"
|
|
Peter Robinson |
a0da87 |
+ test -f "$f$cmpxtn" || continue
|
|
Peter Robinson |
a0da87 |
+ $verbose "copying file $f$cmpxtn"
|
|
Peter Robinson |
65c684 |
+ install -d $destdir/$(dirname "$f$cmpxtn")
|
|
Peter Robinson |
a0da87 |
+ cp -d "$f$cmpxtn" $destdir/"$f$cmpxtn"
|
|
Peter Robinson |
a0da87 |
done
|
|
Peter Robinson |
a0da87 |
|
|
Peter Robinson |
a0da87 |
grep -E '^Link:' WHENCE | sed -e's/^Link: *//g' -e's/-> //g' | while read f d; do
|
|
Peter Robinson |
a0da87 |
- if test -L "$f"; then
|
|
Peter Robinson |
a0da87 |
- test -f "$destdir/$f" && continue
|
|
Peter Robinson |
a0da87 |
- $verbose "copying link $f"
|
|
Peter Robinson |
65c684 |
- install -d $destdir/$(dirname "$f")
|
|
Peter Robinson |
a0da87 |
+ if test -L "$f$cmpxtn"; then
|
|
Peter Robinson |
a0da87 |
+ test -f "$destdir/$f$cmpxtn" && continue
|
|
Peter Robinson |
a0da87 |
+ $verbose "copying link $f$cmpxtn"
|
|
Peter Robinson |
65c684 |
+ install -d $destdir/$(dirname "$f$cmpxtn")
|
|
Peter Robinson |
a0da87 |
cp -d "$f" $destdir/"$f"
|
|
Peter Robinson |
a0da87 |
|
|
Peter Robinson |
a0da87 |
if test "x$d" != "x"; then
|
|
Peter Robinson |
a0da87 |
- target=`readlink "$f"`
|
|
Peter Robinson |
a0da87 |
+ target=`readlink "$f$cmpxtn"`
|
|
Peter Robinson |
a0da87 |
|
|
Peter Robinson |
a0da87 |
if test "x$target" != "x$d"; then
|
|
Peter Robinson |
a0da87 |
$verbose "WARNING: inconsistent symlink target: $target != $d"
|
|
Peter Robinson |
a0da87 |
else
|
|
Peter Robinson |
a0da87 |
if test "x$prune" != "xyes"; then
|
|
Peter Robinson |
a0da87 |
- $verbose "WARNING: unneeded symlink detected: $f"
|
|
Peter Robinson |
a0da87 |
+ $verbose "WARNING: unneeded symlink detected: $f$cmpxtn"
|
|
Peter Robinson |
a0da87 |
else
|
|
Peter Robinson |
a0da87 |
- $verbose "WARNING: pruning unneeded symlink $f"
|
|
Peter Robinson |
a0da87 |
- rm -f "$f"
|
|
Peter Robinson |
a0da87 |
+ $verbose "WARNING: pruning unneeded symlink $f$cmpxtn"
|
|
Peter Robinson |
a0da87 |
+ rm -f "$f$cmpxtn"
|
|
Peter Robinson |
a0da87 |
fi
|
|
Peter Robinson |
a0da87 |
fi
|
|
Peter Robinson |
a0da87 |
else
|
|
Peter Robinson |
a0da87 |
- $verbose "WARNING: missing target for symlink $f"
|
|
Peter Robinson |
a0da87 |
+ $verbose "WARNING: missing target for symlink $f$cmpxtn"
|
|
Peter Robinson |
a0da87 |
fi
|
|
Peter Robinson |
a0da87 |
else
|
|
Peter Robinson |
a0da87 |
- $verbose "creating link $f -> $d"
|
|
Peter Robinson |
65c684 |
- install -d $destdir/$(dirname "$f")
|
|
Peter Robinson |
a0da87 |
- ln -sf "$d" "$destdir/$f"
|
|
Peter Robinson |
a0da87 |
+ $verbose "creating link $f$cmpxtn -> $d$cmpxtn"
|
|
Peter Robinson |
65c684 |
+ install -d $destdir/$(dirname "$f$cmpxtn")
|
|
Peter Robinson |
a0da87 |
+ ln -sf "$d$cmpxtn" "$destdir/$f$cmpxtn"
|
|
Peter Robinson |
a0da87 |
fi
|
|
Peter Robinson |
a0da87 |
done
|
|
Peter Robinson |
a0da87 |
|
|
Peter Robinson |
a0da87 |
--
|
|
Peter Robinson |
a0da87 |
2.29.2
|
|
Peter Robinson |
a0da87 |
|