Bug 69217 - devel/portmk - add a convenient mechanism to handle startup scripts that use rc.subr
Summary: devel/portmk - add a convenient mechanism to handle startup scripts that use ...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Oliver Eikemeier
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-18 01:10 UTC by Florent Thoumie
Modified: 2005-02-07 11:28 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florent Thoumie 2004-07-18 01:10:19 UTC
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.

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



--- portmk-rc-script.diff ends here. -----zXYRETIWaaFbL0VmdgW0cyBvfzeXNRWSaFC35bbjEXJG71LT
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

--- 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.
How-To-Repeat: 
Apply following patch.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2004-07-18 05:49:11 UTC
Responsible Changed
From-To: freebsd-ports-bugs->eik

Over to maintainer.
Comment 2 Kris Kennaway 2004-12-24 07:41:49 UTC
On Wed, Dec 22, 2004 at 11:47:28PM -0500, Joe Marcus Clarke wrote:

> > Nothing in the patch in 69217 applies to the CVS tree, so someone will
> > need to redo it.  If someone else has time to do that before I get to
> > it, that would be very helpful.
> 
> Here you go.  In merging it, I found a bug, so this was a good exercise.
> It looks like the SUB_{LIST,FILES} stuff was already merged, so that's
> probably why it didn't apply before.


This patch breaks everything that sets USE_RC_SUBR=YES
(e.g. security/racoon, and a few others so far).

Because of the proximity of the release and the need to test other
patches, I'm pulling it from the build, and we'll have to revisit it
sometime later once this problem has been corrected.

Kris
Comment 3 krion 2004-12-24 07:49:59 UTC
On Thu, Dec 23, 2004 at 11:41:49PM -0800, Kris Kennaway wrote:
> This patch breaks everything that sets USE_RC_SUBR=YES
> (e.g. security/racoon, and a few others so far).

Could you please add it to PRs' follow-up ?

-Kirill
Comment 4 Kris Kennaway 2004-12-24 08:02:17 UTC
On Fri, Dec 24, 2004 at 02:57:21AM -0500, Joe Marcus Clarke wrote:
> On Thu, 2004-12-23 at 23:41 -0800, Kris Kennaway wrote:
> > On Wed, Dec 22, 2004 at 11:47:28PM -0500, Joe Marcus Clarke wrote:
> > 
> > > > Nothing in the patch in 69217 applies to the CVS tree, so someone will
> > > > need to redo it.  If someone else has time to do that before I get to
> > > > it, that would be very helpful.
> > > 
> > > Here you go.  In merging it, I found a bug, so this was a good exercise.
> > > It looks like the SUB_{LIST,FILES} stuff was already merged, so that's
> > > probably why it didn't apply before.
> > 
> > This patch breaks everything that sets USE_RC_SUBR=YES
> > (e.g. security/racoon, and a few others so far).
> > 
> > Because of the proximity of the release and the need to test other
> > patches, I'm pulling it from the build, and we'll have to revisit it
> > sometime later once this problem has been corrected.
> 
> Silly me.  Yeah, that will happen.  Attached is a new diff with this
> problem fixed.  However, I understand if you want to rip this out of the
> exp build for now.


I already restarted it, so I'll do a run without it and reconsider
this later.  It doesn't seem to be urgent to get this in before 4.11
anyway.

Kris
Comment 5 Florent Thoumie 2005-01-03 08:58:26 UTC
I just see there has been four emails in the audit trail, but i
haven't received any of them.

Is there something you'd like to be reworked before the next run ?
Comment 6 Kirill Ponomarev freebsd_committer freebsd_triage 2005-02-07 11:27:53 UTC
State Changed
From-To: open->closed

Committed, thanks!