From owner-freebsd-ports@FreeBSD.ORG Tue Apr 1 17:21:28 2008 Return-Path: Delivered-To: ports@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 046DA106564A; Tue, 1 Apr 2008 17:21:28 +0000 (UTC) (envelope-from wxs@atarininja.org) Received: from syn.atarininja.org (syn.csh.rit.edu [129.21.60.158]) by mx1.freebsd.org (Postfix) with ESMTP id B81CA8FC24; Tue, 1 Apr 2008 17:21:27 +0000 (UTC) (envelope-from wxs@atarininja.org) Received: by syn.atarininja.org (Postfix, from userid 1001) id 107C65C5C; Tue, 1 Apr 2008 13:23:14 -0400 (EDT) Date: Tue, 1 Apr 2008 13:23:14 -0400 From: Wesley Shields To: Pav Lucistnik Message-ID: <20080401172314.GA42650@atarininja.org> 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> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="SUOF0GtieIMvvwua" Content-Disposition: inline In-Reply-To: <1206662285.3500.4.camel@ikaros.oook.cz> User-Agent: Mutt/1.5.17 (2007-11-01) Cc: ports@FreeBSD.org Subject: Re: There is no way to know what port options mean (in general) X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Apr 2008 17:21:28 -0000 --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--