]> git.proxmox.com Git - mirror_linux-firmware.git/blobdiff - copy-firmware.sh
iwlwifi: update cc/Qu/QuZ firmwares for core83-55 release
[mirror_linux-firmware.git] / copy-firmware.sh
index 148f0f199e5f41e15c703f883c6db613f1c2359b..f9b1f0ffc1c31c08c85d4bdc5c1cca692076885e 100755 (executable)
@@ -44,6 +44,14 @@ while test $# -gt 0; do
             shift
             ;;
 
+        -*)
+            if test "$compress" = "cat"; then
+                echo "ERROR: unknown command-line option: $1"
+                exit 1
+            fi
+            compress="$compress $1"
+            shift
+            ;;
         *)
             if test "x$destdir" != "x"; then
                 echo "ERROR: unknown command-line options: $*"
@@ -56,12 +64,22 @@ while test $# -gt 0; do
     esac
 done
 
+if [ -z "$destdir" ]; then
+       echo "ERROR: destination directory was not specified"
+       exit 1
+fi
+
+if ! which rdfind 2>/dev/null >/dev/null; then
+       echo "ERROR: rdfind is not installed"
+       exit 1
+fi
+
 # shellcheck disable=SC2162 # file/folder name can include escaped symbols
-grep '^File:' WHENCE | sed -e 's/^File: *//g;s/"//g' | while read f; do
+grep -E '^(RawFile|File):' WHENCE | sed -E -e 's/^(RawFile|File): */\1 /;s/"//g' | while read k f; do
     test -f "$f" || continue
     install -d "$destdir/$(dirname "$f")"
     $verbose "copying/compressing file $f$compext"
-    if test "$compress" != "cat" && grep -q "^Raw: $f\$" WHENCE; then
+    if test "$compress" != "cat" && test "$k" = "RawFile"; then
         $verbose "compression will be skipped for file $f"
         cat "$f" > "$destdir/$f"
     else
@@ -69,6 +87,14 @@ grep '^File:' WHENCE | sed -e 's/^File: *//g;s/"//g' | while read f; do
     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
+
 # 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
     if test -L "$f$compext"; then