# SliTaz package receipt.

PACKED_SIZE="192.0K"
UNPACKED_SIZE="824.0K"
PACKAGE="dbus"
VERSION="1.6.22"
CATEGORY="x-window"
SHORT_DESC="D-Bus is a message bus system."
MAINTAINER="pankso@slitaz.org"
LICENSE="GPL2"
TARBALL="$PACKAGE-$VERSION.tar.gz"
WEB_SITE="http://www.freedesktop.org/wiki/Software/dbus"
WGET_URL="http://dbus.freedesktop.org/releases/dbus/$TARBALL"
HOST_ARCH="i486 arm"

DEPENDS="expat xorg-libX11 slitaz-base-files xorg-libICE xorg-libSM \
xorg-libXau xorg-libXdmcp util-linux-uuid"
BUILD_DEPENDS="xorg-libX11-dev expat-dev util-linux-uuid-dev"

# Rules to configure and make the package.
compile_rules()
{
	./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 --> dbus-helper
	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()
{
	# Go for echoing on configuration files if any messagebus user
	# was found.
	if ! grep -qs 'messagebus' "$1/etc/passwd"; then
		action 'Adding user: messagebus...'
		echo 'messagebus:x:25:25:DBUS Daemon User:/dev/null:/bin/false' >> "$1/etc/passwd"
		echo 'messagebus:!:14013:0:99999:7:::' >> "$1/etc/shadow"
		echo 'messagebus:x:25:' >> "$1/etc/group"
		echo 'messagebus:!::' >> "$1/etc/gshadow"
		status
	fi
	if ! grep -qs ^DBUS_OPTIONS "$1/etc/daemons.conf"; then
		action 'Configuring %s/etc/daemons.conf...' "$1"
		cat >> "$1/etc/daemons.conf" << "EOT"
# DBUS daemon options.
DBUS_OPTIONS="--system"

EOT
		status
	fi
	[ -d "$1/var/run" ] || mkdir -p "$1/var/run"
}

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