Blame SOURCES/0001-Add-support-for-compressing-firmware-in-copy-firmwar.patch

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