Fri Apr 17 12:35:11 2020 UTC ()
Pullup ticket #6161 - requested by sborrill
mk/pkginstall: NetBSD 7 bugfix

Revisions pulled up:
- mk/pkginstall/files                                           1.11

---
   Module Name:	pkgsrc
   Committed By:	sborrill
   Date:		Wed Apr 15 13:33:32 UTC 2020

   Modified Files:
   	pkgsrc/mk/pkginstall: files

   Log Message:
   Work around a potential shell bug where "${FOO=${BAR%/*}}" does not work
   if quoted. Seen on NetBSD 7.

   #!/bin/sh
   in="/path/to/dir with space/file"

   : "${file=${in##*/}}"
   : "${dir=${in%/*}}"
   echo "dir:$dir"
   echo "file:$file"
   [ "$dir" = "$file" ] && echo "dir and file are same"

   Leads to errors when adding packages such as:
   ./+FILES: cannot create
   /var/db/pkg.refcount/files/etc/rc.d/xenguest//var/db/pkg/xe-guest-utilities-7.0.0:
   directory nonexistent


(bsiegert)
diff -r1.10 -r1.10.2.1 pkgsrc/mk/pkginstall/files

cvs diff -r1.10 -r1.10.2.1 pkgsrc/mk/pkginstall/files (expand / switch to unified diff)

--- pkgsrc/mk/pkginstall/files 2020/02/11 01:21:25 1.10
+++ pkgsrc/mk/pkginstall/files 2020/04/17 12:35:11 1.10.2.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: files,v 1.10 2020/02/11 01:21:25 rillig Exp $ 1# $NetBSD: files,v 1.10.2.1 2020/04/17 12:35:11 bsiegert Exp $
2# 2#
3# Generate a +FILES script that reference counts config files that are 3# Generate a +FILES script that reference counts config files that are
4# required for the proper functioning of the package. 4# required for the proper functioning of the package.
5# 5#
6case "${STAGE},$1" in 6case "${STAGE},$1" in
7UNPACK,|UNPACK,+FILES) 7UNPACK,|UNPACK,+FILES)
8 ${CAT} > ./+FILES << 'EOF' 8 ${CAT} > ./+FILES << 'EOF'
9#!@SH@ 9#!@SH@
10# 10#
11# +FILES - reference-counted configuration file management script 11# +FILES - reference-counted configuration file management script
12# 12#
13# Usage: ./+FILES ADD|REMOVE|PERMS [metadatadir] 13# Usage: ./+FILES ADD|REMOVE|PERMS [metadatadir]
14# ./+FILES CHECK-ADD|CHECK-REMOVE|CHECK-PERMS [metadatadir] 14# ./+FILES CHECK-ADD|CHECK-REMOVE|CHECK-PERMS [metadatadir]
@@ -88,28 +88,28 @@ case "${PKG_CONFIG_PERMS:-@PKG_CONFIG_PE @@ -88,28 +88,28 @@ case "${PKG_CONFIG_PERMS:-@PKG_CONFIG_PE
88 ;; 88 ;;
89esac 89esac
90case "${PKG_RCD_SCRIPTS:-@PKG_RCD_SCRIPTS@}" in 90case "${PKG_RCD_SCRIPTS:-@PKG_RCD_SCRIPTS@}" in
91[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) 91[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
92 _PKG_RCD_SCRIPTS=yes 92 _PKG_RCD_SCRIPTS=yes
93 ;; 93 ;;
94[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) 94[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
95 _PKG_RCD_SCRIPTS=no 95 _PKG_RCD_SCRIPTS=no
96 ;; 96 ;;
97esac 97esac
98 98
99CURDIR=`${PWD_CMD}` 99CURDIR=`${PWD_CMD}`
100PKG_METADATA_DIR="${2-${CURDIR}}" 100PKG_METADATA_DIR="${2-${CURDIR}}"
101: "${PKGNAME=${PKG_METADATA_DIR##*/}}" 101: ${PKGNAME="${PKG_METADATA_DIR##*/}"}
102: "${PKG_DBDIR=${PKG_METADATA_DIR%/*}}" 102: ${PKG_DBDIR="${PKG_METADATA_DIR%/*}"}
103: "${PKG_REFCOUNT_DBDIR=${PKG_DBDIR}.refcount}" 103: "${PKG_REFCOUNT_DBDIR=${PKG_DBDIR}.refcount}"
104PKG_REFCOUNT_FILES_DBDIR="${PKG_REFCOUNT_DBDIR}/files" 104PKG_REFCOUNT_FILES_DBDIR="${PKG_REFCOUNT_DBDIR}/files"
105 105
106exitcode=0 106exitcode=0
107case $ACTION in 107case $ACTION in
108ADD) 108ADD)
109 ${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" "${SELF}" | ${SORT} -u | 109 ${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" "${SELF}" | ${SORT} -u |
110 while read file f_flags f_eg f_mode f_user f_group; do 110 while read file f_flags f_eg f_mode f_user f_group; do
111 case $file in 111 case $file in
112 "") continue ;; 112 "") continue ;;
113 [!/]*) file="${PKG_PREFIX}/$file" ;; 113 [!/]*) file="${PKG_PREFIX}/$file" ;;
114 esac 114 esac
115 case $f_flags in 115 case $f_flags in