Subject: Re: /usr/pkg/etc/rc.d/*
To: Tom Ivar Helbekkmo <tih@eunetnorge.no>
From: Greg A. Woods <woods@weird.com>
List: current-users
Date: 03/09/2003 15:22:41
[ On Sunday, March 9, 2003 at 20:24:50 (+0100), Tom Ivar Helbekkmo wrote: ]
> Subject: Re: /usr/pkg/etc/rc.d/*
>
> "Greg A. Woods" <woods@weird.com> writes:
> 
> > How can you logically assume that something which needs configuration
> > can "just work" when you install it in your particular environment?
> 
> I don't think anyone is assuming that.  What's being assumed is that
> you can install a software package from pkg_src, configure it, and add
> "mumble=YES" to /etc/rc.conf -- and expect it to start at the next
> reboot.

Anyone making such an assumption apparently hasn't read the text that's
displayed when such a package is installed!  ;-)

(though admittedly the message text isn't quite so lucid as it could be,
but see my suggestions way below)

>  This matches what you do with a number of packages that are
> included in the base system.  Adding a requirement to copy the startup
> script from its installed location in /usr/pkg/etc/rc.d/ to /etc/rc.d/
> seems like it ought to be unnecessary.

Perhaps.  I too have done some things to make it work better, as shown
below.  Note though that there's still some complication when packages
are updated and their rc.d script changes.  I'm thinking very seriously
of turning PKG_RCD_SCRIPTS off again and instead adding some INSTALL
goop to warn if the installed /etc/rc.d copy differs from the version in
examples/rc.d....

(tabs converted to spaces, courtesy cut&paste from silly xterm :-)

Index: bsd.pkg.install.mk
===================================================================
RCS file: /cvs/master/m-NetBSD/main/pkgsrc/mk/bsd.pkg.install.mk,v
retrieving revision 1.40
diff -c -r1.40 bsd.pkg.install.mk
*** bsd.pkg.install.mk  2 Dec 2002 17:07:27 -0000       1.40
--- bsd.pkg.install.mk  22 Jan 2003 00:01:41 -0000
***************
*** 151,157 ****
  RCD_SCRIPTS?=         # empty
  RCD_SCRIPTS_MODE?=    0755
  RCD_SCRIPTS_DIR?=     /etc/rc.d
! RCD_SCRIPTS_EXAMPLEDIR?=      ${PREFIX}/etc/rc.d
  RCD_SCRIPTS_SHELL?=   ${SH}
  FILES_SUBST+=         CONF_FILES=${CONF_FILES:Q}
  FILES_SUBST+=         CONF_FILES_MODE=${CONF_FILES_MODE}
--- 151,157 ----
  RCD_SCRIPTS?=         # empty
  RCD_SCRIPTS_MODE?=    0755
  RCD_SCRIPTS_DIR?=     /etc/rc.d
! RCD_SCRIPTS_EXAMPLEDIR?=      ${PREFIX}/share/examples/rc.d
  RCD_SCRIPTS_SHELL?=   ${SH}
  FILES_SUBST+=         CONF_FILES=${CONF_FILES:Q}
  FILES_SUBST+=         CONF_FILES_MODE=${CONF_FILES_MODE}
***************
*** 201,214 ****
  #
  # 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".
  #
  # 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
  FILES_SUBST+=         PKG_CREATE_USERGROUP=${PKG_CREATE_USERGROUP}
  FILES_SUBST+=         PKG_CONFIG=${PKG_CONFIG}
  FILES_SUBST+=         PKG_RCD_SCRIPTS=${PKG_RCD_SCRIPTS}
--- 201,217 ----
  #
  # PKG_RCD_SCRIPTS indicates whether to automatically install rc.d scripts
  #     to ${RCD_SCRIPTS_DIR}.  It is either YES or NO and defaults to
! #     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?=     YES
  FILES_SUBST+=         PKG_CREATE_USERGROUP=${PKG_CREATE_USERGROUP}
  FILES_SUBST+=         PKG_CONFIG=${PKG_CONFIG}
  FILES_SUBST+=         PKG_RCD_SCRIPTS=${PKG_RCD_SCRIPTS}
***************
*** 268,273 ****
--- 271,278 ----
  
  INSTALL_SCRIPTS_ENV=  PKG_PREFIX=${PREFIX}
  
+ # this should also run the REQUIRE script....
+ 
  pre-install-script: generate-install-scripts
        ${_PKG_SILENT}${_PKG_DEBUG}${SETENV} ${INSTALL_SCRIPTS_ENV}     \
                ${_PKG_DEBUG_SCRIPT} ${INSTALL_FILE} ${PKGNAME} PRE-INSTALL
***************
*** 303,312 ****
  #
  # RCD_SCRIPT_SRC.<script>     the source file for <script>; this will
  #                             be run through FILES_SUBST to generate
! #                             the rc.d script
  #
  # RCD_SCRIPTS_EXAMPLEDIR      the directory in which to install the
! #                             example rc.d scripts
  #
  # If the source rc.d script is not present, then the automatic handling
  # doesn't occur.
--- 308,319 ----
  #
  # RCD_SCRIPT_SRC.<script>     the source file for <script>; this will
  #                             be run through FILES_SUBST to generate
! #                             the rc.d script (defaults to
! #                             ${FILESDIR}/<script>.sh)
  #
  # RCD_SCRIPTS_EXAMPLEDIR      the directory in which to install the
! #                             example rc.d scripts (defaults to
! #                             ${PREFIX}/share/examples/rc.d)
  #
  # If the source rc.d script is not present, then the automatic handling
  # doesn't occur.
***************
*** 318,327 ****
--- 325,337 ----
  .for _script_ in ${RCD_SCRIPTS}
  RCD_SCRIPT_SRC.${_script_}?=  ${FILESDIR}/${_script_}.sh
  
+ GENERATE_PLIST+=      ${ECHO} ${RCD_SCRIPTS_EXAMPLEDIR:S|${PREFIX}/||}/${_script_};
+ 
  .  if !empty(RCD_SCRIPT_SRC.${_script_})
  .    if exists(${RCD_SCRIPT_SRC.${_script_}})
  generate-rcd-scripts: ${WRKDIR}/${_script_}
  ${WRKDIR}/${_script_}: ${RCD_SCRIPT_SRC.${_script_}}
+       @${ECHO_MSG} "${_PKGSRC_IN}> Creating ${.TARGET}"
        ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} |                  \
                ${SED} ${FILES_SUBST_SED} > ${.TARGET}
        ${_PKG_SILENT}${_PKG_DEBUG}${CHMOD} +x ${.TARGET}
Index: install/install
===================================================================
RCS file: /cvs/master/m-NetBSD/main/pkgsrc/mk/install/install,v
retrieving revision 1.19
diff -c -r1.19 install
*** install/install     29 Jan 2003 19:47:29 -0000      1.19
--- install/install     30 Jan 2003 23:21:56 -0000
***************
*** 1,3 ****
--- 1,4 ----
+ # -*- sh -*-
  # start of install
  #
  # $NetBSD: install,v 1.19 2003/01/29 19:47:29 jlam Exp $
***************
*** 53,58 ****
--- 54,60 ----
                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@}"
***************
*** 207,213 ****
                                msgadd "The following files should be created for ${PKGNAME}:"
                                msgadd ""
                        fi
!                       msgadd "#${file} (m=@CONF_FILES_MODE@)"
                elif [ -e "${file}" ]; then
                        ${ECHO} "    ${file} already exists, example file is"
                        ${ECHO} "        ${samplefile}"
--- 209,219 ----
                                msgadd "The following files should be created for ${PKGNAME}:"
                                msgadd ""
                        fi
!                       if [ -e "${samplefile}" ]; then
!                               msgadd "#${file} (m=@CONF_FILES_MODE@) (see ${samplefile})"
!                       else
!                               msgadd "#${file} (m=@CONF_FILES_MODE@) (no example available)"
!                       fi
                elif [ -e "${file}" ]; then
                        ${ECHO} "    ${file} already exists, example file is"
                        ${ECHO} "        ${samplefile}"
***************
*** 231,237 ****
                                msgadd "The following files should be created for ${PKGNAME}:"
                                msgadd ""
                        fi
!                       msgadd "#${file} (m=@SUPPORT_FILES_MODE@)"
                elif [ -e "${file}" ]; then
                        ${ECHO} "    ${file} already exists, example file is"
                        ${ECHO} "        ${samplefile}"
--- 237,247 ----
                                msgadd "The following files should be created for ${PKGNAME}:"
                                msgadd ""
                        fi
!                       if [ -e "${samplefile}" ]; then
!                               msgadd "#${file} (m=@SUPPORT_FILES_MODE@) (see ${samplefile})"
!                       else
!                               msgadd "#${file} (m=@SUPPORT_FILES_MODE@) (no example available)"
!                       fi
                elif [ -e "${file}" ]; then
                        ${ECHO} "    ${file} already exists, example file is"
                        ${ECHO} "        ${samplefile}"
***************
*** 253,265 ****
                        if [ ${_print_file_header} -gt 0 ]; then
                                _print_file_header=0
                                msgadd ""
!                               msgadd "The following files should be created for ${PKGNAME}:"
                                msgadd ""
                        fi
!                       msgadd "#${file} (o=${owner}, g=${group}, m=${mode})"
                elif [ -e ${file} ]; then
!                       ${ECHO} "    ${file} already exists, example file is"
!                       ${ECHO} "        ${samplefile}"
                else
                        if [ -e "${samplefile}" ]; then
                                ${ECHO} "    ${file}"
--- 263,279 ----
                        if [ ${_print_file_header} -gt 0 ]; then
                                _print_file_header=0
                                msgadd ""
!                               msgadd "The following configuration files should be created for ${PKGNAME}:"
                                msgadd ""
                        fi
!                       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 [ -e ${file} ]; then
!                       ${ECHO} "    ${file} already exists"
!                       ${ECHO} "    The original example configuration file is: ${samplefile}"
                else
                        if [ -e "${samplefile}" ]; then
                                ${ECHO} "    ${file}"
***************
*** 280,292 ****
                        if [ ${_print_file_header} -gt 0 ]; then
                                _print_file_header=0
                                msgadd ""
!                               msgadd "The following files should be created for ${PKGNAME}:"
                                msgadd ""
                        fi
!                       msgadd "#${file} (m=@RCD_SCRIPTS_MODE@)"
                elif [ -e "${file}" ]; then
!                       ${ECHO} "    ${file} already exists, example file is"
!                       ${ECHO} "        ${samplefile}"
                else
                        if [ -e "${samplefile}" ]; then
                                ${ECHO} "    ${file}"
--- 294,310 ----
                        if [ ${_print_file_header} -gt 0 ]; then
                                _print_file_header=0
                                msgadd ""
!                               msgadd "The following rc.d scripts should be created for ${PKGNAME}:"
                                msgadd ""
                        fi
!                       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 [ -e "${file}" ]; then
!                       ${ECHO} "    ${file} already exists."
!                       ${ECHO} "    The example rc.d script is: ${samplefile}"
                else
                        if [ -e "${samplefile}" ]; then
                                ${ECHO} "    ${file}"
***************
*** 307,313 ****
                        msgadd "The following files and directories have special permissions:"
                        msgadd ""
                fi
!               msgadd "#${file} (o=${owner}, g=${group}, m=${mode})"
                ${CHOWN} "${owner}" "${file}"
                ${CHGRP} "${group}" "${file}"
                ${CHMOD} ${mode} "${file}"
--- 325,335 ----
                        msgadd "The following files and directories have special permissions:"
                        msgadd ""
                fi
!               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

+1 416 218-0098;            <g.a.woods@ieee.org>;           <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; VE3TCP; Secrets of the Weird <woods@weird.com>