ports/123185: [PATCH]: Mk/bsd.port.mk - Add extended description to OPTIONS

Wesley Shields wxs at FreeBSD.org
Tue Apr 29 03:00:10 UTC 2008


>Number:         123185
>Category:       ports
>Synopsis:       [PATCH]: Mk/bsd.port.mk - Add extended description to OPTIONS
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Apr 29 03:00:09 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Wesley Shields
>Release:        FreeBSD 7.0-RELEASE amd64
>Organization:
>Environment:
System: FreeBSD syn.csh.rit.edu 7.0-RELEASE FreeBSD 7.0-RELEASE #0: Tue Mar 18 20:07:25 EDT 2008 root at syn.csh.rit.edu:/usr/obj/usr/src/sys/GENERIC amd64

>Description:
Based upon a suggestion in [1] I have extended the OPTIONS framework to
support a more detailed description of the options.  I implemented it in
two different ways:

1: Extended the OPTIONS from 3 fields to 4 and add a OPTIONS_DESC knob
that _must_ be turned on when the port is using the 4th field.  This is
because it's impossible to tell between 3 options with the long field
(12 fields total) or 4 options without the long field (also 12 options
total).  While I personally think this approach is a cleaner solution it
does come with an "all-or-nothing" penalty.  A port must support long
descriptions for all of it's options or none at all.

2. Support the addition of OPTION_DESC_FOO for the long description.
While this may not be as clean of a solution (in both the Makefile and
in efficiency of processing - I have to spawn another make process) it
does not have the "all-or-nothing" penalty like the other version.

Personally, I can't decide which solution I like more so I'm sending
them both in.  Part of me likes the efficiency of the first solution
while part of me likes the ability to pick and choose which ones get a
long description in the second one.  I'll leave the ultimate choice up
to portmgr.  :)

If either option is chosen I will happily write up the necessary changes
for the Porter's Handbook.  If either option is interesting but needs
more work I will also be happy to adjust as necessary.

[1]:
http://lists.freebsd.org/pipermail/freebsd-ports/2008-March/047656.html

>How-To-Repeat:
N/A

>Fix:

--- patch-options-desc.diff begins here ---
Index: bsd.port.mk
===================================================================
RCS file: /home/ncvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.592
diff -u -u -r1.592 bsd.port.mk
--- bsd.port.mk	14 Apr 2008 16:46:41 -0000	1.592
+++ bsd.port.mk	29 Apr 2008 02:17:14 -0000
@@ -1234,6 +1234,7 @@
 .else
 UNIQUENAME?=	${PKGNAMEPREFIX}${PORTNAME}
 .endif
+OPTIONSDESCFILE?=	${PORT_DBDIR}/${UNIQUENAME}/options.descr
 OPTIONSFILE?=	${PORT_DBDIR}/${UNIQUENAME}/options
 _OPTIONSFILE!=	${ECHO_CMD} "${OPTIONSFILE}"
 .if defined(OPTIONS)
@@ -5783,6 +5784,7 @@
 		. ${_OPTIONSFILE}; \
 	fi; \
 	set -- ${OPTIONS} XXX; \
