wok-next annotate xcursor-comix/stuff/symdup.sh @ rev 19883
Up geeqie, lxterminal, xcursor-aero, xcursor-comix, xcursor-human, xcursor-obsidian.
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Fri Oct 06 17:00:35 2017 +0300 (2017-10-06) |
parents | |
children |
rev | line source |
---|---|
al@19883 | 1 # substitute repeated files by symlinks |
al@19883 | 2 for path in $install/usr/share/icons/*; do |
al@19883 | 3 # make symlinks separately for every cursor theme |
al@19883 | 4 |
al@19883 | 5 md5file=$(mktemp) |
al@19883 | 6 find $path -type f -exec md5sum '{}' \; | sort > $md5file |
al@19883 | 7 |
al@19883 | 8 for md in $(uniq -d -w32 $md5file | cut -c1-32); do |
al@19883 | 9 # group of similar files |
al@19883 | 10 similar="$(grep $md $md5file | cut -c35-)" |
al@19883 | 11 |
al@19883 | 12 # find shortest filename |
al@19883 | 13 shortest=$(echo "$similar" | cut -d' ' -f1) |
al@19883 | 14 for line in $(echo $similar); do |
al@19883 | 15 [ "${#line}" -lt "${#shortest}" ] && shortest="$line" |
al@19883 | 16 done |
al@19883 | 17 |
al@19883 | 18 # make symlinks to the file with shortest filename |
al@19883 | 19 for file in $similar; do |
al@19883 | 20 [ "$shortest" != "$file" ] && ln -sf $shortest $file |
al@19883 | 21 done |
al@19883 | 22 done |
al@19883 | 23 rm "$md5file" |
al@19883 | 24 done |
al@19883 | 25 |
al@19883 | 26 # make all symlinks relative |
al@19883 | 27 symlinks -crs $install |