# SliTaz package receipt.

PACKED_SIZE="472.0K"
UNPACKED_SIZE="2.3M"
PACKAGE="bluez"
VERSION="4.101"
CATEGORY="system-tools"
SHORT_DESC="Bluetooth protocol stack."
MAINTAINER="pankso@slitaz.org"
LICENSE="GPL2"
WEB_SITE="http://www.bluez.org/"
TARBALL="$PACKAGE-$VERSION.tar.bz2"
#WGET_URL="http://www.kernel.org/pub/linux/bluetooth/$TARBALL"
WGET_URL="http://sourceware.mirrors.tds.net/pub/kernel.org/linux/bluetooth/$TARBALL"
CONFIG_FILES="/etc/bluetooth"
TAGS="bluetooth"

DEPENDS="linux-bluetooth alsa-lib glib dbus pygobject dbus-python"
BUILD_DEPENDS="alsa-lib-dev dbus-dev glib-dev libusb-dev pkg-config libusb-compat"

# Rules to configure and make the package.
compile_rules()
{
	sed -i 's/NEED_USB/xx&/' tools/*.c
	sed -i 's/from gi.repo.*/try:\n  &\nexcept ImportError:\n  import gobject as GObject/' test/simple-agent

	./configure \
		--prefix=/usr \
		--sysconfdir=/etc \
		--localstatedir=/var \
		--libexecdir=/lib \
		--mandir=/usr/share/man \
		--enable-bccmd \
		--enable-dfutool \
		--enable-dund \
		--enable-hid2hci \
		--enable-hidd \
		--enable-pand \
		--enable-usb \
		--enable-cups \
		--enable-tools \
		--enable-wiimote \
		--enable-sap \
		--disable-test \
		--without-systemdunitdir \
		$CONFIGURE_ARGS &&
	make &&
	make DESTDIR=$DESTDIR install
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	mkdir -p $fs/usr/lib/alsa-lib
	cp -a $install/usr/bin $fs/usr
	cp -a $install/usr/sbin $fs/usr
	cp -a $install/usr/lib/*.so* $fs/usr/lib
	cp -a $install/usr/lib/alsa-lib/*.so* $fs/usr/lib/alsa-lib
	cp -a $install/usr/lib/bluetooth $fs/usr/lib
	cp -a $install/usr/lib/cups $fs/usr/lib
	cp -a $install/etc $fs
	cp -a $install/var $fs

	#some extra tools and config files
	cp -a $src/test/simple-agent $fs/usr/bin/bluez-simple-agent
	cp  $src/audio/audio.conf $fs/etc/bluetooth
}

# Post message when installing.
post_install()
{
	[ -s $1/usr/bin/bluepin ] || cat > $1/usr/bin/bluepin <<EOT
#!/bin/sh

printf "PIN:%04d\n" \${1:-$(($RANDOM%10000))}
EOT
	chmod +x $1/usr/bin/bluepin
}
