Re: rpm 5.1.9 issues on powerPC architecture

2016-04-14 Thread Jeff Johnson

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 0xc000. 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(, digest + (digestlen - 4), 4);
  tag = le32toh(tag);
  tag = (rpmTag) (tag & 0x3fff);
  tag = (rpmTag) (tag | 0x4000);
  }   

73 de Jeff

Re: rpm 5.1.9 issues on powerPC architecture

2016-04-14 Thread Jeff Johnson

On Apr 12, 2016, at 2:14 PM, Rajul Bhavsar wrote:
> 
> Hmm why rpm-5.1.9, which was released quite some time ago?
>  Yes, its older version. But that is what current version we had. Will 
>  like to move to 5.4.14 in near future and that rpm version performs all 
>  required queries perfectly fine.
>> $ rpm -qai
>> rpm: -qai: unknown option
>> $
>> 
> 
> Try a simpler query first: does rpm -qa "work"?
>  
>  Yes, -qa works, but --xml or --yaml do not work along with -qpi. Also, 
>  use of --force give same error in rpm -iv command.
>  

OK. All of -i/--info, --xml and --yaml are popt aliases.

Make sure (with strace -e open) that rpm can read /usr/lib/rpm/rpmpopt.

You can also (for --xml and --yaml at least) verify with --queryformat.

All that --yaml does is add this --queryformat option:

rpm -q --qf '[%{*:yaml}\n]' bash

> The -i option is contextually dependent with multiple meanings in rpm
> and the processing is painfully complex. Identifying what does and does not
> work will be helpful in finding a fix.
> 
>> When we try to query custom metadata (implemented using arbitrary tags) then 
>> also it is failing (giving output as (none)). We have proper macro file in 
>> /usr/lib/rpm-5.1.9/macros and rpm is referring to it.
>> 
> 
> (from memory of a recent patch from Poky/Yocto)
> 
> The arbitrary tag values are likely in native endian.
> Did you build and query both on the same machine, or are you
> trying to query a package built on x86_64 on a ppc* machine?
>  
>  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.

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

With arbitrary tags, there are never any missing tags, any tag name will do.
RPM queries have always returned '(none)' in-band (i.e. in the actual output 
string)
for optional tags. That behavior has been extended to arbitrary tags.

hth

73 de Jeff



Re: rpm 5.1.9 issues on powerPC architecture

2016-04-12 Thread Rajul Bhavsar
Thanks Jeff.

Please find answers inline.

-Rajul

On Tue, Apr 12, 2016 at 9:58 PM, Jeff Johnson  wrote:

>
> On Apr 11, 2016, at 1:25 PM, Rajul Bhavsar wrote:
>
> Hi,
>
> We are trying to use rpm 5.1.9 on powerPC architecture. But, we see that
> there are issues with basic querying:
>
>
> Hmm why rpm-5.1.9, which was released quite some time ago?
>  Yes, its older version. But that is what current version we had. Will
> like to move to 5.4.14 in near future and that rpm version performs all
> required queries perfectly fine.
>
> $ rpm -qai
> rpm: -qai: unknown option
> $
>
>
> Try a simpler query first: does rpm -qa "work"?
>


>  Yes, -qa works, but --xml or --yaml do not work along with -qpi.
> Also, use of --force give same error in rpm -iv command.
>


> The -i option is contextually dependent with multiple meanings in rpm
> and the processing is painfully complex. Identifying what does and does not
> work will be helpful in finding a fix.
>
> When we try to query custom metadata (implemented using arbitrary tags)
> then also it is failing (giving output as *(none)*). We have proper macro
> file in /usr/lib/rpm-5.1.9/macros and rpm is referring to it.
>
>
> (from memory of a recent patch from Poky/Yocto)
>
> The arbitrary tag values are likely in native endian.
> Did you build and query both on the same machine, or are you
> trying to query a package built on x86_64 on a ppc* machine?
>


>  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.
>


> $ rpm --showrc | grep macros
> macrofiles:
> /usr/lib/rpm-5.1.9/macros:/usr/lib/rpm-5.1.9/ppc-linux/macros:/etc/rpm/5.1.9/macros.*:/etc/rpm/5.1.9/macros:/etc/rpm/5.1.9/ppc-linux/macros:~/.rpmmacros-5.1.9
> $
>
> We see that on x86_64 these things work fine. We do not see anything
> specific to architecture in the build of rpm, but only difference is that -
> host's arch is x86_64.
>
> Can anybody tell what is peculiar about rpm on powerPC arch?
>
>
> hth
>
> 73 de Jeff
>
> Thanks,
> Rajul
>
>
>


Re: rpm 5.1.9 issues on powerPC architecture

2016-04-12 Thread Jeff Johnson

On Apr 11, 2016, at 1:25 PM, Rajul Bhavsar wrote:

> Hi,
> 
> We are trying to use rpm 5.1.9 on powerPC architecture. But, we see that 
> there are issues with basic querying:
> 

Hmm why rpm-5.1.9, which was released quite some time ago?

> $ rpm -qai
> rpm: -qai: unknown option
> $
> 

Try a simpler query first: does rpm -qa "work"?

The -i option is contextually dependent with multiple meanings in rpm
and the processing is painfully complex. Identifying what does and does not
work will be helpful in finding a fix.

> When we try to query custom metadata (implemented using arbitrary tags) then 
> also it is failing (giving output as (none)). We have proper macro file in 
> /usr/lib/rpm-5.1.9/macros and rpm is referring to it.
> 

(from memory of a recent patch from Poky/Yocto)

The arbitrary tag values are likely in native endian.
Did you build and query both on the same machine, or are you
trying to query a package built on x86_64 on a ppc* machine?

> $ rpm --showrc | grep macros
> macrofiles: 
> /usr/lib/rpm-5.1.9/macros:/usr/lib/rpm-5.1.9/ppc-linux/macros:/etc/rpm/5.1.9/macros.*:/etc/rpm/5.1.9/macros:/etc/rpm/5.1.9/ppc-linux/macros:~/.rpmmacros-5.1.9
> $
> 
> We see that on x86_64 these things work fine. We do not see anything specific 
> to architecture in the build of rpm, but only difference is that - host's 
> arch is x86_64.
> 
> Can anybody tell what is peculiar about rpm on powerPC arch?
> 

hth

73 de Jeff
> Thanks,
> Rajul