RPM Community Forums

Mailing List Message of <rpm-devel>

Re: RPM 5.1.6 w/RPM_VENDOR_OPENPKG set ignores setting of __platform macro at run-time

From: Jeff Johnson <n3npq@mac.com>
Date: Sat 03 Jan 2009 - 21:16:35 CET
Message-id: <D194AE65-C837-48C7-8828-16D065769E5D@mac.com>
<rpm-devel@rpm5.org> is likelier the better place ...

On Jan 3, 2009, at 2:37 PM, Jeff Putsch wrote:

> Howdy,
>
> Please pardon the cross-posting, I'm not sure which list is more  
> appropriate for this post. If an openpkg-* list is more appropriate,  
> please let me know.
>
> I've built RPM 5.1.6 with RPM_VENDOR_OPENPKG defined, expecting to  
> be able to override the location of the platform file via the  
> __platform macro at run-time.
>
> Unfortunately, neither setting __platform in macros files, nor  
> setting it via "--define '__platform /path/to/platform'" on the  
> command line causes RPM 5.1.6 to read the specified platform file.
>
> I've traced the "problem" behavior to the defaultMachine() function  
> in lib/rpmrc.c.
>
> The first time defaultMachine() is called, 'cp = rpmExpand("%{? 
> __platform}", NULL);' is executed, cp is ALWAYS NULL, causing the  
> hardcoded path to the platform file to be used EVERY time.
>
> Subsequent calls to defaultMachine() are short-circuited by the  
> gotDefaults static variable.
>
> Running under gdb to diagnose the problem reveals defaultMachine()  
> is called 4 times prior to setDefaults() being called.
>
> If, in gdb, I set defaultMachine's "gotDefaults" static variable  
> back to "0" AFTER setDefaults is called, then the 'cp = rpmExpand("% 
> {?__platform}", NULL);' line expands properly and the __platform  
> variable is set properly.
>
> The problems seems to occur because rpmReadConfigFiles() calls  
> rpmRebuildTargetVars() BEFORE rpmReadRC() is called and rpmReadRC()  
> seems to initialize the global macro space. I could be wrong about  
> this, but that is what my new-to-RPM-eyes see.
>

There's a __HUGE__ amount (too much imho) of complexity boot-strapping  
RPM configuration.

Note that there is (usually) a %{_target} macro in the paths
to read macros from.

In order to do the expansion of %{_target}, then /etc/rpm/platform  
needs to be read.

If %{__platform} instead of "/etc/rpm/platform" is used, then % 
{__platform} needs to be expanded.

But if %{__platform} is in a macro file, well, we start to come full  
circle.

What might save the mess is that %{__platform} is defined before % 
{__target} is needed.

But that forces initialization to be convolved with itself, some macro  
files can be
read any time, other macro files have complicated pre-requisites that  
are data dependent.

> I've attached a simple patch that is my current work-around to the  
> problem.
>

If the patch is all that is needed (I'll leave to Ralf & OpenPKG to  
apply), then
that can probably be accomodated.

But the chicken <-> egg problem is already starting to cause problems.

hth tnx for the patch.

73 de Jeff

> Thanks,
>
> Jeff.
>
> --- lib/rpmrc.c.orig	2008-10-12 03:38:51.000000000 -0700
> +++ lib/rpmrc.c	2009-01-03 11:23:42.000000000 -0800
> @@ -502,7 +502,7 @@
>  */
> static void defaultMachine(/*@out@*/ const char ** arch,
> 		/*@out@*/ const char ** os)
> -	/*@globals rpmGlobalMacroContext, h_errno, fileSystem,  
> internalState @*/
> +	/*@globals rpmGlobalMacroContext, h_errno, fileSystem,  
> internalState, defaultsInitialized @*/
> 	/*@modifies *arch, *os, rpmGlobalMacroContext, fileSystem,  
> internalState @*/
> {
> #if defined(RPM_VENDOR_OPENPKG) /* larger-utsname */
> @@ -625,7 +625,7 @@
> 	}
> 	if (gotDefaults)
> 	    break;
> -	gotDefaults = 1;
> +	gotDefaults = gotDefaults && defaultsInitialized;
> 	break;
>     }
>
>
> ______________________________________________________________________
> RPM Package Manager                                    http://rpm5.org
> Developer Communication List                        rpm-devel@rpm5.org



  • application/pkcs7-signature attachment: smime.p7s
Received on Sat Jan 3 21:16:40 2009
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.