Date: Sat, 4 Nov 2006 17:07:45 +0100 (CET) From: Ulrich Spoerlein <uspoerlein@gmail.com> To: FreeBSD-gnats-submit@FreeBSD.org Cc: Alejandro Pulver <alepulver@FreeBSD.org>, flz@FreeBSD.org, portmgr@FreeBSD.org Subject: ports/105147: [PATCH] Fix OPTIONS handling for BATCH=yes Message-ID: <200611041607.kA4G7jZD009103@roadrunner.q.local> Resent-Message-ID: <200611041753.kA4HrcT4018704@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 105147 >Category: ports >Synopsis: [PATCH] Fix OPTIONS handling for BATCH=yes >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sat Nov 04 17:53:38 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Ulrich Spoerlein >Release: FreeBSD 6.2-PRERELEASE i386 >Organization: >Environment: >Description: 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 >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 >Fix: --- bsd.port.mk.patch begins here --- 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} --- bsd.port.mk.patch ends here --- -- 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. >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200611041607.kA4G7jZD009103>