ports/90436: [bsd.port.mk] Add a way to handle configuration files

Florent Thoumie flz at xbsd.org
Thu Dec 15 15:10:06 UTC 2005


>Number:         90436
>Category:       ports
>Synopsis:       [bsd.port.mk] Add a way to handle configuration files
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec 15 15:10:02 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Florent Thoumie
>Release:        FreeBSD 6.0-RELEASE amd64
>Organization:
Xbsd.org
>Environment:
System: FreeBSD cream.xbsd.org 6.0-RELEASE FreeBSD 6.0-RELEASE #4: Mon Dec 5 02:31:46 UTC 2005 root at cream.xbsd.org:/usr/src/sys/amd64/compile/CREAM amd64


	
>Description:

Install configuration files from samples. Removes some ugly @exec/@unexec lines
from packing lists. Make sure that these files are created both by ports and
packages.

Introduces two new variables :

- CONF_FILES : files to be created, relative to ${PREFIX}. (default: empty)
- CONF_SUFX : configuration files samples suffix. (default: .sample)

Just make sure that foo.conf.sample gets installed in ${PREFIX}/etc/foo/
and set CONF_FILES= etc/foo/foo.conf.

>How-To-Repeat:
	
>Fix:

	

--- conf_files.diff begins here ---
--- /usr/ports/Mk/bsd.port.mk.orig	Thu Dec 15 13:50:25 2005
+++ /usr/ports/Mk/bsd.port.mk	Thu Dec 15 14:07:14 2005
@@ -1529,6 +1529,10 @@
 .endif
 .endif
 
+.if defined(CONF_FILES)
+CONF_SUFX?=	.sample
+.endif
+
 .if defined(USE_ICONV)
 LIB_DEPENDS+=	iconv.3:${PORTSDIR}/converters/libiconv
 .endif
@@ -3703,8 +3707,8 @@
 _INSTALL_SUSEQ= check-umask install-mtree pre-su-install \
 				pre-su-install-script do-install install-desktop-entries \
 				post-install post-install-script add-plist-info \
-				add-plist-docs add-plist-post install-rc-script compress-man \
-				run-ldconfig fake-pkg security-check
+				add-plist-docs add-plist-post install-rc-script install-conf \
+				compress-man run-ldconfig fake-pkg security-check
 _PACKAGE_DEP=	install
 _PACKAGE_SEQ=	package-message pre-package pre-package-script \
 				do-package post-package-script
@@ -4832,6 +4836,11 @@
 	@${MKDIR} `${DIRNAME} ${TMPPLIST}`
 	@if [ ! -f ${DESCR} ]; then ${ECHO_CMD} "** Missing pkg-descr for ${PKGNAME}."; exit 1; fi
 	@>${TMPPLIST}
+.if defined(CONF_FILES)
+.for conf in ${CONF_FILES}
+	@${ECHO_CMD} "@unexec if cmp -s %D/${conf} %D/${conf}${CONF_SUFX}; then rm %D/${conf}; fi" >> ${TMPPLIST}
+.endfor
+.endif
 	@for file in ${PLIST_FILES}; do \
 		${ECHO_CMD} $${file} | ${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} >> ${TMPPLIST}; \
 	done
@@ -4957,6 +4966,20 @@
 		${ECHO_CMD} "etc/rc.d/$${i%.sh}.sh" >> ${TMPPLIST}; \
 	done
 .endif
+.else
+	@${DO_NADA}
+.endif
+.endif
+
+.if !target(install-conf)
+install-conf:
+.if defined(CONF_FILES)
+	@${ECHO_CMD} "===> Installing configuration file(s)"
+	@${ECHO_CMD} "@cwd ${PREFIX}" >> ${TMPPLIST}
+.for conf in ${CONF_FILES}
+	${INSTALL_DATA} ${PREFIX}/${conf}${CONF_SUFX} ${PREFIX}/${conf}
+	@${ECHO_CMD} "@exec [ -f %D/${conf} ] || cp %D/${conf}${CONF_SUFX} %D/${conf}" >> ${TMPPLIST}
+.endfor
 .else
 	@${DO_NADA}
 .endif
--- conf_files.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list