+	TMPOPTIONSDESCFILE=$$(mktemp -t portoptionsdescr); \
 	while [ $$# -gt 3 ]; do \
 		OPTIONSLIST="$${OPTIONSLIST} $$1"; \
 		defaultval=$$3; \
@@ -5798,14 +5800,21 @@
 			val=$$3; \
 		fi; \
 		DEFOPTIONS="$${DEFOPTIONS} $$1 \"$$2\" $${val}"; \
-		shift 3; \
+		if [ -n "${OPTIONS_DESC}" ]; then \
+			${ECHO_CMD} "$$1: $$4" | fmt >> $${TMPOPTIONSDESCFILE}; \
+			shift 4; \
+		else \
+			${ECHO_CMD} "$$1: $$2 [NO EXTENDED DESCRIPTION]" | fmt >> $${TMPOPTIONSDESCFILE}; \
+			shift 3; \
+		fi; \
 	done; \
 	TMPOPTIONSFILE=$$(mktemp -t portoptions); \
-	trap "${RM} -f $${TMPOPTIONSFILE}; exit 1" 1 2 3 5 10 13 15; \
-	${SH} -c "${DIALOG} --checklist \"Options for ${PKGNAME:C/-([^-]+)$/ \1/}\" 21 70 15 $${DEFOPTIONS} 2> $${TMPOPTIONSFILE}"; \
+	trap "${RM} -f $${TMPOPTIONSFILE}; ${RM} -f $${TMPOPTIONSDESCFILE}; exit 1" 1 2 3 5 10 13 15; \
+	${SH} -c "${DIALOG} --hfile $${TMPOPTIONSDESCFILE} --hline \"Press ? for a detailed description\" --checklist \"Options for ${PKGNAME:C/-([^-]+)$/ \1/}\" 21 70 15 $${DEFOPTIONS} 2> $${TMPOPTIONSFILE}"; \
 	status=$$?; \
 	if [ $${status} -ne 0 ] ; then \
 		${RM} -f $${TMPOPTIONSFILE}; \
+		${RM} -f $${TMPOPTIONSDESCFILE}; \
 		${ECHO_MSG} "===> Options unchanged"; \
 		exit 0; \
 	fi; \
@@ -5832,11 +5841,14 @@
 	if [ `${ID} -u` != 0 -a "x${INSTALL_AS_USER}" = "x" ]; then \
 		${ECHO_MSG} "===>  Switching to root credentials to write ${_OPTIONSFILE}"; \
 		${SU_CMD} "${CAT} $${TMPOPTIONSFILE} > ${_OPTIONSFILE}"; \
+		${SU_CMD} "${CAT} $${TMPOPTIONSDESCFILE} > ${OPTIONSDESCFILE}"; \
 		${ECHO_MSG} "===>  Returning to user credentials"; \
 	else \
 		${CAT} $${TMPOPTIONSFILE} > ${_OPTIONSFILE}; \
+		${CAT} $${TMPOPTIONSDESCFILE} > ${OPTIONSDESCFILE}; \
 	fi; \
-	${RM} -f $${TMPOPTIONSFILE}
+	${RM} -f $${TMPOPTIONSFILE}; \
+	${RM} -f $${TMPOPTIONSDESCFILE}
 .endif
 .endif
 
@@ -5870,7 +5882,11 @@
 		if [ "$${val}" = "missing" ]; then \
 			OPTIONS_INVALID=yes; \
 		fi; \
-		shift 3; \
+		if [ -n "${OPTIONS_DESC}" ]; then \
+			shift 4; \
+		else \
+			shift 3; \
+		fi; \
 	done; \
 	if [ "$${OPTIONS_INVALID}" = "yes" ]; then \
 		cd ${.CURDIR} && ${MAKE} config; \
@@ -5902,8 +5918,13 @@
 		else \
 			val="$$3 (default)"; \
 		fi; \
-		${ECHO_MSG} "     $$1=$${val} \"$$2\""; \
-		shift 3; \
+		if [ -n "${OPTIONS_DESC}" ]; then \
+			${ECHO_CMD} "     $$1=$${val} \"$$2\" ($$4)" | fmt; \
+			shift 4; \
+		else \
+			${ECHO_MSG} "     $$1=$${val} \"$$2\""; \
+			shift 3; \
+		fi; \
 	done
 	@${ECHO_MSG} "===> Use 'make config' to modify these settings"
 .endif
@@ -5911,16 +5932,17 @@
 
 .if !target(rmconfig)
 rmconfig:
-.if defined(OPTIONS) && exists(${_OPTIONSFILE})
+.if defined(OPTIONS) && (exists(${_OPTIONSFILE}) || exists(${OPTIONSDESCFILE}))
 	-@${ECHO_MSG} "===> Removing user-configured options for ${PKGNAME}"; \
 	optionsdir=${_OPTIONSFILE}; optionsdir=$${optionsdir%/*}; \
 	if [ `${ID} -u` != 0 -a "x${INSTALL_AS_USER}" = "x" ]; then \
 		${ECHO_MSG} "===> Switching to root credentials to remove ${_OPTIONSFILE} and $${optionsdir}"; \
-		${SU_CMD} "${RM} -f ${_OPTIONSFILE} ; \
+		${SU_CMD} "${RM} -f ${_OPTIONSFILE} ${OPTIONSDESCFILE}; \
 			${RMDIR} $${optionsdir}"; \
 		${ECHO_MSG} "===> Returning to user credentials"; \
 	else \
 		${RM} -f ${_OPTIONSFILE}; \
+		${RM} -f ${OPTIONSDESCFILE}; \
 		${RMDIR} $${optionsdir}; \
 	fi
 .else
--- patch-options-desc.diff ends here ---


--- patch-options-desc-2.diff begins here ---
Index: bsd.port.mk
===================================================================
RCS file: /home/ncvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.592
diff -u -u -r1.592 bsd.port.mk
--- bsd.port.mk	14 Apr 2008 16:46:41 -0000	1.592
+++ bsd.port.mk	29 Apr 2008 02:37:19 -0000
@@ -1234,6 +1234,7 @@
 .else
 UNIQUENAME?=	${PKGNAMEPREFIX}${PORTNAME}
 .endif
+OPTIONSDESCFILE?=	${PORT_DBDIR}/${UNIQUENAME}/options.descr
 OPTIONSFILE?=	${PORT_DBDIR}/${UNIQUENAME}/options
 _OPTIONSFILE!=	${ECHO_CMD} "${OPTIONSFILE}"
 .if defined(OPTIONS)
@@ -5783,6 +5784,7 @@
 		. ${_OPTIONSFILE}; \
 	fi; \
 	set -- ${OPTIONS} XXX; \
+	TMPOPTIONSDESCFILE=$$(mktemp -t portoptionsdescr); \
 	while [ $$# -gt 3 ]; do \
 		OPTIONSLIST="$${OPTIONSLIST} $$1"; \
 		defaultval=$$3; \
@@ -5798,14 +5800,21 @@
 			val=$$3; \
 		fi; \
 		DEFOPTIONS="$${DEFOPTIONS} $$1 \"$$2\" $${val}"; \
+		LONGDESC=$$(cd ${.CURDIR} && ${MAKE} ${__softMAKEFLAGS} -V OPTION_DESC_$$1); \
+		if [ "x$${LONGDESC}" = "x" ]; then \
+			${ECHO_CMD} "$$1: $$2 [NO EXTENDED DESCRIPTION]" | fmt >> $${TMPOPTIONSDESCFILE}; \
+		else \
+			${ECHO_CMD} $$1: $${LONGDESC} | fmt >> $${TMPOPTIONSDESCFILE}; \
+		fi; \
 		shift 3; \
 	done; \
 	TMPOPTIONSFILE=$$(mktemp -t portoptions); \
-	trap "${RM} -f $${TMPOPTIONSFILE}; exit 1" 1 2 3 5 10 13 15; \
-	${SH} -c "${DIALOG} --checklist \"Options for ${PKGNAME:C/-([^-]+)$/ \1/}\" 21 70 15 $${DEFOPTIONS} 2> $${TMPOPTIONSFILE}"; \
+	trap "${RM} -f $${TMPOPTIONSFILE}; ${RM} -f $${TMPOPTIONSDESCFILE}; exit 1" 1 2 3 5 10 13 15; \
+	${SH} -c "${DIALOG} --hfile $${TMPOPTIONSDESCFILE} --hline \"Press ? for a detailed description\" --checklist \"Options for ${PKGNAME:C/-([^-]+)$/ \1/}\" 21 70 15 $${DEFOPTIONS} 2> $${TMPOPTIONSFILE}"; \
 	status=$$?; \
 	if [ $${status} -ne 0 ] ; then \
 		${RM} -f $${TMPOPTIONSFILE}; \
+		${RM} -f $${TMPOPTIONSDESCFILE}; \
 		${ECHO_MSG} "===> Options unchanged"; \
 		exit 0; \
 	fi; \
@@ -5832,11 +5841,14 @@
 	if [ `${ID} -u` != 0 -a "x${INSTALL_AS_USER}" = "x" ]; then \
 		${ECHO_MSG} "===>  Switching to root credentials to write ${_OPTIONSFILE}"; \
 		${SU_CMD} "${CAT} $${TMPOPTIONSFILE} > ${_OPTIONSFILE}"; \
+		${SU_CMD} "${CAT} $${TMPOPTIONSDESCFILE} > ${OPTIONSDESCFILE}"; \
 		${ECHO_MSG} "===>  Returning to user credentials"; \
 	else \
 		${CAT} $${TMPOPTIONSFILE} > ${_OPTIONSFILE}; \
+		${CAT} $${TMPOPTIONSDESCFILE} > ${OPTIONSDESCFILE}; \
 	fi; \
-	${RM} -f $${TMPOPTIONSFILE}
+	${RM} -f $${TMPOPTIONSFILE}; \
+	${RM} -f $${TMPOPTIONSDESCFILE}
 .endif
 .endif
 
@@ -5916,11 +5928,12 @@
 	optionsdir=${_OPTIONSFILE}; optionsdir=$${optionsdir%/*}; \
 	if [ `${ID} -u` != 0 -a "x${INSTALL_AS_USER}" = "x" ]; then \
 		${ECHO_MSG} "===> Switching to root credentials to remove ${_OPTIONSFILE} and $${optionsdir}"; \
-		${SU_CMD} "${RM} -f ${_OPTIONSFILE} ; \
+		${SU_CMD} "${RM} -f ${_OPTIONSFILE} ${OPTIONSDESCFILE}; \
 			${RMDIR} $${optionsdir}"; \
 		${ECHO_MSG} "===> Returning to user credentials"; \
 	else \
 		${RM} -f ${_OPTIONSFILE}; \
+		${RM} -f ${OPTIONSDESCFILE}; \
 		${RMDIR} $${optionsdir}; \
 	fi
 .else
--- patch-options-desc-2.diff ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list