Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get license from RPM file #7

Open
ice799 opened this issue Nov 17, 2013 · 1 comment
Open

Can't get license from RPM file #7

ice799 opened this issue Nov 17, 2013 · 1 comment

Comments

@ice799
Copy link

ice799 commented Nov 17, 2013

Hi:

I am unable to use the [] method to get the license string from RPM packages with licenses. For example: strace-4.8-4.3.x86_64.rpm (which you can get here: ftp://rpmfind.net/linux/opensuse/factory/repo/oss/suse/x86_64/strace-4.8-4.3.x86_64.rpm)

[joe@mawu:/tmp]% md5sum strace-4.8-4.3.x86_64.rpm
MD5 (strace-4.8-4.3.x86_64.rpm) = 63fc4a8049b7833d65255487b64256ac
[joe@mawu:/tmp]% irb  
irb(main):001:0> require 'rubygems'
=> false
irb(main):002:0> require 'rpm'
=> true
irb(main):003:0> pkg = RPM::Package.open("strace-4.8-4.3.x86_64.rpm")
warning: strace-4.8-4.3.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 3dbdc284: NOKEY
=> #<RPM::Package:0x007f8f8c071bd8 @hdr=#<FFI::AutoPointer address=0x007f8f8b95be80>>
irb(main):004:0> pkg[:arch]
=> "x86_64"
irb(main):005:0> pkg[:name]
=> "strace"
irb(main):006:0> pkg[:license]
=> nil

Yet if I use rpm on the command line and queryformat:

[joe@mawu:/tmp]% rpm -q -p ./strace-4.8-4.3.x86_64.rpm --queryformat "%{LICENSE}\n"
warning: ./strace-4.8-4.3.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 3dbdc284: NOKEY
BSD-3-Clause

Same for other RPMs.

I am using rpm version: RPM version 4.9.1.1

Thanks

@dmacvicar
Copy link
Owner

For some reason FFI is not working with the enum in symbol mode. It works with eg. :name but not with :license:

RPM::C.headerGet(ptr, :license, tagc, RPM::C::HEADERGET_MINMEM)
=> 0
RPM::C.headerGet(ptr, 1014, tagc, RPM::C::HEADERGET_MINMEM)
=> 1
RPM::C.rpmtdGetString(tagc)
=> "GPL"
RPM::C.headerGet(ptr, 1000, tagc, RPM::C::HEADERGET_MINMEM)
=> 1
RPM::C.rpmtdGetString(tagc)
=> "simple"
RPM::C.headerGet(ptr, :name, tagc, RPM::C::HEADERGET_MINMEM)
=> 1
RPM::C.rpmtdGetString(tagc)
=> "simple"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants