From flz@xbsd.org  Fri Feb 11 11:50:32 2005
Return-Path: <flz@xbsd.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 7749016A4D0
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 11 Feb 2005 11:50:32 +0000 (GMT)
Received: from gate.xbsd.org (xbsd.org [82.233.2.192])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 556FA43D3F
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 11 Feb 2005 11:50:31 +0000 (GMT)
	(envelope-from flz@xbsd.org)
Received: from localhost (localhost.xbsd.org [127.0.0.1])
	by gate.xbsd.org (Postfix) with ESMTP id A826311969
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 11 Feb 2005 12:53:48 +0100 (CET)
Received: from gate.xbsd.org ([127.0.0.1])
 by localhost (gate.xbsd.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP
 id 95382-01 for <FreeBSD-gnats-submit@freebsd.org>;
 Fri, 11 Feb 2005 12:53:40 +0100 (CET)
Received: by gate.xbsd.org (Postfix, from userid 2001)
	id 44EAE1195E; Fri, 11 Feb 2005 12:53:40 +0100 (CET)
Message-Id: <20050211115340.44EAE1195E@gate.xbsd.org>
Date: Fri, 11 Feb 2005 12:53:40 +0100 (CET)
From: Florent Thoumie <flz@xbsd.org>
Reply-To: Florent Thoumie <flz@xbsd.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: Mk/bsd.port.mk - add support for early rcNG startup scripts
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         77385
>Category:       ports
>Synopsis:       Mk/bsd.port.mk - add support for early rcNG startup scripts
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    portmgr
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Feb 11 12:00:31 GMT 2005
>Closed-Date:    Mon Feb 28 21:13:01 GMT 2005
>Last-Modified:  Mon Feb 28 21:13:01 GMT 2005
>Originator:     Florent Thoumie
>Release:        FreeBSD 5.3-RELEASE i386
>Organization:
Xbsd.org
>Environment:

System: FreeBSD srv1.xbsd.org 5.3-RELEASE FreeBSD 5.3-RELEASE #2: Wed Nov 24 16:35:34 CET 2004 root@gate.xbsd.org:/usr/src/sys/i386/compile/GATE i386

>Description:

Support for rcNG scripts has been added recently in bsd.port.mk.
This handles expansion of %%RC_SUBR%% in these scripts, installs
them and adds them to the packing list (by setting USE_RC_SUBR to
a list of files).

This new patch works almost exactly the same way, except it changes
the directory where scripts are installed and their extension
(commonly handled with RC_DIR and RC_SUFX).

Setting USE_RCORDER to a list of files will add the dependency on
sysutils/rc_subr (if needed) and set RC_SUBR.

Notes:

x The port can install rcorder(8) startup scripts and/or "classic"
rcNG startup scripts. If both are to be installed, USE_RC_SUBR and
USE_RCORDER must be exclusive lists of scripts (or bad things will
happen).
x USE_RC_SUBR can be unset (or not set) if USE_RCORDER is set.
x This makes use of @cwd which is almost broken with pkg_add -p
(bin/77212). There can be extra @cwd commands, but trying not to put
these extras would make the code less readable.

The patch should be harmless.

>How-To-Repeat:
>Fix:

	

--- rcorder-bpm-v2.diff begins here ---
--- bsd.port.mk.orig	Fri Feb 11 12:37:34 2005
+++ bsd.port.mk	Fri Feb 11 12:21:00 2005
@@ -386,9 +386,14 @@
 # 				  routines found in etc/rc.subr and may need to
 # 				  depend on the sysutils/rc_subr port.
 # 				  If this is set to a list of files, these files will be
-# 				  automatically added to ${SUB_FILES} and some "variable=value"
+# 				  automatically added to ${SUB_FILES}, some %%VAR%%'s will
+# 				  automatically be expanded, they will be installed in
+# 				  ${PREFIX}/etc/rc.d and added to the packing list.
 # 				  pairs will be added to ${SUB_LIST}. These files will be
 # 				  installed in ${PREFIX}/etc/rc.d and added to the packing list.
+# RC_ORDER		- List of rcNG startup scripts to be called early in the boot
+# 				  process. This acts exactly like USE_RC_SUBR except that
+# 				  scripts are installed in /etc/rc.d.
 # RC_SUBR		- Set to path of rc.subr.
 #				  Default: ${LOCALBASE}/etc/rc.subr.
 ##
@@ -1462,17 +1467,20 @@
 .endif
 .endif
 
-.if defined(USE_RC_SUBR)
+.if defined(USE_RC_SUBR) || defined(USE_RCORDER)
 .if ${OSVERSION} < 500037
 RUN_DEPENDS+=	${LOCALBASE}/etc/rc.subr:${PORTSDIR}/sysutils/rc_subr
 RC_SUBR=	${LOCALBASE}/etc/rc.subr
 .else
 RC_SUBR=	/etc/rc.subr
 .endif
-.if ${USE_RC_SUBR:U} != "YES"
 SUB_LIST+=	RC_SUBR=${RC_SUBR}
+.if defined(USE_RC_SUBR) && ${USE_RC_SUBR:U} != "YES"
 SUB_FILES+=	${USE_RC_SUBR}
 .endif
+.if defined(USE_RCORDER)
+SUB_FILES+=	${USE_RCORDER}
+.endif
 .endif
 
 .if defined(USE_ICONV)
@@ -4837,16 +4845,22 @@
 
 .if !target(install-rc-script)
 install-rc-script:
-.if defined(USE_RC_SUBR)
-.if ${USE_RC_SUBR:U} != "YES"
-	@${ECHO_CMD} "===> Installing startup script(s) in ${PREFIX}/etc/rc.d"
-	@if ${EGREP} -qe '^@cw?d' ${TMPPLIST} && \
-		[ "`${SED} -En -e '/^@cw?d[ 	]*/s,,,p' ${TMPPLIST} | ${TAIL} -n 1`" != "${PREFIX}" ]; then \
-		${ECHO_CMD} "@cwd ${PREFIX}" >> ${TMPPLIST}; \
-	fi
+.if defined(USE_RCORDER) || defined(USE_RC_SUBR) && ${USE_RC_SUBR:U} != "YES"
+.if defined(USE_RCORDER)
+	@${ECHO_CMD} "===> Installing early rcNG startup script(s)"
+	@${ECHO_CMD} "@cwd /" >> ${TMPPLIST}
+	@for i in ${USE_RCORDER}; do \
+		${INSTALL_SCRIPT} ${WRKDIR}/$${i} /etc/rc.d/$${i%.sh}; \
+		${ECHO_CMD} "etc/rc.d/$${i%.sh}" >> ${TMPPLIST}; \
+	done
+	@${ECHO_CMD} "@cwd ${PREFIX}" >> ${TMPPLIST}
+.endif
+.if defined(USE_RC_SUBR) && ${USE_RC_SUBR:U} != "YES"
+	@${ECHO_CMD} "===> Installing rcNG startup script(s)"
+	@${ECHO_CMD} "@cwd ${PREFIX}" >> ${TMPPLIST}
 	@for i in ${USE_RC_SUBR}; do \
-		${INSTALL_SCRIPT} ${WRKDIR}/$${i} ${PREFIX}/etc/rc.d; \
-		${ECHO_CMD} etc/rc.d/$${i} >> ${TMPPLIST}; \
+		${INSTALL_SCRIPT} ${WRKDIR}/$${i} ${PREFIX}/etc/rc.d/$${i%.sh}.sh; \
+		${ECHO_CMD} "etc/rc.d/$${i%.sh}.sh" >> ${TMPPLIST}; \
 	done
 .endif
 .else
--- rcorder-bpm-v2.diff ends here ---
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->portmgr 
Responsible-Changed-By: erwin 
Responsible-Changed-When: Fri Feb 11 12:21:08 GMT 2005 
Responsible-Changed-Why:  
Portmgr territory 

http://www.freebsd.org/cgi/query-pr.cgi?pr=77385 
State-Changed-From-To: open->closed 
State-Changed-By: krion 
State-Changed-When: Mon Feb 28 21:12:53 GMT 2005 
State-Changed-Why:  
Committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=77385 
>Unformatted:
