diff options
author | Junghyun Kim <jh0822.kim@samsung.com> | 2016-08-29 13:56:31 +0900 |
---|---|---|
committer | Junghyun Kim <jh0822.kim@samsung.com> | 2016-08-29 13:56:31 +0900 |
commit | 53ce4c8197d9fdfaa2df7661e912290b5d60e9a8 (patch) | |
tree | 0277a399306a216eb6dde51c81f5c7324f2d726a | |
parent | 796ff677d7ed1bdd2fb8d3b48572dba6a8e111f6 (diff) | |
download | fdupes-accepted/tizen_5.5_base_mobile_hotfix.tar.gz fdupes-accepted/tizen_5.5_base_mobile_hotfix.tar.bz2 fdupes-accepted/tizen_5.5_base_mobile_hotfix.zip |
Sort files after finding duplicates.tizen_6.5.m2_releasetizen_6.0.m2_releasetizen_5.5.m2_releasetizen_4.0.m2_releasetizen_4.0.m1_releasetizen_4.0.IoT.p2_releasetizen_4.0.IoT.p1_releasesubmit/tizen_base/20160921.004452submit/tizen_base/20160913.071300submit/tizen_6.5_base/20211027.200601submit/tizen_6.5_base/20211027.183101submit/tizen_6.5_base/20211026.180901submit/tizen_6.0_base_hotfix/20201102.162701submit/tizen_6.0_base_hotfix/20201030.192501submit/tizen_6.0_base/20201029.184801submit/tizen_5.5_base_wearable_hotfix/20201023.155601submit/tizen_5.5_base_mobile_hotfix/20201023.171501submit/tizen_5.5_base/20191030.000001submit/tizen_5.0_base/20181101.000001submit/tizen_4.0_base/20170828.000001submit/tizen_4.0_base/20170828.000000submit/tizen_4.0_base/20170811.071500submit/tizen_3.0_base/20161028.062323submit/tizen_3.0.m2_base/20170104.073748accepted/tizen/base/20160923.170305accepted/tizen/6.5/base/tool/20211027.115158accepted/tizen/6.5/base/20230714.002457accepted/tizen/6.0/base/tool/hotfix/20201102.090004accepted/tizen/6.0/base/tool/hotfix/20201030.124807accepted/tizen/6.0/base/tool/20201029.112006accepted/tizen/6.0/base/20230713.142830accepted/tizen/6.0/base/20201029.110531accepted/tizen/5.5/base/wearable/hotfix/20201023.080616accepted/tizen/5.5/base/mobile/hotfix/20201023.084213accepted/tizen/5.5/base/20191030.081620accepted/tizen/5.0/base/20181101.090205accepted/tizen/4.0/base/20170828.221013accepted/tizen/4.0/base/20170811.092623accepted/tizen/3.0/base/20161028.102927accepted/tizen/3.0.m2/base/20170104.081830tizen_6.5_basetizen_6.0_base_hotfixtizen_6.0_basetizen_5.5_tvtizen_5.5_base_wearable_hotfixtizen_5.5_base_mobile_hotfixtizen_5.5_basetizen_5.0_basetizen_4.0_tvtizen_4.0_basetizen_3.0_basetizen_3.0.m2_basesandbox/backup/fdupes-1.40-20211111accepted/tizen_6.5_base_toolaccepted/tizen_6.5_baseaccepted/tizen_6.0_base_tool_hotfixaccepted/tizen_6.0_base_toolaccepted/tizen_6.0_baseaccepted/tizen_5.5_base_wearable_hotfixaccepted/tizen_5.5_base_mobile_hotfixaccepted/tizen_5.5_baseaccepted/tizen_5.0_baseaccepted/tizen_4.0_baseaccepted/tizen_3.0_baseaccepted/tizen_3.0.m2_base
- PROBLEM
If a and b are found duplicates, one of them is changed to
a symbolic link using %fdupes in a spec file.
However, it is non-deterministic which file is to be symlinked
because fdupes does not sort files.
In this case, OBS can detect the result is different even if
the source is unchanged.
- SOLUTION
I changed macro.fdupes to sort duplicate files.
*** Bug fixed: several groups of duplicates are handled well now.
- BUG
"fdupes -r ." returns like below:
a
b
c
d
e
This means, there are two sets of duplicates (a,b) and (c,d,e).
The previous commit does not consider this case.
(only considers there are single set of duplicates.)
By just sorting everything, all files are considered as duplicates.
We need to sort each set while preserving blank lines.
Now, it performs well even for this case.
Change-Id: I9de68b11674de79c34220f7c324c810aa006cc19
Signed-off-by: Junghyun Kim <jh0822.kim@samsung.com>
-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} |