copy-firmware: Introduce 'RawFile' keyword

Currently, 'Raw: <filename>' needs to be added to WHENCE for files that
must not be compressed. This means that such files need to be listed
twice ('File: <filename>' and 'Raw: <filename>') 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 <juerg.haefliger@canonical.com>
Signed-off-by: Josh Boyer <jwboyer@kernel.org>
This commit is contained in:
Juerg Haefliger 2023-08-09 11:40:59 +02:00 committed by Josh Boyer
parent 2bad80e7ed
commit db99828b24
No known key found for this signature in database
GPG Key ID: A31B6BD72486CFD6
1 changed files with 2 additions and 2 deletions

View File

@ -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