From db99828b2466119dc068d56ffff4066192347105 Mon Sep 17 00:00:00 2001 From: Juerg Haefliger Date: Wed, 9 Aug 2023 11:40:59 +0200 Subject: [PATCH] copy-firmware: Introduce 'RawFile' keyword Currently, 'Raw: ' needs to be added to WHENCE for files that must not be compressed. This means that such files need to be listed twice ('File: ' and 'Raw: ') which is not pretty and error prone. Also, the current implementation is broken for filenames that contain quotes (") and it also requires grep'ing of WHENCE for every processed line which slows things down. Fix all of the above by introducing a new keyword 'RawFile' so that such files are listed only once, quotes are handled correctly and grep is no longer needed. Signed-off-by: Juerg Haefliger Signed-off-by: Josh Boyer --- copy-firmware.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/copy-firmware.sh b/copy-firmware.sh index 20746a47..1ae1e37c 100755 --- a/copy-firmware.sh +++ b/copy-firmware.sh @@ -65,11 +65,11 @@ while test $# -gt 0; do done # shellcheck disable=SC2162 # file/folder name can include escaped symbols -grep '^File:' WHENCE | sed -e 's/^File: *//g;s/"//g' | while read f; do +grep -E '^(RawFile|File):' WHENCE | sed -E -e 's/^(RawFile|File): */\1 /;s/"//g' | while read k f; do test -f "$f" || continue install -d "$destdir/$(dirname "$f")" $verbose "copying/compressing file $f$compext" - if test "$compress" != "cat" && grep -q "^Raw: $f\$" WHENCE; then + if test "$compress" != "cat" && test "$k" = "RawFile"; then $verbose "compression will be skipped for file $f" cat "$f" > "$destdir/$f" else