cups: add systemd support
authorChen Qi <Qi.Chen@windriver.com>
Wed, 3 Sep 2014 07:09:10 +0000 (15:09 +0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 3 Sep 2014 10:09:05 +0000 (11:09 +0100)
Add systemd unit files.

Also remove sysvinit related files if 'sysvinit' is not in
DISTRO_FEATURES.

(From OE-Core rev: 020065d3c57ccdc86c47cd0fc288071cdd194bbc)

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-extended/cups/cups.inc
meta/recipes-extended/cups/cups/cups.path [new file with mode: 0644]
meta/recipes-extended/cups/cups/cups.service [new file with mode: 0644]
meta/recipes-extended/cups/cups/cups.socket [new file with mode: 0644]

index 162b3fd..fbdc48e 100644 (file)
@@ -8,15 +8,20 @@ SRC_URI = "http://www.cups.org/software/${PV}/${BP}-source.tar.bz2 \
            file://0001-don-t-try-to-run-generated-binaries.patch \
            file://cups_serverbin.patch \
            file://cups-no-gcrypt.patch \
+           file://cups.socket \
+           file://cups.path \
+           file://cups.service \
          "
 
 LEAD_SONAME = "libcupsdriver.so"
 
-inherit autotools-brokensep binconfig useradd
+inherit autotools-brokensep binconfig useradd systemd
 
 USERADD_PACKAGES = "${PN}"
 GROUPADD_PARAM_${PN} = "--system lpadmin"
 
+SYSTEMD_SERVICE_${PN} = "cups.socket cups.path cups.service"
+
 PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'zeroconf', 'avahi', '', d)} \
                    ${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam', '', d)}"
 PACKAGECONFIG[avahi] = "--enable-avahi,--disable-avahi,avahi"
@@ -71,6 +76,19 @@ fakeroot do_install () {
        # Remove /var/run from package as cupsd will populate it on startup
        rm -fr ${D}/${localstatedir}/run
        rmdir ${D}/${libdir}/${BPN}/driver
+
+       # Remove sysinit script and symlinks if sysvinit is not in DISTRO_FEATURES
+       if ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','false','true',d)}; then
+           rm -rf ${D}${sysconfdir}/init.d/
+           rm -rf ${D}${sysconfdir}/rc*
+       fi
+
+       # Install systemd unit files
+       install -d ${D}${systemd_unitdir}/system
+       install -m 0644 ${WORKDIR}/cups.socket ${D}${systemd_unitdir}/system
+       install -m 0644 ${WORKDIR}/cups.path ${D}${systemd_unitdir}/system
+       install -m 0644 ${WORKDIR}/cups.service ${D}${systemd_unitdir}/system
+       sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_unitdir}/system/cups.service
 }
 
 python do_package_append() {
diff --git a/meta/recipes-extended/cups/cups/cups.path b/meta/recipes-extended/cups/cups/cups.path
new file mode 100644 (file)
index 0000000..de8cc57
--- /dev/null
@@ -0,0 +1,8 @@
+[Unit]
+Description=CUPS Printer Service Spool
+
+[Path]
+PathExistsGlob=/var/spool/cups/d*
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta/recipes-extended/cups/cups/cups.service b/meta/recipes-extended/cups/cups/cups.service
new file mode 100644 (file)
index 0000000..7d3e839
--- /dev/null
@@ -0,0 +1,10 @@
+[Unit]
+Description=CUPS Printing Service
+
+[Service]
+ExecStart=@SBINDIR@/cupsd -f
+PrivateTmp=true
+
+[Install]
+Also=cups.socket cups.path
+WantedBy=printer.target
diff --git a/meta/recipes-extended/cups/cups/cups.socket b/meta/recipes-extended/cups/cups/cups.socket
new file mode 100644 (file)
index 0000000..3314870
--- /dev/null
@@ -0,0 +1,8 @@
+[Unit]
+Description=CUPS Printing Service Sockets
+
+[Socket]
+ListenStream=/var/run/cups/cups.sock
+
+[Install]
+WantedBy=sockets.target