class RPM::DB
Public Class Methods
Source
# File lib/rpm/db.rb, line 105 def self.each DB.open do |db| it = MatchIterator.from_ptr(RPM::C.rpmdbInitIterator(db.ptr, 0, nil, 0)) if block_given? it.each do |pkg| yield pkg end end end end
@deprecated Use RPM::Transaction#each
Source
# File lib/rpm/db.rb, line 11 def initialize(ts, opts={}) opts[:writable] ||= false @ts = ts RPM::C.rpmtsOpenDB(@ts.ptr, opts[:writable] ? Fcntl::O_RDWR | Fcntl::O_CREAT : Fcntl::O_RDONLY ) end
@visibility private @param ts [Transaction] transaction object
Source
# File lib/rpm/db.rb, line 76 def self.open(writable=false, root='/', &block) open_for_transaction(Transaction.new(:root => root), :writable => false, &block) end
The package database is opened, but transactional processing (@see RPM::DB#transaction) cannot be done for when writable
is false. When writable
is false
then the generated object gets freezed. @param [Boolean] writable Whether the database is writable. Default is false
. @param [String] root Root path for the database, default is empty. @return [RPM::DB]
@example
db = RPM::DB.open db.each do |pkg| puts pkg.name end
Source
# File lib/rpm/db.rb, line 81 def self.open_for_transaction(ts, opts={}) db = new(ts, opts) return db unless block_given? begin yield db ensure db.close unless db.closed? end end
@visibility private
Public Instance Methods
Source
# File lib/rpm/db.rb, line 118 def count_packages(name) end
@return number of instances of name
in the database
Source
# File lib/rpm/db.rb, line 45 def each(&block) @ts.each(&block) end
@yield [Package] Called for each package in the database @example
db.each do |pkg| puts pkg.name end
Source
# File lib/rpm/db.rb, line 34 def each_match(key, val, &block) @ts.each_match(key, val, &block) end
@yield [Package] Called for each match @param [Number] key RPM
tag key @param [String] val Value to match @example
RPM.transaction do |t| t.each_match(RPM::TAG_ARCH, "x86_64") do |pkg| puts pkg.name end end
Source
# File lib/rpm/db.rb, line 95 def home raise NotImplementedError end
@deprecated Not possible to get home value in
newer RPM versions
Source
# File lib/rpm/db.rb, line 19 def init_iterator(tag, val) @ts.init_iterator(tag, val) end
@return [RPM::MatchIterator] Creates an iterator for tag
and val
Source
# File lib/rpm/db.rb, line 50 def ptr RPM::C.rpmtsGetRdb(@ts.ptr) end
@visibility private
Source
# File lib/rpm/db.rb, line 100 def root RPM::C.rpmtsRootDir(@ts.ptr) end
@return [String] The root path of the database