OPTIONSng: Overide options in /var/db/ports/*/options ?

Gyrd Thane Lange gyrd-se at thanelange.no
Wed May 15 16:24:34 UTC 2013


Hi all, its been a while but I have prepared a patch.

On 17.03.2013 21:27, Gyrd Thane Lange wrote:

[Snipped away most of the discussion about whether
/var/db/ports/*/options or make.conf should have the final word, and
mechanisms for forcing one or the other.]

> I would rather have a mechanism where the port dialogue is brought up
> automatically if there is a conflict between the settings in make.conf
> and those stored in */options. The dialogue should then present the
> stored settings, with the make.conf settings applied latest.

(Forget about raising the dialogue and resolving conflicts
automatically. I found a better way.)

> This way my settings in make.conf will no longer be silently ignored.

Rather than forcing either of make.conf or /var/db/ports/*/options to
thrumph the other I have instead settled on a conflict reporting
mechanism that will prevent the port system from silently ignoring my
wishes and allow me to manually resolve the conflicts before building.

The gist of the attached patch is:

1) Go through the options in make.conf and command line (in priority
order) and build two lists:
  - a list of all options that MUST be set
  - a list of all options that MUST NOT be set

2) Compare with current options and build lists where options do not
match users MUST [NOT] preferences.

3) Act on any conflict
Currently I've only implemented a simple way of setting IGNORE with a
list of conflicting options when the following make variable is set.

OPTIONS_CONFLICT_ACTION=fail

If the variable is not set then no action will be taken (making this
feature non-obtrusive to users unless they activate it.) In the future
we may implement other actions: perhaps to automatically bring up the
configuration dialogue.

Note about (1). I see that _[UN]SET_FORCE options have been implemented
after I prepared this patch. This may easily be added to the patch if
required. I have not needed it yet.

This patch is complementary to all the other preference logic, since it
doesn't actually change any options but only report on them.

Best regards,
Gyrd ^_^

-------------- next part --------------
Index: Mk/bsd.options.mk
===================================================================
--- Mk/bsd.options.mk	(revision 317733)
+++ Mk/bsd.options.mk	(working copy)
@@ -315,6 +315,88 @@
 .undef _SORTED_OPTIONS
 .endif
 
+### 2013-04-19, GTL, check for conflicts
+# Build list of users express preference
+# Maintain two lists:
+#   a) A positive list of all options that MUST be set
+#   b) A negative list of all options that MUST NOT be set
+# Priority: (first listed is least important)
+#   1) Global
+#   2) Uniquename
+#   3) with_/without_ (from make.conf)
+#   4) command line
+
+# Global options...
+_OPTIONS_MUST_SET=	${OPTIONS_SET}
+_OPTIONS_MUST_UNSET=	${OPTIONS_UNSET}
+
+# Port specific options...
+.for opt in ${${UNIQUENAME}_SET}
+_OPTIONS_MUST_SET+=	${opt}
+_OPTIONS_MUST_UNSET:=	${_OPTIONS_MUST_UNSET:N${opt}}
+.endfor
+.for opt in ${${UNIQUENAME}_UNSET}
+_OPTIONS_MUST_SET:=	${_OPTIONS_MUST_SET:N${opt}}
+_OPTIONS_MUST_UNSET+=	${opt}
+.endfor
+
+# WITH and WITHOUT found in make.conf or reloaded from old optionsfile
+# Actually, we only want to heed settings from make.conf (not the optionsfile),
+# but I don't know how to tell them apart.
+#.for opt in ${ALL_OPTIONS}
+#.  if defined(WITH_${opt})
+#_OPTIONS_MUST_SET+=	${opt}
+#_OPTIONS_MUST_UNSET:=	${_OPTIONS_MUST_UNSET:N${opt}}
+#.  endif
+#.  if defined(WITHOUT_${opt})
+#_OPTIONS_MUST_SET:=	${_OPTIONS_MUST_SET:N${opt}}
+#_OPTIONS_MUST_UNSET+=	${opt}
+#.  endif
+#.endfor
+
+# Command line...
+.for opt in ${WITH}
+_OPTIONS_MUST_SET+=	${opt}
+_OPTIONS_MUST_UNSET:=	${_OPTIONS_MUST_UNSET:N${opt}}
+.endfor
+.for opt in ${WITHOUT}
+_OPTIONS_MUST_SET:=	${_OPTIONS_MUST_SET:N${opt}}
+_OPTIONS_MUST_UNSET+=	${opt}
+.endfor
+
+# Prettify...
+_OPTIONS_MUST_SET:=	${_OPTIONS_MUST_SET:O:u}
+_OPTIONS_MUST_UNSET:=	${_OPTIONS_MUST_UNSET:O:u}
+
+# report where current options does match users preferences
+.for opt in ${ALL_OPTIONS}
+.  if empty(PORT_OPTIONS:M${opt})
+.    if ${_OPTIONS_MUST_SET:M${opt}}
+_OPTIONS_CONFLICT_SET+=		${opt}
+.    endif
+.  else
+.    if ${_OPTIONS_MUST_UNSET:M${opt}}
+_OPTIONS_CONFLICT_UNSET+=	${opt}
+.    endif
+.  endif
+.endfor
+.undef opt
+.if !empty(OPTIONS_CONFLICT_ACTION:Mfail)
+.  if defined(_OPTIONS_CONFLICT_SET)
+.    if defined(_OPTIONS_CONFLICT_UNSET)
+eol_marker=.
+.    endif
+# Complain about options that should have been set
+IGNORE+=	Option ${_OPTIONS_CONFLICT_SET} unexpectedly unset${eol_marker}
+.  endif
+.  if defined(_OPTIONS_CONFLICT_UNSET)
+# Complain about options that should not have been set
+IGNORE+=	Option ${_OPTIONS_CONFLICT_UNSET} unexpectedly set
+.  endif
+.endif
+### End of conflicts check
+
+
 ### to be removed once old OPTIONS disappear
 .for opt in ${ALL_OPTIONS}
 .if empty(PORT_OPTIONS:M${opt})


More information about the freebsd-ports mailing list