Update copy-firmware script

This commit is contained in:
inference 2023-11-28 06:04:28 +00:00
parent 6bb6b6d2cb
commit 83601c8f0e
Signed by: inference
SSH Key Fingerprint: SHA256:FtEVfx1CmTKMy40VwZvF4k+3TC+QhCWy+EmPRg50Nnc
1 changed files with 20 additions and 10 deletions

View File

@ -9,6 +9,7 @@ prune=no
# shellcheck disable=SC2209
compress=cat
compext=
skip_dedup=0
while test $# -gt 0; do
case $1 in
@ -44,6 +45,11 @@ while test $# -gt 0; do
shift
;;
--ignore-duplicates)
skip_dedup=1
shift
;;
-*)
if test "$compress" = "cat"; then
echo "ERROR: unknown command-line option: $1"
@ -69,9 +75,11 @@ if [ -z "$destdir" ]; then
exit 1
fi
if ! which rdfind 2>/dev/null >/dev/null; then
echo "ERROR: rdfind is not installed"
exit 1
if ! command -v rdfind >/dev/null; then
if [ "$skip_dedup" != 1 ]; then
echo "ERROR: rdfind is not installed. Pass --ignore-duplicates to skip deduplication"
exit 1
fi
fi
# shellcheck disable=SC2162 # file/folder name can include escaped symbols
@ -87,13 +95,15 @@ grep -E '^(RawFile|File):' WHENCE | sed -E -e 's/^(RawFile|File): */\1 /;s/"//g'
fi
done
$verbose "Finding duplicate files"
rdfind -makesymlinks true -makeresultsfile false "$destdir" >/dev/null
find "$destdir" -type l | while read -r l; do
target="$(realpath "$l")"
$verbose "Correcting path for $l"
ln -fs "$(realpath --relative-to="$(dirname "$(realpath -s "$l")")" "$target")" "$l"
done
if [ "$skip_dedup" != 1 ] ; then
$verbose "Finding duplicate files"
rdfind -makesymlinks true -makeresultsfile false "$destdir" >/dev/null
find "$destdir" -type l | while read -r l; do
target="$(realpath "$l")"
$verbose "Correcting path for $l"
ln -fs "$(realpath --relative-to="$(dirname "$(realpath -s "$l")")" "$target")" "$l"
done
fi
# shellcheck disable=SC2162 # file/folder name can include escaped symbols
grep -E '^Link:' WHENCE | sed -e 's/^Link: *//g;s/-> //g' | while read f d; do