wok-next annotate rox-filer/stuff/symdup.sh @ rev 21727

created recipe for vbindiff
author Hans-G?nter Theisgen
date Sat Nov 21 14:32:44 2020 +0100 (2020-11-21)
parents
children
rev   line source
al@21022 1 # substitute repeated files by symlinks
al@21022 2 md5file=$(mktemp)
al@21022 3 find $install -type f -exec md5sum {} \; | sort > $md5file
al@21022 4
al@21022 5 for md in $(uniq -d -w32 $md5file | cut -c1-32); do
al@21022 6 # group of similar files
al@21022 7 similar="$(grep $md $md5file | cut -c35-)"
al@21022 8
al@21022 9 # find shortest filename
al@21022 10 shortest=$(echo "$similar" | cut -d' ' -f1)
al@21022 11 for line in $(echo $similar); do
al@21022 12 [ "${#line}" -lt "${#shortest}" ] && shortest="$line"
al@21022 13 done
al@21022 14
al@21022 15 # make symlinks to the file with shortest filename
al@21022 16 for file in $similar; do
al@21022 17 [ "$shortest" != "$file" ] && ln -sf $shortest $file
al@21022 18 done
al@21022 19 done
al@21022 20 rm "$md5file"
al@21022 21
al@21022 22 # make all symlinks relative
al@21022 23 symlinks -crs $install