%define _unpackaged_files_terminate_build 1

Summary: Bluetooth utilities
Summary(ja): Bluetooth ユーティリティ 
Name: bluez
Version: 5.54
Release: 1%{?_dist_release}
Group: Applications/System
Vendor: Project Vine
Distribution: Vine Linux
Packager: daisuke

License: GPLv2+
URL: http://www.bluez.org/

#----------------------------------------------------------------------------

Source: http://www.kernel.org/pub/linux/bluetooth/%{name}-%{version}.tar.xz
Source1: bluetooth.init.vine
Source3: bluez-uinput.modules

Source11: trusts.txt
Source20: main.conf

# from http://www.linuxfromscratch.org/patches/downloads/bluez/
Patch0: 0001-bluez-5.54-obexd_without_systemd-1.patch

# Patch for Vine
Patch100: 0002-bluez-5.54-daemon.patch
Patch101: 0003-bluez-5.54-config-vine.patch

#----------------------------------------------------------------------------
BuildRoot:	%{_tmppath}/%{name}-%{version}-root

BuildRequires:	flex
BuildRequires:	bison
BuildRequires:	dbus-devel
BuildRequires:	glib2-devel
BuildRequires:	eudev-libudev-devel
BuildRequires:	readline-devel
BuildRequires:  libical-devel

ExcludeArch: s390 s390x

Obsoletes: bluez-pan < 4.0, bluez-sdp < 4.0
Requires: initscripts, bluez-libs = %{version}
Requires: dbus >= 0.60
# Requires: fuse
## Requires: hwdata >= 0.215
Requires: hwdata >= 0.146
# virtual provides "dbus-bluez-pin-helper" ex. bluez-gnome
Requires: dbus-bluez-pin-helper
Requires(preun): /sbin/chkconfig, /sbin/service
Requires(post): /sbin/chkconfig, /sbin/service
#----------------------------------------------------------------------------

Obsoletes: bluez-utils < 4.5-2
Provides: bluez-utils = %{version}-%{release}
Obsoletes: bluez-gstreamer < 5.0
Obsoletes: bluez-alsa < 5.0

#----------------------------------------------------------------------------
%description
Utilities for use in Bluetooth applications:
	- hcitool
	- hciattach
	- hciconfig
	- bluetoothd
	- l2ping
	- start scripts VineLinux (RedHat base)
	- pcmcia configuration files

 Please, read %{_defaultdocdir}/%{name}-%{version}/trusts.txt 

The BLUETOOTH trademarks are owned by Bluetooth SIG, Inc., U.S.A.

%description -l ja
Bluetooth ユーティリティ (bluez-utils):
	- hcitool
	- hciattach
	- hciconfig
	- l2ping
	- 起動スクリプト (Red Hat用をVineLinuxに合わせました)
	- pcmcia コンフィグレーション ファイル
※付属の%{_defaultdocdir}/%{name}-%{version}/trusts.txtもご覧下さい。

(BLUETOOTH は Bluetooth SIG, Inc.(USA)のトレードマークです)

#----------------------------------------------------------------------------
%package libs
Summary: Libraries for use in Bluetooth applications
Summary(ja): BlueTooth アプリケーションの使用するライブラリ(BlueZ)
Group: System Environment/Libraries

%description libs
Libraries for use in Bluetooth applications.

%description libs -l ja
Bluetooth アプリケーションのためのライブラリです。
※BlueZ のユーティリティのためにも必要です

#----------------------------------------------------------------------------
%package libs-devel
Summary: Development libraries for Bluetooth applications
Summary(ja): Bluetooth アプリケーション開発のためのdevelパッケージ
Group: Development/Libraries
Requires: bluez-libs = %{version}
Requires: pkgconfig
Obsoletes: bluez-sdp-devel < 4.0

%description libs-devel
bluez-libs-devel contains development libraries and headers for
use in Bluetooth applications.

%description libs-devel -l ja
bluez-libs-devel パッケージは Bluetooth アプリケーション開発のための
ライブラリやヘッダーファイルを提供します。

#----------------------------------------------------------------------------
%package cups
Summary: CUPS printer backend for Bluetooth printers
Summary(ja): Bluetooth 経由の CUPS プリンタシステム用
Group: System Environment/Daemons
Obsoletes: bluez-utils-cups < 4.5-2
Provides: bluez-utils-cups = %{version}-%{release}
Requires: bluez-libs = %{version}
Requires: cups

%description cups
This package contains the CUPS backend 

%description cups -l ja
Bluetooth対応 プリンターを CUPS印刷システムから利用する
ためのバックエンドです。

#----------------------------------------------------------------------------

%prep
rm -rf $RPM_BUILD_ROOT

%setup -q
%patch0 -p1
%patch100 -p1
%patch101 -p1

%build
%configure \
	--disable-systemd \
	--enable-library \
    --enable-cups \
    --enable-tools \
    --enable-sixaxis \
    --enable-nfc \
	--disable-android

# copy txt
#cp %{SOURCE11} .

make

#----------------------------------------------------------------------------
%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT 

# Remove autocrap and libtool droppings
find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} \;

mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/bluetooth/
mkdir -p $RPM_BUILD_ROOT%{_libdir}/bluetooth/
mkdir -p $RPM_BUILD_ROOT%{_sbindir}

install -D -m0755 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/bluetooth
ln -s ../libexec/bluetooth/bluetoothd $RPM_BUILD_ROOT%{_sbindir}/bluetoothd

#install -D -m0644 %{SOURCE20} $RPM_BUILD_ROOT%{_sysconfdir}/bluetooth/
install -D -m0644 src/main.conf $RPM_BUILD_ROOT%{_sysconfdir}/bluetooth/
# rename serial-api.txt 
#mv  doc/serial-api.txt doc/serial-api_doc.txt

install -D -m0755 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/modules/bluez-uinput.modules

%clean
rm -rf $RPM_BUILD_ROOT

#----------------------------------------------------------------------------
%post
/sbin/chkconfig --add bluetooth
if [ "$1" -ge "1" ]; then
        /sbin/service bluetooth condrestart >/dev/null 2>&1 || :
fi
exit 0

%preun
if [ "$1" = "0" ]; then
        /sbin/service bluetooth stop >/dev/null 2>&1 || :
        /sbin/chkconfig --del bluetooth
fi
exit 0

%post libs
/sbin/ldconfig

%postun libs
/sbin/ldconfig

#----------------------------------------------------------------------------
%files
%defattr(-, root, root)
%license COPYING
%doc AUTHORS INSTALL ChangeLog NEWS README
%dir %{_sysconfdir}/bluetooth/
%config(noreplace) %{_sysconfdir}/bluetooth/*
%{_sysconfdir}/dbus-1/system.d/bluetooth.conf
%{_sysconfdir}/rc.d/init.d/bluetooth
%{_sysconfdir}/sysconfig/modules/bluez-uinput.modules
%{_bindir}/*
%{_sbindir}/bluetoothd
%{_libexecdir}/bluetooth/bluetoothd
%{_libexecdir}/bluetooth/obexd
%dir %{_libdir}/bluetooth
%dir %{_libdir}/bluetooth/plugins
%{_libdir}/bluetooth/plugins/sixaxis.so
%{_mandir}/man1/*
%{_mandir}/man8/*
/lib/udev/hid2hci
/lib/udev/rules.d/97-hid2hci.rules
%dir %{_datadir}/zsh
%dir %{_datadir}/zsh/site-functions
%{_datadir}/zsh/site-functions/_bluetoothctl

%files libs
%defattr(-, root, root)
%{_libdir}/libbluetooth.so.*

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

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


%changelog
* Sun Mar 22 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 5.54-1
- updated to 5.54.
- updated all patches.

* Sun Sep 01 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 5.50-1
- updated to 5.50.

* Fri Jan 26 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 5.48-1
- updated to 5.48.

* Sat Nov 07 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 5.35-1
- update to 5.35
- remove %%{name}-gstreamer, %%{name}-alsa subpackages
- add Patch0 (bluez-5.35-obexd_without_systemd-1.patch)
- add Patch100 (bluez-5.35-daemon.patch)
- add Patch101 (bluez-5.35-config-vine.patch)

* Sat Jul 18 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.101-5
- rebuild with readline-6.3

* Tue Jun 17 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.101-4
- change BuildRequires: eudev-libudev-devel instead of libudev-devel

* Sat Jan 04 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.101-3
- rebuild with VineSeed environment

* Thu Jul 11 2013 Daisuke SUZUKI <daisuke@linux.or.jp> 4.101-2
- build with sbc
  - add BR: sbc-devel

* Sun Jun 24 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.101-1
- new upstream release

* Sun Mar 11 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.99-1
- new upstream release

* Thu Feb 23 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.98-1
- new upstream release

* Sun Dec 25 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.97-1
- new upstream release
- add BuildRequires: check-devel, readline-devel

* Sun Aug 28 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.96-1
- new upstream release
- add BuildRequires: libudev-devel

* Thu Feb 24 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.89-1
- new upstream release

* Sat Feb 05 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.87-1
- new upstream release

* Thu Dec 30 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.84-1
- new upstream release

* Sun Dec 26 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.82-1
- new upstream release

* Fri Dec 10 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.81-1
- new upstream release

* Tue Nov 16 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.79-1
- new upstream release
- drop Patch2

* Wed Nov 03 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.77-1
- new upstream release
- fix %files (change path of alsa/bluetooth.conf)

* Thu Sep 23 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.69-2
- rebuild with rpm-4.8.1 for pkg-config file

* Mon Jul 19 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.69-1
- new upstream release

* Mon Jun 21 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.66-1
- new upstream release

* Sat May 01 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.64-1
- new upstream release
- drop Patch1, Patch5, Patch6

* Sun Jul 05 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 4.42-2
- add bluetooth.init again.
  - on-demand startup on bootup process will fail, because
    D-BUS service is not started yet.

* Sun Jun 28 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 4.42-1
- new upstream release

* Mon Jun 22 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 4.41-2
- remove bluetooth.init
  - on-demand start/stop bluetoothd using udev
  - run hid2hci using udev
- add missing files to %%files

* Fri Jun 19 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 4.41-1
- new upstream release
- add udev rule
- add upstream Patch[2-6]

* Tue May 26 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 4.37-1
- new upstream release

* Fri Oct 24 2008 Seiichirou Babasaki 4.15-1
- Update to 4.15
- added # Maintainers:  comments.
- FedoraCore - LOGS
-- 4.14-2
-- Add script to autoload uinput on startup, so the PS3 remote
   works out-of-the-box
-- 4.14-1 - Update to 4.14
-- 4.13-3
-- Update udev rules (#246840)
-- 4.13-2
-- Fix PS3 BD remote input event generation
-- 4.13-1 - Update to 4.13
-- 4.12-1 - Update to 4.12
-- 4.11-1 - Update to 4.11
-- 4.10-1 - Update to 4.10
-- 4.9-1 - Update to 4.9
-- 4.8-1 - Update to 4.8
-- 4.7-1 - Update to 4.7
-- 4.6-4
-- Fix patch application
-- 4.6-3
-- Add fuzz
-- 4.6-2
-- Fix possible crasher on resume from suspend
-- 4.6-1 - Update to 4.6
-- 4.5-4
-- SDP browse fixes
-- 4.5-3
-- Bluez-alsa needs to provide/obsolete bluez-utils-alsa
-- Use versioned Obsoletes:
-- 4.5-2
-- Change main utils package name to 'bluez'; likewise its subpackages
-- Remove references to obsolete initscripts (hidd,pand,dund)
-- 4.5-1
-- Update to 4.5
-- Fix initscript to actually start bluetoothd by hand
-- Add chkconfig information to the initscript
-- 4.4-2
-- Fix rpmlint problems
-- Fix input device handling
-- 4.4-1
-- Update to 4.4
-- Update source address, and remove unneeded deps (thanks Marcel)
-- 4.1-1
-- Initial build
- updated specfile
- VineLinux-4.2 logfile
-- *Thu Oct 2 2008 Seiichirou Babasaki 3.24-4
-- update bleuz-gnome, rebuild bluez-utils
-- Requires: fuse
-- updated specfile
-- *Tue Sep 30 2008 Seiichirou Babasaki 3.24-3
-- trusts.txt update (added audio profile)
-- updated specfile

#----------------------------------------------------------------------------
* Fri Sep 26 2008 Seiichirou Babasaki 3.32-2
- *.conf update 
- updated specfile

* Fri Jun 13 2008 Seiichirou Babasaki 3.32-1
- Updated 3.32
- Updated specfile
- ** LOGS 3.31-2
- ** Add a .service file, starting up hcid only when used (#446918)
- ** Fix descriptions in the initscript headers (#433647)
- ** LOGS 3.30-2
- ** Add support for Dell HID/HCI switch
- ** LOGS 3.27-1
- ** Ship audio.conf (#278831)
- ** Ship network service

* Sat Jan 26 2008 Seiichirou Babasaki 3.24-2
- Updated specfile 
-   marge bluez-utils-3.24-conf-vl.patch 
-      << bluez-utils-2.3-conf.patch
- add trusts.txt(ja)
- Updated specfile

* Mon Jan 21 2008 Seiichirou Babasaki 3.24-1vl2
- Updated specfile for (dbus-devel >= 0.90)

* Wed Jan 16 2008 Seiichirou Babasaki 3.24-1vl1
- Import bluez-utils - Packager: Babasaki
- Updated specfile for (dbus-devel >= 0.60)
- Update to 3.24
