Date: Tue, 9 Nov 2004 11:20:28 +1100 (EST) From: Edwin Groothuis <edwin@mavetju.org> To: FreeBSD-gnats-submit@FreeBSD.org Subject: ports/73691: [patch] Add rc.subr routines to bsd.port.mk Message-ID: <20041109002028.C175960E3@k7.mavetju> Resent-Message-ID: <200411090030.iA90UZnP007303@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 73691 >Category: ports >Synopsis: [patch] Add rc.subr routines to bsd.port.mk >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Nov 09 00:30:34 GMT 2004 >Closed-Date: >Last-Modified: >Originator: Edwin Groothuis >Release: FreeBSD 5.2.1-RELEASE i386 >Organization: - >Environment: System: FreeBSD k7.mavetju 5.2.1-RELEASE FreeBSD 5.2.1-RELEASE #7: Tue Sep 21 23:13:39 EST 2004 root@k7.mavetju:/usr/src-5.2.1/sys/i386/compile/k7 i386 >Description: Since the implemenation of rc.subr, a lot of ports have adapted the system and the quality of the startup/shutdown/status scripts have increased. But a lot of duplicate code has grown into the ports Makefiles to make sure that the startup scripts got installed properly. Look at the additional www/apache2 port overhead: USE_RC_SUBR= yes RC_SCRIPTS_SUB= PREFIX=${PREFIX} RC_SUBR=${RC_SUBR} post-patch: @${SED} ${RC_SCRIPTS_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \ ${FILESDIR}/apache.sh > ${WRKDIR}/apache2.sh .if !defined(WITH_APR_FROM_PORTS) @${SED} ${RC_SCRIPTS_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \ ${FILESDIR}/apache2libs.sh > ${WRKDIR}/apache2libs.sh .endif post-install: .if !defined(WITH_APR_FROM_PORTS) @${ECHO_CMD} "Installing ${PREFIX}/etc/rc.d/000.apache2libs.sh startup script." @${INSTALL_SCRIPT} -m 751 ${WRKDIR}/apache2libs.sh ${PREFIX}/etc/rc.d/000.apache2libs.sh .endif @${ECHO_CMD} "Installing ${PREFIX}/etc/rc.d/apache2.sh startup script." @${INSTALL_SCRIPT} -m 751 ${WRKDIR}/apache2.sh ${PREFIX}/etc/rc.d/apache2.sh Imagine every port which uses rc.subr to have these identical additional lines to it, that's not really making life easier to maintain. Imagine the following configuration: USE_RC_SUBR= yes RC_FILES= apache2.sh .if !defined(WITH_APR_FROM_PORTS) RC_FILES+= apache2libs.sh .endif And bsd.port.mk would automaticly do the patching, installation and pkg-plist additions! The patch attached is harmless for ports which don't use this new system (since the trigger isn't USE_RC_SUBR but RC_FILES). The patch does.... - It patches the files defined in RC_FILES with the variables defined in RC_SUBST (LOCALBASE, PREFIX, RC_SUBR, X11BASE by default). - It installs the files defined in RC_FILES to PREFIX/etc/rc.d - It adds the files defined in RC_FILES to the PKGPLIST. >How-To-Repeat: >Fix: Index: bsd.port.mk =================================================================== RCS file: /home/pcvs/ports/Mk/bsd.port.mk,v retrieving revision 1.499 diff -u -r1.499 bsd.port.mk --- bsd.port.mk 7 Oct 2004 17:59:18 -0000 1.499 +++ bsd.port.mk 9 Nov 2004 00:11:33 -0000 @@ -349,10 +349,17 @@ # 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. -# -# RC_SUBR - Set to path of rc.subr, defaults to ${LOCALBASE}/etc/rc.subr. +# routines found in etc/rc.subr and may need to +# depend on the sysutils/rc_subr port. +# RC_FILES - List of files to be installed in ${PREFIX}/etc/rc.d. +# Files should be filenames only, and be located +# in ${FILESDIR} +# RC_SUBST - List of parameters to be changed in ${RC_FILES}. The +# syntax is VARIABLE=value, for example AAA=${AAA}. +# The default parameters replaced are: +# LOCALBASE, PREFIX, X11BASE, RC_SUBR +# RC_SUBR - Set to path of rc.subr. +# Default: ${LOCALBASE}/etc/rc.subr. # # USE_APACHE - Says that the port relies on an apache webserver. # APACHE_PORT - CATEGORY and portname of the prefered port for apache. @@ -1371,6 +1378,8 @@ .else RC_SUBR= /etc/rc.subr .endif +RC_SUBST+= LOCALBASE=${LOCALBASE} PREFIX=${PREFIX} \ + RC_SUBR=${RC_SUBR} X11BASE=${X11BASE} .endif .if defined(USE_ICONV) @@ -3540,7 +3549,7 @@ post-extract post-extract-script _PATCH_DEP= extract _PATCH_SEQ= patch-message patch-depends pre-patch pre-patch-script \ - do-patch post-patch post-patch-script + do-patch post-patch post-patch-script patch-rc _CONFIGURE_DEP= patch _CONFIGURE_SEQ= build-depends lib-depends misc-depends configure-message \ pre-configure pre-configure-script patch-autotools \ @@ -3555,7 +3564,8 @@ _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 add-plist-rc 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 @@ -4687,6 +4697,36 @@ .else @${DO_NADA} .endif +.endif + +patch-rc: +.if defined(USE_RC_SUBR) && defined(RC_FILES) +. for f in ${RC_FILES} + @${ECHO_MSG} "===> Patching rc.d file: ${f}" + @${SED} ${RC_SUBST:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \ + ${FILESDIR}/${f} > ${WRKDIR}/${f} +. endfor +.else + @${DO_NADA} +.endif + +install-rc: +.if defined(USE_RC_SUBR) && defined(RC_FILES) +. for f in ${RC_FILES} + @${ECHO_MSG} "===> Installing rc.d file: ${f}" + @${INSTALL_SCRIPT} ${WRKDIR}/${f} ${PREFIX}/etc/rc.d/${f} +. endfor +.else + @${DO_NADA} +.endif + +add-plist-rc: +.if defined(USE_RC_SUBR) && defined(RC_FILES) +. for f in ${RC_FILES} + @${ECHO_CMD} "etc/rc.d/${f}" >> ${TMPPLIST} +. endfor +.else + @${DO_NADA} .endif # Fake installation of package so that user can pkg_delete it later. >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041109002028.C175960E3>