Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Apr 2008 13:23:14 -0400
From:      Wesley Shields <wxs@FreeBSD.org>
To:        Pav Lucistnik <pav@FreeBSD.org>
Cc:        ports@FreeBSD.org
Subject:   Re: There is no way to know what port options mean (in general)
Message-ID:  <20080401172314.GA42650@atarininja.org>
In-Reply-To: <1206662285.3500.4.camel@ikaros.oook.cz>
References:  <20080326053328.GA29448@duncan.reilly.home> <20080326093858.GA78756@eos.sc1.parodius.com> <20080326133611.GD23226@atarininja.org> <20080326141048.M53995@FreeBSD.org> <20080326141829.GE23226@atarininja.org> <1206541372.78560.60.camel@pav.hide.vol.cz> <20080327195819.GB56935@atarininja.org> <1206662285.3500.4.camel@ikaros.oook.cz>

next in thread | previous in thread | raw e-mail | index | archive | help

--SUOF0GtieIMvvwua
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Fri, Mar 28, 2008 at 12:58:05AM +0100, Pav Lucistnik wrote:
> Wesley Shields p??e v ?t 27. 03. 2008 v 15:58 -0400:
> 
> > > I can see it already! :) Can you code it?
> > 
> > As a first pass I've got an almost working skeleton which uses --hfile
> > and pulls the descriptions from OPTIONS variable (using a 4th field).
> > 
> > It also adds --hline "Please use ? for a detailed description" to the
> > dialog call.
> 
> Cool.
> 
> > It's not quite what you were expecting but I'm not sure how to make
> > dialog show two windows at once - admittedly I have not looked too hard
> > at that.
> 
> It might not be possible with existing dialog(1). Anyway, thanks for the
> effort, I'm looking forward to nexxt week for a final patch.

I've attached a first draft (barely tested, I'm more interested in what
you think of the ideas used - specifically OPTIONS_DESC).

I had to implement an OPTIONS_DESC knob that should be set per-port as
the 4th field is added.  This is necessary because it's impossible to
tell the difference between 3 OPTIONS with a long description (12
fields) or 4 OPTIONS without a long description (12 fields).  I've done
some basic testing but intend to clean it up and properly document - in
both bsd.port.mk and the Porter's Handbook - the additions, assuming the
approach I'm using is liked by the community.

The idea is that OPTIONS goes from:
	NAME "Short Description" Status
to a 4 field format:
	NAME  "Short Description" Status "Long Description, probably
	documenting the immediate dependencies and implications of the knob"

With the addition of the 4th field the OPTIONS_DESC variable must be
set, or everything related to OPTIONS will break.  Eventually, as ports
switch to this format the OPTIONS_DESC knob can be removed and made the
default format of 4 fields.

Once a port uses the extended format the dialog screen supports using
'?' or F1 to view the long descriptions.

I've changed the following targets:
config
config-conditional
showconfig
rmconfig

If I've missed anything please let me know.

-- WXS

--SUOF0GtieIMvvwua
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="options-desc.diff"

Index: bsd.port.mk
===================================================================
RCS file: /home/ncvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.591
diff -u -u -r1.591 bsd.port.mk
--- bsd.port.mk	11 Mar 2008 23:45:04 -0000	1.591
+++ bsd.port.mk	1 Apr 2008 17:04:57 -0000
@@ -1229,6 +1229,7 @@
 .else
 UNIQUENAME?=	${PKGNAMEPREFIX}${PORTNAME}
 .endif
+OPTIONSDESCFILE?=	${PORT_DBDIR}/${UNIQUENAME}/options.descr
 OPTIONSFILE?=	${PORT_DBDIR}/${UNIQUENAME}/options
 _OPTIONSFILE!=	${ECHO_CMD} "${OPTIONSFILE}"
 .if defined(OPTIONS)
@@ -5781,6 +5782,7 @@
 		. ${_OPTIONSFILE}; \
 	fi; \
 	set -- ${OPTIONS} XXX; \
+	TMPOPTIONSDESCFILE=$$(mktemp -t portoptionsdescr); \
 	while [ $$# -gt 3 ]; do \
 		OPTIONSLIST="$${OPTIONSLIST} $$1"; \
 		defaultval=$$3; \
@@ -5796,14 +5798,24 @@
 			val=$$3; \
 		fi; \
 		DEFOPTIONS="$${DEFOPTIONS} $$1 \"$$2\" $${val}"; \
-		shift 3; \
+		if [ -n "${OPTIONS_DESC}" ]; then \
+			${ECHO_CMD} "$$1: $$4" | fmt >> $${TMPOPTIONSDESCFILE}; \
+			shift 4; \
+		else \
+			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; \
+	if [ -n "${OPTIONS_DESC}" ]; then \
+		${SH} -c "${DIALOG} --hfile $${TMPOPTIONSDESCFILE} --hline \"Press ? for a detailed description\" --checklist \"Options for ${PKGNAME:C/-([^-]+)$/ \1/}\" 21 70 15 $${DEFOPTIONS} 2> $${TMPOPTIONSFILE}"; \
+	else \
+		${SH} -c "${DIALOG} --checklist \"Options for ${PKGNAME:C/-([^-]+)$/ \1/}\" 21 70 15 $${DEFOPTIONS} 2> $${TMPOPTIONSFILE}"; \
+	fi; \
 	status=$$?; \
 	if [ $${status} -ne 0 ] ; then \
 		${RM} -f $${TMPOPTIONSFILE}; \
+		${RM} -f $${TMPOPTIONSDESCFILE}; \
 		${ECHO_MSG} "===> Options unchanged"; \
 		exit 0; \
 	fi; \
@@ -5830,11 +5842,18 @@
 	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}"; \
+		if [ -n "${OPTIONS_DESC}" ]; then \
+			${SU_CMD} "${CAT} $${TMPOPTIONSDESCFILE} > ${OPTIONSDESCFILE}"; \
+		fi; \
 		${ECHO_MSG} "===>  Returning to user credentials"; \
 	else \
 		${CAT} $${TMPOPTIONSFILE} > ${_OPTIONSFILE}; \
+		if [ -n "${OPTIONS_DESC}" ]; then \
+			${CAT} $${TMPOPTIONSDESCFILE} > ${OPTIONSDESCFILE}; \
+		fi; \
 	fi; \
-	${RM} -f $${TMPOPTIONSFILE}
+	${RM} -f $${TMPOPTIONSFILE}; \
+	${RM} -f $${TMPOPTIONSDESCFILE}
 .endif
 .endif
 
@@ -5868,7 +5887,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; \
@@ -5900,8 +5923,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
@@ -5909,16 +5937,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

--SUOF0GtieIMvvwua--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080401172314.GA42650>