# SliTaz package receipt.

PACKED_SIZE="232.0K"
UNPACKED_SIZE="452.0K"
PACKAGE="slitaz-configs"
VERSION="320"
CATEGORY="base-system"
SHORT_DESC="SliTaz config files and artwork."
MAINTAINER="pankso@slitaz.org"
LICENSE="GPL3"
WEB_SITE="http://www.slitaz.org/"
TARBALL="$PACKAGE-$VERSION.tar.gz"
WGET_URL="http://hg.slitaz.org/slitaz-configs/archive/$VERSION.tar.gz"
HOST_ARCH="i486 arm"

DEPENDS="slitaz-configs-base xorg-libXcomposite xorg-libXdamage \
xorg-xcompmgr transset-df ttf-dejavu slim"
BUILD_DEPENDS="" # see below
SIBLINGS="slitaz-configs-base"

# Special case for ARM since some (most) config files are in slitaz-arm repo.
# i486/arm common configs are provided by slitaz-configs-base.
case "$SLITAZ_ARCH" in
	i?86) CONFIG_FILES="/etc/slitaz/applications.conf" ;;
	arm*) DEPENDS="slitaz-arm-configs ttf-dejavu slim" ;;
esac

case "$ARCH" in
	i?86*) BUILD_DEPENDS="gettext locale-fr locale-hu locale-ja locale-pt_BR \
locale-ru locale-zh_CN" ;;
esac

current_version()
{
	wget -O - http://hg.slitaz.org/$PACKAGE/ 2>/dev/null | \
	sed '/^Changeset/!d;s|.*">|http://hg.slitaz.org/'$PACKAGE'/rev/|;s|<.*||' | \
	xargs wget -O - 2>/dev/null | sed '/rev /!d;s|.*rev ||;s| .*||'
}

# Rules to configure and make the package.
compile_rules()
{
	case "$ARCH" in
		i?86)
			make DESTDIR=$DESTDIR menu
			ln -s menu.en.xml $install/etc/xdg/openbox/menu.xml
			;;
	esac
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	cd ${src}
	case "$ARCH" in
		i?86)
			# Copy rootfs files from the stuff and set permissions.
			mkdir -p $fs/etc/xdg/openbox $fs/usr/share
			cp -a $src/rootfs/etc/xdg/openbox $fs/etc/xdg
		
			# /usr/share
			for i in applications lxdm slim slitaz
			do
				cp -r $src/rootfs/usr/share/$i $fs/usr/share
			done
			cp -a $src/rootfs/usr/bin $fs/usr
			cp -a $src/rootfs/etc/lxpanel $fs/etc
			cp -a $src/rootfs/etc/slitaz $fs/etc
			cp -a $install/etc/xdg/openbox/menu.en.xml \
				$install/etc/xdg/openbox/menu.xml \
				$fs/etc/xdg/openbox ;;
		arm)
			mkdir -p $fs/usr/share
			cp -a $src/rootfs/usr/share/applications $fs/usr/share
			cp -a $src/rootfs/usr/share/slitaz $fs/usr/share ;;
	esac

	# Put LXPanel profile to /etc/skel for new users
	mkdir -p $fs/etc/skel/.config/lxpanel
	cp -a $fs/etc/lxpanel/slitaz $fs/etc/skel/.config/lxpanel

	chown -R root.root $fs
}

post_install()
{
	case "$SLITAZ_ARCH" in
		i?86)
			# By default slim provide a base theme and config file have both
			# base and slitaz who will be choose randomly, so make sure we use
			# only slitaz theme.
			if grep -q 'current_theme       slitaz,base' "$1/etc/slim.conf"; then
				sed -i s/"current_theme .*"/"current_theme       slitaz"/ \
					"$1/etc/slim.conf"
			fi ;;
	esac
}
