File bluez.spec of Package bluez

#
# spec file for package bluez
#
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2010-2012 B1 Systems GmbH, Vohburg, Germany
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           bluez
BuildRequires:  flex
BuildRequires:  libcap-ng-devel
BuildRequires:  pkgconfig(dbus-1) >= 1.4
%if 0%{?suse_version} > 1140
BuildRequires:  systemd
%{?systemd_requires}
%define has_systemd 1
%endif
Version:        4.101
Release:        0
Summary:        Bluetooth Stack for Linux
License:        GPL-2.0+
Group:          Hardware/Mobile
Url:            http://www.bluez.org
Source:         bluez-%{version}.tar.bz2
Source2:        bluez-coldplug.init
Source3:        bluetooth.sysconfig
Source5:        baselibs.conf
Source6:        README.SUSE
Source7:        bluetooth.modprobe
# already fixed upstream
Patch0:         0001-network-fix-network-Connect-method-parameters.patch
BuildRequires:  alsa-devel
BuildRequires:  automake
BuildRequires:  check-devel
BuildRequires:  libsndfile-devel
BuildRequires:  libtool
BuildRequires:  libudev-devel
BuildRequires:  libusb-devel
BuildRequires:  pkg-config
BuildRequires:  readline-devel
BuildRequires:  udev
BuildRequires:  pkgconfig(glib-2.0) >= 2.28
BuildRequires:  pkgconfig(libnl-1)
Requires:       libbluetooth3 = %{version}
Recommends:     sbc
Provides:       bluez-utils = 3.36
Obsoletes:      bluez-utils <= 3.36
Provides:       bluez-audio = 3.36
Obsoletes:      bluez-audio <= 3.36
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if %( echo `rpm -q --queryformat %%{version} udev` ) < 144
%define OLD_UDEV 1
%else
%define OLD_UDEV 0
%if %( echo `rpm -q --queryformat %%{version} udev` ) > 190
%define NEW_UDEV 1
%else
%define NEW_UDEV 0
%endif
%endif

# In openSUSE 11.3 there is upstream compliant CUPS 1.4
# which means to have a fixed "/usr/lib/cups/" directory
# on all platforms (see Novell/Suse Bugzilla bnc#575544):
%if 0%{?suse_version} > 1120
%define cups_lib_dir %{_prefix}/lib/cups
%else
%define cups_lib_dir %{_libdir}/cups
%endif

%description
The Bluetooth stack for Linux.

%package devel
Summary:        Files needed for BlueZ development
License:        GPL-2.0+
Group:          Development/Sources
Requires:       libbluetooth3 = %{version}

%description devel
Files needed to develop applications for the BlueZ Bluetooth protocol
stack.

%package -n libbluetooth3
Summary:        Bluetooth Libraries
License:        GPL-2.0+
Group:          Hardware/Mobile
Provides:       bluez-libs = 3.36
Obsoletes:      bluez-libs <= 3.36

%description -n libbluetooth3
Bluetooth protocol stack libraries.

%package cups
Summary:        CUPS Driver for Bluetooth Printers
License:        GPL-2.0+
Group:          Hardware/Printing
Requires:       libbluetooth3 = %{version}

%description cups
Contains the files required by CUPS for printing to Bluetooth-connected
printers.

%package test
Summary:        Tools for testing of various Bluetooth-functions
License:        GPL-2.0+ and MIT
Group:          Development/Tools/Debuggers
Requires:       dbus-1-python
Requires:       libbluetooth3 = %{version}
Requires:       python-gobject2

%description test
Contains a few tools for testing various bluetooth functions. The
BLUETOOTH trademarks are owned by Bluetooth SIG, Inc., U.S.A.

%package alsa
Summary:        Bluetooth Sound Support
License:        GPL-2.0+
Group:          Productivity/Multimedia/Sound/Utilities
Requires:       libbluetooth3 = %{version}
Provides:       bluez-audio:%{_libdir}/alsa-lib/libasound_module_pcm_bluetooth.so

