File bluez.spec of Package bluez

# spec file for package bluez
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2010-2016 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

Name:           bluez
# FIXME: Do not mangle dbus service / systemd service once we support systemd user services
BuildRequires:  flex
BuildRequires:  libcap-ng-devel
BuildRequires:  systemd-rpm-macros
BuildRequires:  pkgconfig(dbus-1) >= 1.6
Version:        5.41
Release:        0
Summary:        Bluetooth Stack for Linux
License:        GPL-2.0+
Group:          Hardware/Mobile
Source5:        baselibs.conf
Source7:        bluetooth.modprobe
# fix some logitech HID devices, bnc#681049, bnc#850478
Patch1:         bluez-5.11-logitech-hid2hci.patch
Patch2:         bluez-sdp-unix-path.patch
BuildRequires:  alsa-devel
BuildRequires:  automake
BuildRequires:  check-devel
BuildRequires:  libical-devel
BuildRequires:  libsndfile-devel
BuildRequires:  libtool
BuildRequires:  libudev-devel
BuildRequires:  pkg-config
BuildRequires:  readline-devel
BuildRequires:  udev
BuildRequires:  pkgconfig(glib-2.0) >= 2.28
Recommends:     sbc
Provides:       bluez-utils = 3.36
Obsoletes:      bluez-utils <= 3.36
Provides:       bluez-audio = 3.36
Obsoletes:      bluez-audio <= 3.36
Obsoletes:      bluez-hcidump < 5.0
Provides:       bluez-hcidump = %{version}
Obsoletes:      obexd-client < 5.0
Provides:       obexd-client = %{version}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

# 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):
%define cups_lib_dir %{_prefix}/lib/cups

# we want to be able to build with older distros, too...
%{!?_userunitdir: %define _userunitdir %{_prefix}/lib/systemd/user}

BlueZ provides support for the core Bluetooth layers and protocols.

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

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

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

%description -n libbluetooth3
BlueZ provides support for the core Bluetooth layers and protocols.
It is uses a modular implementation. It has many interesting features:

* Multithreaded data processing
* Support for multiple Bluetooth devices
* Real hardware abstraction
* Standard socket interface to all layers
* Device and service level security support

%package cups
Summary:        CUPS Driver for Bluetooth Printers
License:        GPL-2.0+
Group:          Hardware/Printing

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

# disabled for now
%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:       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.

%setup -q
%patch1 -p1
%patch2 -p1
mkdir dbus-apis
cp -a doc/*.txt dbus-apis/
# FIXME: Change the dbus service to be a real service, not systemd launched
sed -i "s:Exec=/bin/false:Exec=%{_libexecdir}/bluetooth/obexd:g" obexd/src/org.bluez.obex.service
sed -i "/SystemdService=.*/d" obexd/src/org.bluez.obex.service

# --enable-experimental is needed or btattach does not build (bug?)
%configure \
	--enable-pie		\
	--enable-library	\
	--enable-tools		\
	--enable-cups		\
	--enable-test		\
	--enable-experimental	\
	--enable-datafiles	\
	--with-systemdsystemunitdir=%{_unitdir}		\

make %{?_smp_mflags} all V=1

rm -v %{buildroot}/%{_libdir}/*.la
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
# no idea why this is suddenly necessary...
install --mode 0755 -d %{buildroot}%{_localstatedir}/lib/bluetooth

# FIXME: Do not delete the systemd service once we support systemd user/session services
rm %{buildroot}%{_userunitdir}/obex.service
# end FIXME

## same as in fedora...
# "make install" fails to install gatttool, used with Bluetooth Low Energy
install -m0755 attrib/gatttool %{buildroot}%{_bindir}

# rpmlint warnings...
cd %{buildroot}%{_libdir}/bluez/test
chmod 0644 *.py *.xml *.dtd

%if ! 0%{?qemu_user_space_build}
make %{?_smp_mflags} check

%service_add_pre bluetooth.service

# todo: check if this is still obeyed / needed with systemd
%{fillup_only -n bluetooth}
# 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 || :

%service_del_preun bluetooth.service

%service_del_postun bluetooth.service

%post -n libbluetooth3 -p /sbin/ldconfig
%postun -n libbluetooth3 -p /sbin/ldconfig

%defattr(-, root, root)
%doc AUTHORS COPYING ChangeLog README dbus-apis
%dir /usr/lib/bluetooth
%doc %{_mandir}/man1/btattach.1.gz
%doc %{_mandir}/man1/hcidump.1.gz
%doc %{_mandir}/man1/hciattach.1.gz
%doc %{_mandir}/man1/hciconfig.1.gz
%doc %{_mandir}/man8/bluetoothd.8.gz
%doc %{_mandir}/man1/hid2hci.1.gz
%doc %{_mandir}/man1/bccmd.1.gz
%doc %{_mandir}/man1/l2ping.1.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/rctest.1.gz
%config %{_sysconfdir}/dbus-1/system.d/bluetooth.conf
%dir %{_localstatedir}/lib/bluetooth
%dir %{_sysconfdir}/modprobe.d
%config(noreplace) %{_sysconfdir}/modprobe.d/50-bluetooth.conf

%files devel
%defattr(-, root, root)

%files -n libbluetooth3
%defattr(-, root, root)

%files cups
%dir %{cups_lib_dir}
%dir %{cups_lib_dir}/backend

%files test
%dir %{_libdir}/bluez

openSUSE Build Service is sponsored by