This is an alpha release! There is still work to be done
Quickstart
Working with RPM package files
require 'rpm'
pkg = RPM::Package.open("file.rpm")
pkg.arch => "x86_64"
pkg.files.each do |file|
puts file.path
end
pkg.changelog.each do |entry|
puts "#{entry.name} #{entry.time} #{entry.text}"
end
Querying the rpm database
require 'rpm'
RPM.transaction do |ts|
ts.each do |pkg|
puts pkg
end
end
Install a package
require 'rpm'
pkg = RPM::Package.open('foo.rpm')
RPM.transaction(rootdir) do |t|
t.install(pkg, 'foo.rpm')
t.commit
end
Introduction
This library is a replacement for the ruby-rpm gem, originally
writen by Kenta Murata around 2002 for the Kondara distribution. Later
mantained by David Lutterkort and myself.
Why?
The original gem supports ancient rpm versions not in use anymore
The original gem was written in C using MRI API
The #ifdef'ing required to support multiple rpm versions made the code
hard to maintain
This gem:
Is pure ruby
Is documented
Has as a goal to support only the latest rpm version plus the ones in
use some releases back in popular rpm based distros
Does not target rpm5, but it may support it someday
As an example the code that implements RPM::Package was reduced
from 1130 lines of code to 320.
Architecture
The gem is divided in two modules:
RPM::C:: which contains the 1:1 mapping to the librpm API
Not all functions are attached, only the ones we actually use.
RPM:: contains the actual higher level API
Status, Compatibility and Differences with ruby-rpm
Only rpm 4.11.x or later will be supported
You can use symbols: instead of RPM::TAG_DESCRIPTION you
can use just :description. 'rpm/compat' is by default loaded
and provides compatibility with the RPM::TAG_* style constants
RPM::DB is not supported. Use RPM::Transaction
Spec and Source classes are not implemented yet
TESTING
Unit tests can be run using the rake test command.
Docker tests
In order to not damage your system, you can run the testsuite under docker:
Build the docker images:
rake docker_images
Run the testsuite under Docker
rake docker_test
TODO
Check Package#signature should return String?
=> ruby-rpm seems to return symbol
Food for thought: Package dependencies and changelog
methods could just use []. Calling headerGet directly saves
us from doing one iteration per attribute
Not sure if Spec can be implemented as it was before with
newer rpms.