]>
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 "$compress" = "cat"; then
49 echo "ERROR: unknown command-line option: $1"
52 compress="$compress $1"
56 if test "x$destdir" != "x"; then
57 echo "ERROR: unknown command-line options: $*"
67 # shellcheck disable=SC2162 # file/folder name can include escaped symbols
68 grep -E '^(RawFile|File):' WHENCE |
sed -E -e 's/^(RawFile|File): */\1 /;s/"//g' |
while read k f
; do
69 test -f "$f" ||
continue
70 install -d "$destdir/$(dirname "$f")"
71 $verbose "copying/compressing file $f$compext"
72 if test "$compress" != "cat" && test "$k" = "RawFile"; then
73 $verbose "compression will be skipped for file $f"
74 cat "$f" > "$destdir/$f"
76 $compress "$f" > "$destdir/$f$compext"
80 $verbose "Finding duplicate files"
81 rdfind
-makesymlinks true
-makeresultsfile false
"$destdir" >/dev
/null
82 find "$destdir" -type l |
while read -r l
; do
83 target
="$(realpath "$l")"
84 $verbose "Correcting path for $l"
85 ln -fs "$(realpath --relative-to="$
(dirname "$(realpath -s "$l")")" "$target")" "$l"
88 # shellcheck disable=SC2162 # file/folder name can include escaped symbols
89 grep -E '^Link:' WHENCE |
sed -e 's/^Link: *//g;s/-> //g' |
while read f d
; do
90 if test -L "$f$compext"; then
91 test -f "$destdir/$f$compext" && continue
92 $verbose "copying link $f$compext"
93 install -d "$destdir/$(dirname "$f")"
94 cp -d "$f$compext" "$destdir/$f$compext"
96 if test "x$d" != "x"; then
97 target
="$(readlink "$f")"
99 if test "x$target" != "x$d"; then
100 $verbose "WARNING: inconsistent symlink target: $target != $d"
102 if test "x$prune" != "xyes"; then
103 $verbose "WARNING: unneeded symlink detected: $f"
105 $verbose "WARNING: pruning unneeded symlink $f"
110 $verbose "WARNING: missing target for symlink $f"
113 directory
="$destdir/$(dirname "$f")"
114 install -d "$directory"
115 target
="$(cd "$directory" && realpath -m -s "$d")"
116 if test -d "$target"; then
117 $verbose "creating link $f -> $d"
118 ln -s "$d" "$destdir/$f"
120 $verbose "creating link $f$compext -> $d$compext"
121 ln -s "$d$compext" "$destdir/$f$compext"
128 # vim: et sw=4 sts=4 ts=4