Class: RPM::DB

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rpm/db.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.eachObject

Deprecated.

Use RPM::Transaction#each



105
106
107
108
109
110
111
112
113
114
# 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

.open(writable = false, root = '/', &block) ⇒ RPM::DB

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.

Examples:

db = RPM::DB.open
db.each do |pkg|
  puts pkg.name
end


76
77
78
# 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

Instance Method Details

#closeObject



54
55
56
# File 'lib/rpm/db.rb', line 54

def close
  RPM::C.rpmtsCloseDB(@ts.ptr)
end

#closed?Boolean



58
59
60
# File 'lib/rpm/db.rb', line 58

def closed?
  ptr.null?
end

#count_packages(name) ⇒ Object

database



118
119
# File 'lib/rpm/db.rb', line 118

def count_packages(name)
end

#each {|Package| ... } ⇒ Object

Examples:

db.each do |pkg|
  puts pkg.name
end

Yields:

  • (Package)

    Called for each package in the database



45
46
47
# File 'lib/rpm/db.rb', line 45

def each(&block)
  @ts.each(&block)
end

#each_match(key, val) {|Package| ... } ⇒ Object

Examples:

RPM.transaction do |t|
  t.each_match(RPM::TAG_ARCH, "x86_64") do |pkg|
    puts pkg.name
  end
end

Yields:

  • (Package)

    Called for each match



34
35
36
# File 'lib/rpm/db.rb', line 34

def each_match(key, val, &block)
  @ts.each_match(key, val, &block)
end

#homeObject

Deprecated.

Not possible to get home value in newer RPM versions

Raises:

  • (NotImplementedError)


95
96
97
# File 'lib/rpm/db.rb', line 95

def home
  raise NotImplementedError
end

#init_iterator(tag, val) ⇒ RPM::MatchIterator



19
20
21
# File 'lib/rpm/db.rb', line 19

def init_iterator(tag, val)
  @ts.init_iterator(tag, val)
end

#rootString



100
101
102
# File 'lib/rpm/db.rb', line 100

def root
  RPM::C.rpmtsRootDir(@ts.ptr)
end