tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
+RCD_SCRIPTS
Form Subject: Re: pkgsrc RC scripts
On Tue, 20 Oct 2009, Joerg Sonnenberger wrote:
> On Tue, Oct 20, 2009 at 12:06:42PM +1300, Steven Drake wrote:
> > If you mean thay should have there own script (eg +RCD_SCRIPTS) then i
> > totaly agree.
>
> Yes.
[....]
> Copying should warn if a script of that name already exists for RC files.
> E.g. if you want to install the BIND package from pkgsrc, it should warn
> that /etc/rc.d/named already exists.
[....]
> > > It might also be nice to setup a rc.conf.d entry,
> >
> > Do you want to elaborate?
>
> Create /etc/rc.conf.d/named with named=NO if the variable is currently
> undefined.
So after working on it for a month here is the code to implement
+RCD_SCRIPTS, the script has a lot of enhancements over what +FILES did:
Please note that all the variable I will mention can be changed when
installing binary package with pkg_add, either by settings in
pkg_install.conf (pkg_install version 20091022 and higher) or by setting
then in the environment.
Firstly it creates and reference-counts the needed directorys. (no need for
+DIRS entrys which wouldn't work anyway).
It installs the RCD_SCRIPTS (make the modification noted below) in the
${RCD_SCRIPTS_DIR}. (with reference-counts)
When installing the rc.d scripts it will make adjustment to then changing
${RC_SUBR_DIR}, ${RC_CONF_DIR} and ${RCD_SCRIPTS_DIR}.
This mean admins can change the location of file rc.subr and rc.conf files!
If the ${PKG_SET_RCVAR} variable is set to yes the it will append an
rcvar=NO entry to rc.conf if the rcvar is currently undefined.
While an file in /etc/rc.conf.d/ may be preferable, it is a lot of extra
work, some people may not like rc.conf.d being created and an explanatory
comment is appended with the entry. I will rework the code is creating
rc.conf.d files is considered much better.
It also has some expanded comments in the CHECK-* sections.
I've tested it as match as I can and will make adjustment if needed/wanted.
P.S. I'm currently working on much update version of the rc.subr package.
Files include:
rcd_scripts: the script template to be copy to mk/pkgsrc/rcd_scripts
rcd_scripts.diff: patch to make the needed changes to bsd.pkginstall.mk,
install and deinstall
files_cleanup.diff: removes the now unneeded code from the files template
--
Steven
UNIX is basically a simple operating system,
but you have to be a genius to understand the simplicity --- dmr
# $NetBSD$
#
# Generate a +RCD_SCRIPTS script that reference counts rc.d script files that
# are required for the proper functioning of the package.
#
case "${STAGE},$1" in
UNPACK,|UNPACK,+RCD_SCRIPTS)
${CAT} > ./+RCD_SCRIPTS << 'EOF'
#!@SH@
#
# +RCD_SCRIPTS - reference-counted rc.d script file management script
#
# Usage: ./+RCD_SCRIPTS ADD|REMOVE [metadatadir]
# ./+RCD_SCRIPTS CHECK-ADD|CHECK-REMOVE [metadatadir]
#
# This script supports two actions, ADD and REMOVE, that will add or
# remove the rc.d script files needed by the package associated with
# <metadatadir>. The CHECK-ADD action will check whether any scripts
# needed by the package are missing, and print an informative message
# noting those scripts. The CHECK-REMOVE action will check whether
# any scripts needed by the package still exist, and print an informative
# message noting those scripts. The CHECK-ADD and CHECK-REMOVE actions
# return non-zero if they detect either missing or existing scripts,
# respectively.
#
# The rc.d scripts are intstalled to the ${RCD_SCRIPTS_DIR} directory as
# determined when the script is executed. The ${RCD_SCRIPTS_DIR} directory
# is created if it does not exist.
#
# When installing the rc.d script files this script will make adjustment to
# the files changing ${RC_SUBR_DIR}, ${RC_CONF_DIR} and ${RCD_SCRIPTS_DIR}.
#
# If ${PKG_SET_RCVAR} is yes then the script will append an rcvar entry for
# each rc.d script and explanatory note to the rc.conf file if the rcvar is
# undefined.
#
# Lines starting with "# RCD_SCRIPT: " are data read by this script that
# name the rc.d script files that should be install for this package to
# function correctly, eg:
#
# # RCD_SCRIPT: bar /example/bar
#
# The first field is the basename of the script to be installed.
#
# The second field is the name of the template/example script. If the
# file path is relative, then it is taken to be relative to ${PKG_PREFIX}.
#
AWK="@AWK@"
CAT="@CAT@"
CP="@CP@"
CHGRP="@CHGRP@"
CHMOD="@CHMOD@"
CHOWN="@CHOWN@"
CMP="@CMP@"
ECHO="@ECHO@"
GREP="@GREP@"
LS="@LS@"
MKDIR="@MKDIR@"
MV="@MV@"
PKG_ADMIN="@PKG_ADMIN@"
PWD_CMD="@PWD_CMD@"
RM="@RM@"
RMDIR="@RMDIR@"
SED="@SED@"
SORT="@SORT@"
TEST="@TEST@"
TRUE="@TRUE@"
SELF=$0
ACTION=$1
: ${PKG_PREFIX=@PREFIX@}
config_var=`${PKG_ADMIN} config-var PKG_CONFIG`
case "${config_var:-${PKG_CONFIG:-@PKG_CONFIG@}}" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
_PKG_CONFIG=yes
;;
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
_PKG_CONFIG=no
;;
esac
config_var=`${PKG_ADMIN} config-var PKG_RCD_SCRIPTS`
case "${config_var:-${PKG_RCD_SCRIPTS:-@PKG_RCD_SCRIPTS@}}" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
_PKG_RCD_SCRIPTS=yes
;;
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
_PKG_RCD_SCRIPTS=no
;;
esac
config_var=`${PKG_ADMIN} config-var PKG_SET_RCVAR`
case "${config_var:-${PKG_SET_RCVAR:-@PKG_SET_RCVAR@}}" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
_PKG_SET_RCVAR=yes
;;
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
_PKG_SET_RCVAR=no
;;
esac
config_var=`${PKG_ADMIN} config-var RCD_SCRIPTS_DIR`
RCD_SCRIPTS_DIR="${config_var:-${RCD_SCRIPTS_DIR:=@RCD_SCRIPTS_DIR@}}"
config_var=`${PKG_ADMIN} config-var RC_SUBR_DIR`
RC_SUBR_DIR="${config_var:-${RC_SUBR_DIR:=@RC_SUBR_DIR@}}"
config_var=`${PKG_ADMIN} config-var RC_CONF_DIR`
RC_CONF_DIR="${config_var:-${RC_CONF_DIR:=@RC_CONF_DIR@}}"
RC_SCRIPT_SUBST=" s!@RCD_SCRIPTS_DIR@!${RCD_SCRIPTS_DIR}!g;
s!@RC_SUBR_DIR@/rc\.subr!${RC_SUBR_DIR}/rc\.subr!g;
s!@RC_CONF_DIR@/rc\.conf!${RC_CONF_DIR}/rc\.conf!g;"
CURDIR=`${PWD_CMD}`
PKG_METADATA_DIR="${2-${CURDIR}}"
: ${PKGNAME=${PKG_METADATA_DIR##*/}}
: ${PKG_DBDIR=${PKG_METADATA_DIR%/*}}
: ${PKG_REFCOUNT_DBDIR=${PKG_DBDIR}.refcount}
PKG_REFCOUNT_FILES_DBDIR="${PKG_REFCOUNT_DBDIR}/files"
PKG_REFCOUNT_DIRS_DBDIR="${PKG_REFCOUNT_DBDIR}/dirs"
RCD_SCRIPTS_DIR_SHADOW_DIR="${PKG_REFCOUNT_DIRS_DBDIR}${RCD_SCRIPTS_DIR}"
RCD_SCRIPTS_DIR_PREEXIST="${RCD_SCRIPTS_DIR_SHADOW_DIR}/+PREEXISTING"
RCD_SCRIPTS_DIR_TOKEN="${RCD_SCRIPTS_DIR_SHADOW_DIR}/${PKGNAME}"
GET_RCVAR_AWK='/\$.*=/{rcvar=substr($1,2,index($1,"=")-2)}; /WARNING/{doset=1};
END{if (doset) print rcvar}'
## Can't do it without rc.subr
${TEST} -f "${RC_SUBR_DIR}/rc.subr" || _PKG_SET_RCVAR=no
exitcode=0
case $ACTION in
ADD)
if ${TEST} ! -d "${RCD_SCRIPTS_DIR_SHADOW_DIR}"; then
${MKDIR} "${RCD_SCRIPTS_DIR_SHADOW_DIR}"
${TEST} ! -d "${RCD_SCRIPTS_DIR}" ||
${ECHO} "${PKGNAME}" > ${RCD_SCRIPTS_DIR_PREEXIST}
fi
if ${TEST} -f "${RCD_SCRIPTS_DIR_TOKEN}" &&
${GREP} "^${PKG_METADATA_DIR}$" ${RCD_SCRIPTS_DIR_TOKEN} >/dev/null;
then
:
else
${ECHO} "${PKG_METADATA_DIR}" >> ${RCD_SCRIPTS_DIR_TOKEN}
fi
case "$_PKG_CONFIG:$_PKG_RCD_SCRIPTS" in
yes:yes)
${TEST} ! -d "${RCD_SCRIPTS_DIR}" &&
${MKDIR} ${RCD_SCRIPTS_DIR}
;;
esac
${SED} -n "/^\# RCD_SCRIPT: /{s/^\# RCD_SCRIPT: //;p;}" ${SELF} |
${SORT} -u |
while read name f_eg; do
file="${RCD_SCRIPTS_DIR}/${name}"
case $f_eg in
"") continue ;;
[!/]*) f_eg="${PKG_PREFIX}/$f_eg" ;;
esac
shadow_dir="${PKG_REFCOUNT_FILES_DBDIR}$file"
preexist="$shadow_dir/+PREEXISTING"
token="$shadow_dir/${PKGNAME}"
if ${TEST} ! -d "$shadow_dir"; then
${MKDIR} $shadow_dir
${TEST} ! -f "$file" ||
${ECHO} "${PKGNAME}" > $preexist
fi
if ${TEST} -f "$token" && \
${GREP} "^${PKG_METADATA_DIR}$" $token >/dev/null; then
:
else
${ECHO} "${PKG_METADATA_DIR}" >> $token
fi
if ${TEST} ! -f "$file" -a ! -f "$f_eg" -a ! -c "$f_eg"; then
:
else
case "$_PKG_CONFIG:$_PKG_RCD_SCRIPTS" in
yes:yes)
## Skip installation if this is a name clash.
if ${TEST} "${RCD_SCRIPTS_DIR}" != "/etc/rc.d" \
-a -f "/etc/rc.d/$name" ;then
:
elif ${TEST} -f "$file"; then
${ECHO} "${PKGNAME}: $file already
exists"
elif ${TEST} -f "$f_eg" -o -c "$f_eg"; then
${ECHO} "${PKGNAME}: Modifing $f_eg and
installing to $file"
${SED} -e "${RC_SCRIPT_SUBST}" $f_eg
>$file
${CHMOD} 0755 $file
fi
;;
esac
case "$_PKG_CONFIG:$_PKG_RCD_SCRIPTS:$_PKG_SET_RCVAR" in
yes:yes:yes)
rcvar=`$file rcvar 2>&1 | awk
"${GET_RCVAR_AWK}"`
if ${TEST} "x$rcvar" != "x"; then
${ECHO} "${PKGNAME}: Setting
'${rcvar}=NO' in ${RC_CONF_DIR}/rc.conf."
{
${ECHO} ""
${ECHO} "# The following
variable definition was automaticly added by the PkgSrc"
${ECHO} "# package ${PKGNAME}
for the ${file} rc.d script."
${ECHO} "${rcvar}=NO"
} >>${RC_CONF_DIR}/rc.conf
fi
;;
esac
fi
done
;;
REMOVE)
${SED} -n "/^\# RCD_SCRIPT: /{s/^\# RCD_SCRIPT: //;p;}" ${SELF} |
${SORT} -ru |
while read name f_eg; do
file="${RCD_SCRIPTS_DIR}/${name}"
case $f_eg in
"") continue ;;
[!/]*) f_eg="${PKG_PREFIX}/$f_eg" ;;
esac
shadow_dir="${PKG_REFCOUNT_FILES_DBDIR}$file"
# XXX: perms is left because of old +FILES code.
perms="$shadow_dir/+PERMISSIONS"
preexist="$shadow_dir/+PREEXISTING"
token="$shadow_dir/${PKGNAME}"
tokentmp="$token.tmp.$$"
if ${TEST} -f "$token" && \
${GREP} "^${PKG_METADATA_DIR}$" $token >/dev/null; then
${CAT} "$token" | ${GREP} -v "^${PKG_METADATA_DIR}$" >
$tokentmp
case `${CAT} $tokentmp | ${SED} -n "$="` in
"")
if ${TEST} -f "$preexist"; then
:
elif ${TEST} -f "$file" -a \( -f "$f_eg" -o -c
"$f_eg" \) && \
${SED} -e "${RC_SCRIPT_SUBST}" "$f_eg" |
${CMP} -s "$file" "-"; then
case "$_PKG_CONFIG:$_PKG_RCD_SCRIPTS" in
yes:yes)
${RM} -f "$file"
;;
esac
fi
${RM} -f $perms $preexist $token $token.tmp.*
${RMDIR} -p $shadow_dir 2>/dev/null || ${TRUE}
;;
*)
${MV} -f $tokentmp $token
;;
esac
fi
done
tokentmp="${RCD_SCRIPTS_DIR_TOKEN}.tmp.$$"
if ${TEST} -f "${RCD_SCRIPTS_DIR_TOKEN}" &&
${GREP} "^${PKG_METADATA_DIR}$" ${RCD_SCRIPTS_DIR_TOKEN} >/dev/null;
then
${CAT} "${RCD_SCRIPTS_DIR_TOKEN}" | ${GREP} -v
"^${PKG_METADATA_DIR}$" > $tokentmp
case `${CAT} $tokentmp | ${SED} -n "$="` in
"")
if ${TEST} ! -f "${RCD_SCRIPTS_DIR_PREEXIST}"; then
case "$_PKG_CONFIG:$_PKG_RCD_SCRIPTS" in
yes:yes)
${RMDIR} -p ${RCD_SCRIPTS_DIR}
2>/dev/null || ${TRUE}
;;
esac
fi
${RM} -f ${RCD_SCRIPTS_DIR_PREEXIST}
${RCD_SCRIPTS_DIR_TOKEN} ${RCD_SCRIPTS_DIR_TOKEN}.tmp.*
${RMDIR} -p ${RCD_SCRIPTS_DIR_SHADOW_DIR} 2>/dev/null
|| ${TRUE}
;;
*)
${MV} -f $tokentmp ${RCD_SCRIPTS_DIR_TOKEN}
;;
esac
fi
;;
CHECK-ADD)
${SED} -n "/^\# RCD_SCRIPT: /{s/^\# RCD_SCRIPT: //;p;}" ${SELF} |
${SORT} -ru |
{ while read name f_eg; do
file="${RCD_SCRIPTS_DIR}/${name}"
${TEST} ! -f "$file" || continue
case $f_eg in
"") continue ;;
[!/]*) f_eg="${PKG_PREFIX}/$f_eg" ;;
esac
case "$printed_header" in
yes) ;;
*) printed_header=yes
${ECHO}
"==========================================================================="
${ECHO} "The following rc.d scripts should be created
(and made executable) for"
${ECHO} "${PKGNAME}:"
;;
esac
${ECHO} ""
${ECHO} " $file"
${TEST} ! -f "$f_eg" || ${ECHO} " [$f_eg]"
if ${TEST} "${RCD_SCRIPTS_DIR}" != "/etc/rc.d" -a -f
"/etc/rc.d/$name" ;then
${ECHO} " WARNING: the above may clash with the
already installed"
${ECHO} " '/etc/rc.d/$name' script!"
${ECHO} ""
fi
done
case "$printed_header" in
yes) ${ECHO} ""
${ECHO} "After creating the above scripts you may want to
execute them with the"
${ECHO} "argument 'rcvar' to check the state of the yes/no
control variable and"
${ECHO} "then edit rc.conf(5) to set it to your preferance."
if ${TEST} ! -d "${RCD_SCRIPTS_DIR}"; then
${ECHO} ""
${ECHO} "Note: The directory '${RCD_SCRIPTS_DIR}' will
have to be created first!"
fi
${ECHO}
"==========================================================================="
exit 1
;;
esac; }
${TEST} $? -eq 0 || exitcode=1
;;
CHECK-REMOVE)
${SED} -n "/^\# RCD_SCRIPT: /{s/^\# RCD_SCRIPT: //;p;}" ${SELF} |
${SORT} -ru |
{ while read name f_eg; do
file="${RCD_SCRIPTS_DIR}/${name}"
${TEST} -f "$file" || continue
shadow_dir="${PKG_REFCOUNT_FILES_DBDIR}$file"
${TEST} ! -d "$shadow_dir" || continue # refcount isn't zero
case "$printed_header" in
yes) ;;
*) printed_header=yes
${ECHO}
"==========================================================================="
${ECHO} "The following rc.d scripts are no longer being
used by ${PKGNAME},"
${ECHO} "and they can be removed:"
${ECHO} ""
;;
esac
${ECHO} " $file"
done
case "$printed_header" in
yes) ${ECHO} ""
if ${TEST} ! -d "${RCD_SCRIPTS_DIR_SHADOW_DIR}"; then
${ECHO} "If after the above files are removed and the
directory '${RCD_SCRIPTS_DIR}'"
${ECHO} "is empty it can also be removed."
fi
${ECHO}
"==========================================================================="
exit 1
;;
esac; }
${TEST} $? -eq 0 || exitcode=1
;;
*)
${ECHO} "Usage: ./+RCD_SCRIPTS ADD|REMOVE [metadatadir]"
${ECHO} " ./+RCD_SCRIPTS CHECK-ADD|CHECK-REMOVE [metadatadir]"
;;
esac
exit $exitcode
EOF
${SED} -n "/^\# RCD_SCRIPT: /p" ${SELF} >> ./+RCD_SCRIPTS
${CHMOD} +x ./+RCD_SCRIPTS
;;
esac
Index: pkgsrc/mk/pkginstall/bsd.pkginstall.mk
===================================================================
--- pkgsrc.orig/mk/pkginstall/bsd.pkginstall.mk 2009-11-25 17:53:36.000000000
+1300
+++ pkgsrc/mk/pkginstall/bsd.pkginstall.mk 2009-11-26 16:37:00.000000000
+1300
@@ -11,6 +11,10 @@ _USER_VARS.pkginstall= \
PKG_CREATE_USERGROUP \
PKG_CONFIG PKG_CONFIG_PERMS \
PKG_RCD_SCRIPTS \
+ PKG_SET_RCVAR \
+ RCD_SCRIPTS_DIR \
+ RC_SUBR_DIR \
+ RC_CONF_DIR \
PKG_REGISTER_SHELLS \
PKG_UPDATE_FONTS_DB \
FONTS_VERBOSE INFO_FILES_VERBOSE
@@ -425,11 +429,6 @@ ${_INSTALL_PERMS_FILE}: ../../mk/pkginst
# However, all files listed in REQD_FILES_PERMS should be under
# ${PREFIX}. (XXX: Why?)
#
-# RCD_SCRIPTS lists the basenames of the rc.d scripts. They are
-# expected to be found in ${PREFIX}/share/examples/rc.d, and
-# the scripts will be copied into ${RCD_SCRIPTS_DIR} with
-# ${RCD_SCRIPTS_MODE} permissions.
-#
# If any file pathnames are relative, then they are taken to be relative
# to ${PREFIX}.
#
@@ -439,13 +438,6 @@ ${_INSTALL_PERMS_FILE}: ../../mk/pkginst
CONF_FILES?= # empty
CONF_FILES_MODE?= 0644
CONF_FILES_PERMS?= # empty
-RCD_SCRIPTS?= # empty
-RCD_SCRIPTS_MODE?= 0755
-RCD_SCRIPTS_EXAMPLEDIR= share/examples/rc.d
-RCD_SCRIPTS_SHELL?= ${SH}
-FILES_SUBST+= RCD_SCRIPTS_SHELL=${RCD_SCRIPTS_SHELL:Q}
-MESSAGE_SUBST+= RCD_SCRIPTS_DIR=${RCD_SCRIPTS_DIR}
-MESSAGE_SUBST+= RCD_SCRIPTS_EXAMPLEDIR=${RCD_SCRIPTS_EXAMPLEDIR}
_INSTALL_FILES_FILE= ${_PKGINSTALL_DIR}/files
_INSTALL_FILES_DATAFILE= ${_PKGINSTALL_DIR}/files-data
@@ -489,16 +481,6 @@ _pkginstall-postinstall-check: .PHONY
done
${_INSTALL_FILES_DATAFILE}:
- ${RUN}${MKDIR} ${.TARGET:H}
- ${RUN}${_FUNC_STRIP_PREFIX}; \
- set -- dummy ${RCD_SCRIPTS}; shift; \
- exec 1>>${.TARGET}; \
- while ${TEST} $$# -gt 0; do \
- script="$$1"; shift; \
- file="${RCD_SCRIPTS_DIR:S/^${PREFIX}\///}/$$script"; \
- egfile="${RCD_SCRIPTS_EXAMPLEDIR}/$$script"; \
- ${ECHO} "# FILE: $$file cr $$egfile ${RCD_SCRIPTS_MODE}"; \
- done
${RUN}${_FUNC_STRIP_PREFIX}; \
set -- dummy ${CONF_FILES}; shift; \
exec 1>>${.TARGET}; \
@@ -553,6 +535,55 @@ ${_INSTALL_FILES_FILE}: ../../mk/pkginst
${TOUCH} ${TOUCH_ARGS} ${.TARGET}; \
fi
+# RCD_SCRIPTS lists the basenames of the rc.d scripts. They are
+# expected to be found in ${PREFIX}/share/examples/rc.d
+# The scripts will be install to ${RCD_SCRIPTS_DIR}.
+# During installation the values of ${RC_SUBR_DIR}, ${RC_CONF_DIR}
+# and ${RCD_SCRIPTS_DIR} will be changed.
+#
+# Keywords: etc rc.d conf configuration
+#
+RCD_SCRIPTS?= # empty
+RCD_SCRIPTS_EXAMPLEDIR= share/examples/rc.d
+RCD_SCRIPTS_SHELL?= ${SH}
+RC_SUBR_DIR?= /etc
+RC_CONF_DIR?= /etc
+FILES_SUBST+= RCD_SCRIPTS_SHELL=${RCD_SCRIPTS_SHELL:Q}
+FILES_SUBST+= RC_SUBR_DIR=${RC_SUBR_DIR:Q}
+FILES_SUBST+= RC_CONF_DIR=${RC_CONF_DIR:Q}
+FILES_SUBST+= RCD_SCRIPTS_DIR=${RCD_SCRIPTS_DIR:Q}
+MESSAGE_SUBST+= RCD_SCRIPTS_DIR=${RCD_SCRIPTS_DIR}
+MESSAGE_SUBST+= RCD_SCRIPTS_EXAMPLEDIR=${RCD_SCRIPTS_EXAMPLEDIR}
+MESSAGE_SUBST+= RC_CONF_DIR=${RC_CONF_DIR}
+
+_INSTALL_RCD_SCRIPTS_FILE= ${_PKGINSTALL_DIR}/rcd_scripts
+_INSTALL_RCD_SCRIPTS_DATAFILE= ${_PKGINSTALL_DIR}/rcd_scripts-data
+_INSTALL_UNPACK_TMPL+= ${_INSTALL_RCD_SCRIPTS_FILE}
+_INSTALL_DATA_TMPL+= ${_INSTALL_RCD_SCRIPTS_DATAFILE}
+
+${_INSTALL_RCD_SCRIPTS_DATAFILE}:
+ ${RUN}${MKDIR} ${.TARGET:H}
+ ${RUN}${_FUNC_STRIP_PREFIX}; \
+ set -- dummy ${RCD_SCRIPTS}; shift; \
+ exec 1>>${.TARGET}; \
+ while ${TEST} $$# -gt 0; do \
+ script="$$1"; shift; \
+ egfile="${RCD_SCRIPTS_EXAMPLEDIR}/$$script"; \
+ ${ECHO} "# RCD_SCRIPT: $$script $$egfile"; \
+ done
+
+${_INSTALL_RCD_SCRIPTS_FILE}: ${_INSTALL_RCD_SCRIPTS_DATAFILE}
+${_INSTALL_RCD_SCRIPTS_FILE}: ../../mk/pkginstall/rcd_scripts
+ ${RUN}${MKDIR} ${.TARGET:H}
+ ${RUN} \
+ ${SED} ${FILES_SUBST_SED} ../../mk/pkginstall/rcd_scripts > ${.TARGET}
+ ${RUN} \
+ if ${_ZERO_FILESIZE_P} ${_INSTALL_RCD_SCRIPTS_DATAFILE}; then \
+ ${RM} -f ${.TARGET}; \
+ ${TOUCH} ${TOUCH_ARGS} ${.TARGET}; \
+ fi
+
+
# OWN_DIRS contains a list of directories for this package that should be
# created and should attempt to be destroyed by the INSTALL/DEINSTALL
# scripts. MAKE_DIRS is used the same way, but the package admin
@@ -611,12 +642,6 @@ ${_INSTALL_DIRS_DATAFILE}:
esac; \
;; \
esac
- ${RUN} \
- exec 1>>${.TARGET}; \
- case ${RCD_SCRIPTS:M*:Q}"" in \
- "") ;; \
- *) ${ECHO} "# DIR: ${RCD_SCRIPTS_DIR:S/${PREFIX}\///} m" ;; \
- esac
${RUN}${_FUNC_STRIP_PREFIX}; \
set -- dummy ${MAKE_DIRS}; shift; \
exec 1>>${.TARGET}; \
@@ -927,6 +952,10 @@ ${_INSTALL_FONTS_FILE}: ../../mk/pkginst
# to ${RCD_SCRIPTS_DIR}. It is either YES or NO and defaults to
# NO. This variable only takes effect if ${PKG_CONFIG} == "YES".
#
+# PKG_SET_RCVAR indicates whether to the the rcvar for the RCD_SCRIPTS to
+# NO if is not currently set. It is either YES or NO and defaults
+# to NO.
+#
# PKG_REGISTER_SHELLS indicates whether to automatically register shells
# in /etc/shells. It is either YES or NO and defaults to YES.
#
@@ -954,6 +983,7 @@ PKG_CREATE_USERGROUP?= YES
PKG_CONFIG?= YES
PKG_CONFIG_PERMS?= NO
PKG_RCD_SCRIPTS?= NO
+PKG_SET_RCVAR?= NO
PKG_REGISTER_SHELLS?= YES
PKG_UPDATE_FONTS_DB?= YES
FONTS_VERBOSE?= ${PKG_DEVELOPER:DYES:UNO}
@@ -962,6 +992,7 @@ FILES_SUBST+= PKG_CREATE_USERGROUP=${PK
FILES_SUBST+= PKG_CONFIG=${PKG_CONFIG:Q}
FILES_SUBST+= PKG_CONFIG_PERMS=${PKG_CONFIG_PERMS:Q}
FILES_SUBST+= PKG_RCD_SCRIPTS=${PKG_RCD_SCRIPTS:Q}
+FILES_SUBST+= PKG_SET_RCVAR=${PKG_SET_RCVAR:Q}
FILES_SUBST+= PKG_REGISTER_SHELLS=${PKG_REGISTER_SHELLS:Q}
FILES_SUBST+= PKG_UPDATE_FONTS_DB=${PKG_UPDATE_FONTS_DB:Q}
FILES_SUBST+= FONTS_VERBOSE=${FONTS_VERBOSE:Q}
@@ -1118,6 +1149,12 @@ post-install-script:
# If the source rc.d script is not present, then the automatic handling
# doesn't occur.
+# XXX: These next substiutions are for scripts that have the pathnames rather
+# XXX: than the ready to replace tags!
+RCD_SCRIPT_EXTRA_SUBST_SED= -e s!/etc/rc\.d!${RCD_SCRIPTS_DIR:Q}!
+RCD_SCRIPT_EXTRA_SUBST_SED+= -e s!/etc/rc\.subr!${RC_SUBR_DIR:Q}/rc.subr!
+RCD_SCRIPT_EXTRA_SUBST_SED+= -e s!/etc/rc\.conf!${RC_CONF_DIR:Q}/rc.conf!
+
.PHONY: generate-rcd-scripts
generate-rcd-scripts: # do nothing
@@ -1133,7 +1170,7 @@ RCD_SCRIPT_WRK.${_script_}?= ${WRKDIR}/$
generate-rcd-scripts: ${RCD_SCRIPT_WRK.${_script_}}
${RCD_SCRIPT_WRK.${_script_}}: ${RCD_SCRIPT_SRC.${_script_}}
@${STEP_MSG} "Creating ${.TARGET}"
- ${RUN}${CAT} ${.ALLSRC} | ${SED} ${FILES_SUBST_SED} > ${.TARGET}
+ ${RUN}${CAT} ${.ALLSRC} | ${SED} ${FILES_SUBST_SED}
${RCD_SCRIPT_EXTRA_SUBST_SED} > ${.TARGET}
${RUN}${CHMOD} +x ${.TARGET}
install-rcd-scripts: install-rcd-${_script_}
Index: pkgsrc/mk/pkginstall/deinstall
===================================================================
--- pkgsrc.orig/mk/pkginstall/deinstall 2009-11-25 17:47:42.000000000 +1300
+++ pkgsrc/mk/pkginstall/deinstall 2009-11-26 16:37:00.000000000 +1300
@@ -37,6 +37,8 @@ DEINSTALL)
#
${TEST} ! -x ./+FILES ||
./+FILES REMOVE ${PKG_METADATA_DIR}
+ ${TEST} ! -x ./+RCD_SCRIPTS ||
+ ./+RCD_SCRIPTS REMOVE ${PKG_METADATA_DIR}
;;
POST-DEINSTALL)
@@ -71,6 +73,8 @@ POST-DEINSTALL)
./+USERGROUP CHECK-REMOVE ${PKG_METADATA_DIR}
${TEST} ! -x ./+FILES ||
./+FILES CHECK-REMOVE ${PKG_METADATA_DIR}
+ ${TEST} ! -x ./+RCD_SCRIPTS ||
+ ./+RCD_SCRIPTS CHECK-REMOVE ${PKG_METADATA_DIR}
${TEST} ! -x ./+DIRS ||
./+DIRS CHECK-REMOVE ${PKG_METADATA_DIR}
;;
Index: pkgsrc/mk/pkginstall/install
===================================================================
--- pkgsrc.orig/mk/pkginstall/install 2009-11-25 17:47:42.000000000 +1300
+++ pkgsrc/mk/pkginstall/install 2009-11-26 16:37:00.000000000 +1300
@@ -54,6 +54,11 @@ POST-INSTALL)
${TEST} ! -x ./+FILES ||
./+FILES PERMS ${PKG_METADATA_DIR}
#
+ # Install rc.d scripts into place.
+ #
+ ${TEST} ! -x ./+RCD_SCRIPTS ||
+ ./+RCD_SCRIPTS ADD ${PKG_METADATA_DIR}
+ #
# Set special permissions on any files/directories that need them.
#
${TEST} ! -x ./+PERMS ||
@@ -74,6 +79,8 @@ POST-INSTALL)
./+FILES CHECK-ADD ${PKG_METADATA_DIR}
${TEST} ! -x ./+FILES ||
./+FILES CHECK-PERMS ${PKG_METADATA_DIR}
+ ${TEST} ! -x ./+RCD_SCRIPTS ||
+ ./+RCD_SCRIPTS CHECK-ADD ${PKG_METADATA_DIR}
;;
VIEW-INSTALL)
Index: pkgsrc/mk/pkginstall/files
===================================================================
--- pkgsrc.orig/mk/pkginstall/files 2009-11-26 16:37:15.000000000 +1300
+++ pkgsrc/mk/pkginstall/files 2009-11-26 16:39:26.000000000 +1300
@@ -46,7 +46,6 @@ UNPACK,|UNPACK,+FILES)
#
# c file is copied into place
# f ignore ${PKG_CONFIG}
-# r file is an rc.d script (consider ${PKG_RCD_SCRIPTS})
#
AWK="@AWK@"
CAT="@CAT@"
@@ -92,15 +91,6 @@ case "${config_var:-${PKG_CONFIG_PERMS:-
_PKG_CONFIG_PERMS=no
;;
esac
-config_var=`${PKG_ADMIN} config-var PKG_RCD_SCRIPTS`
-case "${config_var:-${PKG_RCD_SCRIPTS:-@PKG_RCD_SCRIPTS@}}" in
-[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
- _PKG_RCD_SCRIPTS=yes
- ;;
-[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
- _PKG_RCD_SCRIPTS=no
- ;;
-esac
case $ACTION in
VIEW-REMOVE)
@@ -159,8 +149,8 @@ ADD)
if ${TEST} ! -f "$file" -a ! -f "$f_eg" -a ! -c "$f_eg"; then
:
else
- case "$f_flags:$_PKG_CONFIG:$_PKG_RCD_SCRIPTS" in
-
*f*:*:*|[!r]:yes:*|[!r][!r]:yes:*|[!r][!r][!r]:yes:*|*r*:yes:yes)
+ case "$f_flags:$_PKG_CONFIG" in
+ *f*:*|*:yes)
if ${TEST} -f "$file"; then
${ECHO} "${PKGNAME}: $file already
exists"
elif ${TEST} -f "$f_eg" -o -c "$f_eg"; then
@@ -215,8 +205,8 @@ REMOVE)
:
elif ${TEST} -f "$file" -a \( -f "$f_eg" -o -c
"$f_eg" \) && \
${CMP} -s "$file" "$f_eg"; then
- case
"$f_flags:$_PKG_CONFIG:$_PKG_RCD_SCRIPTS" in
-
*f*:*:*|[!r]:yes:*|[!r][!r]:yes:*|[!r][!r][!r]:yes:*|*r*:yes:yes)
+ case "$f_flags:$_PKG_CONFIG" in
+ *f*:*|*:yes)
${RM} -f "$file"
;;
esac
Home |
Main Index |
Thread Index |
Old Index