Date: Thu, 10 Oct 2002 22:57:23 +0200 From: Neil Blakey-Milner <nbm@mithrandr.moria.org> To: Kris Kennaway <kris@obsecurity.org> Cc: ports@FreeBSD.org, eivind@FreeBSD.org Subject: Re: Updated dialog-based config patches Message-ID: <20021010205723.GA20541@mithrandr.moria.org> In-Reply-To: <20021010181035.GA19338@mithrandr.moria.org> References: <20020930062804.GA50001@xor.obsecurity.org> <20021006202120.GA96047@xor.obsecurity.org> <20021010132556.GA17714@mithrandr.moria.org> <20021010181035.GA19338@mithrandr.moria.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--BXVAT5kNtrzKuDFl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu 2002-10-10 (20:10), Neil Blakey-Milner wrote: > On Thu 2002-10-10 (15:25), Neil Blakey-Milner wrote: > > I'd like to see the saved options be written either at install, or at a > > specific "make saveoptions". This also means that people can do port > > builds as user much easier. > > > > I'll follow up with code shortly. > > Comments, please. I'm working on another patch that'll replace the > options parsing within bsd.port.mk in favour of a more > applicaiton-neutral way of doing it, so something like gportconf ("just > a port configuration utility" - > (http://people.FreeBSD.org/~nbm/portconf/gportconf.jpg) and gpkgman > ("pib-like port builder and package manager" - > (http://people.FreeBSD.org/~nbm/gpkgman2.jpeg) can be possible again in > the future. Ok, this moves out the construction of the dialog into a tool called "config_dialog". Put config_dialog into ports/Tools. Basically, the "API" is passing option information via environment variables (djb and roam will be proud) in a way that can support backwards and forwards compatibility reasonably well. While not possible with this patch, people could easily replace their own configurator instead of config_dialog, and that configurator could be kept relatively out-of-date from bsd.port.mk, so long as some basic rules are followed. External ports builders, such as pib-like constructs, could call 'make config' with the write variables set to have a script of their choice run, and it can translate the option information into something the port builder can understand. One simple example would be a script that converted the option information in the environment into an XML file that the port builder can then read, and then it can display the options to the user. The way things are at the moment, config_dialog will only display options of type 'boolean', and then set WITH_ or WITHOUT_. Later if we add a type called 'anything' or 'string' or 'integer' or whatever, config_dialog might ask those after it does the checklist, or maybe it'd ignore it. The port builder could build a pretty nice screen which integrates all the choices. Also, while config_dialog will probably never learn about 'classes' or dependencies/conflicts, it'll just ignore them, but ports builders (like gportconf did - example in URL above) could integrate them. Anyway, I think this leaves us in a better position. Neil -- Neil Blakey-Milner nbm@mithrandr.moria.org --BXVAT5kNtrzKuDFl Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="bsd.port.mk.portconf-external.patch" Index: bsd.port.mk =================================================================== RCS file: /home/ncvs/ports/Mk/bsd.port.mk,v retrieving revision 1.426 diff -u -r1.426 bsd.port.mk --- bsd.port.mk 2 Oct 2002 07:18:17 -0000 1.426 +++ bsd.port.mk 10 Oct 2002 20:30:47 -0000 @@ -519,6 +519,8 @@ # PATCH_DEBUG - If set, print out more information about the patches as # it attempts to apply them. # PKG_DBDIR - Where package installation is recorded (default: /var/db/pkg) +# PORT_DBDIR - Where port configuration options are recorded +# (default: /var/db/port) # NO_PKG_REGISTER - Don't register a port installation as a package. # FORCE_PKG_REGISTER - If set, it will overwrite any existing package # registration information in ${PKG_DBDIR}/${PKGNAME}. @@ -555,6 +557,7 @@ CP?= /bin/cp CUT?= /usr/bin/cut DC?= /usr/bin/dc +DIALOG?= /usr/bin/dialog EGREP?= /usr/bin/egrep EXPR?= /bin/expr FALSE?= false # Shell builtin @@ -653,6 +656,15 @@ .include "${MASTERDIR}/Makefile.local" .endif +# where 'make config' records user configuration options +PORT_DBDIR?= /var/db/port + +OPTIONSFILE?=${PORT_DBDIR}/${PORTNAME}/options +WRKOPTIONSFILE?=${WRKDIR}/portoptions +.if exists(${WRKOPTIONSFILE}) +.include "${WRKOPTIONSFILE}" +.endif + .if !defined(PORTNAME) || !defined(PORTVERSION) || defined(PKGNAME) .BEGIN: @${ECHO_CMD} "${PKGNAME}: You need to define PORTNAME and PORTVERSION instead of PKGNAME." @@ -2179,7 +2191,6 @@ .if !target(do-extract) do-extract: - @${RM} -rf ${WRKDIR} @${MKDIR} ${WRKDIR} @for file in ${EXTRACT_ONLY}; do \ if ! (cd ${WRKDIR} && ${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${_DISTDIR}/$$file ${EXTRACT_AFTER_ARGS});\ @@ -2542,12 +2553,18 @@ pre-install-script do-install generate-plist post-install \ post-install-script compress-man run-ldconfig fake-pkg \ security-check +.if defined(OPTIONS) && exists(${WRKOPTIONSFILE}) && !defined(CONFIG_NOSAVE) +_INSTALL_SEQ+= saveconfig +.endif _PACKAGE_DEP= install _PACKAGE_SEQ= package-message pre-package pre-package-script \ do-package post-package-script -.if !target(fetch) +.if !target(fetch) && (!defined(OPTIONS) || defined(CONFIG_DONE)) fetch: ${_FETCH_SEQ} +.else +fetch: config + @cd ${.CURDIR} && ${MAKE} CONFIG_DONE=1 ${__softMAKEFLAGS} ${_FETCH_SEQ} .endif # Main logick. The loop generates 6 main targets and using cookies @@ -2555,8 +2572,11 @@ .for target in extract patch configure build install package -.if !target(${target}) +.if !target(${target}) && (!defined(OPTIONS) || defined(CONFIG_DONE)) ${target}: ${${target:U}_COOKIE} +.else +${target}: config + @cd ${.CURDIR} && ${MAKE} CONFIG_DONE=1 ${__softMAKEFLAGS} ${${target:U}_COOKIE} .endif .if !exists(${${target:U}_COOKIE}) @@ -3501,6 +3521,85 @@ OSVERSION="${OSVERSION:S/"/"'"'"/g:S/\$/\$\$/g:S/\\/\\\\/g}" \ PORTOBJFORMAT="${PORTOBJFORMAT:S/"/"'"'"/g:S/\$/\$\$/g:S/\\/\\\\/g}" \ SYSTEMVERSION="${SYSTEMVERSION:S/"/"'"'"/g:S/\$/\$\$/g:S/\\/\\\\/g}" +.endif + +.if !target(reconfig) +reconfig: + @cd ${.CURDIR} && ${MAKE} SPECIFIC_RECONFIG=yes config +.endif + +.if !target(config) +config: + @${MKDIR} ${WRKDIR} +.if !defined(OPTIONS) + @${ECHO_MSG} "==> No options to configure" +.elif !defined(ALWAYS_RECONFIG) && exists(${OPTIONSFILE}) && !defined(SPECIFIC_RECONFIG) +. if !exists(${WRKOPTIONSFILE}) + @${CP} ${OPTIONSFILE} ${WRKOPTIONSFILE} +. endif +.elif defined(ALWAYS_RECONFIG) && exists(${WRKOPTIONSFILE}) && !defined(SPECIFIC_RECONFIG) + @${DO_NADA} +.elif !defined(ALWAYS_RECONFIG) && exists(${WRKOPTIONSFILE}) && !defined(SPECIFIC_RECONFIG) + @${DO_NADA} +.else +.if !exists(${WRKOPTIONSFILE}) +. if exists(${OPTIONSFILE}) + @${CP} ${OPTIONSFILE} ${WRKOPTIONSFILE} +. endif +.endif + set ${OPTIONS} XXX; \ + while [ "$$#" -gt 3 ]; do \ + export OPTIONSLIST="$${OPTIONSLIST} $$1"; \ + export OPTION_$$1_DESCRIPTION="$$2" ; \ + export OPTION_$$1_DEFAULT="$$3" ; \ + export OPTION_$$1_TYPE=boolean ; \ + shift 3; \ + done; \ + export PORTNAME=${PORTNAME}; \ + export PORTVERSION=${PORTVERSION}; \ + sh ${PORTSDIR}/Tools/config_dialog ${WRKOPTIONSFILE} ${WRKOPTIONSFILE} \ + || (${ECHO_MSG} "==> Config cancelled!"; exit 1) +.elif defined(PACKAGE_BUILDING) || defined(BATCH) +.endif +.endif + +.if !target(saveconfig) +saveconfig: +.if !exists(${WRKOPTIONSFILE}) + @${ECHO_MSG} "==> No user-specified options to save for ${PORTNAME}" +.else + @${MKDIR} ${PORT_DBDIR}/${PORTNAME} 2> /dev/null || \ + (${ECHO_MSG} "==> Cannot create ${PORT_DBDIR}/${PORTNAME}, check permissions"; exit 1) + @${CP} ${WRKOPTIONSFILE} ${OPTIONSFILE} + @${RM} ${WRKOPTIONSFILE} +.endif +.endif + +.if !target(showconfig) +showconfig: +.if exists(${WRKOPTIONSFILE}) + @${ECHO_MSG} "==> The following unsaved configuration options are set for ${PORTNAME}"; \ + ${GREP} -v ^# ${WRKOPTIONSFILE} +.elif exists(${OPTIONSFILE}) + @${ECHO_MSG} "==> The following saved configuration options are set for ${PORTNAME}"; \ + ${GREP} -v ^# ${OPTIONSFILE} +.else + @${ECHO_MSG} "==> No configuration options are set for this port" +.if defined(OPTIONS) + @${ECHO_MSG} " Use 'make config' to set default values" +.endif +.endif +.endif + +.if !target(rmconfig) +rmconfig: +.if exists(${OPTIONSFILE}) + -@${ECHO_MSG} "==> Removing user-configured options for ${PORTNAME}"; \ + ${RM} -f ${OPTIONSFILE}; \ + ${RMDIR} ${PORT_DBDIR}/${PORTNAME} +.else + @${ECHO_MSG} "==> No user-specified options configured for ${PORTNAME}" +.endif .endif .endif --BXVAT5kNtrzKuDFl Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=config_dialog #!/bin/sh case $1 in '') ;; *) if [ -e $1 ]; then . $1 fi ;; esac case $2 in '') ;; *) OUTPUTFILE=$1 ;; esac TMPOPTIONSFILE=$(mktemp -t portconftemp) TMPOUTPUTFILE=$(mktemp -t portconftemp) trap "rm -f ${TMPOPTIONSFILE}; exit 1" 1 2 3 5 10 13 15 for option in ${OPTIONSLIST}; do eval optiontype=\$OPTION_${option}_TYPE eval optiondefault=\$OPTION_${option}_DEFAULT eval optiondescription=\$OPTION_${option}_DESCRIPTION echo "Option $option is of type $optiontype" echo "Option $option is for: $optiondescription" case $optiontype in boolean) eval withvar=\${WITH_${option}} eval withoutvar=\${WITHOUT_${option}} if [ ! -z "${withvar}" ]; then optiondefault=on elif [ ! -z "${withoutvar}" ]; then optiondefault=off fi ;; esac DEFOPTIONS="${DEFOPTIONS} $option \"$optiondescription\" $optiondefault" done sh -c "dialog --checklist \"Options for ${PORTNAME} ${PORTVERSION}\" 21 70 15 ${DEFOPTIONS}" 2> ${TMPOPTIONSFILE} status=$? if [ ${status} -ne 0 ] ; then rm -f ${TMPOPTIONSFILE} exit 1 fi SELOPTIONS=$(cat ${TMPOPTIONSFILE}) rm -f ${TMPOPTIONSFILE} echo "# This file is auto-generated by 'make config'. No user-servicable parts" > ${TMPOUTPUTFILE} echo "# inside!" >> ${TMPOUTPUTFILE} for option in ${OPTIONSLIST}; do \ echo ${SELOPTIONS} | grep -qw ${option} if [ $? -eq 0 ]; then echo WITH_${option}=true >> ${TMPOUTPUTFILE} else echo WITHOUT_${option}=true >> ${TMPOUTPUTFILE} fi done if [ ! -z "${OUTPUTFILE}" ]; then cp -f ${TMPOUTPUTFILE} ${OUTPUTFILE} else cat ${TMPOUTPUTFILE} fi rm -f ${TMPOUTPUTFILE} exit 0 --BXVAT5kNtrzKuDFl-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021010205723.GA20541>