app-admin/cancd: modernize the service script and ebuild.
authorMichael Orlitzky <mjo@gentoo.org>
Sun, 17 Dec 2017 23:33:46 +0000 (18:33 -0500)
committerMichael Orlitzky <mjo@gentoo.org>
Sun, 17 Dec 2017 23:33:46 +0000 (18:33 -0500)
This commit creates a new revision (-r4) that replaces the earlier
unstable -r3. The ebuild itself includes an update to EAPI=6 and the
associated simplifications, as well as the addition of a new user
named "cancd" that is used by the init script.

The service script was completely rewritten and simplified, and now
uses more modern features of OpenRC. The original motivation for
that was bug 603208.

This is a non-maintainer commit, but robbat2 (the maintainer on file)
recently made a post to gentoo-dev, "Packages up for grabs: robbat2
edition," stating that this package was up for grabs.

Closes: https://bugs.gentoo.org/603208
Package-Manager: Portage-2.3.13, Repoman-2.3.3

app-admin/cancd/cancd-0.1.0-r4.ebuild [moved from app-admin/cancd/cancd-0.1.0-r3.ebuild with 69% similarity]
app-admin/cancd/files/cancd-0.1.0-build-r1.patch [moved from app-admin/cancd/files/cancd-0.1.0-build.patch with 89% similarity]
app-admin/cancd/files/cancd-conf.d [deleted file]
app-admin/cancd/files/cancd-conf.d-r1 [new file with mode: 0644]
app-admin/cancd/files/cancd-init.d [deleted file]
app-admin/cancd/files/cancd-init.d-r1 [new file with mode: 0644]

similarity index 69%
rename from app-admin/cancd/cancd-0.1.0-r3.ebuild
rename to app-admin/cancd/cancd-0.1.0-r4.ebuild
index 6ad37a6163ffcc715ee9ba1ff438a47ea770d24c..d662129917517ddc5bbdfb0465a3d969658fa27f 100644 (file)
@@ -1,11 +1,11 @@
 # Copyright 1999-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI=5
+EAPI=6
 
-inherit eutils
+inherit user
 
-DESCRIPTION="the CA NetConsole Daemon receives output from the Linux netconsole driver"
+DESCRIPTION="CA NetConsole Daemon receives output from the Linux netconsole driver"
 HOMEPAGE="http://oss.oracle.com/projects/cancd/"
 SRC_URI="http://oss.oracle.com/projects/cancd/dist/files/source/${P}.tar.gz"
 
@@ -14,9 +14,14 @@ SLOT="0"
 KEYWORDS="~amd64 ~x86"
 IUSE=""
 
+PATCHES=(
+       "${FILESDIR}/${P}-build-r1.patch"
+       "${FILESDIR}/${P}-c-cleanup.patch"
+)
+
 src_prepare() {
-       epatch "${FILESDIR}"/${P}-build.patch #246734
-       epatch "${FILESDIR}"/${P}-c-cleanup.patch
+       default
+
        # slight makefile cleanup
        sed -i \
                -e '/^CFLAGS/s,-g,,' \
@@ -27,11 +32,12 @@ src_prepare() {
 
 src_install() {
        dosbin cancd
-       newinitd "${FILESDIR}"/cancd-init.d cancd
-       newconfd "${FILESDIR}"/cancd-conf.d cancd
+       newinitd "${FILESDIR}"/cancd-init.d-r1 cancd
+       newconfd "${FILESDIR}"/cancd-conf.d-r1 cancd
        newinitd "${FILESDIR}"/netconsole-init.d netconsole
        newconfd "${FILESDIR}"/netconsole-conf.d netconsole
-       keepdir /var/crash
-       fowners adm:nobody /var/crash
-       fperms 700 /var/crash
+}
+
+pkg_preinst() {
+       enewuser cancd
 }
similarity index 89%
rename from app-admin/cancd/files/cancd-0.1.0-build.patch
rename to app-admin/cancd/files/cancd-0.1.0-build-r1.patch
index b1c99b1cd56527077c229a70ff949347d7be8844..19bc929b2bc09da63de9910c941faef7258a8c8b 100644 (file)
@@ -2,8 +2,8 @@ fix building with newer glibc
 
 http://bugs.gentoo.org/246734
 
---- cancd.c
-+++ cancd.c
+--- a/cancd.c
++++ b/cancd.c
 @@ -36,6 +36,7 @@
  #include <libgen.h>
  #include <getopt.h>
diff --git a/app-admin/cancd/files/cancd-conf.d b/app-admin/cancd/files/cancd-conf.d
deleted file mode 100644 (file)
index 7b4dd27..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/sbin/openrc-run
-# Copyright 1999-2005 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-# user to run as, root strongly discouraged
-# user should have /bin/false for a shell
-# but file access into /var
-CHUID='adm:nobody'
-
-# port to listen on
-CANCD_PORT=6667
-
-# directory to output to
-CRASH_DIR=/var/crash
-
-# one file per minute, one dir per host/date
-#CRASH_FORMAT="%Q/%Y-%m-%d/%H:%M.log"
-# one file per day, one dir per host
-CRASH_FORMAT="%Q/%Y-%m-%d.log"
diff --git a/app-admin/cancd/files/cancd-conf.d-r1 b/app-admin/cancd/files/cancd-conf.d-r1
new file mode 100644 (file)
index 0000000..1332229
--- /dev/null
@@ -0,0 +1,14 @@
+#!/sbin/openrc-run
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# port to listen on
+CANCD_PORT=6667
+
+# directory to output to
+CANCD_LOG_DIR=/var/log/cancd
+
+# one file per minute, one dir per host/date
+#CANCD_LOG_FORMAT="%Q/%Y-%m-%d/%H:%M.log"
+# one file per day, one dir per host
+CANCD_LOG_FORMAT="%Q/%Y-%m-%d.log"
diff --git a/app-admin/cancd/files/cancd-init.d b/app-admin/cancd/files/cancd-init.d
deleted file mode 100644 (file)
index eb0d34e..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/sbin/openrc-run
-# Copyright 1999-2011 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-depend() {
-       need net
-}
-
-start() {
-       mkdir -p ${CRASH_DIR}
-       chown ${CHUID} ${CRASH_DIR}
-       chmod 700 ${CRASH_DIR}
-       ebegin "Starting cancd"
-       start-stop-daemon --start --quiet --user ${CHUID} --exec /usr/sbin/cancd  -- -p ${CANCD_PORT} -l "${CRASH_DIR}" -o "${CRASH_FORMAT}"
-       eend ${?}
-}
-
-stop() {
-       ebegin "Stopping cancd"
-       start-stop-daemon --stop --quiet --exec /usr/sbin/cancd
-       eend ${?}
-}
diff --git a/app-admin/cancd/files/cancd-init.d-r1 b/app-admin/cancd/files/cancd-init.d-r1
new file mode 100644 (file)
index 0000000..a2a96f1
--- /dev/null
@@ -0,0 +1,22 @@
+#!/sbin/openrc-run
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+command="/usr/sbin/cancd"
+command_args="-p ${CANCD_PORT}
+              -l ${CANCD_LOG_DIR}
+              -o ${CANCD_LOG_FORMAT}"
+command_user="cancd"
+
+# cancd daemonizes itself, but doesn't write a PID file and doesn't
+# have an option to run in the foreground. So the best we can do
+# is try to match the process name when stopping it.
+procname="cancd"
+
+depend() {
+    need net
+}
+
+start_pre() {
+    checkpath --directory --owner cancd --mode 0700 "${CANCD_LOG_DIR}"
+}