Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Jul 2004 02:04:21 +0200 (CEST)
From:      Florent Thoumie <flz@xbsd.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/69217: devel/portmk - add a convenient mechanism to handle startup scripts that use rc.subr
Message-ID:  <20040718000421.45B411027@gw.xbsd.org>
Resent-Message-ID: <200407180010.i6I0AJRO018884@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         69217
>Category:       ports
>Synopsis:       devel/portmk - add a convenient mechanism to handle startup scripts that use rc.subr
>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:   Sun Jul 18 00:10:19 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Florent Thoumie
>Release:        FreeBSD 4.9-RC i386
>Organization:
Xbsd.org
>Environment:

System: FreeBSD gw 4.9-RC FreeBSD 4.9-RC #4: Sun Oct 5 14:25:09 CEST 2003 rf@gw:/usr/src/sys/compile/GW i386

>Description:

This patch provides a convenient way to install startup scripts that use rc.subr.

This is based on ports/67151.

Just have to put myport.sh.in in files/, and add USE_RC_SUBR=myport.sh.


>How-To-Repeat:

Apply following patch.

>Fix:

--- portmk-rc-script.diff begins here. ---

--- bsd.port.mk.old	Tue Jul  6 14:41:03 2004
+++ bsd.port.mk	Sun Jul 18 01:31:07 2004
@@ -344,8 +344,12 @@
 # WITH_MYSQL_VER	- User defined variable to set MySQL version.
 #
 # USE_RC_SUBR		- Says the ports startup/shutdown script uses the common
-#			  	routines found in etc/rc.subr and may need to
-#				depend on the sysutils/rc_subr port.
+# 				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"
+#				pairs will be added to ${SUB_LIST}. These files will be
+#				installed in ${PREFIX}/etc/rc.d and added to the packing list.
 #
 # RC_SUBR		- Set to path of rc.subr, defaults to ${LOCALBASE}/etc/rc.subr.
 #
@@ -717,6 +721,18 @@
 #				  (default: ${WRKDIR}/.PLIST.mktmp).
 # PLIST_SUB		- List of "variable=value" pair for substitution in ${PLIST}
 # 				  (default: see below).
+#
+# SUB_FILES		- Files that should be passed through sed and redirected to ${WRKDIR}.
+#				- For each file specified in SUB_FILES, there must be a corresponding
+#				  file in ${FILESDIR} whose suffix is ".in". For instance,
+#				  if the Makefile specifies "SUB_FILES= pkg-message" then there must be
+#				  a file called pkg-message.in in ${FILESDIR}.
+#				- The substitution process is the same as PLIST_FILES, as described
+#				  below except that any line beginning with @comment is deleted.
+# SUB_LIST		- List of "variable=value" pair for substitution in ${SUB_FILES}
+# 				  (some pair are added by default: eg. PREFIX=${PREFIX}).
+#
+#
 # INSTALLS_SHLIB - If set, bsd.port.mk will automatically run ldconfig commands
 #				  from post-install and also add appropriate @exec/@unexec
 #				  directives to directories listed in LDCONFIG_DIRS.
--- bsd.port.post.mk.old	Wed Jul  7 16:51:17 2004
+++ bsd.port.post.mk	Sun Jul 18 01:48:57 2004
@@ -25,6 +25,8 @@
 INSTALL_WRKSRC?=${WRKSRC}
 
 PLIST_SUB+=	OSREL=${OSREL} PREFIX=%D LOCALBASE=${LOCALBASE} X11BASE=${X11BASE}
+SUB_LIST+=	PREFIX=${PREFIX} LOCALBASE=${LOCALBASE} X11BASE=${X11BASE}	\
+			DATADIR=${DATADIR} DOCSDIR=${DOCSDIR} EXAMPLESDIR=${EXAMPLESDIR}
 
 .if defined(WITHOUT_CPU_CFLAGS)
 .if defined(_CPUCFLAGS)
@@ -178,6 +180,10 @@
 .else
 RC_SUBR=	/etc/rc.subr
 .endif
+.if ${USE_RC_SUBR} != "yes"
+SUB_LIST+=	RC_SUBR=${RC_SUBR}
+SUB_FILES+=	${USE_RC_SUBR}
+.endif
 .endif
 
 .if defined(USE_ICONV)
@@ -1961,11 +1967,12 @@
 _INSTALL_DEP=	build
 _INSTALL_SEQ=	install-message check-conflicts \
 			    run-depends lib-depends pre-install pre-install-script \
-				generate-plist check-already-installed
+				apply-slist generate-plist check-already-installed
 _INSTALL_SUSEQ= check-umask install-mtree pre-su-install \
 				pre-su-install-script do-install post-install \
 				post-install-script add-plist-info add-plist-docs \
-				compress-man run-ldconfig fake-pkg security-check
+				install-rc-script compress-man run-ldconfig fake-pkg \
+				security-check
 _PACKAGE_DEP=	install
 _PACKAGE_SEQ=	package-message pre-package pre-package-script \
 				do-package post-package-script
@@ -2863,6 +2870,29 @@
 .endif
 .endif
 
+_SUB_LIST_TEMP=	${SUB_LIST:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/}
+.if !target(apply-slist)
+apply-slist:
+# Apply substitutions on files specified in SUB_FILES.
+.if defined(SUB_FILES)
+	@for file in ${SUB_FILES}; do \
+		if [ ! -r ${FILESDIR}/$${file}.in ]; then \
+			${ECHO_CMD} ">> Missing file : ${FILESDIR}/$${file}.in for ${PKGNAME}."; \
+			exit 1; \
+		else \
+				${SED} ${_SUB_LIST_TEMP} -e '/^@comment /d' ${FILESDIR}/$${file}.in > ${WRKDIR}/$${file}; \
+		fi; \
+	done
+.for i in pkg-message pkg-install pkg-deinstall pkg-req
+.if ${SUB_FILES:M${i}*}!=""
+${i:S/-//:U}=	${WRKDIR}/${SUB_FILES:M${i}*}
+.endif
+.endfor
+.else
+	@${DO_NADA}
+.endif
+.endif
+
 # Generate packing list.  Also tests to make sure all required package
 # files exist.
 
@@ -2973,6 +3003,24 @@
 .else
 	@${DO_NADA}
 .endif
+.endif
+
+.if !target(install-rc-script)
+install-rc-script:
+# Install startup script(s) specified in USE_RC_SUBR.
+.if defined(USE_RC_SUBR) && ${USE_RC_SUBR} != "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
+	@for i in ${USE_RC_SUBR}; do \
+		${INSTALL_SCRIPT} ${WRKDIR}/$${i} ${PREFIX}/etc/rc.d; \
+		${ECHO_CMD} etc/rc.d/$${i} >> ${TMPPLIST}; \
+	done
+.endif
+.else
+	@${DO_NADA}
 .endif
 
 # Compress (or uncompress) and symlink manpages.

--- portmk-rc-script.diff ends here. ---
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040718000421.45B411027>