#!/bin/sh

# don't cripple the image to be copied over
[ -z "$GLOBAL_LIVE_INSTALL" ] || exit 0
[ ! -x /usr/sbin/live-install ] || exit 0
[ ! -x /usr/sbin/livecd-install ] || exit 0

if [ -n "$GLOBAL_LOCALES" ]; then
	# -not -name C* -a -not -name en* -a -not -name ru*
	LOCALES="$(echo "C*" $GLOBAL_LOCALES | sed 's/ / -a -not -name /g;s/^/-not -name /;s/_[A-Z]*/*/g')"
else
	LOCALES="-not -name C*"
fi

find /usr/share/locale /usr/lib/locale -mindepth 1 -maxdepth 1 \
	$LOCALES -exec rm -r {} \;

:
