[bluez/f14/master] systemd hookup

Lennart Poettering lennart at fedoraproject.org
Mon Sep 13 20:00:00 UTC 2010


commit efe2cb4d51188ba4f54321dbfd54b36dea66183c
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Sep 13 21:58:40 2010 +0200

    systemd hookup

 0001-systemd-install-systemd-unit-files.patch |  124 +++++++++++++++++++++++++
 bluez.spec                                    |   58 +++++++++---
 2 files changed, 167 insertions(+), 15 deletions(-)
---
diff --git a/0001-systemd-install-systemd-unit-files.patch b/0001-systemd-install-systemd-unit-files.patch
new file mode 100644
index 0000000..900cae5
--- /dev/null
+++ b/0001-systemd-install-systemd-unit-files.patch
@@ -0,0 +1,124 @@
+From bbdb8577cae7446865840ced5b007b9b39b548a3 Mon Sep 17 00:00:00 2001
+From: Lennart Poettering <lennart at poettering.net>
+Date: Wed, 21 Jul 2010 19:20:44 +0200
+Subject: [PATCH] systemd: install systemd unit files
+
+This also enables bus activation for bluetoothd, but only if systemd is
+running. Only if that's the case we can make sure in a race-free fashion
+that bluetoothd is not started twice at the same time.
+---
+ Makefile.am                  |   21 ++++++++++++++++++---
+ configure.ac                 |    9 +++++++++
+ scripts/.gitignore           |    1 +
+ scripts/bluetooth.service.in |   12 ++++++++++++
+ scripts/org.bluez.service    |    5 +++++
+ 5 files changed, 45 insertions(+), 3 deletions(-)
+ create mode 100644 scripts/.gitignore
+ create mode 100644 scripts/bluetooth.service.in
+ create mode 100644 scripts/org.bluez.service
+
+diff --git a/Makefile.am b/Makefile.am
+index 65d4312..a2b53e8 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -301,7 +301,8 @@ endif
+ CLEANFILES += $(rules_DATA)
+ 
+ EXTRA_DIST += scripts/bluetooth.rules \
+-		scripts/bluetooth-hid2hci.rules scripts/bluetooth-serial.rules
++		scripts/bluetooth-hid2hci.rules scripts/bluetooth-serial.rules \
++		scripts/bluetooth.service.in scripts/org.bluez.service
+ 
+ if PCMCIA
+ udevdir = $(libexecdir)/udev
+@@ -309,6 +310,20 @@ udevdir = $(libexecdir)/udev
+ dist_udev_SCRIPTS = scripts/bluetooth_serial
+ endif
+ 
++if HAVE_SYSTEMD
++systemdsystemunit_DATA = \
++       scripts/bluetooth.service
++
++scripts/bluetooth.service: scripts/bluetooth.service.in
++	@$(SED) -e "s|\@sbindir\@|$(sbindir)|" $< >$@
++
++dbussystemservicesdir = $(datadir)/dbus-1/system-services
++
++dbussystemservices_DATA = \
++	scripts/org.bluez.service
++
++endif
++
+ EXTRA_DIST += doc/manager-api.txt \
+ 		doc/adapter-api.txt doc/device-api.txt \
+ 		doc/service-api.txt doc/agent-api.txt doc/attribute-api.txt \
+@@ -328,9 +343,9 @@ pkgconfigdir = $(libdir)/pkgconfig
+ 
+ pkgconfig_DATA = bluez.pc
+ 
+-DISTCHECK_CONFIGURE_FLAGS = --disable-udevrules --enable-attrib
++DISTCHECK_CONFIGURE_FLAGS = --disable-udevrules --enable-attrib --with-systemdsystemunitdir=
+ 
+-DISTCLEANFILES = $(pkgconfig_DATA)
++DISTCLEANFILES = $(pkgconfig_DATA) scripts/bluetooth.service
+ 
+ MAINTAINERCLEANFILES = Makefile.in \
+ 	aclocal.m4 configure config.h.in config.sub config.guess \
+diff --git a/configure.ac b/configure.ac
+index b004f6e..86b398f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -64,5 +64,14 @@ if (test "${enable_netlink}" = "yes"); then
+ fi
+ AM_CONDITIONAL(NETLINK, test "${enable_netlink}" = "yes")
+ 
++# systemd
++
++AC_ARG_WITH([systemdsystemunitdir],
++        AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
++        [],
++        [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
++AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
++AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir"])
++
+ AC_OUTPUT(Makefile scripts/bluetooth.rules doc/version.xml
+ 					src/bluetoothd.8 bluez.pc)
+diff --git a/scripts/.gitignore b/scripts/.gitignore
+new file mode 100644
+index 0000000..4b9f765
+--- /dev/null
++++ b/scripts/.gitignore
+@@ -0,0 +1 @@
++bluetooth.service
+diff --git a/scripts/bluetooth.service.in b/scripts/bluetooth.service.in
+new file mode 100644
+index 0000000..f95b0b0
+--- /dev/null
++++ b/scripts/bluetooth.service.in
+@@ -0,0 +1,12 @@
++[Unit]
++Description=Bluetooth Manager
++After=syslog.target
++
++[Service]
++Type=dbus
++BusName=org.bluez
++ExecStart=@sbindir@/bluetoothd -n
++StandardOutput=syslog
++
++[Install]
++WantedBy=bluetooth.target
+diff --git a/scripts/org.bluez.service b/scripts/org.bluez.service
+new file mode 100644
+index 0000000..2a3b057
+--- /dev/null
++++ b/scripts/org.bluez.service
+@@ -0,0 +1,5 @@
++[D-BUS Service]
++Name=org.bluez
++Exec=/bin/false
++User=root
++SystemdService=bluetooth.service
+-- 
+1.7.0.1
+
diff --git a/bluez.spec b/bluez.spec
index 3b91d25..9e83cca 100644
--- a/bluez.spec
+++ b/bluez.spec
@@ -1,7 +1,7 @@
 Summary: Bluetooth utilities
 Name: bluez
 Version: 4.71
-Release: 1%{?dist}
+Release: 2%{?dist}
 License: GPLv2+
 Group: Applications/System
 Source: http://www.kernel.org/pub/linux/bluetooth/%{name}-%{version}.tar.gz
@@ -20,6 +20,7 @@ Patch2: bluez-try-utf8-harder.patch
 Patch4: bluez-socket-mobile-cf-connection-kit.patch
 # http://thread.gmane.org/gmane.linux.bluez.kernel/2396
 Patch5: 0001-Add-sixaxis-cable-pairing-plugin.patch
+Patch6: 0001-systemd-install-systemd-unit-files.patch
 
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
 URL: http://www.bluez.org/
@@ -31,7 +32,7 @@ BuildRequires: gstreamer-plugins-base-devel, gstreamer-devel
 BuildRequires: libsndfile-devel
 BuildRequires: libcap-ng-devel
 # For cable pairing
-BuildRequires: libudev-devel 
+BuildRequires: libudev-devel
 %ifnarch s390 s390x
 BuildRequires: libusb1-devel
 %endif
@@ -106,7 +107,7 @@ Requires: bluez-libs = %{version}
 Requires: bluez = %{version}
 
 %description cups
-This package contains the CUPS backend 
+This package contains the CUPS backend
 
 %description gstreamer
 This package contains gstreamer plugins for the Bluetooth SBC audio format
@@ -131,16 +132,17 @@ This includes hidd, dund and pand.
 %patch2 -p1 -b .non-utf8-name
 %patch4 -p1 -b .socket-mobile
 %patch5 -p1 -b .cable-pairing
+%patch6 -p1 -b .systemd
 
 %build
 libtoolize -f -c
 autoreconf
-%configure --enable-cups --enable-dfutool --enable-tools --enable-bccmd --enable-gstreamer --enable-hidd --enable-pand --enable-dund --with-ouifile=/usr/share/hwdata/oui.txt
+%configure --enable-cups --enable-dfutool --enable-tools --enable-bccmd --enable-gstreamer --enable-hidd --enable-pand --enable-dund --with-ouifile=/usr/share/hwdata/oui.txt --with-systemdsystemunitdir=/lib/systemd/system
 make
 
 %install
 rm -rf $RPM_BUILD_ROOT
-make install DESTDIR=$RPM_BUILD_ROOT 
+make install DESTDIR=$RPM_BUILD_ROOT
 /sbin/ldconfig -n $RPM_BUILD_ROOT/%{_libdir}
 # Remove autocrap and libtool droppings
 rm -f $RPM_BUILD_ROOT/%{_libdir}/*.la				\
@@ -148,7 +150,7 @@ rm -f $RPM_BUILD_ROOT/%{_libdir}/*.la				\
 	$RPM_BUILD_ROOT/%{_libdir}/bluetooth/plugins/*.la	\
 	$RPM_BUILD_ROOT/%{_libdir}/gstreamer-0.10/*.la
 
-for a in bluetooth dund pand rfcomm ; do 
+for a in bluetooth dund pand rfcomm ; do
 	install -D -m0755 $RPM_SOURCE_DIR/$a.init $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/$a
 	if [ -e $RPM_SOURCE_DIR/$a.conf ] ; then
 		install -D -m0644 $RPM_SOURCE_DIR/$a.conf $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/$a
@@ -170,24 +172,45 @@ install -D -m0755 %{SOURCE8} $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/modules/bl
 
 install -d -m0755 $RPM_BUILD_ROOT/%{_localstatedir}/lib/bluetooth
 
+rm -f $RPM_BUILD_ROOT/lib/udev/rules.d/97-bluetooth.rules
+rm -f $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d/bluetooth
+
 %clean
 rm -rf $RPM_BUILD_ROOT
 
 %post libs -p /sbin/ldconfig
 
 %post
-/sbin/chkconfig --add bluetooth
-if [ "$1" -ge "1" ]; then
-	/sbin/service bluetooth condrestart >/dev/null 2>&1 || :
+#/sbin/chkconfig --add bluetooth
+#if [ "$1" -ge "1" ]; then
+#	/sbin/service bluetooth condrestart >/dev/null 2>&1 || :
+#fi
+#exit 0
+if [ $1 -eq 1 ]; then
+        /bin/systemctl daemon-reload >/dev/null 2>&1 || :
 fi
-exit 0
 
 %postun libs -p /sbin/ldconfig
 
 %preun
-if [ "$1" = "0" ]; then
-	/sbin/service bluetooth stop >/dev/null 2>&1 || :
-	/sbin/chkconfig --del bluetooth
+#if [ "$1" = "0" ]; then
+#	/sbin/service bluetooth stop >/dev/null 2>&1 || :
+#	/sbin/chkconfig --del bluetooth
+#fi
+if [ $1 -eq 0 ]; then
+        /bin/systemctl disable bluetooth.service >/dev/null 2>&1 || :
+        /bin/systemctl stop bluetooth.service >/dev/null 2>&1 || :
+fi
+
+%postun
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+        /bin/systemctl try-restart bluetooth.service >/dev/null 2>&1 || :
+fi
+
+%triggerun -- bluez < 4.71-2
+if /sbin/chkconfig bluetooth ; then
+        /bin/systemctl enable bluetooth.service >/dev/null 2>&1 || :
 fi
 
 %post compat
@@ -232,10 +255,12 @@ fi
 %config %{_sysconfdir}/dbus-1/system.d/bluetooth.conf
 %{_libdir}/bluetooth/
 /lib/udev/bluetooth_serial
-/lib/udev/rules.d/97-bluetooth.rules
+#/lib/udev/rules.d/97-bluetooth.rules
 %{_sysconfdir}/udev/rules.d/97-bluetooth-serial.rules
-%{_sysconfdir}/rc.d/init.d/bluetooth
+#%{_sysconfdir}/rc.d/init.d/bluetooth
 %{_localstatedir}/lib/bluetooth
+/lib/systemd/system/bluetooth.service
+%{_datadir}/dbus-1/system-services/org.bluez.service
 
 %files libs
 %defattr(-, root, root)
@@ -278,6 +303,9 @@ fi
 %{_mandir}/man1/pand.1.gz
 
 %changelog
+* Mon Sep 13 2010 Lennart Poettering <lpoetter at redhat.com> - 4.71-2
+- systemd hookup
+
 * Fri Sep 10 2010 Bastien Nocera <bnocera at redhat.com> 4.71-1
 - Update to 4.71
 


More information about the scm-commits mailing list