pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/mk/install Assert INSTALLATION_DIRS begin with ${PREFI...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/53a6037fa74c
branches:  trunk
changeset: 366240:53a6037fa74c
user:      jlam <jlam%pkgsrc.org@localhost>
date:      Mon Aug 07 15:49:44 2017 +0000

description:
Assert INSTALLATION_DIRS begin with ${PREFIX} or are relative.

Add an assertion that all paths listed in INSTALLATION_DIRS must
either begin with ${PREFIX}/ or are relative paths.  Clarify in the
documentation that INSTALLATION_DIRS can list either type of path.

Some packages are using INSTALLATION_DIRS to create directory trees
outside of ${PREFIX}, e.g., under ${PKG_SYSCONFBASE} or ${VARBASE}.
However, these directories are only created as part of the
"install" target, which causes them to only be created during the
staged installation into ${DESTDIR} and not at all if their binary
packages are installed.  These packages should be fixed to use
MAKE_DIRS or OWN_DIRS to create these directory trees at the proper
time.

diffstat:

 mk/install/install.mk |  33 ++++++++++++++++++++++-----------
 1 files changed, 22 insertions(+), 11 deletions(-)

diffs (60 lines):

diff -r 7a615648447d -r 53a6037fa74c mk/install/install.mk
--- a/mk/install/install.mk     Mon Aug 07 11:11:22 2017 +0000
+++ b/mk/install/install.mk     Mon Aug 07 15:49:44 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: install.mk,v 1.70 2017/06/01 02:15:10 jlam Exp $
+# $NetBSD: install.mk,v 1.71 2017/08/07 15:49:44 jlam Exp $
 #
 # This file provides the code for the "install" phase.
 #
@@ -38,10 +38,11 @@
 #
 # INSTALLATION_DIRS
 #      A list of directories that should be created at the very
-#      beginning of the install phase. These directories are relative
-#      to ${PREFIX}. As a convenience, a leading gnu/ is transformed
-#      to ${PKGGNUDIR} and a leading man/ is transformed to
-#      ${PKGMANDIR}, to save package authors from typing too much.
+#      beginning of the install phase. These directories MUST either
+#      be paths that contain a leading {PREFIX}/ or be relative
+#      paths. As a convenience, a leading gnu/ is transformed to
+#      ${PKGGNUDIR} and a leading man/ is transformed to ${PKGMANDIR},
+#      to save package authors from typing too much.
 #
 # AUTO_MKDIRS
 # INSTALLATION_DIRS_FROM_PLIST
@@ -237,18 +238,28 @@
        esac;                                                           \
        }
 
+# _INSTALLATION_DIRS
+#      Contains the items listed in ${INSTALLATION_DIRS} with the
+#      following transformations performed, in order:
+#
+#      1. Leading "${PREFIX}/" is stripped.
+#      2. Leading "gnu/" is transformed into "${PKGGNUDIR}".
+#      3. Leading "man/" is transformed into "${PKGMANDIR}/".
+#
+# ASSERT: Paths listed in ${_INSTALLATION_DIRS} must be relative paths.
+#
+_INSTALLATION_DIRS=    ${INSTALLATION_DIRS:C,^${PREFIX}/,,:C,^gnu/,${PKGGNUDIR},:C,^man/,${PKGMANDIR}/,}
+.if !empty(_INSTALLATION_DIRS:M/*)
+PKG_FAIL_REASON+=      "INSTALLATION_DIRS items must begin with "${PREFIX:Q}" or be relative paths."
+.endif
+
 .PHONY: install-makedirs
 install-makedirs:
        ${RUN} ${INSTALL_DATA_DIR} ${DESTDIR}${PREFIX}
 .if defined(INSTALLATION_DIRS) && !empty(INSTALLATION_DIRS)
        @${STEP_MSG} "Creating installation directories"
        ${RUN}                                                          \
-       for dir in ${INSTALLATION_DIRS:C,^gnu/,${PKGGNUDIR},:C,^man/,${PKGMANDIR}/,}; do \
-               case "$$dir" in                                         \
-               ${PREFIX}/*)                                            \
-                       dir=`${ECHO} "$$dir" | ${SED} "s|^${PREFIX}/||"` ;; \
-               /*)     continue ;;                                     \
-               esac;                                                   \
+       for dir in ${_INSTALLATION_DIRS}; do                            \
                ${_INSTALL_ONE_DIR_CMD};                                \
        done
 .endif # INSTALLATION_DIRS



Home | Main Index | Thread Index | Old Index