app-admin/cancd: modernize the service script and ebuild.

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
This commit is contained in:
Michael Orlitzky
2017-12-17 18:33:46 -05:00
parent 533e21084f
commit c9aa851c80
6 changed files with 54 additions and 53 deletions

View 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
}

View 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>

View File

@@ -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"

View File

@@ -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"

View File

@@ -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 ${?}
}

View File

@@ -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}"
}