diff options
-rw-r--r-- | packaging/macros.fdupes | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/packaging/macros.fdupes b/packaging/macros.fdupes index e99f1f2..9ec8e78 100644 --- a/packaging/macros.fdupes +++ b/packaging/macros.fdupes @@ -2,22 +2,26 @@ %fdupes(s) \ _target=""; \ _symlinks=0; \ + _files=(); \ %{-s:_symlinks=1;} \ fdupes -q -n -r %1 | \ while read _file; do \ - if test -z "$_target" ; then \ - _target="$_file"; \ - else \ - if test -z "$_file" ; then \ - _target=""; \ - continue ; \ - fi ; \ - if test "$_symlinks" = 1; then \ - ln -sf "${_target#%{buildroot}}" "$_file"; \ - else \ - ln -f "$_target" "$_file"; \ - fi ;\ - fi ; \ + if test -z $_file; then \ + _sorted_files=($(for i in ${_files[*]}; do echo $i; done | sort)); \ + _target=${_sorted_files[0]}; \ + for i in $(seq 1 $((${#_sorted_files[@]}-1))); do \ + symlink_file=${_sorted_files[$i]}; \ + rm $symlink_file;\ + if test "$_symlinks" = 1; then \ + ln -sf "${_target#%{buildroot}}" "$symlink_file"; \ + else \ + ln -f "$_target" "$symlink_file"; \ + fi ;\ + done; \ + _files=(); \ + else \ + _files+=($_file); \ + fi; \ done \ %{nil} |