2014-01-11 16:52:34 +00:00
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
# Make files or directories 'unique', by adding a prefix or suffix.
|
|
|
|
#
|
|
|
|
# Feature: uniquefiles
|
|
|
|
# Usage: USES=uniquefiles or USES=uniquefiles:ARGS
|
|
|
|
# Valid ARGS: dirs
|
|
|
|
#
|
|
|
|
# dirs: The port needs a prefix (and only a prefix) based on
|
2014-06-18 07:17:13 +00:00
|
|
|
# UNIQUE_PREFIX for the standard directories
|
|
|
|
# DOCSDIR, EXAMPLESDIR, DATADIR, WWWDIR, ETCDIR
|
2014-01-11 16:52:34 +00:00
|
|
|
#
|
|
|
|
# Variables for ports:
|
|
|
|
#
|
2014-06-18 07:17:13 +00:00
|
|
|
# UNIQUE_PREFIX - The prefix to be used for directories and files.
|
|
|
|
# Default: ${PKGNAMEPREFIX}.
|
2014-01-11 16:52:34 +00:00
|
|
|
# UNIQUE_PREFIX_FILES - A list of files that need to be prefixed.
|
2014-06-18 07:17:13 +00:00
|
|
|
# Default: empty
|
|
|
|
# UNIQUE_SUFFIX - The suffix to be used for files.
|
|
|
|
# Default: ${PKGNAMESUFFIX}.
|
2014-01-11 16:52:34 +00:00
|
|
|
# UNIQUE_SUFFIX_FILES - A list of files that need to be suffixed.
|
2014-06-18 07:17:13 +00:00
|
|
|
# Default: empty
|
2014-01-11 16:52:34 +00:00
|
|
|
#
|
|
|
|
# Variables for the ports framework, but NOT individual ports:
|
|
|
|
#
|
|
|
|
# UNIQUE_DEFAULT_LINKS - When set to "yes", symlinks of the original
|
2014-06-18 07:17:13 +00:00
|
|
|
# filenames are also created pointing to their
|
|
|
|
# UNIQUE_* counterparts.
|
|
|
|
# This is useful for supporting multiple logical
|
|
|
|
# instances from a single physical port, but where
|
|
|
|
# you want to mark only *one* of those instances to
|
|
|
|
# provide original filenames.
|
2014-01-11 16:52:34 +00:00
|
|
|
#
|
2014-06-18 07:17:13 +00:00
|
|
|
# category/py-foo, installed as:
|
2014-01-11 16:52:34 +00:00
|
|
|
#
|
2014-06-18 07:17:13 +00:00
|
|
|
# py27-foo for Python 2.7 (DEFAULT_VERSION)
|
|
|
|
# py33-foo for Python 3.3
|
2014-01-11 16:52:34 +00:00
|
|
|
#
|
2014-06-18 07:17:13 +00:00
|
|
|
# Results in:
|
2014-01-11 16:52:34 +00:00
|
|
|
#
|
2014-06-18 07:17:13 +00:00
|
|
|
# py27-foo
|
|
|
|
# bin/foo-2.7 (UNIQUE_SUFFIX)
|
|
|
|
# bin/foo -> bin/foo-2.7 (symlinked original filename)
|
|
|
|
# py33-foo creates:
|
|
|
|
# bin/foo-3.3 (UNIQUE_SUFFIX)
|
2014-01-11 16:52:34 +00:00
|
|
|
#
|
2014-06-18 07:17:13 +00:00
|
|
|
# Default: no
|
2014-01-11 16:52:34 +00:00
|
|
|
#
|
|
|
|
# UNIQUE_FIND_PREFIX_FILES - A shell command to be executed to find files for
|
2014-06-18 07:17:13 +00:00
|
|
|
# the specific port. This has to return a
|
|
|
|
# list of files to be iterated over.
|
|
|
|
# Default: empty
|
2014-01-11 16:52:34 +00:00
|
|
|
#
|
|
|
|
# UNIQUE_FIND_SUFFIX_FILES - A shell command to be executed to find files for
|
2014-06-18 07:17:13 +00:00
|
|
|
# the specific port. This has to return a
|
|
|
|
# list of files to be iterated over.
|
|
|
|
# Default: empty
|
2014-01-11 16:52:34 +00:00
|
|
|
#
|
2017-12-19 16:23:48 +00:00
|
|
|
# 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.
|
|
|
|
#
|
2014-01-11 16:52:34 +00:00
|
|
|
# NOTE: multiple logical instances are not supported by pkg and the original
|
|
|
|
# pkg_tools at the moment.
|
|
|
|
#
|
2014-03-15 10:31:54 +00:00
|
|
|
# MAINTAINER: portmgr@FreeBSD.org
|
2014-01-11 16:52:34 +00:00
|
|
|
|
|
|
|
.if !defined(_INCLUDE_USES_UNIQUEFILES_MK)
|
|
|
|
_INCLUDE_USES_UNIQUEFILES_MK= yes
|
|
|
|
|
|
|
|
UNIQUE_PREFIX?= ${PKGNAMEPREFIX}
|
|
|
|
UNIQUE_SUFFIX?= ${PKGNAMESUFFIX}
|
2014-06-18 07:17:13 +00:00
|
|
|
UNIQUE_PREFIX_FILES?= # empty
|
|
|
|
UNIQUE_SUFFIX_FILES?= # empty
|
2014-01-11 16:52:34 +00:00
|
|
|
|
2017-12-19 16:23:48 +00:00
|
|
|
UNIQUE_SUFFIX_TYPES+= SUFFIX
|
|
|
|
|
2014-01-11 16:52:34 +00:00
|
|
|
.if ${uniquefiles_ARGS:Mdirs}
|
|
|
|
DOCSDIR= ${PREFIX}/share/doc/${UNIQUE_PREFIX}${PORTNAME}
|
2014-06-18 07:17:13 +00:00
|
|
|
EXAMPLESDIR= ${PREFIX}/share/examples/${UNIQUE_PREFIX}${PORTNAME}
|
2014-01-11 16:52:34 +00:00
|
|
|
DATADIR= ${PREFIX}/share/${UNIQUE_PREFIX}${PORTNAME}
|
|
|
|
WWWDIR= ${PREFIX}/www/${UNIQUE_PREFIX}${PORTNAME}
|
|
|
|
ETCDIR= ${PREFIX}/etc/${UNIQUE_PREFIX}${PORTNAME}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
UNIQUE_DEFAULT_LINKS?= no
|
|
|
|
UNIQUE_FIND_PREFIX_FILES?= # empty
|
|
|
|
UNIQUE_FIND_SUFFIX_FILES?= # empty
|
|
|
|
|
2014-08-07 16:57:00 +00:00
|
|
|
_USES_POST+= uniquefiles
|
|
|
|
.endif # _INCLUDE_USES_UNIQUEFILES_MK
|
|
|
|
|
2014-01-11 16:52:34 +00:00
|
|
|
.if defined(_POSTMKINCLUDED) && !defined(_INCLUDE_USES_UNIQUEFILES_POST_MK)
|
|
|
|
_INCLUDE_USES_UNIQUEFILES_POST_MK= yes
|
|
|
|
|
|
|
|
_UNIQUEPKGLIST= ${WRKDIR}/.PLIST.uniquefiles
|
|
|
|
|
|
|
|
.if ${UNIQUE_DEFAULT_LINKS} == yes
|
|
|
|
_DO_CONDITIONAL_SYMLINK= \
|
2014-02-11 18:37:07 +00:00
|
|
|
if [ ! -e ${STAGEDIR}${PREFIX}/$${fname} -a ! -L ${STAGEDIR}${PREFIX}/$${fname} ]; then \
|
2015-06-02 03:25:00 +00:00
|
|
|
${ECHO_MSG} "Link: @$${fname} --> $${newf}"; \
|
2017-04-20 11:13:37 +00:00
|
|
|
${RLN} ${STAGEDIR}${PREFIX}/$${newf} ${STAGEDIR}${PREFIX}/$${fname}; \
|
2017-12-19 16:23:48 +00:00
|
|
|
${ECHO_CMD} LINKED:$${newf}%%EXTRA_EXT%%:$${fname}%%EXTRA_EXT%% >> ${_UNIQUEPKGLIST}; \
|
2014-01-11 16:52:34 +00:00
|
|
|
fi
|
|
|
|
.else
|
|
|
|
# We are not symlinking the renamed binary.
|
|
|
|
_DO_CONDITIONAL_SYMLINK= ${DO_NADA}
|
|
|
|
.endif
|
|
|
|
|
Rewrite the target ordering code.
The targets now have priority assigned to them, and, when the dependency
ordering magic is done at the end of bsd.port.mk, they are sorted
according to their priority.
This allows USES to add targets easily and have them run whenever they
want without touching bsd.port.mk.
To add a target that runs just before post-configure run, do:
_USES_configure+= 695:my-post-configure
my-post-configure:
do something
To fine tune when the target is ran, look at the values in the *_SEQ
variables at the end of bsd.port.mk, and the other USES.
Allow ports Makefiles to override the priority of targets with the
TARGET_ORDER_OVERRIDE variable. For example, to get post-install
running earlier, (its default is 700) do:
TARGET_ORDER_OVERRIDE= 650:post-install
While there, add options target helpers for the do-* targets when they
exist.
Reviewed by: antoine, bapt
Exp-run by: antoine
Sponsored by: Absolight
Differential Revision: https://reviews.freebsd.org/D3099
2015-08-17 13:31:25 +00:00
|
|
|
_USES_stage+= 775:move-uniquefiles
|
2014-01-11 16:52:34 +00:00
|
|
|
move-uniquefiles:
|
|
|
|
.if ${UNIQUE_PREFIX_FILES} || ${UNIQUE_FIND_PREFIX_FILES}
|
2015-06-02 03:25:00 +00:00
|
|
|
@${ECHO_MSG} "===> Creating unique files: Move files needing PREFIX";
|
2014-01-11 16:52:34 +00:00
|
|
|
.endif
|
|
|
|
.for entry in ${UNIQUE_PREFIX_FILES}
|
|
|
|
@fname=${entry}; \
|
2014-02-11 18:37:07 +00:00
|
|
|
if [ -e ${STAGEDIR}${PREFIX}/$${fname} -o -L ${STAGEDIR}${PREFIX}/$${fname} ]; then \
|
2014-01-11 16:52:34 +00:00
|
|
|
newf=$${fname%/*}/${UNIQUE_PREFIX}$${fname##*/} ; \
|
2015-06-02 03:25:00 +00:00
|
|
|
${ECHO_MSG} "Move: $${fname} --> $${newf}" ; \
|
2014-01-11 16:52:34 +00:00
|
|
|
${MV} ${STAGEDIR}${PREFIX}/$${fname} ${STAGEDIR}${PREFIX}/$${newf}; \
|
|
|
|
${ECHO_CMD} MOVED:$${fname}:$${newf} >> ${_UNIQUEPKGLIST}; \
|
2017-12-19 16:23:48 +00:00
|
|
|
${_DO_CONDITIONAL_SYMLINK:S/%%EXTRA_EXT%%//g}; \
|
2014-01-11 16:52:34 +00:00
|
|
|
else \
|
|
|
|
${ECHO_MSG} "Makefile error: UNIQUE (prefix): $${fname} not found"; \
|
|
|
|
${FALSE}; \
|
|
|
|
fi;
|
|
|
|
.endfor
|
|
|
|
.if ${UNIQUE_FIND_PREFIX_FILES}
|
|
|
|
@for fname in `${UNIQUE_FIND_PREFIX_FILES}`; do \
|
2014-02-11 18:37:07 +00:00
|
|
|
if [ -e ${STAGEDIR}${PREFIX}/$${fname} -o -L ${STAGEDIR}${PREFIX}/$${fname} ]; then \
|
2014-01-11 16:52:34 +00:00
|
|
|
newf=$${fname%/*}/${UNIQUE_PREFIX}$${fname##*/} ; \
|
2015-06-02 03:25:00 +00:00
|
|
|
${ECHO_MSG} "Move: $${fname} --> $${newf}" ; \
|
2014-01-11 16:52:34 +00:00
|
|
|
${MV} ${STAGEDIR}${PREFIX}/$${fname} ${STAGEDIR}${PREFIX}/$${newf}; \
|
|
|
|
${ECHO_CMD} MOVED:$${fname}:$${newf} >> ${_UNIQUEPKGLIST}; \
|
2017-12-19 16:23:48 +00:00
|
|
|
${_DO_CONDITIONAL_SYMLINK:S/%%EXTRA_EXT%%//g}; \
|
2014-01-11 16:52:34 +00:00
|
|
|
else \
|
|
|
|
${ECHO_MSG} "Makefile error: UNIQUE (prefix): $${fname} not found"; \
|
|
|
|
${FALSE}; \
|
|
|
|
fi; \
|
|
|
|
done;
|
|
|
|
.endif
|
|
|
|
|
2017-12-19 16:23:48 +00:00
|
|
|
.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
|
2015-06-02 03:25:00 +00:00
|
|
|
@${ECHO_MSG} "===> Creating unique files: Move files needing SUFFIX";
|
2017-12-19 16:23:48 +00:00
|
|
|
. endif
|
|
|
|
. endif
|
|
|
|
. for entry in ${UNIQUE_${sufxtype}_FILES}
|
2014-01-11 16:52:34 +00:00
|
|
|
@fname=${entry}; \
|
2017-12-19 16:23:48 +00:00
|
|
|
if [ -n "${UNIQUE_${sufxtype}_EXTRA_EXT}" ]; then \
|
|
|
|
fname=$${fname%${UNIQUE_${sufxtype}_EXTRA_EXT}}; \
|
|
|
|
fi; \
|
2014-02-11 18:37:07 +00:00
|
|
|
if [ -e ${STAGEDIR}${PREFIX}/$${fname} -o -L ${STAGEDIR}${PREFIX}/$${fname} ]; then \
|
2017-12-19 16:23:48 +00:00
|
|
|
ofname=$${fname##*/}; \
|
|
|
|
newf=$${fname%/*}/$${ofname%${UNIQUE_${sufxtype}_WITH_EXT}}${UNIQUE_SUFFIX}$${ofname#$${ofname%${UNIQUE_${sufxtype}_WITH_EXT}}}; \
|
2015-06-02 03:25:00 +00:00
|
|
|
${ECHO_MSG} "Move: $${fname} --> $${newf}"; \
|
2014-01-11 16:52:34 +00:00
|
|
|
${MV} ${STAGEDIR}${PREFIX}/$${fname} ${STAGEDIR}${PREFIX}/$${newf}; \
|
2017-12-19 16:23:48 +00:00
|
|
|
${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}; \
|
2014-01-11 16:52:34 +00:00
|
|
|
else \
|
|
|
|
${ECHO_MSG} "Makefile error: UNIQUE (suffix): $${fname} not found"; \
|
|
|
|
${FALSE}; \
|
|
|
|
fi;
|
2017-12-19 16:23:48 +00:00
|
|
|
. 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; \
|
2014-02-11 18:37:07 +00:00
|
|
|
if [ -e ${STAGEDIR}${PREFIX}/$${fname} -o -L ${STAGEDIR}${PREFIX}/$${fname} ]; then \
|
2017-12-19 16:23:48 +00:00
|
|
|
ofname=$${fname##*/}; \
|
|
|
|
newf=$${fname%/*}/$${ofname%${UNIQUE_${sufxtype}_WITH_EXT}}${UNIQUE_SUFFIX}$${ofname#$${ofname%${UNIQUE_${sufxtype}_WITH_EXT}}}; \
|
2015-06-02 03:25:00 +00:00
|
|
|
${ECHO_MSG} "Move: $${fname} --> $${newf}"; \
|
2014-01-11 16:52:34 +00:00
|
|
|
${MV} ${STAGEDIR}${PREFIX}/$${fname} ${STAGEDIR}${PREFIX}/$${newf}; \
|
2017-12-19 16:23:48 +00:00
|
|
|
${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}; \
|
2014-01-11 16:52:34 +00:00
|
|
|
else \
|
|
|
|
${ECHO_MSG} "Makefile error: UNIQUE (suffix): $${fname} not found"; \
|
|
|
|
${FALSE}; \
|
|
|
|
fi; \
|
|
|
|
done;
|
2017-12-19 16:23:48 +00:00
|
|
|
. endif
|
|
|
|
.endfor
|
2014-01-11 16:52:34 +00:00
|
|
|
|
|
|
|
# Using .if exists(${_UNIQUEPKGPLIST} below instead of the sh test
|
|
|
|
# does not work in poudriere. It works fine on the CLI, though...
|
Rewrite the target ordering code.
The targets now have priority assigned to them, and, when the dependency
ordering magic is done at the end of bsd.port.mk, they are sorted
according to their priority.
This allows USES to add targets easily and have them run whenever they
want without touching bsd.port.mk.
To add a target that runs just before post-configure run, do:
_USES_configure+= 695:my-post-configure
my-post-configure:
do something
To fine tune when the target is ran, look at the values in the *_SEQ
variables at the end of bsd.port.mk, and the other USES.
Allow ports Makefiles to override the priority of targets with the
TARGET_ORDER_OVERRIDE variable. For example, to get post-install
running earlier, (its default is 700) do:
TARGET_ORDER_OVERRIDE= 650:post-install
While there, add options target helpers for the do-* targets when they
exist.
Reviewed by: antoine, bapt
Exp-run by: antoine
Sponsored by: Absolight
Differential Revision: https://reviews.freebsd.org/D3099
2015-08-17 13:31:25 +00:00
|
|
|
_USES_stage+= 950:move-uniquefiles-plist
|
2014-01-11 16:52:34 +00:00
|
|
|
move-uniquefiles-plist:
|
|
|
|
@if [ -e ${_UNIQUEPKGLIST} ]; then \
|
|
|
|
orgIFS=$$IFS; IFS=":"; while read command entry newentry; do \
|
|
|
|
IFS=$$orgIFS; \
|
|
|
|
case $${command} in \
|
|
|
|
MOVED) \
|
|
|
|
${REINPLACE_CMD} -e "s|^$${entry}$$|$${newentry}|" ${TMPPLIST}; \
|
|
|
|
;; \
|
|
|
|
LINKED) \
|
|
|
|
${AWK} '$$0 ~ pe { print; print ne ;next }1' \
|
|
|
|
pe="$${entry}" ne="$${newentry}" \
|
|
|
|
${TMPPLIST} > ${TMPPLIST}.uniquefilestmp; \
|
|
|
|
${MV} ${TMPPLIST}.uniquefilestmp ${TMPPLIST}; \
|
|
|
|
;; \
|
|
|
|
*) ;; \
|
|
|
|
esac; \
|
|
|
|
IFS=":"; \
|
|
|
|
done < ${_UNIQUEPKGLIST}; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
.endif # defined(_POSTMKINCLUDED)
|