Subject: Re: /usr/pkg/etc/rc.d
To: Thomas T. Thai <tom@minnesota.com>
From: Greg A. Woods <woods@weird.com>
List: netbsd-users
Date: 12/03/2004 17:39:38
[ On Friday, December 3, 2004 at 13:45:41 (-0500), Steven M. Bellovin wrote: ]
> Subject: Re: /usr/pkg/etc/rc.d
>
> In other words, there are two mutally conflicting requirements. Choose
> your poison...
Actually the conceptual conflict goes away completely if instead of
calling the install directory PREFIX/etc/rc.d it is called
PREFIX/share/examples/rc.d -- then it is clear that the installed files
are only examples, and just as the other installed _example_ config
files must be copied into place, so must the _example_ rc.d scripts.
(whitespace in the following is wrong -- see comprehensive patch at end of msg)
Index: bsd.pkg.install.mk
===================================================================
RCS file: /cvs/master/m-NetBSD/main/pkgsrc/mk/bsd.pkg.install.mk,v
retrieving revision 1.62
diff -u -r1.62 bsd.pkg.install.mk
--- bsd.pkg.install.mk 10 Jul 2004 20:54:44 -0000 1.62
+++ bsd.pkg.install.mk 24 Sep 2004 15:29:43 -0000
@@ -173,7 +173,7 @@
SUPPORT_FILES_PERMS?= # empty
RCD_SCRIPTS?= # empty
RCD_SCRIPTS_MODE?= 0755
-RCD_SCRIPTS_EXAMPLEDIR?= ${PREFIX}/etc/rc.d
+RCD_SCRIPTS_EXAMPLEDIR?= share/examples/rc.d
RCD_SCRIPTS_SHELL?= ${SH}
FILES_SUBST+= CONF_FILES=${CONF_FILES:Q}
FILES_SUBST+= CONF_FILES_MODE=${CONF_FILES_MODE}
Further these scripts are in fact automatically installed in the right
place in the same way as example config files if the following change to
the same file is made as well, or if this variable is set in /etc/mk.conf:
-PKG_RCD_SCRIPTS?= NO
+PKG_RCD_SCRIPTS?= YES
Of course there may be problems (or at least a perception of potential
problems) with automatic installation of scripts that don't honour
controls in /etc/rc.conf and which go and do their thing all the time.
Such scripts should of course be fixed ASAP, but in the mean time anyone
who donesn't want the risk can omit the above change and/or disable it
in their own /etc/mk.conf.
If, as I and others have argued several times in tech-pkg, these changes
were made official then this never-ending FAQ would never ever appear
again and a great deal of confusion and consternation would be avoided
by all. Sadly some powers that be seem vehemently opposed for
(publicly) unexplained reasons.
There are a few other little wiggles and cleanups that can be addressed
with this complete, white-space intact, patch. I've been using this
patch happily and successfully for perhaps as long as a year or more now
and with absolutely no adverse side-effects.
Index: mk/bsd.pkg.install.mk
===================================================================
RCS file: /cvs/master/m-NetBSD/main/pkgsrc/mk/bsd.pkg.install.mk,v
retrieving revision 1.62
diff -u -r1.62 bsd.pkg.install.mk
--- mk/bsd.pkg.install.mk 10 Jul 2004 20:54:44 -0000 1.62
+++ mk/bsd.pkg.install.mk 3 Dec 2004 22:31:11 -0000
@@ -161,8 +161,8 @@
# at post-install time.
#
# RCD_SCRIPTS works lists the basenames of the rc.d scripts. They are
-# expected to be found in ${RCD_SCRIPTS_EXAMPLEDIR}, and the scripts
-# will be copied into ${RCD_SCRIPTS_DIR} with ${RCD_SCRIPTS_MODE}
+# expected to be found in ${PREFIX}/${RCD_SCRIPTS_EXAMPLEDIR}, and the
+# scripts will be copied into ${RCD_SCRIPTS_DIR} with ${RCD_SCRIPTS_MODE}
# permissions.
#
CONF_FILES?= # empty
@@ -173,7 +173,7 @@
SUPPORT_FILES_PERMS?= # empty
RCD_SCRIPTS?= # empty
RCD_SCRIPTS_MODE?= 0755
-RCD_SCRIPTS_EXAMPLEDIR?= ${PREFIX}/etc/rc.d
+RCD_SCRIPTS_EXAMPLEDIR?= share/examples/rc.d
RCD_SCRIPTS_SHELL?= ${SH}
FILES_SUBST+= CONF_FILES=${CONF_FILES:Q}
FILES_SUBST+= CONF_FILES_MODE=${CONF_FILES_MODE}
@@ -221,14 +221,17 @@
#
# PKG_RCD_SCRIPTS indicates whether to automatically install rc.d scripts
# to ${RCD_SCRIPTS_DIR}. It is either YES or NO and defaults to
-# NO. This variable only takes effect if ${PKG_CONFIG} == "YES".
+# YES. This variable only takes effect if ${PKG_CONFIG} == "YES".
+#
+# Note this means adding a package with any RCD_SCRIPTS will
+# cause warnings to be displayed upon boot by /etc/rc.
#
# These values merely set the defaults for INSTALL/DEINSTALL scripts, but
# they may be overridden by resetting them in the environment.
#
PKG_CREATE_USERGROUP?= YES
PKG_CONFIG?= YES
-PKG_RCD_SCRIPTS?= NO
+PKG_RCD_SCRIPTS?= YES
FILES_SUBST+= PKG_CREATE_USERGROUP=${PKG_CREATE_USERGROUP}
FILES_SUBST+= PKG_CONFIG=${PKG_CONFIG}
FILES_SUBST+= PKG_RCD_SCRIPTS=${PKG_RCD_SCRIPTS}
@@ -294,6 +297,8 @@
INSTALL_SCRIPTS_ENV= PKG_PREFIX=${PREFIX}
+# this should also run the REQUIRE script....
+
.PHONY: pre-install-script post-install-script
pre-install-script: generate-install-scripts
@@ -311,6 +316,7 @@
.if !empty(DEINSTALL_SRC)
generate-install-scripts: ${DEINSTALL_FILE}
${DEINSTALL_FILE}: ${DEINSTALL_SRC}
+ @${ECHO_MSG} "${_PKGSRC_IN}> Creating DEINSTALL script ${.TARGET}"
${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} | \
${SED} ${FILES_SUBST_SED} > ${.TARGET}
${_PKG_SILENT}${_PKG_DEBUG}${CHMOD} +x ${.TARGET}
@@ -319,6 +325,7 @@
.if !empty(INSTALL_SRC)
generate-install-scripts: ${INSTALL_FILE}
${INSTALL_FILE}: ${INSTALL_SRC}
+ @${ECHO_MSG} "${_PKGSRC_IN}> Creating INSTALL script ${.TARGET}"
${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} | \
${SED} ${FILES_SUBST_SED} > ${.TARGET}
${_PKG_SILENT}${_PKG_DEBUG}${CHMOD} +x ${.TARGET}
@@ -332,32 +339,34 @@
#
# RCD_SCRIPT_SRC.<script> the source file for <script>; this will
# be run through FILES_SUBST to generate
-# the rc.d script
+# the rc.d script (defaults to
+# ${FILESDIR}/<script>.sh)
#
# RCD_SCRIPTS_EXAMPLEDIR the directory in which to install the
-# example rc.d scripts
+# example rc.d scripts (defaults to
+# share/examples/rc.d)
#
# If the source rc.d script is not present, then the automatic handling
# doesn't occur.
.PHONY: generate-rcd-scripts
post-build: generate-rcd-scripts
-generate-rcd-scripts: # do nothing
+generate-rcd-scripts: # do nothing by default
.PHONY: install-rcd-scripts
post-install: install-rcd-scripts
-install-rcd-scripts: # do nothing
+install-rcd-scripts: # do nothing by default
.for _script_ in ${RCD_SCRIPTS}
RCD_SCRIPT_SRC.${_script_}?= ${FILESDIR}/${_script_}.sh
-RCD_SCRIPT_WRK.${_script_}?= ${WRKDIR}/${_script_}
+RCD_SCRIPT_WRK.${_script_}= ${WRKDIR}/${_script_}
-GENERATE_PLIST+= ${ECHO} ${RCD_SCRIPTS_EXAMPLEDIR:S|${PREFIX}/||}/${_script_};
+GENERATE_PLIST+= ${ECHO} ${RCD_SCRIPTS_EXAMPLEDIR}/${_script_};
. if !empty(RCD_SCRIPT_SRC.${_script_})
-. if exists(${RCD_SCRIPT_SRC.${_script_}})
generate-rcd-scripts: ${RCD_SCRIPT_WRK.${_script_}}
${RCD_SCRIPT_WRK.${_script_}}: ${RCD_SCRIPT_SRC.${_script_}}
+ @${ECHO_MSG} "${_PKGSRC_IN}> Creating RCD script: '${_script_}'"
${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} | \
${SED} ${FILES_SUBST_SED} > ${.TARGET}
${_PKG_SILENT}${_PKG_DEBUG}${CHMOD} +x ${.TARGET}
@@ -365,16 +374,16 @@
install-rcd-scripts: install-rcd-${_script_}
install-rcd-${_script_}: ${RCD_SCRIPT_WRK.${_script_}}
${_PKG_SILENT}${_PKG_DEBUG} \
- if [ ! -d ${RCD_SCRIPTS_EXAMPLEDIR} ]; then \
+ if [ ! -d ${PREFIX}/${RCD_SCRIPTS_EXAMPLEDIR} ]; then \
${INSTALL} -d -o ${SHAREOWN} -g ${SHAREGRP} \
- -m 0755 ${RCD_SCRIPTS_EXAMPLEDIR}; \
+ -m 0755 ${PREFIX}/${RCD_SCRIPTS_EXAMPLEDIR}; \
fi
+ @${ECHO_MSG} "${_PKGSRC_IN}> Installing RCD script to ${PREFIX}/${RCD_SCRIPTS_EXAMPLEDIR}/${_script_}"
${_PKG_SILENT}${_PKG_DEBUG} \
if [ -f ${RCD_SCRIPT_WRK.${_script_}} ]; then \
${INSTALL_SCRIPT} ${RCD_SCRIPT_WRK.${_script_}} \
- ${RCD_SCRIPTS_EXAMPLEDIR}/${_script_}; \
+ ${PREFIX}/${RCD_SCRIPTS_EXAMPLEDIR}/${_script_}; \
fi
-. endif
. endif
.endfor
--
Greg A. Woods
+1 416 218-0098 VE3TCP RoboHack <woods@robohack.ca>
Planix, Inc. <woods@planix.com> Secrets of the Weird <woods@weird.com>