Browse Source

Make rdfind optional

A number of distributions don't include rdfind by default.  This is an
optimization, so make it optional via a --ignore-duplicates option and a
new make target.

Distributions that include rdfind should add it as a dependency for
their linux-firmware package.  Those that don't should use the new
target or option.

Signed-off-by: Josh Boyer <jwboyer@kernel.org>
main
Josh Boyer 1 year ago
parent
commit
4124f8f928
No known key found for this signature in database
GPG Key ID: A31B6BD72486CFD6
  1. 4
      Makefile
  2. 28
      copy-firmware.sh

4
Makefile

@ -30,6 +30,10 @@ install:
install -d $(DESTDIR)$(FIRMWAREDIR) install -d $(DESTDIR)$(FIRMWAREDIR)
./copy-firmware.sh $(DESTDIR)$(FIRMWAREDIR) ./copy-firmware.sh $(DESTDIR)$(FIRMWAREDIR)


install-nodedup:
install -d $(DESTDIR)$(FIRMWAREDIR)
./copy-firmware.sh --ignore-duplicates $(DESTDIR)$(FIRMWAREDIR)

install-xz: install-xz:
install -d $(DESTDIR)$(FIRMWAREDIR) install -d $(DESTDIR)$(FIRMWAREDIR)
./copy-firmware.sh --xz $(DESTDIR)$(FIRMWAREDIR) ./copy-firmware.sh --xz $(DESTDIR)$(FIRMWAREDIR)

28
copy-firmware.sh

@ -9,6 +9,7 @@ prune=no
# shellcheck disable=SC2209 # shellcheck disable=SC2209
compress=cat compress=cat
compext= compext=
skip_dedup=0


while test $# -gt 0; do while test $# -gt 0; do
case $1 in case $1 in
@ -44,6 +45,11 @@ while test $# -gt 0; do
shift shift
;; ;;


--ignore-duplicates)
skip_dedup=1
shift
;;

-*) -*)
if test "$compress" = "cat"; then if test "$compress" = "cat"; then
echo "ERROR: unknown command-line option: $1" echo "ERROR: unknown command-line option: $1"
@ -70,8 +76,10 @@ if [ -z "$destdir" ]; then
fi fi


if ! command -v rdfind >/dev/null; then if ! command -v rdfind >/dev/null; then
echo "ERROR: rdfind is not installed" if [ "$skip_dedup" != 1 ]; then
exit 1 echo "ERROR: rdfind is not installed. Pass --ignore-duplicates to skip deduplication"
exit 1
fi
fi fi


# shellcheck disable=SC2162 # file/folder name can include escaped symbols # 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 fi
done done


$verbose "Finding duplicate files" if [ "$skip_dedup" != 1 ] ; then
rdfind -makesymlinks true -makeresultsfile false "$destdir" >/dev/null $verbose "Finding duplicate files"
find "$destdir" -type l | while read -r l; do rdfind -makesymlinks true -makeresultsfile false "$destdir" >/dev/null
target="$(realpath "$l")" find "$destdir" -type l | while read -r l; do
$verbose "Correcting path for $l" target="$(realpath "$l")"
ln -fs "$(realpath --relative-to="$(dirname "$(realpath -s "$l")")" "$target")" "$l" $verbose "Correcting path for $l"
done ln -fs "$(realpath --relative-to="$(dirname "$(realpath -s "$l")")" "$target")" "$l"
done
fi


# shellcheck disable=SC2162 # file/folder name can include escaped symbols # 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 grep -E '^Link:' WHENCE | sed -e 's/^Link: *//g;s/-> //g' | while read f d; do

Loading…
Cancel
Save