Subject: Re: defaulting rc.d scripts to share/examples/rc.d
To: Jeremy C. Reed <reed@reedmedia.net>
From: Greg A. Woods <woods@planix.com>
List: tech-pkg
Date: 09/24/2004 11:33:46
[ On Thursday, September 23, 2004 at 16:14:54 (-0700), Jeremy C. Reed wrote: ]
> Subject: defaulting rc.d scripts to share/examples/rc.d
>
> For a long, long time, I have been defaulting rc.d scripts to
> share/examples/rc.d/.
Me too! :-)
There are some minor improvements you could still make to your proposed
changes:
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 24 Sep 2004 15:29:43 -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}
@@ -209,6 +209,7 @@
FILES_SUBST+= OWN_DIRS=${OWN_DIRS:Q}
FILES_SUBST+= OWN_DIRS_PERMS=${OWN_DIRS_PERMS:Q}
+
# PKG_CREATE_USERGROUP indicates whether the INSTALL script should
# automatically add any needed users/groups to the system using
# useradd/groupadd. It is either YES or NO and defaults to YES.
@@ -221,14 +222,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 +298,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 +317,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 +326,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 +340,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 +375,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
cvs diff: Diffing mk/install
Index: mk/install/deinstall
===================================================================
RCS file: /cvs/master/m-NetBSD/main/pkgsrc/mk/install/deinstall,v
retrieving revision 1.28
diff -u -r1.28 deinstall
--- mk/install/deinstall 10 Jul 2004 20:42:37 -0000 1.28
+++ mk/install/deinstall 24 Sep 2004 15:25:08 -0000
@@ -1,3 +1,4 @@
+# -*- sh -*-
# start of deinstall
#
# $NetBSD: deinstall,v 1.28 2004/07/10 20:42:37 salo Exp $
@@ -31,7 +32,7 @@
if [ "${_PKG_RCD_SCRIPTS}" = "YES" ]; then
eval set -- ${RCD_SCRIPTS}
for script; do
- samplefile="${RCD_SCRIPTS_EXAMPLEDIR}/${script}"
+ samplefile="${PKG_PREFIX}/${RCD_SCRIPTS_EXAMPLEDIR}/${script}"
file="${RCD_SCRIPTS_DIR}/${script}"
shift
ALL_FILES="${ALL_FILES} \"${samplefile}\" \"${file}\""
Index: mk/install/install
===================================================================
RCS file: /cvs/master/m-NetBSD/main/pkgsrc/mk/install/install,v
retrieving revision 1.31
diff -u -r1.31 install
--- mk/install/install 10 Jul 2004 20:42:37 -0000 1.31
+++ mk/install/install 24 Sep 2004 15:24:21 -0000
@@ -1,3 +1,4 @@
+# -*- sh -*-
# start of install
#
# $NetBSD: install,v 1.31 2004/07/10 20:42:37 salo Exp $
@@ -67,6 +68,7 @@
for userset; do
save_IFS="${IFS}"; IFS=":"
set -- ${userset}
+ # user:group[:[userid][:[descr][:[home][:shell]]]]
user="$1"; group="$2"; userid="$3"
descr="${4:-${PKGBASE} ${user} user}"
home="${5:-@PKG_USER_HOME@}"
@@ -240,7 +242,11 @@
msgadd "The following files should be created for ${PKGNAME}:"
msgadd ""
fi
- msgadd "#${file} (m=@CONF_FILES_MODE@)"
+ if [ -e "${samplefile}" ]; then
+ msgadd "#${file} (m=@CONF_FILES_MODE@) (see ${samplefile})"
+ else
+ msgadd "#${file} (m=@CONF_FILES_MODE@) (no example available)"
+ fi
elif [ -f "${file}" ]; then
if [ ! "${file}" -ef "${samplefile}" ]; then
${ECHO} " ${file} already exists, example file is"
@@ -266,7 +272,11 @@
msgadd "The following files should be created for ${PKGNAME}:"
msgadd ""
fi
- msgadd "#${file} (m=@SUPPORT_FILES_MODE@)"
+ if [ -e "${samplefile}" ]; then
+ msgadd "#${file} (m=@SUPPORT_FILES_MODE@) (see ${samplefile})"
+ else
+ msgadd "#${file} (m=@SUPPORT_FILES_MODE@) (no example available)"
+ fi
elif [ -f "${file}" ]; then
if [ ! "${file}" -ef "${samplefile}" ]; then
${ECHO} " ${file} already exists, example file is"
@@ -290,14 +300,18 @@
if [ ${_print_file_header} -gt 0 ]; then
_print_file_header=0
msgadd ""
- msgadd "The following files should be created for ${PKGNAME}:"
+ msgadd "The following configuration files should be created for ${PKGNAME}:"
msgadd ""
fi
- msgadd "#${file} (o=${owner}, g=${group}, m=${mode})"
+ if [ -e "${samplefile}" ]; then
+ msgadd "#${file} (owner=${owner}, group=${group}, mode=${mode}) (see ${samplefile})"
+ else
+ msgadd "#${file} (owner=${owner}, group=${group}, mode=${mode}) (no example available)"
+ fi
elif [ -f ${file} ]; then
if [ ! "${file}" -ef "${samplefile}" ]; then
- ${ECHO} " ${file} already exists, example file is"
- ${ECHO} " ${samplefile}"
+ ${ECHO} " ${file} already exists"
+ ${ECHO} " The original example configuration file is: ${samplefile}"
fi
else
if [ -f "${samplefile}" ]; then
@@ -311,7 +325,7 @@
done
eval set -- ${RCD_SCRIPTS}
for script; do
- samplefile="${RCD_SCRIPTS_EXAMPLEDIR}/${script}"
+ samplefile="${PKG_PREFIX}/${RCD_SCRIPTS_EXAMPLEDIR}/${script}"
file="${RCD_SCRIPTS_DIR}/${script}"
if [ "${_PKG_CONFIG}" = "NO" -o \
@@ -319,14 +333,18 @@
if [ ${_print_file_header} -gt 0 ]; then
_print_file_header=0
msgadd ""
- msgadd "The following files should be created for ${PKGNAME}:"
+ msgadd "The following rc.d scripts should be created for ${PKGNAME}:"
msgadd ""
fi
- msgadd "#${file} (m=@RCD_SCRIPTS_MODE@)"
+ if [ -e "${samplefile}" ]; then
+ msgadd "#${file} (mode=@RCD_SCRIPTS_MODE@) (see ${samplefile})"
+ else
+ msgadd "#${file} (mode=@RCD_SCRIPTS_MODE@) (no example script available)"
+ fi
elif [ -f "${file}" ]; then
if [ ! "${file}" -ef "${samplefile}" ]; then
- ${ECHO} " ${file} already exists, example file is"
- ${ECHO} " ${samplefile}"
+ ${ECHO} " ${file} already exists."
+ ${ECHO} " The example rc.d script is: ${samplefile}"
fi
else
if [ -f "${samplefile}" ]; then
@@ -348,7 +366,11 @@
msgadd "The following files and directories have special permissions:"
msgadd ""
fi
- msgadd "#${file} (o=${owner}, g=${group}, m=${mode})"
+ if [ -e "${samplefile}" ]; then
+ msgadd "#${file} (o=${owner}, g=${group}, m=${mode}) (see ${samplefile})"
+ else
+ msgadd "#${file} (o=${owner}, g=${group}, m=${mode}) (no example available)"
+ fi
${CHOWN} "${owner}" "${file}"
${CHGRP} "${group}" "${file}"
${CHMOD} ${mode} "${file}"
--
Greg A. Woods
Planix, Inc.
<woods@planix.com> +1 416 489-5852 x122 http://www.planix.com/