bluez/0001-systemd-install-systemd-unit-files.patch
2011-06-03 12:16:49 +01:00

126 lines
3.7 KiB
Diff

From c4b7096f8643d23111f91c60cbd2a62883d419ba Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@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 | 13 +++++++++++++
scripts/org.bluez.service | 5 +++++
5 files changed, 46 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 4659c80..c2a6976 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -352,7 +352,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 = @UDEV_DIR@
@@ -360,6 +361,20 @@ udevdir = @UDEV_DIR@
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 \
@@ -385,9 +400,9 @@ pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = bluez.pc
-DISTCHECK_CONFIGURE_FLAGS = --disable-udevrules
+DISTCHECK_CONFIGURE_FLAGS = --disable-udevrules --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 2ce4acf..07b9e55 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,5 +57,14 @@ if (test "${enable_capng}" = "yes"); then
AC_DEFINE(HAVE_CAPNG, 1, [Define to 1 if you have capabilities library.])
fi
+# 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..d0089ea
--- /dev/null
+++ b/scripts/bluetooth.service.in
@@ -0,0 +1,13 @@
+[Unit]
+Description=Bluetooth Manager
+After=syslog.target
+
+[Service]
+Type=dbus
+BusName=org.bluez
+ExecStart=@sbindir@/bluetoothd -n
+StandardOutput=syslog
+
+[Install]
+WantedBy=bluetooth.target
+Alias=dbus-org.bluez.service
diff --git a/scripts/org.bluez.service b/scripts/org.bluez.service
new file mode 100644
index 0000000..dd7ae8f
--- /dev/null
+++ b/scripts/org.bluez.service
@@ -0,0 +1,5 @@
+[D-BUS Service]
+Name=org.bluez
+Exec=/bin/false
+User=root
+SystemdService=dbus-org.bluez.service
--
1.7.5.1