# SliTaz package receipt.

PACKAGE="dbus"
VERSION="1.12.20"
CATEGORY="x-window"
SHORT_DESC="D-Bus is a message bus system."
DEPENDS="expat xorg-libX11 xorg-libICE xorg-libSM"
BUILD_DEPENDS="expat-dev xorg-libX11-dev libgio-dev glib-dev \
xorg-libICE-dev xorg-libSM-dev libxslt libxml2-tools"
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 --prefix=/usr \
            --sysconfdir=/etc \
            --localstatedir=/var \
            --enable-user-session \
	    --disable-doxygen-docs \
	    --disable-xml-docs \
            --disable-static \
            --with-systemduserunitdir=no \
            --with-systemdsystemunitdir=no \
            --docdir=/usr/share/doc/dbus-1.12.20 \
            --with-console-auth-dir=/run/console \
	    --libexecdir=/usr/lib/dbus \
            --with-system-pid-file=/run/dbus/pid \
            --with-system-socket=/run/dbus/system_bus_socket \
	    $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
}