Bug 105147 - [PATCH] Fix OPTIONS handling for BATCH=yes
Summary: [PATCH] Fix OPTIONS handling for BATCH=yes
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Port Management Team
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-04 17:53 UTC by Ulrich Spoerlein
Modified: 2007-04-04 07:15 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ulrich Spoerlein 2006-11-04 17:53:38 UTC
There is a flaw with our current OPTIONS handling, when BATCH is defined.
The default options (set by the maintainer) will always be defined
additionally to options set by the user via make.conf or command line.

This would not be a problem, if porters always checked, that overrides
are defined, and not that default options are defined.

I arbitrarly used games/quake2forge for this test, I don't mean to disregard
Alejandro!

We have the following code there:
OPTIONS=        AO "Build libao sound module" off \
...
                GL "Build OpenGL renderer" on
...
.if defined(WITH_GL)
USE_GL=         yes
CONFIGURE_ARGS+=--with-opengl=${X11BASE}
PLIST_SUB+=     GL=""
.else
CONFIGURE_ARGS+=--with-opengl=no
PLIST_SUB+=     GL="@comment "
.endif

If BATCH is set, bsd.port.mk will set WITH_GL=true ... always. That means the
correct way to check for OPTIONS is to check if an override has been given.

Now, we _could_ fix the code above to read
.if !defined(WITHOUT_GL)
USE_GL=         yes
CONFIGURE_ARGS+=--with-opengl=${X11BASE}
PLIST_SUB+=     GL=""
.else
CONFIGURE_ARGS+=--with-opengl=no
PLIST_SUB+=     GL="@comment "
.endif

And be happy, but we would also have to fix a bazillion of other ports that make
the same error. I wrote a script that checks for these conditions, and believe me
there are lots of ports making the same, wrong, assumptions.

I propose to fix this with the attached patch instead. It will NOT set the default
option if BATCH is defined WHEN an opposite option has been specified on the command
line or in make.conf

Fix: 

-- 
Ulrich Spoerlein

PS: I'm not sure if we could get rid of all checks like "if !defined(WITHOUT_FOO)"
with this patch and use "if defined(WITH_FOO)" instead. Of course, only for ports
that use OPTIONS.--4OjW1sGIbXYkMggtzn7GjX7XDOWGjBpoftu8I6yHH5NIS1X6
Content-Type: text/plain; name="bsd.port.mk.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="bsd.port.mk.patch"

Index: bsd.port.mk
===================================================================
RCS file: /home/ncvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.544
diff -u -p -r1.544 bsd.port.mk
--- bsd.port.mk	30 Sep 2006 19:25:45 -0000	1.544
+++ bsd.port.mk	4 Nov 2006 15:49:54 -0000
@@ -1237,11 +1237,14 @@ WITH:=
 .	if defined(OPTIONS)
 REALOPTIONS=${OPTIONS:C/".*"//g}
 .	for O in ${REALOPTIONS}
+# Don't set the options, if there is a user override defined in the
+# environment. This makes it easier for porters to check which options
+# are truly defined.
 RO:=${O}
-.	if ${RO:L} == off
+.	if ${RO:L} == off && !defined(WITH_${OPT})
 WITHOUT:=	${WITHOUT} ${OPT}
 .	endif
-.	if ${RO:L} == on
+.	if ${RO:L} == on && !defined(WITHOUT_${OPT})
 WITH:=		${WITH} ${OPT}
 .	endif
 OPT:=${RO}
How-To-Repeat: Earlier behaviour (look for --with-opengl=...):
% make __MAKE_CONF=/dev/null -DBATCH -DWITHOUT_GL -V CONFIGURE_ARGS -VWITH_GL -VWITHOUT_GL
--program-transform-name='s/^quake2$/quake2forge/' --without-ao --with-opengl=/usr/X11R6 --disable-sdl --disable-sdltest --with-svgalib=no --with-x --x-libraries=/usr/X11R6/lib --x-includes=/usr/X11R6/include --prefix=/usr/local --build=i386-portbld-freebsd6.2
true
1

As you see, WITHOUT_GL is ignored.


Fixed behaviour:
% make __MAKE_CONF=/dev/null -DBATCH -DWITHOUT_GL -V CONFIGURE_ARGS -VWITH_GL -VWITHOUT_GL
--program-transform-name='s/^quake2$/quake2forge/' --without-ao --with-opengl=no --disable-sdl --disable-sdltest --with-svgalib=no --with-x --x-libraries=/usr/X11R6/lib --x-includes=/usr/X11R6/include --prefix=/usr/local --build=i386-portbld-freebsd6.2

1

Now, WITHOUT_GL will prevent WITH_GL being set, making the if defined(WITH_GL)
check meaningful
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2006-11-04 19:03:29 UTC
Responsible Changed
From-To: freebsd-ports-bugs->portmgr

Affects bsd.port.mk.
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2007-04-04 07:15:26 UTC
State Changed
From-To: open->closed

rafan has heard from this submitter that the latest commit fixes this problem.