Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Nov 2010 09:38:02 GMT
From:      bapt <bapt@FreeBSD.org>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/152568: New option framework proposal
Message-ID:  <201011250938.oAP9c2kp061053@red.freebsd.org>
Resent-Message-ID: <201011250940.oAP9e9sK052304@freefall.freebsd.org>

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

>Number:         152568
>Category:       ports
>Synopsis:       New option framework proposal
>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:   Thu Nov 25 09:40:09 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     bapt
>Release:        8.1-STABLE
>Organization:
>Environment:
FreeBSD azathoth.lan 8.1-STABLE FreeBSD 8.1-STABLE #1 r214596M: Sun Oct 31 14:25:29 CET 2010     root@azathoth.lan:/usr/obj/usr/src/sys/AZATHOTH  amd64

>Description:
Here is a new option framework proposal.

First the problem with the actual situation.
the option framework has some problems :
- for a given option we have two variable : WITH_OPT WITHOUT_OPT only
having to check one will be great.
- the option framework isn't consistent : if you set a WITH_BLA in
/etc/make.conf, make config doesn't mind about it for example.

So here is my proposal and a patch that implements it :

for porters :
3 types of options : simple, group and list
- simple options are the same as the current options (ie user can
activate what ever they wants)
- group options are options where at least one has to be set (1-N)
- list options are options where only one has to be set and only one
can be set (exclusive options)

group and list can be conditionnal

a maintainer can defined them it the ports and some can be defined system wide.

every options can have a description but this is not mandatory.

maintainer can set default options (DEFAULT_OPTS) and remove global
options that the ports doesn't support yet OPTS_RM.

in a ports how to define them like this

OPTS= OPT1 OPT2 OPT3

OPTS_GROUP= GRP1 GRP2
OPTS_GROUP_GRP1= OPT4 OPT5
OPTS_GROUP_GRP2= OPT6 OPT7

OPTS_LIST= LIST1
OPTS_LIST_LIST1= OPT8 OTP9 OPT10


DEFAULT_OPTS= OPT2 OPT3 OPT9 OPT7 OPT8 OPT4
OPTS_RM= NLS NOPORTDOCS

to define a desciption for a given option :
OPT1_DESC= "Description of my option"

To use conditionnal group or list just append to OPTS the name of the goup
in that case the list ou group is checked only if the group name is activated by the user.

make showoptions will present all the options and their descriptions :

===> The following configuration options are available:
OPT1=off: Description of my option
OPT2=on
OPT3=on
====> Options available for the group GRP1: you have to choose at
least one of them
OPT4=on
OPT5=off
====> Options available for the group GRP2: you have to choose at
least one of them
OPT6=off
OPT7=on
====> Options available for the group LIST1: you have to select only one of them
OPT8=on
OPT9=off
OPT10=off

a user can set in make.conf global options for the whole ports :
OPTS_SET= OPT1 OPT3
of unset them system wide
OPTS_UNSET= OPT10 OPT15

per port options can be specified in two ways for a given ports :
through /etc/make.conf:
${UNIQUENAME}_OPTS_SET= OPT1

${UNIQUENAME}_OPTS_UNSET= OPT2

for zsh it would be:
zsh_OPTS_SET= OPT1
zsh_OPTS_UNSET= OPT2

through /var/db/ports/${UNIQUENAME}/opts (in case we add a dialog like feature)
OPTS_SET= OPT1
OPTS_UNSET= OPT2

The framework check how the options are set in the following way :
1/ set the default options has wanted by the maintainer
2/ override them using the system wide options (OPTS_(UN)SET)
3/ the per ports defined options in /var/db/ports/${UNIQUENAME}/opts
4/ the per ports defined options in make.conf ${UNIQUENAME}_OPTS_(UN)SET

We can maintain some generic options descriptions like it is done in the KNOBS

for the maintainer to check if an option is set or not, we do not need
to choose between WITHOUT ou WITH option the options as to be checked
that way:
if !empty(PORTS_OPTS:MOPT1)
@${ECHO_CMD} " the option OPT1 is set"
.else
@${ECHO_CMD} "the option OPT2 is not set"
.endif

the framework check (check-options) for the consitency for the options
set (exclusive options and 1-n option)

In the patch nothing is activated by default (user has make
check-options himself currently)
there is nothing to create /var/db/ports/${UNIQUENAME}/opts it don't
really like having a gui for that but I understand some prefers so the framework option is already ready to have one.

The new framework can live with the old one
The implementation is really really simple.
In the implementation I added 3 global options: NOPORTDOCS NOPORTDATA
NOPORTEXAMPLES

for description we could imagine something like Mk/bsd.options.desc.mk
full of 
GTK2_DESC= add support for gtk ui
MYSQL_DEC= add support for mysql sgdb

and so on.

A variable exists to override every options sets : OPTS_OVERRIDE if set for example in make -DOPTS_OVERRIDE="OPTS1" then the ports will only see OPTS1 as set and ignore all the other user settings.

Variable names are temporary if you have better ideas :)

I think it is quite easy to extend to add features later.

http://people.freebsd.org/~bapt/ports-newopts.patch

I also wrote a quick and dirty example based on the vim ports: 
http://people.freebsd.org/~bapt/vim-newopts.patch

>How-To-Repeat:

>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:



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