Subject: Re: Handling options in bl3 files
To: Dieter Baron <dillo@danbala.tuwien.ac.at>
From: Johnny Lam <jlam@NetBSD.org>
List: tech-pkg
Date: 06/01/2005 12:51:53
Dieter Baron wrote:
> 
>   If kdelibs is already installed, the options used to compile the
> installed package should be used, not the current option settings:
> 
> PKG_BUILD_OPTIONS.kdelibs!= \
> 	pkg_info -B kdelibs | sed -n 's/^PKG_OPTIONS=[ 	]*//p'

The best way is with:

PKG_BUILD_OPTIONS.kdelibs!= pkg_info -Q PKG_OPTIONS kdelibs

Extracting PKG_OPTIONS with an eye toward this problem is actually the 
main reason why I implemented -Q in the first place.  I think that 
someone who builds packages will almost always want to build packages 
using the existing, installed packages as the base upon which to build. 
  Given this, querying the installed packages for their PKG_OPTIONS is 
the logical step that must be taken.  Todd notes that it's possible for 
a current setting of variables in /etc/mk.conf to conflict with the 
installed package's options.  In this case, I think we should try to 
note an error which would prompt the user to rebuild the offending 
dependency.

As Todd also points out, querying the installed package is problematic 
because buildlink3.mk files figure out which dependencies are needed, 
but dependencies aren't actually installed until later, so we have an 
ordering problem.  While you're correct that we can do one thing if the 
package is already installed and another if it isn't, I thought I'd try 
to figure out some other way to modify pkgsrc in which we could 
guarantee that the dependencies will always be installed so that 
checking the installed package will always work.  In the meantime, the 
existing code does what we've always done -- rely on /etc/mk.conf to 
present the state of the system, so I'm comfortable with leaving it 
as-is until we can hopefully transition to a system where we can 
actively query the system's state.

	Cheers,

	-- Johnny Lam <jlam@NetBSD.org>