Module: RPM

Defined in:
lib/rpm/gem_version.rb,
lib/rpm.rb,
lib/rpm/c.rb,
lib/rpm/c.rb,
lib/rpm/db.rb,
lib/rpm/file.rb,
lib/rpm/utils.rb,
lib/rpm/compat.rb,
lib/rpm/c/rpmdb.rb,
lib/rpm/c/rpmds.rb,
lib/rpm/c/rpmfi.rb,
lib/rpm/c/rpmio.rb,
lib/rpm/c/rpmps.rb,
lib/rpm/c/rpmtd.rb,
lib/rpm/c/rpmts.rb,
lib/rpm/package.rb,
lib/rpm/problem.rb,
lib/rpm/version.rb,
lib/rpm/c/header.rb,
lib/rpm/c/rpmcli.rb,
lib/rpm/c/rpmlib.rb,
lib/rpm/c/rpmlog.rb,
lib/rpm/c/rpmtag.rb,
lib/rpm/c/rpmprob.rb,
lib/rpm/c/rpmmacro.rb,
lib/rpm/c/rpmtypes.rb,
lib/rpm/dependency.rb,
lib/rpm/transaction.rb,
lib/rpm/c/rpmcallback.rb,
lib/rpm/match_iterator.rb

Overview

The reason this file is gem_version.rb and not version.rb is because it conflicts with the version.rb class

Defined Under Namespace

Modules: C, Utils Classes: CallbackData, ChangeLog, Conflict, DB, Dependency, File, MatchIterator, Obsolete, Package, Problem, Provide, Require, Transaction, Version

Constant Summary collapse

TAG =
RPM::C::Tag
LOG =
RPM::C::Log
SENSE =
RPM::C::Sense
FILE =
RPM::C::FileAttrs
FILE_STATE =
RPM::C::FileState
TRANS_FLAG =
RPM::C::TransFlags
PROB_FILTER =
RPM::C::ProbFilter
MIRE =
RPM::C::RegexpMode
PKG_NAME =
"ruby-rpm"
GEM_VERSION =
"0.0.5"

Class Method Summary collapse

Class Method Details

.[](name) ⇒ String

Returns value of macro name.

Parameters:

  • name (String)

    Name of the macro

Returns:

  • (String)

    value of macro name



45
46
47
48
49
50
51
# File 'lib/rpm.rb', line 45

def self.[](name)
  val = String.new
  buffer = ::FFI::MemoryPointer.new(:pointer, 1024)
  buffer.write_string("%{#{name}}")
  ret = RPM::C.expandMacros(nil, nil, buffer, 1024)
  buffer.read_string
end

.[]=(name, value) ⇒ Object

Setup a macro

Parameters:

  • name (String)

    Name of the macro

  • value (String)

    Value of the macro or nil to delete it



56
57
58
59
60
61
62
# File 'lib/rpm.rb', line 56

def self.[]=(name, value)
  if value.nil?
    RPM::C.delMacro(nil, name.to_s)
  else
    RPM::C.addMacro(nil, name.to_s, "", value.to_s, RPM::C::RMIL_DEFAULT)
  end
end

.transaction(root = '/') ⇒ Object

Creates a new transaction and pass it to the given block

Examples:

RPM.transaction do |ts|
   ...
end

Parameters:

  • root (String) (defaults to: '/')

    dir, default ‘/’



33
34
35
36
37
38
39
40
41
# File 'lib/rpm.rb', line 33

def self.transaction(root = '/')
  begin
    ts = Transaction.new
    ts.root_dir = root
    yield ts
  ensure
    ts.ptr.free
  end
end