]>
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 rdfind_results
=/dev
/null
15 while test $# -gt 0; do
18 # shellcheck disable=SC2209
21 rdfind_results
=results.txt
31 if test "$compext" = ".zst"; then
32 echo "ERROR: cannot mix XZ and ZSTD compression"
35 compress="xz --compress --quiet --stdout --check=crc32"
41 if test "$compext" = ".xz"; then
42 echo "ERROR: cannot mix XZ and ZSTD compression"
45 # shellcheck disable=SC2209
46 compress="zstd --compress --quiet --stdout"
52 if test "$compress" = "cat"; then
53 echo "ERROR: unknown command-line option: $1"
56 compress="$compress $1"
60 if test "x$destdir" != "x"; then
61 echo "ERROR: unknown command-line options: $*"
71 # shellcheck disable=SC2162 # file/folder name can include escaped symbols
72 grep -E '^(RawFile|File):' WHENCE |
sed -E -e 's/^(RawFile|File): */\1 /;s/"//g' |
while read k f
; do
73 test -f "$f" ||
continue
74 install -d "$destdir/$(dirname "$f")"
75 $verbose "copying/compressing file $f$compext"
76 if test "$compress" != "cat" && test "$k" = "RawFile"; then
77 $verbose "compression will be skipped for file $f"
78 cat "$f" > "$destdir/$f"
80 $compress "$f" > "$destdir/$f$compext"
84 # shellcheck disable=SC2162 # file/folder name can include escaped symbols
85 grep -E '^Link:' WHENCE |
sed -e 's/^Link: *//g;s/-> //g' |
while read f d
; do
86 if test -L "$f$compext"; then
87 test -f "$destdir/$f$compext" && continue
88 $verbose "copying link $f$compext"
89 install -d "$destdir/$(dirname "$f")"
90 cp -d "$f$compext" "$destdir/$f$compext"
92 if test "x$d" != "x"; then
93 target
="$(readlink "$f")"
95 if test "x$target" != "x$d"; then
96 $verbose "WARNING: inconsistent symlink target: $target != $d"
98 if test "x$prune" != "xyes"; then
99 $verbose "WARNING: unneeded symlink detected: $f"
101 $verbose "WARNING: pruning unneeded symlink $f"
106 $verbose "WARNING: missing target for symlink $f"
109 directory
="$destdir/$(dirname "$f")"
110 install -d "$directory"
111 target
="$(cd "$directory" && realpath -m -s "$d")"
112 if test -d "$target"; then
113 $verbose "creating link $f -> $d"
114 ln -s "$d" "$destdir/$f"
116 $verbose "creating link $f$compext -> $d$compext"
117 ln -s "$d$compext" "$destdir/$f$compext"
122 $verbose rdfind
-makesymlinks true
"$destdir" -outputname $rdfind_results "$quiet"
123 find "$destdir" -type l |
while read -r l
; do
124 target
="$(realpath "$l")"
125 ln -fs "$(realpath --relative-to="$
(dirname "$(realpath -s "$l")")" "$target")" "$l"
130 # vim: et sw=4 sts=4 ts=4