pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk/install When using pkginstall to create INSTALL/DEI...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/3ebb28a1f2fd
branches:  trunk
changeset: 497525:3ebb28a1f2fd
user:      jlam <jlam%pkgsrc.org@localhost>
date:      Fri Jul 29 21:41:04 2005 +0000

description:
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:

 mk/install/bsd.pkginstall.mk |  34 +++++++++++++++++++++++++++-------
 mk/install/dirs              |  24 ++++++++++++++++--------
 mk/install/files             |  41 ++++++++++++++++++++++++++++++++---------
 mk/install/perms             |  11 ++++++++---
 4 files changed, 83 insertions(+), 27 deletions(-)

diffs (truncated from 381 to 300 lines):

diff -r 9cc957bebafa -r 3ebb28a1f2fd mk/install/bsd.pkginstall.mk
--- a/mk/install/bsd.pkginstall.mk      Fri Jul 29 21:05:20 2005 +0000
+++ b/mk/install/bsd.pkginstall.mk      Fri Jul 29 21:41:04 2005 +0000
@@ -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 @@
 # 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 @@
        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 @@
 #      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 @@
        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 @@
                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 @@
        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 @@
 #      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 @@
        ${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 @@
        ${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 @@
        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-${_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 -r 9cc957bebafa -r 3ebb28a1f2fd mk/install/dirs
--- a/mk/install/dirs   Fri Jul 29 21:05:20 2005 +0000
+++ b/mk/install/dirs   Fri Jul 29 21:41:04 2005 +0000
@@ -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 @@
 : ${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 @@
        ${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 @@
        ${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 @@
        ${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 @@
        ${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 -r 9cc957bebafa -r 3ebb28a1f2fd mk/install/files
--- a/mk/install/files  Fri Jul 29 21:05:20 2005 +0000
+++ b/mk/install/files  Fri Jul 29 21:41:04 2005 +0000
@@ -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 @@
 SELF=$0
 ACTION=$1
 
+: ${PKG_PREFIX=@PREFIX@}
+
 case ${ACTION} in
 VIEW-REMOVE)
        DEPOTDIR="$2"
@@ -73,12 +78,17 @@
        ${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 @@
        ${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 @@
        ${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}/}" ;;



Home | Main Index | Thread Index | Old Index