]>
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
14 while test $# -gt 0; do
17 # shellcheck disable=SC2209
28 if test "$compext" = ".zst"; then
29 echo "ERROR: cannot mix XZ and ZSTD compression"
32 compress="xz --compress --quiet --stdout --check=crc32"
38 if test "$compext" = ".xz"; then
39 echo "ERROR: cannot mix XZ and ZSTD compression"
42 # shellcheck disable=SC2209
43 compress="zstd --compress --quiet --stdout"
54 if test "$compress" = "cat"; then
55 echo "ERROR: unknown command-line option: $1"
58 compress="$compress $1"
62 if test "x$destdir" != "x"; then
63 echo "ERROR: unknown command-line options: $*"
73 if [ -z "$destdir" ]; then
74 echo "ERROR: destination directory was not specified"
78 if ! command -v rdfind
>/dev
/null
; then
79 if [ "$skip_dedup" != 1 ]; then
80 echo "ERROR: rdfind is not installed. Pass --ignore-duplicates to skip deduplication"
85 # shellcheck disable=SC2162 # file/folder name can include escaped symbols
86 grep -E '^(RawFile|File):' WHENCE |
sed -E -e 's/^(RawFile|File): */\1 /;s/"//g' |
while read k f
; do
87 test -f "$f" ||
continue
88 install -d "$destdir/$(dirname "$f")"
89 $verbose "copying/compressing file $f$compext"
90 if test "$compress" != "cat" && test "$k" = "RawFile"; then
91 $verbose "compression will be skipped for file $f"
92 cat "$f" > "$destdir/$f"
94 $compress "$f" > "$destdir/$f$compext"
98 if [ "$skip_dedup" != 1 ] ; then
99 $verbose "Finding duplicate files"
100 rdfind
-makesymlinks true
-makeresultsfile false
"$destdir" >/dev
/null
101 find "$destdir" -type l |
while read -r l
; do
102 target
="$(realpath "$l")"
103 $verbose "Correcting path for $l"
104 ln -fs "$(realpath --relative-to="$
(dirname "$(realpath -s "$l")")" "$target")" "$l"
108 # shellcheck disable=SC2162 # file/folder name can include escaped symbols
109 grep -E '^Link:' WHENCE |
sed -e 's/^Link: *//g;s/-> //g' |
while read f d
; do
110 if test -L "$f$compext"; then
111 test -f "$destdir/$f$compext" && continue
112 $verbose "copying link $f$compext"
113 install -d "$destdir/$(dirname "$f")"
114 cp -d "$f$compext" "$destdir/$f$compext"
116 if test "x$d" != "x"; then
117 target
="$(readlink "$f")"
119 if test "x$target" != "x$d"; then
120 $verbose "WARNING: inconsistent symlink target: $target != $d"
122 if test "x$prune" != "xyes"; then
123 $verbose "WARNING: unneeded symlink detected: $f"
125 $verbose "WARNING: pruning unneeded symlink $f"
130 $verbose "WARNING: missing target for symlink $f"
133 directory
="$destdir/$(dirname "$f")"
134 install -d "$directory"
135 target
="$(cd "$directory" && realpath -m -s "$d")"
136 if test -d "$target"; then
137 $verbose "creating link $f -> $d"
138 ln -s "$d" "$destdir/$f"
140 $verbose "creating link $f$compext -> $d$compext"
141 ln -s "$d$compext" "$destdir/$f$compext"
148 # vim: et sw=4 sts=4 ts=4