RPM Community Forums

Mailing List Message of <rpm-devel>

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

From: Jeff Putsch <putsch@mxim.com>
Date: Sat 03 Jan 2009 - 20:37:00 CET
Message-Id: <4EE02DD2-7218-4272-99E9-42DB1A9B1C73@mxim.com>

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  

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.

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



--- 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)
-	gotDefaults = 1;
+	gotDefaults = gotDefaults && defaultsInitialized;
Received on Sat Jan 3 20:56:44 2009
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.