Index: bsd.port.mk =================================================================== RCS file: /exports/cvsroot-freebsd/ports/Mk/bsd.port.mk,v retrieving revision 1.686 diff -u -r1.686 bsd.port.mk --- bsd.port.mk 9 Jun 2011 08:22:45 -0000 1.686 +++ bsd.port.mk 30 Jun 2011 08:49:18 -0000 @@ -631,6 +631,8 @@ # INSTALL_DATA - A command to install sharable data. # INSTALL_MAN - A command to install manpages. May or not compress, # depending on the value of MANCOMPRESSED (see below). +# INSTALL_CONF - A command to install configuration files. Not normally called +# by ports directly, use CONF_FILES (see below). # # Boolean to control whether manpages are installed. # @@ -687,6 +689,18 @@ # Default: "share/info" if ${PREFIX} is equal to /usr # and "info" otherwise. # +# Set the following to specify all conf files your port installs. +# +# CONF_FILES - A list of configuration files that have been installed as +# sample files (with the extension .pkgconf), relative to +# PREFIX. Shell glob patterns can be used, directories include +# the entire subtree of contained files with these +# extensions and directories. +# Files included will be copied over if not already existing, +# and will be removed on deinstall if the same as the .pkgconf +# files. +# Useful for large numbers of configuration files. +# # Set the following to specify all documentation your port installs into # ${DOCSDIR} # @@ -2416,12 +2430,20 @@ _BINOWNGRP= -o ${BINOWN} -g ${BINGRP} _SHROWNGRP= -o ${SHAREOWN} -g ${SHAREGRP} _MANOWNGRP= -o ${MANOWN} -g ${MANGRP} +_CONFOWNGRP= -o ${CONFOWN} -g ${CONFGRP} .else _BINOWNGRP= _SHROWNGRP= _MANOWNGRP= +_CONFOWNGRP= .endif +# CONF* macros are only defined in recent versions; these +# lines can be removed once 8.2-RELEASE is no longer supported. +CONFOWN?= root +CONFGRP?= wheel +CONFMODE?= 644 + # A few aliases for *-install targets INSTALL_PROGRAM= \ ${INSTALL} ${COPY} ${STRIP} ${_BINOWNGRP} -m ${BINMODE} @@ -2435,6 +2457,8 @@ ${INSTALL} ${COPY} ${_SHROWNGRP} -m ${SHAREMODE} INSTALL_MAN= \ ${INSTALL} ${COPY} ${_MANOWNGRP} -m ${MANMODE} +INSTALL_CONF= \ + ${INSTALL} ${COPY} ${_CONFOWNGRP} -m ${CONFMODE} INSTALL_MACROS= BSD_INSTALL_PROGRAM="${INSTALL_PROGRAM}" \ BSD_INSTALL_LIB="${INSTALL_LIB}" \ @@ -4463,10 +4487,10 @@ pre-install-script generate-plist check-already-installed _INSTALL_SUSEQ= check-umask install-mtree pre-su-install \ pre-su-install-script create-users-groups do-install \ - install-desktop-entries install-license install-rc-script \ - post-install post-install-script add-plist-info \ - add-plist-docs add-plist-examples add-plist-data \ - add-plist-post fix-plist-sequence compress-man \ + install-desktop-entries install-license install-conf-files \ + install-rc-script post-install post-install-script \ + add-plist-info add-plist-docs add-plist-examples \ + add-plist-data add-plist-post fix-plist-sequence compress-man \ install-ldconfig-file fake-pkg security-check _PACKAGE_DEP= install _PACKAGE_SEQ= package-message pre-package pre-package-script \ @@ -5968,6 +5992,46 @@ .endif .endif +.if !target(install-conf-files) +install-conf-files: +. if defined(CONF_FILES) + @${ECHO_MSG} "===> Installing configuration file(s)" + @if ${EGREP} -qe '^@cw?d' ${TMPPLIST} && \ + [ "`${SED} -En -e '/^@cw?d[ ]*/s,,,p' ${TMPPLIST} | ${TAIL} -n 1`" != "${PREFIX}" ]; then \ + ${ECHO_CMD} "@cwd " >> ${TMPPLIST}; \ + fi +. for confs in ${CONF_FILES} + @if ${ECHO_CMD} "${confs}"| ${AWK} '$$1 ~ /(\*|\||\[|\]|\?|\{|\}|\$$)/ { exit 1 };'; then \ + if [ ! -e ${PREFIX}/${confs} ] ; then \ + ${ECHO_CMD} "@unexec cmp -s %D/${confs}.pkgconf %D/${confs} \ + && ${RM} -f %D/${confs} || true" >> ${TMPPLIST} ; \ + ${ECHO_CMD} ${confs}.pkgconf >> ${TMPPLIST} ; \ + ${ECHO_CMD} "@exec [ -f %D/${confs} ] \ + || ${INSTALL_CONF} %D/%F %D/${confs}" \ + >> ${TMPPLIST} ; \ + [ -f ${PREFIX}/${confs} ] \ + || ${INSTALL_CONF} ${PREFIX}/${confs}.pkgconf \ + ${PREFIX}/${confs} ; \ + fi ; \ + fi +. endfor + @for confs in $$( cd ${PREFIX} && ${FIND} -P ${CONF_FILES} ! -type d -and -name *.pkgconf 2>/dev/null ) ; \ + do ${ECHO_CMD} "@unexec cmp -s %D/$${confs} %D/$${confs%.pkgconf} \ + && ${RM} -f %D/$${confs%.pkgconf} || true" >> ${TMPPLIST} ; \ + ${ECHO_CMD} $${confs} >> ${TMPPLIST} ; \ + ${ECHO_CMD} "@exec [ -f %D/$${confs%.pkgconf} ] \ + || ${INSTALL_CONF} %D/%F %D/$${confs%.pkgconf}" >> ${TMPPLIST} ; \ + [ -f ${PREFIX}/$${confs%.pkgconf} ] \ + || ${INSTALL_CONF} ${PREFIX}/$${confs} ${PREFIX}/$${confs%.pkgconf} ; \ + done + @${FIND} -P -d ${CONF_FILES:S/^/${PREFIX}\//} -type d 2>/dev/null | \ + ${SED} -ne 's,^.*$$,@unexec rmdir & 2>/dev/null || true,p' \ + >> ${TMPPLIST} +. else + ${DO_NADA} +. endif +.endif + .if !target(install-rc-script) install-rc-script: .if defined(USE_RCORDER) || defined(USE_RC_SUBR) && ${USE_RC_SUBR:U} != "YES"