ports/54116: New port: sysutils/rc_subr (rcNG support for port scripts)
Scot W. Hetzel
hetzels at westbend.net
Fri Jul 4 22:40:19 UTC 2003
>Number: 54116
>Category: ports
>Synopsis: New port: sysutils/rc_subr (rcNG support for port scripts)
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Fri Jul 04 15:40:16 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator: Scot W. Hetzel
>Release: FreeBSD 4.8-STABLE i386
>Organization:
West Bend Internet
>Environment:
System: FreeBSD WBIw009.westbend.net 4.8-STABLE FreeBSD 4.8-STABLE #6: Tue Jun 10 11:57:57 CDT 2003 root at WBIw009.westbend.net:/usr/obj/usr/src/4x/sys/GENERIC-SMP i386
>Description:
FreeBSD 5.x introduced the rcNG system brought in from NetBSD.
RcNG places common routines into /etc/rc.subr for all startup/
shutdown scripts to use. This greatly simplifies the writing
of startup/shutdown scripts. RcNG also provides scripts with
a common set of arguments (start, stop, restart, rcvar, status,
poll, ... ).
Currently, the ports startup/shutdown scripts do not support
rcNG, due to older versions of FreeBSD do not have /etc/rc.subr.
I had a look at how NetBSD solved this problem, and thier scripts
are a combination of rcOLD and rcNG. These scripts determine
which system they are running on by checking for the existence
of /etc/rc.subr.
I had been converting my ports (see security/cyrus-sasl and
www/apache13-fp) to use the same approach as NetBSD. While this
works, it over complicates the startup/shutdown script by needing
to check for which rc system the script is running on. Also the
port maintainer would need to check their script to ensure it runs
on both rcOLD and rcNG systems.
This port aims to solve this problem by getting rid of the
rcOLD completely, and only provide rcNG in the port statup/shutdown
scripts.
As port's rc scripts are converted to rcNG, the port maintainer
must define USE_RC_SUBR in its Makefile. This will cause the port
to have a run dependency on sysutils/rc_subr on systems where
/etc/rc.subr doesn't exist. The port maintainer will also need to
substitute RC_SUBR with the value of ${RC_SUBR} in their script.
Attached is the shar archive for sysutils/rc_subr port. I have also
included the patch for bsd.port.mk (rc_subr/patch-bsd.port.mk).
I have also included a patch for security/cyrus-sasl as an example
port whose startup/shutdown scripts has been fully converted to rcNG
(rc_subr/patch-cyrus-sasl). With this patch applied, I was able to
start, stop, and issue the status commands for the startup/shutdown
scripts on FreeBSD 4.8 and 5.1.
NOTE:
1. I placed the port in sysutils, if that is incorrect then change
the CATAGORIES variable, and bsd.port.mk to the correct value.
2. Currently, the distfile for the port is being hosted at
ftp.westbend.net, I would like to request that this distfile
be hosted at MASTER_SITE_LOCAL.
3. After portmgr approves the bsd.port.mk patch, and rc_subr is
commited, please commit the patch to security/cyrus-sasl.
>How-To-Repeat:
>Fix:
# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
# rc_subr
# rc_subr/Makefile
# rc_subr/distinfo
# rc_subr/pkg-descr
# rc_subr/pkg-plist
# rc_subr/patch-cyrus-sasl
# rc_subr/patch-bsd.port.mk
#
echo c - rc_subr
mkdir -p rc_subr > /dev/null 2>&1
echo x - rc_subr/Makefile
sed 's/^X//' >rc_subr/Makefile << 'END-of-rc_subr/Makefile'
X# New ports collection makefile for: rc_subr
X# Date created: July 4, 2003
X# Whom: hetzels at westbend.net
X#
X# $FreeBSD$
X#
X
XPORTNAME= rc_subr
XPORTVERSION= 1.13
XCATEGORIES= sysutils
XMASTER_SITES= ${MASTER_SITE_LOCAL} \
X ftp://ftp.westbend.net/pub/FreeBSD/ports/local-distfiles/%SUBDIR%/
XMASTER_SITE_SUBDIR= rcNG
X
XMAINTAINER= ports at freebsd.org
XCOMMENT= Common startup and shutdown subroutines used by scripts
X
XNO_BUILD= yes
X
XMAN8= rc.subr.8
X
Xdo-install:
X ${INSTALL_DATA} -m 644 ${WRKSRC}/rc.subr ${PREFIX}/etc/
X ${INSTALL_MAN} ${WRKSRC}/rc.subr.8 ${PREFIX}/man/man8
X
X.include <bsd.port.pre.mk>
XCVS_CMD?= cvs -z3
XCVS_SITES?= :pserver:anoncvs at anoncvs.FreeBSD.org:/home/ncvs \
X :pserver:anoncvs at anoncvs.de.FreeBSD.org:/home/ncvs \
X :pserver:anoncvs at anoncvs2.de.FreeBSD.org:/home/ncvs \
X :pserver:anoncvs at anoncvs.jp.FreeBSD.org:/home/ncvs
X
XCVS_FILE1= src/etc/rc.subr
XCVS_FILE2= src/share/man/man8/rc.subr.8
XCVS_MANVER= 1.3
X
X#
X# CVS checkout stuff mostly stolen from security/openssh-askpass port by
X# kris at freebsd.org
X#
X# NOTE: Don't forget to type 'anoncvs' for password
X#
Xtarball:
X ${MKDIR} ${DISTDIR}/${PKGNAME} && \
X cd ${DISTDIR}/${PKGNAME}; \
X for CVS_SITE in ${CVS_SITES}; do \
X ${ECHO_MSG} ">> Attempting to check out from $${CVS_SITE}."; \
X if ${CVS_CMD} -d $${CVS_SITE} login ; then \
X if ${CVS_CMD} -d $${CVS_SITE} co -r "${PORTVERSION}" \
X ${CVS_FILE1}; then \
X ${CVS_CMD} -d $${CVS_SITE} co -r ${CVS_MANVER} ${CVS_FILE2}; \
X cd ${DISTDIR}; \
X ${ECHO_MSG} ">> Creating dist tarball in ${DISTDIR}"; \
X ${ECHO_MSG} ">> \"${PKGNAME}.tar.gz\"."; \
X ${MV} ${PKGNAME}/${CVS_FILE1} ${PKGNAME}; \
X ${MV} ${PKGNAME}/${CVS_FILE2} ${PKGNAME}; \
X ${RM} -rf ${PKGNAME}/src; \
X ${TAR} -czf ${PKGNAME}.tar.gz ${PKGNAME}; \
X exit; \
X fi \
X fi \
X done; \
X ${RMDIR} ${DISTDIR}/${PKGNAME}; \
X ${ECHO_MSG} ">> CVS checkout failed."; \
X exit 1;
X
X.include <bsd.port.post.mk>
END-of-rc_subr/Makefile
echo x - rc_subr/distinfo
sed 's/^X//' >rc_subr/distinfo << 'END-of-rc_subr/distinfo'
XMD5 (rc_subr-1.13.tar.gz) = 54803c0c3c702f174f3885bdd2f1f55c
END-of-rc_subr/distinfo
echo x - rc_subr/pkg-descr
sed 's/^X//' >rc_subr/pkg-descr << 'END-of-rc_subr/pkg-descr'
XWith the change to a new rc system in FreeBSD 5.x, common routines for
Xstarting, stopping, and restarting daemons was placed into /etc/rc.subr.
Xthis makes it easier to write new startup/shutdown scripts and to have
Xthem ordered correctly with rcorder.
X
XWhile FreeBSD < 5.x won't be able to take advantage of rcorder. We can
Xtake advantage of the simplified startup/shutdown scripts by using rc.subr.
END-of-rc_subr/pkg-descr
echo x - rc_subr/pkg-plist
sed 's/^X//' >rc_subr/pkg-plist << 'END-of-rc_subr/pkg-plist'
Xetc/rc.subr
END-of-rc_subr/pkg-plist
echo x - rc_subr/patch-cyrus-sasl
sed 's/^X//' >rc_subr/patch-cyrus-sasl << 'END-of-rc_subr/patch-cyrus-sasl'
XIndex: cyrus-sasl/Makefile
X===================================================================
XRCS file: /home/ncvs/ports/security/cyrus-sasl/Makefile,v
Xretrieving revision 1.50
Xdiff -u -r1.50 Makefile
X--- cyrus-sasl/Makefile 9 May 2003 12:41:21 -0000 1.50
X+++ cyrus-sasl/Makefile 4 Jul 2003 19:08:45 -0000
X@@ -7,7 +7,7 @@
X
X PORTNAME= cyrus-sasl
X PORTVERSION= 1.5.28
X-PORTREVISION= 1
X+PORTREVISION= 2
X CATEGORIES= security ipv6
X MASTER_SITES= ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/%SUBDIR%/ \
X ftp://ftp.westbend.net/pub/cyrus-mail/%SUBDIR%/ \
X@@ -47,6 +47,8 @@
X sasl_setprop.3 sasl_usererr.3
X MAN8= sasldblistusers.8 saslpasswd.8 saslauthd1.8
X
X+USE_RC_SUBR= YES
X+
X USE_AUTOMAKE_VER=14
X USE_LIBTOOL= YES
X AUTOMAKE_ARGS= --add-missing --include-deps
X@@ -182,6 +184,7 @@
X .endif
X
X RC_SCRIPTS_SUB= PREFIX=${PREFIX} \
X+ RC_SUBR=${RC_SUBR} \
X PWCHECK=${PWCHECK} \
X ENABLE_PWCHECK=${ENABLE_PWCHECK} \
X ENABLE_SASLAUTHD=${ENABLE_SASLAUTHD} \
XIndex: cyrus-sasl/files/pwcheck.sh
X===================================================================
XRCS file: /home/ncvs/ports/security/cyrus-sasl/files/pwcheck.sh,v
Xretrieving revision 1.8
Xdiff -u -r1.8 pwcheck.sh
X--- cyrus-sasl/files/pwcheck.sh 9 May 2003 12:41:21 -0000 1.8
X+++ cyrus-sasl/files/pwcheck.sh 4 Jul 2003 19:10:20 -0000
X@@ -25,56 +25,12 @@
X cyrus_pwcheck_program="${prefix}/sbin/%%PWCHECK%%" # pwcheck program to use
X # (pwcheck/pwcheck_pam)
X
X-if [ -f /etc/rc.subr ]; then
X- . /etc/rc.subr
X+. %%RC_SUBR%%
X
X- name="cyrus_pwcheck"
X- rcvar=`set_rcvar`
X- command=${prefix}/sbin/%%PWCHECK%%
X- pidfile="/var/run/pwcheck.pid"
X+name="cyrus_pwcheck"
X+rcvar=`set_rcvar`
X+command=${prefix}/sbin/%%PWCHECK%%
X+pidfile="/var/run/pwcheck.pid"
X
X- load_rc_config $name
X- run_rc_command "$1"
X-else
X- # Suck in the configuration variables.
X- if [ -z "${source_rc_confs_defined}" ]; then
X- if [ -r /etc/defaults/rc.conf ]; then
X- . /etc/defaults/rc.conf
X- source_rc_confs
X- elif [ -r /etc/rc.conf ]; then
X- . /etc/rc.conf
X- fi
X- fi
X-
X- rc=0
X-
X- case "${cyrus_pwcheck_enable}" in
X- [Yy][Ee][Ss])
X- case "${1}" in
X-
X- start)
X- if [ -x ${cyrus_pwcheck_program} ] ; then
X- ${cyrus_pwcheck_program} && echo -n " cyrus_pwcheck"
X- fi
X- ;;
X-
X- stop)
X- if [ -r /var/run/pwcheck.pid ]; then
X- kill `cat /var/run/pwcheck.pid` && echo -n " cyrus_pwcheck"
X- rm /var/run/pwcheck.pid
X- fi
X- ;;
X-
X- *)
X- echo "usage: $0 {start|stop}" 1>&2
X- rc=64
X- ;;
X- esac
X- ;;
X- *)
X- rc=0
X- ;;
X- esac
X-
X- exit $rc
X-fi
X+load_rc_config $name
X+run_rc_command "$1"
XIndex: cyrus-sasl/files/saslauthd.sh
X===================================================================
XRCS file: /home/ncvs/ports/security/cyrus-sasl/files/saslauthd.sh,v
Xretrieving revision 1.3
Xdiff -u -r1.3 saslauthd.sh
X--- cyrus-sasl/files/saslauthd.sh 9 May 2003 12:41:21 -0000 1.3
X+++ cyrus-sasl/files/saslauthd.sh 4 Jul 2003 19:13:23 -0000
X@@ -25,72 +25,12 @@
X #saslauthd1_program="${prefix}/sbin/saslauthd1" # Location of saslauthd1
X saslauthd1_flags="-a pam" # Flags to saslauthd program
X
X-if [ -f /etc/rc.subr ]; then
X- . /etc/rc.subr
X+. %%RC_SUBR%%
X
X- name="saslauthd1"
X- rcvar=`set_rcvar`
X- command="${prefix}/sbin/${name}"
X- pidfile="/var/state/${name}/mux.pid"
X+name="saslauthd1"
X+rcvar=`set_rcvar`
X+command="${prefix}/sbin/${name}"
X+pidfile="/var/state/${name}/mux.pid"
X
X- load_rc_config $name
X- run_rc_command "$1"
X-else
X- # Suck in the configuration variables.
X- if [ -z "${source_rc_confs_defined}" ]; then
X- if [ -r /etc/defaults/rc.conf ]; then
X- . /etc/defaults/rc.conf
X- source_rc_confs
X- elif [ -r /etc/rc.conf ]; then
X- . /etc/rc.conf
X- fi
X- fi
X-
X- if [ -n "${sasl_saslauthd1_enable}" ]; then
X- echo "sasl_saslauthd1_enable has been depreciated, use saslauthd1_enable instead"
X- saslauthd1_enable=$sasl_saslauthd1_enable
X- fi
X-
X- if [ -z "${saslauthd1_program}" ]; then
X- saslauthd1_program=${prefix}/sbin/saslauthd1
X- fi
X-
X- if [ -n "${sasl_saslauthd1_flags}" ]; then
X- echo "sasl_saslauthd1_flags has been depreciated, use saslauthd1_flags instead"
X- saslauthd1_flags=$sasl_saslauthd1_flags
X- fi
X-
X- rc=0
X-
X- case "${saslauthd1_enable}" in
X- [Yy][Ee][Ss])
X- case "${1}" in
X-
X- start)
X- if [ -x ${saslauthd1_program} ] ; then
X- ${saslauthd1_program} ${saslauthd1_flags} \
X- && echo -n " saslauthd1"
X- fi
X- ;;
X-
X- stop)
X- if [ -r /var/state/saslauthd1/mux.pid ]; then
X- kill `cat /var/state/saslauthd1/mux.pid` && \
X- echo -n " saslauthd1"
X- rm /var/state/saslauthd1/mux.pid
X- fi
X- ;;
X-
X- *)
X- echo "usage: $0 {start|stop}" 1>&2
X- rc=64
X- ;;
X- esac
X- ;;
X- *)
X- rc=0
X- ;;
X- esac
X-
X- exit $rc
X-fi
X+load_rc_config $name
X+run_rc_command "$1"
END-of-rc_subr/patch-cyrus-sasl
echo x - rc_subr/patch-bsd.port.mk
sed 's/^X//' >rc_subr/patch-bsd.port.mk << 'END-of-rc_subr/patch-bsd.port.mk'
XIndex: bsd.port.mk
X===================================================================
XRCS file: /home/ncvs/ports/Mk/bsd.port.mk,v
Xretrieving revision 1.454
Xdiff -u -r1.454 bsd.port.mk
X--- bsd.port.mk 26 Jun 2003 22:58:21 -0000 1.454
X+++ bsd.port.mk 4 Jul 2003 18:47:34 -0000
X@@ -372,6 +372,15 @@
X # Default: not set.
X # USE_LINUX_PREFIX - controls the action of PREFIX (see above).
X #
X+# USE_RC_SUBR - Says the ports startup/shutdown script uses the common
X+# routines found in etc/rc.subr and may need to
X+# depend on the sysutils/rc_subr port.
X+#
X+# RC_SUBR - Set to path of rc.subr, defaults to /etc/rc.subr on
X+# 5.x and to ${PREFIX}/etc/rc.subr on non-rcNG
X+# systems.
X+#
X+#
X # Dependency checking. Use these if your port requires another port
X # not in the list above. (Default: empty.)
X #
X@@ -1333,6 +1342,15 @@
X .endif
X .endif
X
X+.if defined(USE_RC_SUBR)
X+.if exists(/etc/rc.subr)
X+RC_SUBR= /etc/rc.subr
X+.else
X+RUN_DEPENDS+= ${LOCALBASE}/etc/rc.subr:${PORTSDIR}/sysutils/rc_subr
X+RC_SUBR= ${LOCALBASE}/etc/rc.subr
X+.endif
X+.endif
X+
X .if defined(USE_LINUX)
X RUN_DEPENDS+= ${LINUXBASE}/etc/redhat-release:${PORTSDIR}/emulators/linux_base
X .endif
END-of-rc_subr/patch-bsd.port.mk
exit
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list