Wed Jun 10 16:06:09 2020 UTC ()
mk/plist: Add EARLY_PRINT_PLIST_AWK

EARLY_PRINT_PLIST_AWK is like PRINT_PLIST_AWK but operates before the
file/directory lists are sorted.

Discussed on tech-pkg@ mainly to address `print-PLIST' order problems for
Python 3 packages:

 <https://mail-index.NetBSD.org/tech-pkg/2020/05/27/msg023249.html>


(leot)
diff -r1.54 -r1.55 pkgsrc/mk/plist/plist.mk
diff -r1.35 -r1.36 pkgsrc/mk/plist/print-plist.mk

cvs diff -r1.54 -r1.55 pkgsrc/mk/plist/plist.mk (expand / switch to unified diff)

--- pkgsrc/mk/plist/plist.mk 2020/03/30 22:54:24 1.54
+++ pkgsrc/mk/plist/plist.mk 2020/06/10 16:06:09 1.55
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: plist.mk,v 1.54 2020/03/30 22:54:24 rillig Exp $ 1# $NetBSD: plist.mk,v 1.55 2020/06/10 16:06:09 leot Exp $
2# 2#
3# This Makefile fragment handles the creation of PLISTs for use by 3# This Makefile fragment handles the creation of PLISTs for use by
4# pkg_create(8). 4# pkg_create(8).
5# 5#
6# The following variables affect the PLIST generation: 6# The following variables affect the PLIST generation:
7# 7#
8# PLIST_TYPE specifies whether the generated PLIST is derived 8# PLIST_TYPE specifies whether the generated PLIST is derived
9# automatically from the installed files, or if the PLIST entries 9# automatically from the installed files, or if the PLIST entries
10# are listed in files. Valid values are "dynamic" and "static", 10# are listed in files. Valid values are "dynamic" and "static",
11# and the default value is "static". 11# and the default value is "static".
12# 12#
13# PLIST_VARS is the list of names corresponding to automatic variables 13# PLIST_VARS is the list of names corresponding to automatic variables
14# generated by plist.mk to simplify having conditionally-present 14# generated by plist.mk to simplify having conditionally-present
@@ -137,28 +137,29 @@ _PLIST_AWK_ENV+= TEST=${TOOLS_TEST:Q} @@ -137,28 +137,29 @@ _PLIST_AWK_ENV+= TEST=${TOOLS_TEST:Q}
137_PLIST_AWK_ENV+= ${PLIST_AWK_ENV} 137_PLIST_AWK_ENV+= ${PLIST_AWK_ENV}
138 138
139# PLIST_SUBST contains package-settable VAR=value substitutions that are 139# PLIST_SUBST contains package-settable VAR=value substitutions that are
140# used when generating the actual file list for the package from the 140# used when generating the actual file list for the package from the
141# package's PLIST files, as listed in PLIST_SRC. These files may contain 141# package's PLIST files, as listed in PLIST_SRC. These files may contain
142# placeholders of the form ${VAR}, which are then substituted by their 142# placeholders of the form ${VAR}, which are then substituted by their
143# corresponding value from PLIST_SUBST. 143# corresponding value from PLIST_SUBST.
144# 144#
145# Example: PLIST_SUBST+= PKGNAME=${PKGNAME_NOREV} means that the package's 145# Example: PLIST_SUBST+= PKGNAME=${PKGNAME_NOREV} means that the package's
146# PLIST file may contain the placeholder ${PKGNAME}, which will be replaced 146# PLIST file may contain the placeholder ${PKGNAME}, which will be replaced
147# with the package version excluding the "nb13" extension. 147# with the package version excluding the "nb13" extension.
148# 148#
149# The other direction of generating the package's PLIST file from the list 149# The other direction of generating the package's PLIST file from the list
150# of actually installed files is covered by PRINT_PLIST_AWK. This is only 150# of actually installed files is covered by EARLY_PRINT_PLIST_AWK and
151# needed when developing the package itself, for example after an update. 151# PRINT_PLIST_AWK. This is only needed when developing the package itself,
 152# for example after an update.
152# 153#
153PLIST_SUBST+= OPSYS=${OPSYS:Q} \ 154PLIST_SUBST+= OPSYS=${OPSYS:Q} \
154 OS_VERSION=${OS_VERSION:Q} \ 155 OS_VERSION=${OS_VERSION:Q} \
155 MACHINE_ARCH=${MACHINE_ARCH:Q} \ 156 MACHINE_ARCH=${MACHINE_ARCH:Q} \
156 MACHINE_GNU_ARCH=${MACHINE_GNU_ARCH:Q} \ 157 MACHINE_GNU_ARCH=${MACHINE_GNU_ARCH:Q} \
157 MACHINE_GNU_PLATFORM=${MACHINE_GNU_PLATFORM:Q} \ 158 MACHINE_GNU_PLATFORM=${MACHINE_GNU_PLATFORM:Q} \
158 LN=${LN:Q} \ 159 LN=${LN:Q} \
159 LOWER_VENDOR=${LOWER_VENDOR:Q} \ 160 LOWER_VENDOR=${LOWER_VENDOR:Q} \
160 LOWER_OPSYS=${LOWER_OPSYS:Q} \ 161 LOWER_OPSYS=${LOWER_OPSYS:Q} \
161 LOWER_OS_VERSION=${LOWER_OS_VERSION:Q} \ 162 LOWER_OS_VERSION=${LOWER_OS_VERSION:Q} \
162 PKGBASE=${PKGBASE:Q} \ 163 PKGBASE=${PKGBASE:Q} \
163 PKGNAME=${PKGNAME_NOREV:Q} \ 164 PKGNAME=${PKGNAME_NOREV:Q} \
164 PKGLOCALEDIR=${PKGLOCALEDIR:Q} \ 165 PKGLOCALEDIR=${PKGLOCALEDIR:Q} \

cvs diff -r1.35 -r1.36 pkgsrc/mk/plist/print-plist.mk (expand / switch to unified diff)

--- pkgsrc/mk/plist/print-plist.mk 2020/04/18 10:54:21 1.35
+++ pkgsrc/mk/plist/print-plist.mk 2020/06/10 16:06:09 1.36
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: print-plist.mk,v 1.35 2020/04/18 10:54:21 rillig Exp $ 1# $NetBSD: print-plist.mk,v 1.36 2020/06/10 16:06:09 leot Exp $
2# 2#
3# Automatic PLIST generation 3# Automatic PLIST generation
4# - files & symlinks first 4# - files & symlinks first
5# - empty directories are handled properly 5# - empty directories are handled properly
6# - dirs from mtree files are excluded 6# - dirs from mtree files are excluded
7# - substitute for platform or package specifics substrings 7# - substitute for platform or package specifics substrings
8# 8#
9# Usage: 9# Usage:
10# - make install 10# - make install
11# - make print-PLIST | brain >PLIST 11# - make print-PLIST | brain >PLIST
12# 12#
13# Keywords: plist print-plist 13# Keywords: plist print-plist
14 14
@@ -84,26 +84,29 @@ _PRINT_PLIST_LIBTOOLIZE_FILTER?= ${CAT} @@ -84,26 +84,29 @@ _PRINT_PLIST_LIBTOOLIZE_FILTER?= ${CAT}
84.endif 84.endif
85 85
86.PHONY: print-PLIST 86.PHONY: print-PLIST
87.if !target(print-PLIST) 87.if !target(print-PLIST)
88print-PLIST: 88print-PLIST:
89 ${RUN} ${ECHO} '@comment $$'NetBSD'$$' 89 ${RUN} ${ECHO} '@comment $$'NetBSD'$$'
90 ${RUN} ${ALL_ENV}; \ 90 ${RUN} ${ALL_ENV}; \
91 shlib_type=${SHLIB_TYPE:Q}; \ 91 shlib_type=${SHLIB_TYPE:Q}; \
92 case $$shlib_type in \ 92 case $$shlib_type in \
93 "a.out") genlinks=1 ;; \ 93 "a.out") genlinks=1 ;; \
94 *) genlinks=0 ;; \ 94 *) genlinks=0 ;; \
95 esac; \ 95 esac; \
96 ${_PRINT_PLIST_FILES_CMD} \ 96 ${_PRINT_PLIST_FILES_CMD} \
 97 | ${AWK} ' \
 98 ${EARLY_PRINT_PLIST_AWK} \
 99 { print $$0; }' \
97 | ${_PRINT_PLIST_LIBTOOLIZE_FILTER} \ 100 | ${_PRINT_PLIST_LIBTOOLIZE_FILTER} \
98 | ${SORT} \ 101 | ${SORT} \
99 | ${AWK} ' \ 102 | ${AWK} ' \
100 { sub("${DESTDIR:S|+|\\\\+|g}${PREFIX}/\\./", ""); } \ 103 { sub("${DESTDIR:S|+|\\\\+|g}${PREFIX}/\\./", ""); } \
101 ${_PRINT_PLIST_AWK_IGNORE} { next; } \ 104 ${_PRINT_PLIST_AWK_IGNORE} { next; } \
102 ${PRINT_PLIST_AWK} \ 105 ${PRINT_PLIST_AWK} \
103 ${_PRINT_PLIST_AWK_SUBST} \ 106 ${_PRINT_PLIST_AWK_SUBST} \
104 /^@/ { print $$0; next } \ 107 /^@/ { print $$0; next } \
105 /.*\/lib[^\/]+\.so\.[0-9]+\.[0-9]+\.[0-9]+$$/ { \ 108 /.*\/lib[^\/]+\.so\.[0-9]+\.[0-9]+\.[0-9]+$$/ { \
106 print $$0; \ 109 print $$0; \
107 sub("\\.[0-9]+$$", ""); \ 110 sub("\\.[0-9]+$$", ""); \
108 if ('$$genlinks') print $$0; \ 111 if ('$$genlinks') print $$0; \
109 sub("\\.[0-9]+$$", ""); \ 112 sub("\\.[0-9]+$$", ""); \
@@ -114,26 +117,29 @@ print-PLIST: @@ -114,26 +117,29 @@ print-PLIST:
114 } \ 117 } \
115 /.*\/lib[^\/]+\.so\.[0-9]+\.[0-9]+$$/ { \ 118 /.*\/lib[^\/]+\.so\.[0-9]+\.[0-9]+$$/ { \
116 print $$0; \ 119 print $$0; \
117 sub("\\.[0-9]+$$", ""); \ 120 sub("\\.[0-9]+$$", ""); \
118 if ('$$genlinks') print $$0; \ 121 if ('$$genlinks') print $$0; \
119 sub("\\.[0-9]+$$", ""); \ 122 sub("\\.[0-9]+$$", ""); \
120 if ('$$genlinks') print $$0; \ 123 if ('$$genlinks') print $$0; \
121 next; \ 124 next; \
122 } \ 125 } \
123 /^man\// { sub("\\.gz$$", ""); } \ 126 /^man\// { sub("\\.gz$$", ""); } \
124 { print $$0; }' 127 { print $$0; }'
125 ${RUN}\ 128 ${RUN}\
126 for i in `${_PRINT_PLIST_DIRS_CMD} \ 129 for i in `${_PRINT_PLIST_DIRS_CMD} \
 130 | ${AWK} ' \
 131 ${EARLY_PRINT_PLIST_AWK} \
 132 { print $$0; }' \
127 | ${SORT} -r \ 133 | ${SORT} -r \
128 | ${AWK} ' \ 134 | ${AWK} ' \
129 /emul\/linux\/proc/ { next; } \ 135 /emul\/linux\/proc/ { next; } \
130 /${DESTDIR:S|/|\\/|g:S/+/\\\\+/g}${PREFIX:S|/|\\/|g}\/\.$$/ { next; } \ 136 /${DESTDIR:S|/|\\/|g:S/+/\\\\+/g}${PREFIX:S|/|\\/|g}\/\.$$/ { next; } \
131 /${PKG_DBDIR:S|/|\\/|g}\// { next; } \ 137 /${PKG_DBDIR:S|/|\\/|g}\// { next; } \
132 { sub("${DESTDIR:S/+/\\\\\\+/g}${PREFIX}/\\\\./", ""); } \ 138 { sub("${DESTDIR:S/+/\\\\\\+/g}${PREFIX}/\\\\./", ""); } \
133 { sub("^${PKGINFODIR}/", "info/"); } \ 139 { sub("^${PKGINFODIR}/", "info/"); } \
134 { sub("^${PKGMANDIR}/", "man/"); } \ 140 { sub("^${PKGMANDIR}/", "man/"); } \
135 /^${PKG_DBDIR:S|^${PREFIX}/||:S|/|\\/|g}(\/|$$)/ { next; } \ 141 /^${PKG_DBDIR:S|^${PREFIX}/||:S|/|\\/|g}(\/|$$)/ { next; } \
136 /^${PKGINFODIR:S|/|\\/|g}$$/ { next; } \ 142 /^${PKGINFODIR:S|/|\\/|g}$$/ { next; } \
137 { print $$0; }'` ; \ 143 { print $$0; }'` ; \
138 do \ 144 do \
139 if [ `${LS} -la ${DESTDIR}${PREFIX}/$$i | ${WC} -l` = 3 ]; then \ 145 if [ `${LS} -la ${DESTDIR}${PREFIX}/$$i | ${WC} -l` = 3 ]; then \