ports/105958: [PATCH]: Mk/bsd.port.mk: Add support for CONF_FILES

Frank J. Laszlo laszlof at FreeBSD.org
Tue Nov 28 16:50:07 UTC 2006

>Number:         105958
>Category:       ports
>Synopsis:       [PATCH]: Mk/bsd.port.mk: Add support for CONF_FILES
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Nov 28 16:50:05 GMT 2006
>Originator:     Frank J. Laszlo
>Release:        FreeBSD 6.0-STABLE i386
System: FreeBSD freefall.freebsd.org 6.0-STABLE FreeBSD 6.0-STABLE #0: Sat Dec 10 03:18:20 UTC 2005 kensmith at freefall.freebsd.org:/usr/obj/usr/src/sys/FREEFALL i386

	The amount of ports that use: "@unexec if cmp -s %D/etc/foo.conf.sample %D/etc/foo.conf; then rm -f %D/foo.conf;
	fi" is getting quite large. I believe its about time that this be handled in a much simpler fashion. I propose
	adding 2 knobs. CONF_FILES and DEF_CONF_SUFFIX. CONF_FILES will contain files, relative to PREFIX, that should
	not be removed if they are modified from the original. Most commonly this is done with config files. We do this
	by comparing the installed .conf file with a .sample (default) version of the same file. DEF_CONF_SUFFIX is the
	suffix to use for the default configuration. In most cases this will be .sample, .dist, -dist, or .default. I
	have set it to .sample by default, as this seems to be the most common. This should not affect any currently
	installed ports, and only serves as a simpler way of get around the previous @unexec command.



--- bsd.port.mk-CONF_FILES.diff begins here ---
Index: bsd.port.mk
RCS file: /home/pcvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.544
diff -u -r1.544 bsd.port.mk
--- bsd.port.mk	30 Sep 2006 19:25:45 -0000	1.544
+++ bsd.port.mk	28 Nov 2006 16:41:48 -0000
@@ -857,6 +857,15 @@
 # MTREE_FILE	- The name of the mtree file.
 #				  Default: /etc/mtree/BSD.x11.dist if USE_X_PREFIX is set,
 #				  /etc/mtree/BSD.local.dist otherwise.
+# CONF_FILES	- This directive should be used to define config files
+#				  installed by a port. The associated default config file should
+#				  also exist and be installed. (DEF_CONF_SUFFIX) Files here are 
+#				  relative to PREFIX. This is the equivalent of:
+#				  @unexec if cmp  -s %D/etc/foo.conf.sample %D/etc/foo.conf; then 
+#				  rm -f %D/etc/foo.conf; fi
+#				- Filename suffix for the default CONF_FILES.
+#				  Default: .sample
 # PLIST_DIRS	- Directories to be added to packing list
 # PLIST_FILES	- Files and symbolic links to be added to packing list
@@ -5419,6 +5428,16 @@
 	@${ECHO_CMD} '@cwd ${PREFIX}' >> ${TMPPLIST}
+.if !defined(DEF_CONF_SUFFIX)
+	DEF_CONF_SUFFIX=       .sample
+.if defined(CONF_FILES)
+	@for i in ${CONF_FILES}; do \
+		${ECHO_CMD} "@unexec if cmp -s %D/$${i}${DEF_CONF_SUFFIX} %D/$${i}; then rm -f %D/$${i}; fi" >> ${TMPPLIST}; \
+		${ECHO_CMD} "@unexec rm -f %D/$${i}${DEF_CONF_SUFFIX}" >> ${TMPPLIST}; \
+	done
 	@for i in $$(${ECHO_CMD} ${__MANPAGES} ${_TMLINKS:M${_PREFIX}*:S|^${_PREFIX}/||} ' ' | ${SED} -E -e 's|man([1-9ln])/([^/ ]+) |cat\1/\2 |g'); do \
 		${ECHO_CMD} "@unexec rm -f %D/$${i%.gz} %D/$${i%.gz}.gz" >> ${TMPPLIST}; \
--- bsd.port.mk-CONF_FILES.diff ends here ---


More information about the freebsd-ports-bugs mailing list