Date: Fri, 24 Dec 2004 12:45:14 +0100 (CET) From: dirk.meyer@dinoex.sub.org To: FreeBSD-gnats-submit@FreeBSD.org Subject: ports/75464: bsd.port.mk install default configuration files Message-ID: <200412241145.iBOBjEJh068541@home.dinoex.sub.de> Resent-Message-ID: <200412241150.iBOBoJVu007973@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 75464 >Category: ports >Synopsis: bsd.port.mk install default configuration files >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Dec 24 11:50:19 GMT 2004 >Closed-Date: >Last-Modified: >Originator: Dirk Meyer >Release: FreeBSD 4.11-PRERELEASE i386 >Organization: privat >Environment: FreeBSD ports >Description: - add new features: PORTEXAMPLES, similar to PORTDOCS ETC_DEFAULT_FILES for default configuration files >How-To-Repeat: Install all sample files not in etc, but in /usr/local/share/examples/<portname>/default/ eg in the apache13-modssl port you like to specify: ETC_DEFAULT_FILES = \ apache/access.conf apache/httpd.conf \ apache/magic apache/mime.types \ apache/srm.conf \ rc.d/apache.sh bsd.port.mk will handle: - the pkg-plist entrys for the samples - the installation when the coresponding files in /usr/local/etc/ does not exist. - the deinstalltion check, preserving existing configuration files. - create and removal of subdirectories. >Fix: apply this patch: Index: bsd.port.mk =================================================================== RCS file: /home/pcvs/ports/Mk/bsd.port.mk,v retrieving revision 1.502 diff -u -r1.502 bsd.port.mk --- bsd.port.mk 23 Dec 2004 01:35:38 -0000 1.502 +++ bsd.port.mk 24 Dec 2004 11:34:10 -0000 @@ -553,6 +553,28 @@ # installed (for example because NOPORTDOCS is defined). # Useful for dynamically generated documentation. # +# Set the following to specify all documentation your port installs into +# ${EXAMPLESDIR} +# +# PORTEXAMPLES - A list of files and directories relative to EXAMPLESDIR. +# Shell glob patterns can be used, directories include +# the entire subtree of contained files and directories. +# Useful for dynamically generated examples. +# +# ETC_DEFAULT_DIR - A directory relative to EXAMPLESDIR, which contains +# default configuration files. +# Default: "default" +# +# ETC_TARGET_DIR - A directory relative to PREFIX, which contains +# configuration files for this port at runtime +# Default: "etc" +# +# ETC_DEFAULT_FILES - A list of files that are installed relative to +# ETC_DEFAULT_DIR, to create a default configuration +# when this config file is not present in +# ETC_TARGET_DIR. This files are removed on deinstall +# only when they have not beenn altered. +# # Default targets and their behaviors: # # fetch - Retrieves ${DISTFILES} (and ${PATCHFILES} if defined) @@ -3645,7 +3667,8 @@ _INSTALL_SUSEQ= check-umask install-mtree pre-su-install \ pre-su-install-script do-install post-install \ post-install-script add-plist-info add-plist-docs \ - add-plist-post compress-man run-ldconfig fake-pkg security-check + add-plist-examples add-plist-post compress-man \ + fake-pkg security-check _PACKAGE_DEP= install _PACKAGE_SEQ= package-message pre-package pre-package-script \ do-package post-package-script @@ -4758,6 +4781,57 @@ .endif .endif +add-plist-docs: add-plist-examples + +.if !target(add-plist-examples) +add-plist-examples: +.if defined(PORTEXAMPLES) + @if ${EGREP} -qe '^@cw?d' ${TMPPLIST} && \ + [ "`${SED} -En -e '/^@cw?d[ ]*/s,,,p' ${TMPPLIST} | ${TAIL} -n 1`" != "${PREFIX}" ]; then \ + ${ECHO_CMD} "@cwd ${PREFIX}" >> ${TMPPLIST}; \ + fi +.if defined(ETC_DEFAULT_FILES) + @${FIND} -P ${ETC_DEFAULT_FILES:S/^/${EXAMPLESDIR_ETC}\//} ! -type d | \ + while read sample; do \ + src="%D/$${sample#${PREFIX}/}"; \ + dst="%D/${ETC_TARGET_DIR}$${sample#${EXAMPLESDIR_ETC}}"; \ + echo '@unexec if cmp -s "'$${dst}'" "'$${src}'"; then rm -f "'$${dst}'"; else echo "preserving '$${dst}'" >&2; fi';\ + done >> ${TMPPLIST} +.endif + @${FIND} -P ${PORTEXAMPLES:S/^/${EXAMPLESDIR}\//} ! -type d | \ + ${SED} -ne 's,^${PREFIX}/,,p' >> ${TMPPLIST} +.if defined(ETC_DEFAULT_FILES) + @${FIND} -P -d ${EXAMPLESDIR_ETC} -type d | \ + while read dir; do \ + dst="${ETC_TARGET_DIR}$${dir#${EXAMPLESDIR_ETC}}"; \ + etc="${ETC_DEFAULT_DIR}"; \ + if [ "$${#dst}" -gt "$${#etc}" ]; then echo '@exec mkdir -p "'$${dst}'"'; fi; \ + done >> ${TMPPLIST} + @${FIND} -P ${ETC_DEFAULT_FILES:S/^/${EXAMPLESDIR_ETC}\//} ! -type d | \ + while read sample; do \ + src="%D/$${sample#${PREFIX}/}"; \ + dst="%D/${ETC_TARGET_DIR}$${sample#${EXAMPLESDIR_ETC}}"; \ + echo '@exec [ ! -f "'$${dst}'" ] && cp "'$${src}'" "'$${dst}'"';\ + done >> ${TMPPLIST} + @${FIND} -P -d ${EXAMPLESDIR_ETC} -type d | \ + while read dir; do \ + dst="${ETC_TARGET_DIR}$${dir#${EXAMPLESDIR_ETC}}"; \ + etc="${ETC_DEFAULT_DIR}"; \ + if [ "$${#dst}" -gt "$${#etc}" ]; then echo "@unexec rmdir %D/$${dst} 2>/dev/null || true"; fi; \ + dst="$${dir#${PREFIX}/}"; \ + echo "@dirrm $${dst}"; \ + done >> ${TMPPLIST} +.endif + @${FIND} -P -d ${PORTEXAMPLES:S/^/${EXAMPLESDIR}\//} -type d | \ + ${SED} -ne 's,^${PREFIX}/,@dirrm ,p' >> ${TMPPLIST} + @if [ -d "${EXAMPLESDIR}" ]; then \ + ${ECHO_CMD} "@unexec rmdir %D/${EXAMPLESDIR:S,^${PREFIX}/,,} 2>/dev/null || true" >> ${TMPPLIST}; \ + fi +.else + @${DO_NADA} +.endif +.endif + # If we're installing into a non-standard PREFIX, we need to remove that directory at # deinstall-time add-plist-post: >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200412241145.iBOBjEJh068541>