Date: Fri, 25 Apr 2008 22:02:16 -0400 From: Wesley Shields <wxs@FreeBSD.org> To: ports@FreeBSD.org Subject: long descriptions in OPTIONS Message-ID: <20080426020216.GM23691@atarininja.org>
next in thread | raw e-mail | index | archive | help
--17pEHd4RhPHOinZp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Based upon an idea in an earlier thread on this list[1] I came up with two ways of adding an extended description to our existing OPTIONS framework. 1: Extend the OPTIONS to be 4 fields instead of the current 3 fields. The 4th field would be the long description - providing more detailed information about what this option does or supports. In order to distinguish between a port with 4 OPTIONS without the long description (12 fields) and a port with 3 OPTIONS with the long description (also 12 fields) the patch requires the port to turn on a knob (OPTIONS_DESC) when using the long field. The idea is that over time this will become the default and can eventually be removed. 2: Leave OPTIONS as is but support a DESC_FOO variable for each OPTION. This variable would be the long description field, and if it doesn't exist a default message indicating such would be displayed. Both of these methods are displayed to the user when '?' or F1 is pressed during the dialog screen. In the case of (1) the extra dialog is only shown if the port supports it. In the case of (2) the extra dialog is always available since we have a default message to display. I suppose a third way would be to use a default message when the knob is not set for (1), which would probably simplify things slightly. Personally, I prefer (1) but I'm open to suggestions on how to improve either of them, or an entirely new idea all together. I'd like to submit these as PRs eventually, so please do try to keep the bikesheds to a minimum. :) I've attached both ideas in case people want to try the implementation. The first one is a few weeks old now and will likely require slight massaging to apply. -- WXS [1]: http://lists.freebsd.org/pipermail/freebsd-ports/2008-March/047656.html --17pEHd4RhPHOinZp 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 --17pEHd4RhPHOinZp Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="options-desc-2.diff" 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 25 Apr 2008 23:01:35 -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 DESC_$$1); \ + if [ "x$${LONGDESC}" = "x" ]; then \ + ${ECHO_CMD} "$$1: No long description specified. Contact the maintainer to fix this." | 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}"; \ + ${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 --17pEHd4RhPHOinZp--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080426020216.GM23691>