%description alsa
The package contains libraries for using bluetooth audio services.

The BLUETOOTH trademarks are owned by Bluetooth SIG, Inc., USA.

%package compat
Summary:        Bluetooth Stack for Linux
License:        GPL-2.0+
Group:          Hardware/Mobile
Requires:       libbluetooth3 = %{version}

%description compat
The Bluetooth stack for Linux. This package contains older and partly
deprecated binaries that might still be needed for compatibility.

%prep
%setup -q
%patch0 -p1
cp %{SOURCE6} .
mkdir dbus-apis
cp -a doc/*.txt dbus-apis/

%build
autoreconf -fiv
%configure --with-pic \
%if 0%{?has_systemd}
			--with-systemdunitdir=%{_unitdir} \
%endif
			--libexecdir=/lib \
			--enable-gstreamer	\
			--enable-alsa		\
			--enable-usb		\
			--enable-tools		\
			--enable-bccmd		\
			--enable-hid2hci	\
			--enable-dfutool	\
			--enable-cups		\
			--enable-test		\
			--enable-pand		\
			--enable-dund		\
			--enable-wiimote	\
			--enable-datafiles	\
			--enable-pcmcia

make %{?_smp_mflags} all V=1

%install
%make_install
# bluez-test
cd test
install --mode=0755	\
	simple-agent	\
	simple-service	\
	list-devices	\
	test-audio	\
	test-adapter	\
	test-device	\
	test-discovery	\
	test-input	\
	test-manager	\
	test-network	\
	test-serial	\
	test-service	\
	test-telephony	\
	%{buildroot}/%{_bindir}/
cd ..
rm -v %{buildroot}/%{_libdir}/*.la
rm -rvf %{buildroot}/%{_libdir}/gstreamer-*
rm -v %{buildroot}/%{_libdir}/alsa-lib/*.la
%if ! 0%{?has_systemd}
install --mode=0755 -D %{SOURCE2} %{buildroot}/%{_sysconfdir}/init.d/bluez-coldplug
%endif
install --mode=0644 -D %{SOURCE3} %{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.bluetooth
install --mode=0644 -D %{SOURCE7} %{buildroot}/%{_sysconfdir}/modprobe.d/50-bluetooth.conf
# In openSUSE 11.3 there is upstream compliant CUPS 1.4
# which means to have a fixed "/usr/lib/cups/" directory
# on all platforms (see Novell/Suse Bugzilla bnc#575544):
if ! test -e %{buildroot}%{cups_lib_dir}/backend/bluetooth
then if test -e %{buildroot}%{_libdir}/cups/backend/bluetooth
     then mkdir -p %{buildroot}%{cups_lib_dir}/backend
          mv %{buildroot}%{_libdir}/cups/backend/bluetooth %{buildroot}%{cups_lib_dir}/backend/bluetooth
     fi
fi
# no idea why this is suddenly necessary...
install --mode 0755 -d %{buildroot}%{_localstatedir}/lib/bluetooth

%check
make check

%clean
rm -rf %{buildroot}

%pre
%if 0%{?has_systemd}
%service_add_pre bluetooth.service
%endif

%post
# todo: check if this is still obeyed / needed with systemd
%{fillup_only -n bluetooth}
%if 0%{?has_systemd}
# We need the bluez systemd service enabled at any time. It won't start up
# on it's own, as it is triggered by udev in the end (bnc#796671)
/bin/systemctl enable bluetooth.service 2>&1 || :
/bin/systemctl daemon-reload >/dev/null 2>&1 || : 
%else
%{insserv_force_if_yast bluez-coldplug}
%endif

%preun
%if 0%{?has_systemd}
%service_del_preun bluetooth.service
%else
%stop_on_removal bluez-coldplug
%endif

%postun
%{insserv_cleanup}
%if 0%{?has_systemd}
%service_del_postun bluetooth.service
%else
%{insserv_cleanup}
%endif

%post -n libbluetooth3 -p /sbin/ldconfig

%postun -n libbluetooth3 -p /sbin/ldconfig

%files
%defattr(-, root, root)
%doc AUTHORS COPYING ChangeLog README README.SUSE dbus-apis
%{_bindir}/hcitool
%{_bindir}/l2ping
%{_bindir}/rfcomm
%{_bindir}/sdptool
%{_bindir}/ciptool
%{_bindir}/dfutool
%{_bindir}/gatttool
%{_sbindir}/hciattach
%{_sbindir}/hciconfig
%{_sbindir}/bluetoothd
#%{_sbindir}/hid2hci
%{_sbindir}/bccmd
%if 0%{NEW_UDEV}
%{_prefix}/lib/udev/
%else
/lib/udev/
%endif
%if 0%{OLD_UDEV}
%dir %{_sysconfdir}/udev/rules.d
%config %{_sysconfdir}/udev/rules.d/*
%endif
%doc %{_mandir}/man8/hciattach.8.gz
%doc %{_mandir}/man8/hciconfig.8.gz
%doc %{_mandir}/man8/bluetoothd.8.gz
%doc %{_mandir}/man8/hid2hci.8.gz
%doc %{_mandir}/man8/bccmd.8.gz
%doc %{_mandir}/man8/l2ping.8.gz
%doc %{_mandir}/man1/hcitool.1.gz
%doc %{_mandir}/man1/sdptool.1.gz
%doc %{_mandir}/man1/ciptool.1.gz
%doc %{_mandir}/man1/rfcomm.1.gz
%doc %{_mandir}/man1/dfutool.1.gz
%doc %{_mandir}/man1/hciemu.1.gz
%doc %{_mandir}/man1/rctest.1.gz
%dir %{_sysconfdir}/bluetooth
%config(noreplace) %{_sysconfdir}/bluetooth/main.conf
%config(noreplace) %{_sysconfdir}/bluetooth/rfcomm.conf
%{_localstatedir}/adm/fillup-templates/sysconfig.bluetooth
%config %{_sysconfdir}/dbus-1/system.d/bluetooth.conf
%dir %{_localstatedir}/lib/bluetooth
%dir %{_sysconfdir}/modprobe.d
%config(noreplace) %{_sysconfdir}/modprobe.d/50-bluetooth.conf
%if 0%{?has_systemd}
%{_unitdir}/bluetooth.service
%else
%{_sysconfdir}/init.d/bluez-coldplug
%endif
%{_datadir}/dbus-1/system-services/org.bluez.service

%files devel
%defattr(-, root, root)
%{_includedir}/bluetooth
%{_libdir}/libbluetooth.so
%{_libdir}/pkgconfig/bluez.pc

%files -n libbluetooth3
%defattr(-, root, root)
%{_libdir}/libbluetooth.so.*
%doc AUTHORS COPYING ChangeLog README

%files cups
%defattr(-,root,root)
%dir %{cups_lib_dir}
%dir %{cups_lib_dir}/backend
%{cups_lib_dir}/backend/bluetooth

%files test
%defattr(-,root,root)
%{_sbindir}/hciemu
%{_bindir}/l2test
%{_bindir}/rctest
%{_bindir}/list-devices
%{_bindir}/simple-agent
%{_bindir}/simple-service
%{_bindir}/test-adapter
%{_bindir}/test-audio
%{_bindir}/test-device
%{_bindir}/test-discovery
%{_bindir}/test-input
%{_bindir}/test-manager
%{_bindir}/test-network
%{_bindir}/test-serial
%{_bindir}/test-service
%{_bindir}/test-telephony

%files alsa
%defattr(-,root,root)
%dir %{_datadir}/alsa
%config %{_datadir}/alsa/bluetooth.conf
%{_libdir}/alsa-lib/*.so

%files compat
%defattr(-,root,root)
%{_bindir}/dund
%{_bindir}/pand
%doc %{_mandir}/man1/pand.1.gz
%doc %{_mandir}/man1/dund.1.gz

%changelog
openSUSE Build Service is sponsored by