]>
git.proxmox.com Git - mirror_linux-firmware.git/blob - copy-firmware.sh
2 # SPDX-License-Identifier: GPL-2.0
4 # Copy firmware files based on WHENCE list
9 # shellcheck disable=SC2209
13 while test $# -gt 0; do
16 # shellcheck disable=SC2209
27 if test "$compext" = ".zst"; then
28 echo "ERROR: cannot mix XZ and ZSTD compression"
31 compress="xz --compress --quiet --stdout --check=crc32"
37 if test "$compext" = ".xz"; then
38 echo "ERROR: cannot mix XZ and ZSTD compression"
41 # shellcheck disable=SC2209
42 compress="zstd --compress --quiet --stdout"
48 if test "x$destdir" != "x"; then
49 echo "ERROR: unknown command-line options: $*"
59 # shellcheck disable=SC2162 # file/folder name can include escaped symbols
60 grep '^File:' WHENCE |
sed -e 's/^File: *//g;s/"//g' |
while read f
; do
61 test -f "$f" ||
continue
62 install -d "$destdir/$(dirname "$f")"
63 $verbose "copying/compressing file $f$compext"
64 if test "$compress" != "cat" && grep -q "^Raw: $f\$" WHENCE
; then
65 $verbose "compression will be skipped for file $f"
66 cat "$f" > "$destdir/$f"
68 $compress "$f" > "$destdir/$f$compext"
72 # shellcheck disable=SC2162 # file/folder name can include escaped symbols
73 grep -E '^Link:' WHENCE |
sed -e 's/^Link: *//g;s/-> //g' |
while read f d
; do
74 if test -L "$f$compext"; then
75 test -f "$destdir/$f$compext" && continue
76 $verbose "copying link $f$compext"
77 install -d "$destdir/$(dirname "$f")"
78 cp -d "$f$compext" "$destdir/$f$compext"
80 if test "x$d" != "x"; then
81 target
="$(readlink "$f")"
83 if test "x$target" != "x$d"; then
84 $verbose "WARNING: inconsistent symlink target: $target != $d"
86 if test "x$prune" != "xyes"; then
87 $verbose "WARNING: unneeded symlink detected: $f"
89 $verbose "WARNING: pruning unneeded symlink $f"
94 $verbose "WARNING: missing target for symlink $f"
97 directory
="$destdir/$(dirname "$f")"
98 install -d "$directory"
99 target
="$(cd "$directory" && realpath -m -s "$d")"
100 if test -d "$target"; then
101 $verbose "creating link $f -> $d"
102 ln -s "$d" "$destdir/$f"
104 $verbose "creating link $f$compext -> $d$compext"
105 ln -s "$d$compext" "$destdir/$f$compext"
112 # vim: et sw=4 sts=4 ts=4