File bluez.spec of Package bluez.17280

#
# spec file for package bluez
#
# Copyright (c) 2020 SUSE LLC
# Copyright (c) 2010-2013 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 https://bugs.opensuse.org/
#


Name:           bluez
# FIXME: Do not mangle dbus service / systemd service once we support systemd user services
BuildRequires:  flex
BuildRequires:  libcap-ng-devel
BuildRequires:  systemd-devel
BuildRequires:  pkgconfig(dbus-1) >= 1.4
%{?systemd_requires}
Version:        5.13
Release:        0
Summary:        Bluetooth Stack for Linux
License:        GPL-2.0-or-later
Group:          Hardware/Mobile
URL:            http://www.bluez.org
Source:         http://www.kernel.org/pub/linux/bluetooth/bluez-%{version}.tar.xz
Source5:        baselibs.conf
Source6:        README.SUSE
Source7:        bluetooth.modprobe
Source99:       README.packagers
Patch2:         bluez-sdp-unix-path.patch
Patch3:         0001-tools-add-bcm43xx-specific-init-in-hciattach.patch
Patch4:         0002-tools-fix-headers-for-bcm43xx.patch
Patch5:         0003-hciattach-bcm43xx-Use-final-baudrate-to-download-the.patch
Patch6:         0004-bcm43xx-The-UART-speed-must-be-reset-after-the-firmw.patch
Patch7:         0005-Move-the-43xx-firmware-into-lib-firmware.patch
Patch8:         unit-Fix-test-failures-with-glib-2.39.0.patch
Patch9:         unit-Fix-gobex-unit-tests.patch
Patch10:        bluez-sdp-Fix-Out-of-bounds-heap-read-in-service_search_at.patch
Patch11:        bluez-tools-csr-Fix-wrong-error-check.patch
Patch12:        bluez-tools-csr-Fix-possible-buffer-overflow.patch
Patch101:       built_fixed.patch
# PATCH_FIX-UPSTREAM: bsc#1013721 CVE-2016-9800
Patch102:       hcidump-fixed-hci-frame-dump-stack-buffer-overflow.patch
Patch103:       CVE-2016-9804-tool-hcidump-Fix-memory-leak-with-malformed-packet.patch
# PATCH_FIX-UPSTREAM: bsc#1013732 CVE-2016-9801
Patch104:       hcidump-Fix-set_ext_ctrl-global-buffer-overflow.patch
# PATCH_FIX-UPSTREAM: bsc#1166751 CVE-2020-0556
Patch105:       HOGP-must-only-accept-data-from-bonded-devices.patch
Patch106:       HID-accepts-bonded-device-connections-only.patch
# PATCH_FIX-UPSTREAM: btmon: multiple memory management vulnerabilities fixed bsc#1015173 CVE-2016-9918
Patch201:       0001-btmon-fix-segfault-caused-by-integer-underflow.patch
Patch202:       0002-btmon-fix-segfault-caused-by-buffer-overflow.patch
Patch203:       0003-btmon-fix-segfault-caused-by-integer-underflow.patch
Patch204:       0004-btmon-fix-segfault-caused-by-buffer-over-read.patch
# PATCH_FIX-UPSTREAM: bsc#1013708 CVE-2016-9797
Patch205:       hcidump-Fix-memory-leak.patch
# bsc#1013708 CVE-2016-9797 
Patch206:       hcidump-Add-assoc-dump-function-assoc-date-length-ch.patch
# bsc#1015171 CVE-2016-9917
Patch207:       hcidump-Fix-memory-leak-with-malformed-packet.patch
# bsc#1013712 CVE-2016-9798
Patch208:       hcidump-Fixed-malformed-segment-frame-length.patch
Patch209:       lib-Change-bluetooth.h-to-compile-in-strict-C.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

%description
The Bluetooth stack for Linux.

%package devel
Summary:        Files needed for BlueZ development
License:        GPL-2.0-or-later
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-or-later
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
#Requires:       libbluetooth3 = %{version}
License:        GPL-2.0-or-later
Group:          Hardware/Printing

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

# disabled for now
%package test
Summary:        Tools for testing of various Bluetooth-functions
License:        GPL-2.0-or-later 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.

%prep
%setup -q
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch101 -p1
%patch102 -p1
%patch103 -p1
%patch104 -p1
%patch105 -p1
%patch106 -p1
%patch201 -p1
%patch202 -p1
%patch203 -p1
%patch204 -p1
%patch205 -p1
%patch206 -p1
%patch207 -p1
%patch208 -p1
%patch209 -p1
cp %{SOURCE6} .
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
# END FIXME

%build
# autoreconf -fiv
%configure --with-pic \
	--enable-pie		\
	--enable-library	\
	--enable-tools		\
	--enable-cups		\
	--enable-test		\
	--enable-datafiles

make %{?_smp_mflags} all V=1

%install
%make_install
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
     fi
fi
# 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}%{_prefix}/lib/systemd/user/obex.service
# end FIXME

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

%clean
rm -rf %{buildroot}

%pre
%service_add_pre bluetooth.service

%post
%{?udev_rules_update:%udev_rules_update}
# 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 || :

%preun
%service_del_preun bluetooth.service

%postun
%service_del_postun bluetooth.service

%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}/hciattach
%{_bindir}/hciconfig
%dir /usr/lib/bluetooth
/usr/lib/bluetooth/bluetoothd
/usr/lib/bluetooth/obexd
%{_bindir}/bluetoothctl
%{_bindir}/btmon
%{_bindir}/hcidump
%{_bindir}/bccmd
%{_prefix}/lib/udev/
%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
#%dir %{_sysconfdir}/bluetooth
#%config(noreplace) %{_sysconfdir}/bluetooth/main.conf
#%config(noreplace) %{_sysconfdir}/bluetooth/rfcomm.conf
%config %{_sysconfdir}/dbus-1/system.d/bluetooth.conf
%dir %{_localstatedir}/lib/bluetooth
%dir %{_sysconfdir}/modprobe.d
%config(noreplace) %{_sysconfdir}/modprobe.d/50-bluetooth.conf
%{_unitdir}/bluetooth.service
%{_datadir}/dbus-1/system-services/org.bluez.service
%{_datadir}/dbus-1/services/org.bluez.obex.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)
#{_bindir}/hciemu
%{_bindir}/l2test
%{_bindir}/rctest
%dir %{_libdir}/bluez
%{_libdir}/bluez/test

%changelog
openSUSE Build Service is sponsored by