#! /bin/sh

# This script removes all symbolic links in icon set directories, while
# keeping all info about them in the special file. This info can be used by
# the compliment script unpack-symlinks to restore these symbolic links.
# The script can be used for developer systems which don't like symlinks.
#
# GPL'ed by Mikhael Goikhman.

ICONS_DIR=../../icons
INFO_FILE=_symlinks.lst

cd $ICONS_DIR
for iconSet in *; do
        echo -n "Processing $iconSet ... "
	cd $iconSet
	[ -f $INFO_FILE ] && cd .. && echo skipped && continue
	# Note, this will, probably, not work with non-GNU sed.
	find . -type l -print | cut -c3- | xargs -n 1 ls -l | \
		sed 's/^.* \([^ ]*\) -> \(.*\)$/\2 \1/' >$INFO_FILE
#	cat $INFO_FILE | cut -d" " -f2 | xargs -n 5 echo
	cat $INFO_FILE | cut -d" " -f2 | xargs -n 1 rm
	cd ..
        echo "done"
done
