This is an alpha release! There is still work to be done
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
require 'rpm'
RPM.transaction do |ts|
ts.each do |pkg|
puts pkg
end
end
require 'rpm'
pkg = RPM::Package.open('foo.rpm')
RPM.transaction(rootdir) do |t|
t.install(pkg, 'foo.rpm')
t.commit
end
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
- Uses FFI, so it should work with other interpreters (Because rubinius/rubinius#682 it currently does not work on Rubinius)
- 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.
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
- Tested rpm 4.9 only
- 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
Unit tests can be run using the rake test
command.
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
- 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.
- RPM#expand
- RPM#[]
- RPM#[]=
- RPM#readrc
- RPM#init_macros
- RPM#verbosity
- RPM#verbosity=
- Package#open
- Package#new
- Package#create
- Package#load
- Package#clear_cache
- Package#use_cache
- Package#[]
- Package#delete_tag
- Package#sprintf [?] Package#signature
- Package#arch
- Package#name
- Package#version
- Package#files
- Package#provides
- Package#requires
- Package#conflicts
- Package#obsoletes
- Package#changelog
- Package#add_dependency
- Package#add_string
- Package#add_string_array
- Package#add_int32
- Package#dump
- Package#to_s
- Package#inspect
- Package#copy_to
- Dependency#initialize
- Dependency#name
- Dependency#version
- Dependency#flags
- Dependency#owner
- Dependency#lt?
- Dependency#gt?
- Dependency#eq?
- Dependency#le?
- Dependency#ge?
- Dependency#satisfy?
- Dependency#nametag
- Dependency#versiontag
- Dependency#flagstag
- Provide#initialize
- Require#initialize
- Require#pre?
- Conflict#initialize
- Obsolete#initialize
- ChangeLog#time
- ChangeLog#name
- ChangeLog#text
- Version (Comparable)
- Version#initialize
- Version#<=>
- Version#newer?
- Version#older?
- Version#v
- Version#r
- Version#e
- Version#to_s
- Version#to_vre
- Version#inspect
- Version#hash
- File#initialize
- File#path
- File#to_s (alias path)
- File#md5sum
- File#link_to
- File#size
- File#mtime
- File#owner
- File#group
- File#rdev
- File#mode
- File#attr
- File#state
- File#symlink?
- File#config?
- File#doc?
- File#donotuse?
- File#missingok?
- File#specfile?
- File#ghost?
- File#license?
- File#readme?
- File#exclude?
- File#replaced?
- File#notinstalled?
- File#netshared?
- DB (Enumerable)
- DB#new
- DB#open
- DB#init
- DB#rebuild
- DB#close
- DB#closed?
- DB#root
- DB#home
- DB#writable?
- DB#each_match
- DB#each
- DB#transaction
- DB#init_iterator
- DB#dup
- DB#clone
- MatchIterator (Enumerable)
- MatchIterator#each
- MatchIterator#next_iterator
- MatchIterator#offset
- MatchIterator#set_iterator_re
- MatchIterator#regexp
- MatchIterator#set_iterator_version
- MatchIterator#version
- MatchIterator#get_iterator_count
- MatchIterator#length
- Transaction#db
- Transaction#script_file
- Transaction#script_file=
- Transaction#install
- Transaction#upgrade
- Transaction#available
- Transaction#delete
- Transaction#check
- Transaction#order
- Transaction#keys
- Transaction#commit
- Transaction#abort
- Transaction#dup
- Transaction#clone
- Source#initialize
- Source#fullname
- Source#to_s (alias fullname)
- Source#num
- Source#no?
- Spec#open
- Spec#new
- Spec#buildroot
- Spec#buildsubdir
- Spec#buildarchs
- Spec#buildrequires
- Spec#build_restrictions
- Spec#sources
- Spec#packages
- Spec#build
- Spec#expand_macros
- Spec#dup
- Spec#clone
-
Copyright © 2011 Duncan Mac-Vicar Prett dmacvicar@suse.de
-
Copyright © 2011 SUSE Linux Products GmbH
-
This gem is a pure-ruby rewrite of ruby-rpm: Copyright © 2002 Kenta Murata. Relicensed with his permission.
Licensed under the MIT license. See MIT-LICENSE for details.