Description of problem: In 'mock' we change personality of system when we are building i686 package on x86_64 host. But bpersonality is set by 'rpm-python' only once when module is loaded. And can not be changed later. So we must workaround it by lazy import of rpm module. It would be nice if you can provide some function, which would re-read personality and re-inicialize it. How reproducible: Create evil.spec with: BuildArch i686 And try: #!/usr/bin/python import ctypes # taken from sys/personality.h PER_LINUX32=0x0008 PER_LINUX=0x0000 personality_defs = { 'x86_64': PER_LINUX, 'ppc64': PER_LINUX, 'sparc64': PER_LINUX, 'i386': PER_LINUX32, 'i586': PER_LINUX32, 'i686': PER_LINUX32, 'ppc': PER_LINUX32, 'sparc': PER_LINUX32, 'sparcv9': PER_LINUX32, 'ia64' : PER_LINUX, 'alpha' : PER_LINUX, 's390' : PER_LINUX32, 's390x' : PER_LINUX, } _libc = ctypes.cdll.LoadLibrary(None) #SWAP _libc.personality(personality_defs['i686']) import rpm ts = rpm.ts() ts.parseSpec('evil.spec') This will work. But if you swap those two lines after #SWAP, then if will not work and fail with: error: No compatible architectures found for build Traceback (most recent call last): File "/tmp/test", line 22, in <module> ts.parseSpec('evil.spec') File "/usr/lib64/python2.7/site-packages/rpm/transaction.py", line 41, in parseSpec return _rpmb.spec(specfile) ValueError: can't parse specfile
Hmm, I was about to say "just call rpm.reloadConfig()" but that wont work, apparently it doesn't reset *all* the internal hw detection state foobar. Which means its not doing its work properly... I'll have a look.
Fixed upstream in the sense that rpm.reloadConfig() does a full reconfigure, previously the default machine data was only calculated on the very first call to rpmReadConfigFiles() which in python case occurs at module import. You'll still need a manual rpm.reloadConfig() when messing with personalities though, so whether the "official fix" is any better than your workaround ... depends I guess.
Oops, forgot to link the fix: http://rpm.org/gitweb?p=rpm.git;a=commitdiff;h=4ff89adb0dcabd86afc0230c4e8ef98c5f7cdc65
Closing. Please reopen if you need this to go into an update.