wok diff xcursor-obsidian/stuff/symdup.sh @ rev 21800

guvcview: update bdeps
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Aug 10 14:24:44 2019 +0200 (2019-08-10)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xcursor-obsidian/stuff/symdup.sh	Sat Aug 10 14:24:44 2019 +0200
     1.3 @@ -0,0 +1,23 @@
     1.4 +# substitute repeated files by symlinks
     1.5 +md5file=$(mktemp)
     1.6 +find $install -type f -exec md5sum {} \; | sort > $md5file
     1.7 +
     1.8 +for md in $(uniq -d -w32 $md5file | cut -c1-32); do
     1.9 +	# group of similar files
    1.10 +	similar="$(grep $md $md5file | cut -c35-)"
    1.11 +
    1.12 +	# find shortest filename
    1.13 +	shortest=$(echo "$similar" | cut -d' ' -f1)
    1.14 +	for line in $(echo $similar); do
    1.15 +		[ "${#line}" -lt "${#shortest}" ] && shortest="$line"
    1.16 +	done
    1.17 +
    1.18 +	# make symlinks to the file with shortest filename
    1.19 +	for file in $similar; do
    1.20 +		[ "$shortest" != "$file" ] && ln -sf $shortest $file
    1.21 +	done
    1.22 +done
    1.23 +rm "$md5file"
    1.24 +
    1.25 +# make all symlinks relative
    1.26 +symlinks -crs $install