summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorjlam <jlam>2005-07-29 21:41:04 +0000
committerjlam <jlam>2005-07-29 21:41:04 +0000
commit74ce37eddf1f647735e43783191fa3db49c90004 (patch)
treed87db74e743dd5fa89a8441507e6308560b45147 /mk
parentea4338348490c45fb9523f0671eee42dd126efc1 (diff)
downloadpkgsrc-74ce37eddf1f647735e43783191fa3db49c90004.tar.gz
When using pkginstall to create INSTALL/DEINSTALL scripts to handle
config files, directories, rc.d scripts, etc., use relative paths as much as possible to avoid hard-coding the ${PREFIX}-location in which the files should be installed. Where full paths are specified, if the path is within ${PREFIX}, then automatically strip off the ${PREFIX} part when creating the entries for the helper scripts. Also, modify the helper scripts to understand that relative paths should be considered to be relative to ${PKG_PREFIX}.
Diffstat (limited to 'mk')
-rw-r--r--mk/install/bsd.pkginstall.mk34
-rw-r--r--mk/install/dirs24
-rw-r--r--mk/install/files41
-rw-r--r--mk/install/perms11
4 files changed, 83 insertions, 27 deletions
diff --git a/mk/install/bsd.pkginstall.mk b/mk/install/bsd.pkginstall.mk
index 561462eeaa3..eb230831619 100644
--- a/mk/install/bsd.pkginstall.mk
+++ b/mk/install/bsd.pkginstall.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkginstall.mk,v 1.4 2005/07/29 18:32:18 jlam Exp $
+# $NetBSD: bsd.pkginstall.mk,v 1.5 2005/07/29 21:41:04 jlam Exp $
#
# This Makefile fragment is included by bsd.pkg.mk to use the common
# INSTALL/DEINSTALL scripts. To use this Makefile fragment, simply:
@@ -162,7 +162,8 @@ ${INSTALL_USERGROUP_FILE}: ../../mk/install/usergroup
# SPECIAL_PERMS are lists that look like:
# file user group mode
# At post-install time, file (it may be a directory) is changed to be
-# owned by user:group with mode permissions.
+# owned by user:group with mode permissions. If a file pathname
+# is relative, then it is taken to be relative to ${PREFIX}.
#
# SPECIAL_PERMS should be used primarily to change permissions of files or
# directories listed in the PLIST. This may be used to make certain files
@@ -198,6 +199,7 @@ ${INSTALL_PERMS_FILE}: ../../mk/install/perms
while ${TEST} $$# -gt 0; do \
file="$$1"; owner="$$2"; group="$$3"; mode="$$4"; \
shift; shift; shift; shift; \
+ file="$${file#${PREFIX}/}"; \
${ECHO} "# PERMS: $$file $$mode $$owner $$group"; \
done; \
${ECHO} "EOF_PERMS"; \
@@ -231,6 +233,9 @@ ${INSTALL_PERMS_FILE}: ../../mk/install/perms
# 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}.
+#
CONF_FILES?= # empty
CONF_FILES_MODE?= 0644
CONF_FILES_PERMS?= # empty
@@ -267,12 +272,16 @@ ${INSTALL_FILES_FILE}: ../../mk/install/files
while ${TEST} $$# -gt 0; do \
egfile="$$1"; file="$$2"; \
shift; shift; \
+ egfile="$${egfile#${PREFIX}/}"; \
+ file="$${file#${PREFIX}/}"; \
${ECHO} "# FILE: $$file c $$egfile ${CONF_FILES_MODE}"; \
done; \
eval set -- ${SUPPORT_FILES} ; \
while ${TEST} $$# -gt 0; do \
egfile="$$1"; file="$$2"; \
shift; shift; \
+ egfile="$${egfile#${PREFIX}/}"; \
+ file="$${file#${PREFIX}/}"; \
${ECHO} "# FILE: $$file c $$egfile ${SUPPORT_FILES_MODE}"; \
done; \
eval set -- ${CONF_FILES_PERMS} ${SUPPORT_FILES_PERMS} ; \
@@ -280,6 +289,8 @@ ${INSTALL_FILES_FILE}: ../../mk/install/files
egfile="$$1"; file="$$2"; \
owner="$$3"; group="$$4"; mode="$$5"; \
shift; shift; shift; shift; shift; \
+ egfile="$${egfile#${PREFIX}/}"; \
+ file="$${file#${PREFIX}/}"; \
${ECHO} "# FILE: $$file c $$egfile $$mode $$owner $$group"; \
done; \
${ECHO} "EOF_FILES"; \
@@ -312,8 +323,8 @@ ${INSTALL_RCD_SCRIPTS_FILE}: ../../mk/install/files
eval set -- ${RCD_SCRIPTS} ; \
while ${TEST} $$# -gt 0; do \
script="$$1"; shift; \
- file="${RCD_SCRIPTS_DIR}/$$script"; \
- egfile="${PREFIX}/${RCD_SCRIPTS_EXAMPLEDIR}/$$script"; \
+ file="${RCD_SCRIPTS_DIR:S/^${PREFIX}\///}/$$script"; \
+ egfile="${RCD_SCRIPTS_EXAMPLEDIR}/$$script"; \
${ECHO} "# FILE: $$file c $$egfile ${RCD_SCRIPTS_MODE}"; \
done; \
${ECHO} "EOF_RCD_SCRIPTS"; \
@@ -337,6 +348,9 @@ ${INSTALL_RCD_SCRIPTS_FILE}: ../../mk/install/files
# is used the same way but the package admin isn't prompted to remove
# the directory at post-deinstall time if it isn't empty.
#
+# If any directory pathnames are relative, then they are taken to be
+# relative to ${PREFIX}.
+#
MAKE_DIRS?= # empty
MAKE_DIRS_PERMS?= # empty
OWN_DIRS?= # empty
@@ -362,32 +376,36 @@ ${INSTALL_DIRS_FILE}: ../../mk/install/dirs
${ECHO} ""; \
case "${PKG_SYSCONFSUBDIR}${CONF_FILES}${CONF_FILES_PERMS}${SUPPORT_FILES}${SUPPORT_FILES_PERMS}" in \
"") ;; \
- *) ${ECHO} "# DIR: ${PKG_SYSCONFDIR} m" ;; \
+ *) ${ECHO} "# DIR: ${PKG_SYSCONFDIR:S/${PREFIX}\///} m" ;; \
esac; \
case "${RCD_SCRIPTS}" in \
"") ;; \
- *) ${ECHO} "# DIR: ${RCD_SCRIPTS_DIR} m" ;; \
+ *) ${ECHO} "# DIR: ${RCD_SCRIPTS_DIR:S/${PREFIX}\///} m" ;; \
esac; \
eval set -- ${MAKE_DIRS} ; \
while ${TEST} $$# -gt 0; do \
dir="$$1"; shift; \
+ dir="$${dir#${PREFIX}/}"; \
${ECHO} "# DIR: $$dir m"; \
done; \
eval set -- ${OWN_DIRS} ; \
while ${TEST} $$# -gt 0; do \
dir="$$1"; shift; \
+ dir="$${dir#${PREFIX}/}"; \
${ECHO} "# DIR: $$dir mo"; \
done; \
eval set -- ${MAKE_DIRS_PERMS} ; \
while ${TEST} $$# -gt 0; do \
dir="$$1"; owner="$$2"; group="$$3"; mode="$$4"; \
shift; shift; shift; shift; \
+ dir="$${dir#${PREFIX}/}"; \
${ECHO} "# DIR: $$dir m $$owner $$group $$mode"; \
done; \
eval set -- ${OWN_DIRS_PERMS} ; \
while ${TEST} $$# -gt 0; do \
dir="$$1"; owner="$$2"; group="$$3"; mode="$$4"; \
shift; shift; shift; shift; \
+ dir="$${dir#${PREFIX}/}"; \
${ECHO} "# DIR: $$dir mo $$owner $$group $$mode"; \
done; \
${ECHO} "EOF_DIRS"; \
@@ -400,7 +418,7 @@ ${INSTALL_DIRS_FILE}: ../../mk/install/dirs
${MV} -f ${.TARGET}.tmp ${.TARGET}
# PKG_SHELL contains the pathname of the shell that should be added or
-# removed from the shell database, /etc/shells. If the pathname
+# removed from the shell database, /etc/shells. If a pathname
# is relative, then it is taken to be relative to ${PREFIX}.
#
PKG_SHELL?= # empty
@@ -424,6 +442,7 @@ ${INSTALL_SHELL_FILE}: ../../mk/install/shell
eval set -- ${PKG_SHELL} ; \
while ${TEST} $$# -gt 0; do \
i="$$1"; shift; \
+ i="$${i#${PREFIX}/}"; \
${ECHO} "# SHELL: $$i"; \
done; \
${ECHO} "EOF_SHELL"; \
@@ -592,6 +611,7 @@ install-rcd-scripts: install-rcd-${_script_}
install-rcd-${_script_}: ${RCD_SCRIPT_WRK.${_script_}}
${_PKG_SILENT}${_PKG_DEBUG} \
if [ -f ${RCD_SCRIPT_WRK.${_script_}} ]; then \
+ ${MKDIR} ${PREFIX}/${RCD_SCRIPTS_EXAMPLEDIR}; \
${INSTALL_SCRIPT} ${RCD_SCRIPT_WRK.${_script_}} \
${PREFIX}/${RCD_SCRIPTS_EXAMPLEDIR}/${_script_}; \
fi
diff --git a/mk/install/dirs b/mk/install/dirs
index 81ba70aa022..9d33289ffd8 100644
--- a/mk/install/dirs
+++ b/mk/install/dirs
@@ -1,6 +1,6 @@
#!@SH@
#
-# $NetBSD: dirs,v 1.6 2005/07/27 16:18:54 jlam Exp $
+# $NetBSD: dirs,v 1.7 2005/07/29 21:41:04 jlam Exp $
#
# +DIRS - reference-counted directory management script
#
@@ -24,7 +24,10 @@
# # DIR: /etc/foo m
# # DIR: /var/log/foo/tmp mo foo-user foo-group 0700
#
-# The second field in each DIRS entry is a set of flags with the following
+# For each DIR entry, if the directory path is relative, then it is taken
+# to be relative to ${PKG_PREFIX}.
+#
+# The second field in each DIR entry is a set of flags with the following
# meaning:
#
# m create (make) the directory when ADDing
@@ -52,6 +55,7 @@ PKG_METADATA_DIR="${2-`${PWD_CMD}`}"
: ${PKGNAME=${PKG_METADATA_DIR##*/}}
: ${PKG_DBDIR=${PKG_METADATA_DIR%/*}}
: ${PKG_REFCOUNT_DBDIR=${PKG_DBDIR}.refcount}
+: ${PKG_PREFIX=@PREFIX@}
PKG_REFCOUNT_DIRS_DBDIR="${PKG_REFCOUNT_DBDIR}/dirs"
@@ -61,7 +65,8 @@ ADD)
${SED} -n "/^\# DIR: /{s/^\# DIR: //;p;}" ${SELF} | ${SORT} -u |
while read dir d_flags d_user d_group d_mode; do
case $dir in
- ""|[!/]*) continue ;;
+ "") continue ;;
+ [!/]*) dir="${PKG_PREFIX}/$dir" ;;
esac
case $d_flags in
*m*) ;;
@@ -102,7 +107,8 @@ REMOVE)
${SED} -n "/^\# DIR: /{s/^\# DIR: //;p;}" ${SELF} | ${SORT} -ru |
while read dir d_flags d_user d_group d_mode; do
case $dir in
- ""|[!/]*) continue ;;
+ "") continue ;;
+ [!/]*) dir="${PKG_PREFIX}/$dir" ;;
esac
case $d_flags in
*m*) ;;
@@ -135,9 +141,10 @@ CHECK-ADD)
${SED} -n "/^\# DIR: /{s/^\# DIR: //;p;}" ${SELF} | ${SORT} -u |
{ while read dir d_flags d_user d_group d_mode; do
case $dir in
- ""|[!/]*) continue ;;
- *) ${TEST} ! -d "$dir" || continue ;;
+ "") continue ;;
+ [!/]*) dir="${PKG_PREFIX}/$dir" ;;
esac
+ ${TEST} ! -d "$dir" || continue
case $d_flags in
*m*) ;;
*) continue ;;
@@ -172,9 +179,10 @@ CHECK-REMOVE)
${SED} -n "/^\# DIR: /{s/^\# DIR: //;p;}" ${SELF} | ${SORT} -ru |
{ while read dir d_flags d_user d_group d_mode; do
case $dir in
- ""|[!/]*) continue ;;
- *) ${TEST} -d "$dir" || continue ;;
+ "") continue ;;
+ [!/]*) dir="${PKG_PREFIX}/$dir" ;;
esac
+ ${TEST} -d "$dir" || continue
case $d_flags in
*o*) ;;
*) continue ;;
diff --git a/mk/install/files b/mk/install/files
index 90372a349b3..ecf0fa5340d 100644
--- a/mk/install/files
+++ b/mk/install/files
@@ -1,6 +1,6 @@
#!@SH@
#
-# $NetBSD: files,v 1.6 2005/07/27 16:18:54 jlam Exp $
+# $NetBSD: files,v 1.7 2005/07/29 21:41:04 jlam Exp $
#
# +FILES - reference-counted configuration file management script
#
@@ -26,6 +26,9 @@
# # FILE: /etc/bar.conf c /example/bar.conf
# # FILE: /etc/baz/conf c /example/baz.conf 0600 foo-user foo-group
#
+# For each FILE entry, if the file path is relative, then it is taken to
+# be relative to ${PKG_PREFIX}.
+#
# The second field in each FILE entry is a set of flags with the following
# meaning:
#
@@ -52,6 +55,8 @@ TRUE="@TRUE@"
SELF=$0
ACTION=$1
+: ${PKG_PREFIX=@PREFIX@}
+
case ${ACTION} in
VIEW-REMOVE)
DEPOTDIR="$2"
@@ -73,12 +78,17 @@ ADD)
${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -u |
{ while read file f_flags f_eg f_mode f_user f_group; do
case $file in
- ""|[!/]*) continue ;;
+ "") continue ;;
+ [!/]*) file="${PKG_PREFIX}/$file" ;;
esac
case $f_flags in
*c*) ;;
*) continue ;;
esac
+ case $f_eg in
+ "") continue ;;
+ [!/]*) f_eg="${PKG_PREFIX}/$f_eg" ;;
+ esac
shadow_dir="${PKG_REFCOUNT_FILES_DBDIR}$file"
perms="$shadow_dir/+PERMISSIONS"
@@ -144,12 +154,18 @@ REMOVE)
${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru |
while read file f_flags f_eg f_mode f_user f_group; do
case $file in
- ""|[!/]*) continue ;;
+ "") continue ;;
+ [!/]*) file="${PKG_PREFIX}/$file" ;;
esac
case $f_flags in
*c*) ;;
*) continue ;;
esac
+ case $f_eg in
+ "") continue ;;
+ [!/]*) f_eg="${PKG_PREFIX}/$f_eg" ;;
+ esac
+
shadow_dir="${PKG_REFCOUNT_FILES_DBDIR}$file"
perms="$shadow_dir/+PERMISSIONS"
preexist="$shadow_dir/+PREEXISTING"
@@ -181,10 +197,10 @@ VIEW-REMOVE)
${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru |
while read file f_flags f_eg f_mode f_user f_group; do
case $file in
- ${DEPOTDIR}/*) ;;
+ ${DEPOTDIR}/*) link="${VIEWDIR}/${file#${DEPOTDIR}/}" ;;
+ [!/]*) link="${VIEWDIR}/$file" ;;
*) continue ;;
esac
- link="${VIEWDIR}/${file#${DEPOTDIR}/}"
dir="${link%[^/]*}"
if ${TEST} -h "$link"; then
${RM} -f $link
@@ -197,13 +213,19 @@ CHECK-ADD)
${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru |
{ while read file f_flags f_eg f_mode f_user f_group; do
case $file in
- ""|[!/]*) continue ;;
- *) ${TEST} ! -f "$file" || continue ;;
+ "") continue ;;
+ [!/]*) file="${PKG_PREFIX}/$file" ;;
esac
+ ${TEST} ! -f "$file" || continue
case $f_flags in
*c*) ;;
*) continue ;;
esac
+ case $f_eg in
+ "") continue ;;
+ [!/]*) f_eg="${PKG_PREFIX}/$f_eg" ;;
+ esac
+
case "$printed_header" in
yes) ;;
*) printed_header=yes
@@ -241,9 +263,10 @@ CHECK-REMOVE)
${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru |
{ while read file f_flags f_eg f_mode f_user f_group; do
case $file in
- ""|[!/]*) continue ;;
- *) ${TEST} -f "$file" || continue ;;
+ "") continue ;;
+ [!/]*) file="${PKG_PREFIX}/$file" ;;
esac
+ ${TEST} -f "$file" || continue
shadow_dir="${PKG_REFCOUNT_FILES_DBDIR}$file"
${TEST} ! -d "$shadow_dir" || continue # refcount isn't zero
case "$printed_header" in
diff --git a/mk/install/perms b/mk/install/perms
index 3d8e6b5b484..a7e632afa77 100644
--- a/mk/install/perms
+++ b/mk/install/perms
@@ -1,6 +1,6 @@
#!@SH@
#
-# $NetBSD: perms,v 1.2 2005/04/20 17:13:28 seb Exp $
+# $NetBSD: perms,v 1.3 2005/07/29 21:41:04 jlam Exp $
#
# +PERMS - special file and directory permissions management script
#
@@ -16,6 +16,9 @@
# # PERMS: /usr/pkg/bin/lppasswd 4711 lp sys
# # PERMS: /usr/pkg/etc/pwd.db 0600
#
+# For each PERMS entry, if the file path is relative, then it is taken to
+# be relative to ${PKG_PREFIX}.
+#
CHGRP="@CHGRP@"
CHMOD="@CHMOD@"
CHOWN="@CHOWN@"
@@ -28,13 +31,15 @@ TEST="@TEST@"
SELF=$0
PKG_METADATA_DIR="${1-`${PWD_CMD}`}"
: ${PKGNAME=${PKG_METADATA_DIR##*/}}
+: ${PKG_PREFIX=@PREFIX@}
${SED} -n "/^\# PERMS: /{s/^\# PERMS: //;p;}" ${SELF} | ${SORT} -u |
{ while read file f_mode f_user f_group; do
case $file in
- ""|[!/]*) continue ;;
- *) ${TEST} -f "$file" || continue ;;
+ "") continue ;;
+ [!/]*) file="${PKG_PREFIX}/$file" ;;
esac
+ ${TEST} -f "$file" || continue
case "$printed_header" in
yes) ;;
*) printed_header=yes