aboutsummaryrefslogtreecommitdiffstats
path: root/Mk
diff options
context:
space:
mode:
authormat <mat@FreeBSD.org>2017-12-20 00:23:48 +0800
committermat <mat@FreeBSD.org>2017-12-20 00:23:48 +0800
commite2e0f973b1073a63f0912edaf8e8d499bae1193f (patch)
tree7d530d9aabea9a037ed02ad61ef394b729dcdf43 /Mk
parentdb9adfad16c9f1e482219cdc358bf2d73214b918 (diff)
downloadfreebsd-ports-gnome-e2e0f973b1073a63f0912edaf8e8d499bae1193f.tar.gz
freebsd-ports-gnome-e2e0f973b1073a63f0912edaf8e8d499bae1193f.tar.zst
freebsd-ports-gnome-e2e0f973b1073a63f0912edaf8e8d499bae1193f.zip
Enhance USES=uniquefiles to be more generic.
This allows to have more complex renaming schemes. Until now, it could only add a prefix or a suffix, but this was not working at all for man pages, because it would give man/man1/pyfoo.1.gz-2.7 or man/man1/pyfoo-1-2.7.gz. With this change, a man page will be correctly renamed to man/man1/pyfoo-2.7.1.gz. Unfix ports that were already handling man pages. PR: 220214 Submitted by: Fukang Chen (previous patch) Exp-run by: antoine Sponsored by: Absolight Differential Revision: https://reviews.freebsd.org/D13444
Diffstat (limited to 'Mk')
-rw-r--r--Mk/Uses/python.mk14
-rw-r--r--Mk/Uses/uniquefiles.mk62
2 files changed, 55 insertions, 21 deletions
diff --git a/Mk/Uses/python.mk b/Mk/Uses/python.mk
index 4ee191581088..947f34aef9d0 100644
--- a/Mk/Uses/python.mk
+++ b/Mk/Uses/python.mk
@@ -580,15 +580,19 @@ UNIQUE_DEFAULT_LINKS= no
.endif
UNIQUE_PREFIX= ${PYTHON_PKGNAMEPREFIX}
UNIQUE_SUFFIX= -${PYTHON_VER}
+UNIQUE_SUFFIX_TYPES+= SUFFIX_MAN
+UNIQUE_SUFFIX_MAN_WITH_EXT= .[1-9ln]
+UNIQUE_SUFFIX_MAN_EXTRA_EXT= .gz
.if defined(_PYTHON_FEATURE_AUTOPLIST)
-UNIQUE_FIND_SUFFIX_FILES= \
- ${SED} -e 's|^${PREFIX}/||' ${_PYTHONPKGLIST} ${TMPPLIST} | \
- ${EGREP} -e '^bin/.*$$|^sbin/.*$$|^libexec/.*$$'
+_UNIQUE_FIND_SUFFIX_FILES= ${SED} -e 's|^${PREFIX}/||' ${_PYTHONPKGLIST} ${TMPPLIST}
.else
-UNIQUE_FIND_SUFFIX_FILES= \
- ${EGREP} -he '^bin/.*$$|^sbin/.*$$|^libexec/.*$$' ${TMPPLIST} 2>/dev/null
+_UNIQUE_FIND_SUFFIX_FILES= ${SED} -e 's|^${PREFIX}/||' ${TMPPLIST} 2>/dev/null
.endif
+UNIQUE_FIND_SUFFIX_FILES+= ${_UNIQUE_FIND_SUFFIX_FILES} | \
+ ${EGREP} -he '^bin/.*$$|^sbin/.*$$|^libexec/.*$$'
+UNIQUE_FIND_SUFFIX_MAN_FILES+= ${_UNIQUE_FIND_SUFFIX_FILES} | \
+ ${EGREP} -he '^man/man[1-9ln]/.*$$'
.endif # defined(_PYTHON_FEATURE_CONCURRENT)
_CURRENTPORT:= ${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}
diff --git a/Mk/Uses/uniquefiles.mk b/Mk/Uses/uniquefiles.mk
index 940ef3535408..43d0206e4db0 100644
--- a/Mk/Uses/uniquefiles.mk
+++ b/Mk/Uses/uniquefiles.mk
@@ -56,6 +56,19 @@
# list of files to be iterated over.
# Default: empty
#
+# UNIQUE_SUFFIX_TYPES - A list of TAGS to defined more complex unique
+# suffix handling. It can, for example, handle
+# man pages by doing:
+#
+# UNIQUE_SUFFIX_TYPES+= SUFFIX_MAN
+# UNIQUE_SUFFIX_MAN_WITH_EXT= .[1-9ln]
+# UNIQUE_SUFFIX_MAN_EXTRA_EXT= .gz
+# UNIQUE_FIND_SUFFIX_MAN_FILES= ${EGREP} -he '^man/man[1-9ln]/.*$$' ${TMPPLIST} 2>/dev/null
+#
+# The make(1) target that renames the files
+# runs before the man pages are compressed,
+# this is what the EXTRA_EXT bit is for.
+#
# NOTE: multiple logical instances are not supported by pkg and the original
# pkg_tools at the moment.
#
@@ -69,6 +82,8 @@ UNIQUE_SUFFIX?= ${PKGNAMESUFFIX}
UNIQUE_PREFIX_FILES?= # empty
UNIQUE_SUFFIX_FILES?= # empty
+UNIQUE_SUFFIX_TYPES+= SUFFIX
+
.if ${uniquefiles_ARGS:Mdirs}
DOCSDIR= ${PREFIX}/share/doc/${UNIQUE_PREFIX}${PORTNAME}
EXAMPLESDIR= ${PREFIX}/share/examples/${UNIQUE_PREFIX}${PORTNAME}
@@ -94,7 +109,7 @@ _DO_CONDITIONAL_SYMLINK= \
if [ ! -e ${STAGEDIR}${PREFIX}/$${fname} -a ! -L ${STAGEDIR}${PREFIX}/$${fname} ]; then \
${ECHO_MSG} "Link: @$${fname} --> $${newf}"; \
${RLN} ${STAGEDIR}${PREFIX}/$${newf} ${STAGEDIR}${PREFIX}/$${fname}; \
- ${ECHO_CMD} LINKED:$${newf}:$${fname} >> ${_UNIQUEPKGLIST}; \
+ ${ECHO_CMD} LINKED:$${newf}%%EXTRA_EXT%%:$${fname}%%EXTRA_EXT%% >> ${_UNIQUEPKGLIST}; \
fi
.else
# We are not symlinking the renamed binary.
@@ -113,7 +128,7 @@ move-uniquefiles:
${ECHO_MSG} "Move: $${fname} --> $${newf}" ; \
${MV} ${STAGEDIR}${PREFIX}/$${fname} ${STAGEDIR}${PREFIX}/$${newf}; \
${ECHO_CMD} MOVED:$${fname}:$${newf} >> ${_UNIQUEPKGLIST}; \
- ${_DO_CONDITIONAL_SYMLINK}; \
+ ${_DO_CONDITIONAL_SYMLINK:S/%%EXTRA_EXT%%//g}; \
else \
${ECHO_MSG} "Makefile error: UNIQUE (prefix): $${fname} not found"; \
${FALSE}; \
@@ -126,7 +141,7 @@ move-uniquefiles:
${ECHO_MSG} "Move: $${fname} --> $${newf}" ; \
${MV} ${STAGEDIR}${PREFIX}/$${fname} ${STAGEDIR}${PREFIX}/$${newf}; \
${ECHO_CMD} MOVED:$${fname}:$${newf} >> ${_UNIQUEPKGLIST}; \
- ${_DO_CONDITIONAL_SYMLINK}; \
+ ${_DO_CONDITIONAL_SYMLINK:S/%%EXTRA_EXT%%//g}; \
else \
${ECHO_MSG} "Makefile error: UNIQUE (prefix): $${fname} not found"; \
${FALSE}; \
@@ -134,36 +149,51 @@ move-uniquefiles:
done;
.endif
-.if ${UNIQUE_SUFFIX_FILES} || ${UNIQUE_FIND_SUFFIX_FILES}
+.for sufxtype in ${UNIQUE_SUFFIX_TYPES}
+. if (defined(UNIQUE_${sufxtype}_FILES) && ${UNIQUE_${sufxtype}_FILES}) || \
+ (defined(UNIQUE_FIND_${sufxtype}_FILES) && ${UNIQUE_FIND_${sufxtype}_FILES})
+. if defined(UNIQUE_${sufxtype}_WITH_EXT) && ${UNIQUE_${sufxtype}_WITH_EXT}
+ @${ECHO_MSG} "===> Creating unique files: Move ${sufxtype:S|SUFFIX_||} files needing SUFFIX";
+. else
@${ECHO_MSG} "===> Creating unique files: Move files needing SUFFIX";
-.endif
-.for entry in ${UNIQUE_SUFFIX_FILES}
+. endif
+. endif
+. for entry in ${UNIQUE_${sufxtype}_FILES}
@fname=${entry}; \
+ if [ -n "${UNIQUE_${sufxtype}_EXTRA_EXT}" ]; then \
+ fname=$${fname%${UNIQUE_${sufxtype}_EXTRA_EXT}}; \
+ fi; \
if [ -e ${STAGEDIR}${PREFIX}/$${fname} -o -L ${STAGEDIR}${PREFIX}/$${fname} ]; then \
- newf=$${fname%/*}/$${fname##*/}${UNIQUE_SUFFIX}; \
+ ofname=$${fname##*/}; \
+ newf=$${fname%/*}/$${ofname%${UNIQUE_${sufxtype}_WITH_EXT}}${UNIQUE_SUFFIX}$${ofname#$${ofname%${UNIQUE_${sufxtype}_WITH_EXT}}}; \
${ECHO_MSG} "Move: $${fname} --> $${newf}"; \
${MV} ${STAGEDIR}${PREFIX}/$${fname} ${STAGEDIR}${PREFIX}/$${newf}; \
- ${ECHO_CMD} MOVED:$${fname}:$${newf} >> ${_UNIQUEPKGLIST}; \
- ${_DO_CONDITIONAL_SYMLINK}; \
+ ${ECHO_CMD} MOVED:$${fname}${UNIQUE_${sufxtype}_EXTRA_EXT}:$${newf}${UNIQUE_${sufxtype}_EXTRA_EXT} >> ${_UNIQUEPKGLIST}; \
+ ${_DO_CONDITIONAL_SYMLINK:S/%%EXTRA_EXT%%/${UNIQUE_${sufxtype}_EXTRA_EXT}/g}; \
else \
${ECHO_MSG} "Makefile error: UNIQUE (suffix): $${fname} not found"; \
${FALSE}; \
fi;
-.endfor
-.if ${UNIQUE_FIND_SUFFIX_FILES}
- @for fname in `${UNIQUE_FIND_SUFFIX_FILES}`; do \
+. endfor
+. if defined(UNIQUE_FIND_${sufxtype}_FILES) && ${UNIQUE_FIND_${sufxtype}_FILES}
+ @for fname in `${UNIQUE_FIND_${sufxtype}_FILES}`; do \
+ if [ -n "${UNIQUE_${sufxtype}_EXTRA_EXT}" ]; then \
+ fname=$${fname%${UNIQUE_${sufxtype}_EXTRA_EXT}}; \
+ fi; \
if [ -e ${STAGEDIR}${PREFIX}/$${fname} -o -L ${STAGEDIR}${PREFIX}/$${fname} ]; then \
- newf=$${fname%/*}/$${fname##*/}${UNIQUE_SUFFIX}; \
+ ofname=$${fname##*/}; \
+ newf=$${fname%/*}/$${ofname%${UNIQUE_${sufxtype}_WITH_EXT}}${UNIQUE_SUFFIX}$${ofname#$${ofname%${UNIQUE_${sufxtype}_WITH_EXT}}}; \
${ECHO_MSG} "Move: $${fname} --> $${newf}"; \
${MV} ${STAGEDIR}${PREFIX}/$${fname} ${STAGEDIR}${PREFIX}/$${newf}; \
- ${ECHO_CMD} MOVED:$${fname}:$${newf} >> ${_UNIQUEPKGLIST}; \
- ${_DO_CONDITIONAL_SYMLINK}; \
+ ${ECHO_CMD} MOVED:$${fname}${UNIQUE_${sufxtype}_EXTRA_EXT}:$${newf}${UNIQUE_${sufxtype}_EXTRA_EXT} >> ${_UNIQUEPKGLIST}; \
+ ${_DO_CONDITIONAL_SYMLINK:S/%%EXTRA_EXT%%/${UNIQUE_${sufxtype}_EXTRA_EXT}/g}; \
else \
${ECHO_MSG} "Makefile error: UNIQUE (suffix): $${fname} not found"; \
${FALSE}; \
fi; \
done;
-.endif
+. endif
+.endfor
# Using .if exists(${_UNIQUEPKGPLIST} below instead of the sh test
# does not work in poudriere. It works fine on the CLI, though...