# SliTaz package receipt.

PACKED_SIZE="172.0K"
UNPACKED_SIZE="660.0K"
PACKAGE="dbus"
VERSION="1.4.16"
CATEGORY="x-window"
SHORT_DESC="D-Bus is a message bus system."
DEPENDS="expat xorg-libX11 slitaz-base-files xorg-libICE xorg-libSM \
xorg-libXau xorg-libXdmcp util-linux-ng-uuid"
BUILD_DEPENDS="xorg-libX11-dev expat-dev util-linux-ng-uuid-dev"
MAINTAINER="pankso@slitaz.org"
TARBALL="$PACKAGE-$VERSION.tar.gz"
WEB_SITE="http://www.freedesktop.org/wiki/Software/dbus"
WGET_URL="http://dbus.freedesktop.org/releases/dbus/$TARBALL"

# Rules to configure and make the package.
compile_rules()
{
	cd $src
	./configure \
		--libexecdir=/usr/lib/dbus \
		--sysconfdir=/etc \
		--localstatedir=/var \
		$CONFIGURE_ARGS &&
	make &&
	make -j 1 install
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	mkdir -p $fs/usr/lib $fs/usr/share
	cp -a $install/etc $fs
	cp -a $install/var $fs
	cp -a $install/usr/bin $fs/usr
	cp -a $install/usr/lib/*.so* $fs/usr/lib
	cp -a $install/usr/lib/dbus $fs/usr/lib
	# Remove helper (600 Kb).
	rm $fs/usr/lib/dbus/dbus-daemon-launch-helper
	cp -a $install/usr/share/dbus* $fs/usr/share
	# Init script
	cp -a $stuff/etc $fs
	chown -R root.root $fs
}

pre_install()
{
	local root
	root=$1
	# Go for echoing on configuration files if any messagebus user
	# was found.
	if ! grep -q 'messagebus' $root/etc/passwd; then
		echo -n "Adding user: messagebus..."
		echo 'messagebus:x:25:25:DBUS Daemon User:/dev/null:/bin/false' >> $root/etc/passwd
		echo 'messagebus:!:14013:0:99999:7:::' >> $root/etc/shadow
		echo 'messagebus:x:25:' >> $root/etc/group
		echo 'messagebus:!::' >> $root/etc/gshadow
		status
	fi
	if ! grep -q ^DBUS_OPTIONS $root/etc/daemons.conf; then
		echo -n "Configuring $root/etc/daemons.conf..."
		cat >> $root/etc/daemons.conf << "EOT"
# DBUS daemon options.
DBUS_OPTIONS="--system"

EOT
		status
	fi
}

pre_remove()
{
	if [ -z "$1" ]; then
		/etc/init.d/dbus stop
		deluser messagebus
	fi
}
