pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc mk/pkginstall/files: allow spaces in configuration fil...
details: https://anonhg.NetBSD.org/pkgsrc/rev/9a75dd9aa8ed
branches: trunk
changeset: 411360:9a75dd9aa8ed
user: rillig <rillig%pkgsrc.org@localhost>
date: Tue Feb 11 01:59:30 2020 +0000
description:
mk/pkginstall/files: allow spaces in configuration file names
Fixes PR pkg/42191.
diffstat:
mk/pkginstall/bsd.pkginstall.mk | 50 +++++++++++++++++++++----------------
regress/conf-files-spaces/DESCR | 2 +
regress/conf-files-spaces/Makefile | 28 +++++++++++++++++++++
regress/conf-files-spaces/PLIST | 4 +++
regress/conf-files-spaces/spec | 30 ++++++++++++++++++++++
5 files changed, 92 insertions(+), 22 deletions(-)
diffs (293 lines):
diff -r 79f3a49108c1 -r 9a75dd9aa8ed mk/pkginstall/bsd.pkginstall.mk
--- a/mk/pkginstall/bsd.pkginstall.mk Tue Feb 11 01:21:25 2020 +0000
+++ b/mk/pkginstall/bsd.pkginstall.mk Tue Feb 11 01:59:30 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkginstall.mk,v 1.72 2018/11/30 18:38:20 rillig Exp $
+# $NetBSD: bsd.pkginstall.mk,v 1.73 2020/02/11 01:59:30 rillig Exp $
#
# This Makefile fragment is included by bsd.pkg.mk and implements the
# common INSTALL/DEINSTALL scripts framework. To use the pkginstall
@@ -60,7 +60,7 @@
# The Solaris /bin/sh does not know the ${foo#bar} shell substitution.
# This shell function serves a similar purpose, but is specialized on
# stripping ${PREFIX}/ from a pathname.
-_FUNC_STRIP_PREFIX= \
+_PKGINSTALL_FUNCS_SH= \
strip_prefix() { \
${AWK} 'END { \
plen = length(prefix); \
@@ -69,6 +69,10 @@
} \
print s; \
}' s="$$1" prefix=${PREFIX:Q}/ /dev/null; \
+ }; \
+ \
+ shquote_backslash() { \
+ ${ECHO} "$$1" | ${SED} 's,[^-A-Za-z0-9.\/_],\\&,g'; \
}
_PKGINSTALL_DIR= ${WRKDIR}/.pkginstall
@@ -418,7 +422,7 @@
${_INSTALL_PERMS_DATAFILE}:
${RUN}${MKDIR} ${.TARGET:H}
- ${RUN}${_FUNC_STRIP_PREFIX}; \
+ ${RUN}${_PKGINSTALL_FUNCS_SH}; \
set -- dummy ${SPECIAL_PERMS}; shift; \
exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
@@ -505,7 +509,7 @@
privileged-install-hook: _pkginstall-postinstall-check
_pkginstall-postinstall-check: .PHONY
${RUN} p="${DESTDIR}${PREFIX}"; \
- ${_FUNC_STRIP_PREFIX}; \
+ ${_PKGINSTALL_FUNCS_SH}; \
canon() { f=`strip_prefix "$$1"`; case $$f in [!/]*) f="$$p/$$f"; esac; echo "$$f"; }; \
needargs() { [ $$3 -ge $$2 ] || ${FAIL_MSG} "[bsd.pkginstall.mk] $$1 must have a multiple of $$2 words. Rest: $$4"; }; \
set args ${_INSTALL_RCD_SCRIPTS}; shift; \
@@ -540,7 +544,7 @@
${_INSTALL_FILES_DATAFILE}:
${RUN}${MKDIR} ${.TARGET:H}
- ${RUN}${_FUNC_STRIP_PREFIX}; \
+ ${RUN}${_PKGINSTALL_FUNCS_SH}; \
set -- dummy ${_INSTALL_RCD_SCRIPTS}; shift; \
exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
@@ -549,17 +553,19 @@
egfile="${RCD_SCRIPTS_EXAMPLEDIR}/$$script"; \
${ECHO} "# FILE: $$file cr $$egfile ${RCD_SCRIPTS_MODE}"; \
done
- ${RUN}${_FUNC_STRIP_PREFIX}; \
+ ${RUN}${_PKGINSTALL_FUNCS_SH}; \
set -- dummy ${CONF_FILES}; shift; \
exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
egfile="$$1"; file="$$2"; \
shift; shift; \
egfile=`strip_prefix "$$egfile"`; \
+ egfile=`shquote_backslash "$$egfile"`; \
file=`strip_prefix "$$file"`; \
+ file=`shquote_backslash "$$file"`; \
${ECHO} "# FILE: $$file c $$egfile ${CONF_FILES_MODE}"; \
done
- ${RUN}${_FUNC_STRIP_PREFIX}; \
+ ${RUN}${_PKGINSTALL_FUNCS_SH}; \
set -- dummy ${REQD_FILES}; shift; \
exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
@@ -569,7 +575,7 @@
file=`strip_prefix "$$file"`; \
${ECHO} "# FILE: $$file cf $$egfile ${REQD_FILES_MODE}"; \
done
- ${RUN}${_FUNC_STRIP_PREFIX}; \
+ ${RUN}${_PKGINSTALL_FUNCS_SH}; \
set -- dummy ${CONF_FILES_PERMS}; shift; \
exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
@@ -580,7 +586,7 @@
file=`strip_prefix "$$file"`; \
${ECHO} "# FILE: $$file c $$egfile $$mode $$owner $$group"; \
done
- ${RUN}${_FUNC_STRIP_PREFIX}; \
+ ${RUN}${_PKGINSTALL_FUNCS_SH}; \
set -- dummy ${REQD_FILES_PERMS}; shift; \
exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
@@ -643,7 +649,7 @@
${_INSTALL_DIRS_DATAFILE}:
${RUN}${MKDIR} ${.TARGET:H}
- ${RUN}${_FUNC_STRIP_PREFIX}; \
+ ${RUN}${_PKGINSTALL_FUNCS_SH}; \
exec 1>>${.TARGET}; \
case ${PKG_SYSCONFSUBDIR:M*:Q}${CONF_FILES:M*:Q}${CONF_FILES_PERMS:M*:Q}"" in \
"") ;; \
@@ -667,7 +673,7 @@
"") ;; \
*) ${ECHO} "# DIR: ${RCD_SCRIPTS_DIR:S/${PREFIX}\///} m" ;; \
esac
- ${RUN}${_FUNC_STRIP_PREFIX}; \
+ ${RUN}${_PKGINSTALL_FUNCS_SH}; \
set -- dummy ${MAKE_DIRS}; shift; \
exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
@@ -675,7 +681,7 @@
dir=`strip_prefix "$$dir"`; \
${ECHO} "# DIR: $$dir m"; \
done
- ${RUN}${_FUNC_STRIP_PREFIX}; \
+ ${RUN}${_PKGINSTALL_FUNCS_SH}; \
set -- dummy ${REQD_DIRS}; shift; \
exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
@@ -683,7 +689,7 @@
dir=`strip_prefix "$$dir"`; \
${ECHO} "# DIR: $$dir fm"; \
done
- ${RUN}${_FUNC_STRIP_PREFIX}; \
+ ${RUN}${_PKGINSTALL_FUNCS_SH}; \
set -- dummy ${OWN_DIRS}; shift; \
exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
@@ -691,7 +697,7 @@
dir=`strip_prefix "$$dir"`; \
${ECHO} "# DIR: $$dir mo"; \
done
- ${RUN}${_FUNC_STRIP_PREFIX}; \
+ ${RUN}${_PKGINSTALL_FUNCS_SH}; \
set -- dummy ${MAKE_DIRS_PERMS}; shift; \
exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
@@ -700,7 +706,7 @@
dir=`strip_prefix "$$dir"`; \
${ECHO} "# DIR: $$dir m $$mode $$owner $$group"; \
done
- ${RUN}${_FUNC_STRIP_PREFIX}; \
+ ${RUN}${_PKGINSTALL_FUNCS_SH}; \
set -- dummy ${REQD_DIRS_PERMS}; shift; \
exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
@@ -709,7 +715,7 @@
dir=`strip_prefix "$$dir"`; \
${ECHO} "# DIR: $$dir fm $$mode $$owner $$group"; \
done
- ${RUN}${_FUNC_STRIP_PREFIX}; \
+ ${RUN}${_PKGINSTALL_FUNCS_SH}; \
set -- dummy ${OWN_DIRS_PERMS}; shift; \
exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
@@ -770,7 +776,7 @@
install-script-data: install-script-data-info-files
install-script-data-info-files:
.if defined(INFO_FILES)
- ${RUN}${_FUNC_STRIP_PREFIX}; \
+ ${RUN}${_PKGINSTALL_FUNCS_SH}; \
if ${TEST} -x ${INSTALL_FILE}; then \
${INFO_FILES_cmd} | \
while read file; do \
@@ -826,7 +832,7 @@
${_INSTALL_SHELL_DATAFILE}:
${RUN}${MKDIR} ${.TARGET:H}
- ${RUN}${_FUNC_STRIP_PREFIX}; \
+ ${RUN}${_PKGINSTALL_FUNCS_SH}; \
set -- dummy ${PKG_SHELL}; shift; \
exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
@@ -932,7 +938,7 @@
${_INSTALL_FONTS_DATAFILE}:
${RUN}${MKDIR} ${.TARGET:H}
- ${RUN}${_FUNC_STRIP_PREFIX}; \
+ ${RUN}${_PKGINSTALL_FUNCS_SH}; \
set -- dummy ${FONTS_DIRS.ttf}; shift; \
exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
@@ -940,7 +946,7 @@
dir=`strip_prefix "$$dir"`; \
${ECHO} "# FONTS: $$dir ttf"; \
done
- ${RUN}${_FUNC_STRIP_PREFIX}; \
+ ${RUN}${_PKGINSTALL_FUNCS_SH}; \
set -- dummy ${FONTS_DIRS.type1}; shift; \
exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
@@ -948,7 +954,7 @@
dir=`strip_prefix "$$dir"`; \
${ECHO} "# FONTS: $$dir type1"; \
done
- ${RUN}${_FUNC_STRIP_PREFIX}; \
+ ${RUN}${_PKGINSTALL_FUNCS_SH}; \
set -- dummy ${FONTS_DIRS.x11}; shift; \
exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
@@ -996,7 +1002,7 @@
.PHONY: install-script-data-icon-themes
install-script-data: install-script-data-icon-themes
install-script-data-icon-themes:
- ${RUN}${_FUNC_STRIP_PREFIX}; \
+ ${RUN}${_PKGINSTALL_FUNCS_SH}; \
if ${TEST} -x ${INSTALL_FILE}; then \
${ICON_THEMES_cmd} | \
while read theme; do \
diff -r 79f3a49108c1 -r 9a75dd9aa8ed regress/conf-files-spaces/DESCR
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/conf-files-spaces/DESCR Tue Feb 11 01:59:30 2020 +0000
@@ -0,0 +1,2 @@
+Demonstrates that the names of CONF_FILES can contain spaces and that
+these can be quoted using backslashes, double quotes or single quotes.
diff -r 79f3a49108c1 -r 9a75dd9aa8ed regress/conf-files-spaces/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/conf-files-spaces/Makefile Tue Feb 11 01:59:30 2020 +0000
@@ -0,0 +1,28 @@
+# $NetBSD: Makefile,v 1.1 2020/02/11 01:59:30 rillig Exp $
+#
+# Requires bmake from 2015 or later, since in previous versions, the .for
+# loop did split the variable values strictly on spaces, without taking
+# backslashes or quotes into account.
+
+PKGNAME= conf-files-spaces-2020.02.11
+CATEGORIES= misc
+DISTFILES= # none
+
+COMMENT= Demonstrates spaces in configuration file names
+LICENSE= 2-clause-bsd
+
+BUILD_DIRS= # none
+EGDIR= share/${PKGBASE}
+EGFILES= back\ slash.conf "d quot.conf" 's quot.conf'
+
+.for file in ${EGFILES}
+CONF_FILES+= ${EGDIR}/${file} ${PKG_SYSCONFDIR}/${file}
+.endfor
+
+do-install:
+ mkdir ${DESTDIR}${PREFIX}/${EGDIR}
+.for file in ${EGFILES}
+ ${INSTALL_DATA} /dev/null ${DESTDIR}${PREFIX}/${EGDIR}/${file}
+.endfor
+
+.include "../../mk/bsd.pkg.mk"
diff -r 79f3a49108c1 -r 9a75dd9aa8ed regress/conf-files-spaces/PLIST
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/conf-files-spaces/PLIST Tue Feb 11 01:59:30 2020 +0000
@@ -0,0 +1,4 @@
+@comment $NetBSD: PLIST,v 1.1 2020/02/11 01:59:30 rillig Exp $
+share/conf-files-spaces/back slash.conf
+share/conf-files-spaces/d quot.conf
+share/conf-files-spaces/s quot.conf
diff -r 79f3a49108c1 -r 9a75dd9aa8ed regress/conf-files-spaces/spec
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/conf-files-spaces/spec Tue Feb 11 01:59:30 2020 +0000
@@ -0,0 +1,30 @@
+# $NetBSD: spec,v 1.1 2020/02/11 01:59:30 rillig Exp $
+#
+# Up to February 2020, pkgsrc could not handle configuration files with
+# spaces in their names.
+
+do_setup() {
+ $TEST_MAKE deinstall clean
+}
+
+do_test() {
+ PKG_CONFIG=yes $TEST_MAKE install >> "$TEST_OUTFILE"
+
+ sysconfdir=`$TEST_MAKE show-var VARNAME=PKG_SYSCONFDIR`
+ for file in "back slash.conf" "d quot.conf" "s quot.conf"; do
+ test -f "$sysconfdir/$file" || regress_fail "'$file' not found"
+ done
+
+ PKG_CONFIG=yes $TEST_MAKE deinstall >> "$TEST_OUTFILE"
+}
+
+check_result() {
+ exit_status "0"
+ output_require ": copying .*/back slash.conf to .*/back slash.conf"
+ output_require ": copying .*/d quot.conf to .*/d quot.conf"
+ output_require ": copying .*/s quot.conf to .*/s quot.conf"
+}
+
+do_cleanup() {
+ $TEST_MAKE deinstall clean
+}
Home |
Main Index |
Thread Index |
Old Index