RPM Community Forums

Mailing List Message of <rpm-users>

Re: rpm 5.1.9 issues on powerPC architecture

From: Jeff Johnson <n3npq@mac.com>
Date: Thu 14 Apr 2016 - 18:31:43 CEST
Message-id: <F206B05F-A319-4F08-8C25-0ADB2696A3D9@mac.com>

On Apr 14, 2016, at 12:15 PM, Jeff Johnson wrote:

> 
>> >>>> rpm files are generated on x86_64 machines but querying it on ppc machines (arch within rpm is ppc). Inbuilt metadata can be queried using --qf but not custom metadata. I guessed that endianness should not have impact rpm metadata content. But, even if it has, then it should give garbled values and not "(none)" as its result. However, querying custom metadata works fine in 5.4.14.
>>  
> 
> Yes arbitrary tags in metadata should be platform independent as a goal. But not in rpm-5.1.9 == a bug.
> 

I should state the problem more carefully:

The meatadata and the tags assigned to the arbitrary metadata ARE independent
of platform in the sense that that are marked with 0xc0000000. What is/was broken
is that the truncated SHA1 for the remaining 30bits of the tag assignment is little
endian.

The fix on PPC and big-endian machines is to swab the 30bits before generating
the tag assignment.

> The tag itself, not its content, is what is not platform independent. Hence not "garbled".
> 

The fix on PPC and big-endian machines is to swab the 30bits before generating
the tag assignment.

So its a fairly simple one line patch in rpmio/tagname in _tagGenerate() in rpm-5.1.9
that end up looking should look like this:

    if (digest && digestlen > 4) {
          /* The tag is stored in a uniform byte order for cross-endian compatib  ility. 
             Swap to the host uses. */
          memcpy(&tag, digest + (digestlen - 4), 4);
          tag = le32toh(tag);
          tag = (rpmTag) (tag & 0x3fffffff);
          tag = (rpmTag) (tag | 0x40000000);
      }   

73 de Jeff
Received on Thu Apr 14 18:31:50 2016
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.