# SliTaz package receipt.

PACKED_SIZE="320.0K"
UNPACKED_SIZE="912.0K"
PACKAGE="slitaz-configs-base"
VERSION="320"
CATEGORY="base-system"
SHORT_DESC="SliTaz config files for text based systems."
MAINTAINER="pankso@slitaz.org"
LICENSE="GPL3"
WEB_SITE="http://www.slitaz.org/"
SOURCE="slitaz-configs"
TARBALL="$SOURCE-$VERSION.tar.gz"
WGET_URL="http://hg.slitaz.org/slitaz-configs/archive/$VERSION.tar.gz"
HOST_ARCH="i486 arm"

DEPENDS="tazlito tazpkg"
SIBLINGS="slitaz-configs"

# Handle SliTaz arch
case "$SLITAZ_ARCH" in
	arm*) DEPENDS="" ;;
esac

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

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	# Patch .xinitrc to ensure kmap is correctly set on lxpanel
	# when slim autologin. Thanks Gibor to found this bug
	cd $src
	patch -p1 < $stuff/fix-kmap-label-lxpanel.patch

	# Copy rootfs files and set permissions.
	case "$ARCH" in
		arm*)
			# Most ARM configs are in: slitaz-arm repo but Openbox, webhome
			# are common to all arch.
			mkdir -p $fs/usr/share $fs/etc
			cp -a $src/rootfs/usr/bin $fs/usr 
			cp -a $src/rootfs/etc/lxpanel $fs/etc 
			cp -a $src/rootfs/etc/skel $fs/etc
			# No dbus on ARM
			sed "s/exec dbus.*$/exec\"/" -i $fs/etc/skel/.xinitrc ;;
		*)
			mkdir -p \
				$fs/usr/share
			# XDG user directories
			for dir in Desktop Documents Downloads Images Music Public \
				Templates Videos; do
				mkdir -p $fs/etc/skel/$dir
			done
			cp -a $src/rootfs/boot $fs/
			cp -a $src/rootfs/etc/skel $fs/etc
			cp -a $src/rootfs/etc/polkit-1 $fs/etc ;;
	esac
	
	for i in images pixmaps themes webhome; do
		cp -r $src/rootfs/usr/share/$i $fs/usr/share
	done

	cp -a $src/rootfs/root $fs
	chown -R root:root $fs
	chmod 0750 $fs/root
}

post_install()
{
	[ -z "$quiet" ] && echo -en "\nUpdating ~/.xinitrc"
	for i in $(ls -d "$1/root" "$1"/home/* 2> /dev/null); do
		[ -d "$i" ] && cp -f "$1/etc/skel/.xinitrc" "$i"
	done
	sed -i 's|$HOME/.config|/etc|' "$1/root/.xinitrc"
}
