Class: RPM::DB

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

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) each_match(tag, val)



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

def DB.each_match(tag, val)
  begin
    db = RPM::DB.new
    db.each_match(tag, val) {|*a| yield a}
  end
  GC.start
end

+ (Object) init

Initialize the package database The database #root / var / lib /rpm is created.

Parameters:

  • root (String)

    Root of the database

  • writable (Boolean)

    Whether the database is writable. Default false.



# File 'ext/rpm/db.c'

static VALUE
db_s_init(int argc, VALUE* argv, VALUE obj)
{
    int writable = 0;
    const char* root;

    switch (argc) {
    case 0:
rb_raise(rb_eArgError, "too few argument(1..2)");

    case 1: case 2:
if (TYPE(argv[0]) != T_STRING) {
    rb_raise(rb_eTypeError, "illegal argument type");
}

+ (RPM::DB) new

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

Parameters:

  • writable (Boolean)

    Whether the database is writable. Default is false.

  • root (String)

    Root path for the database, default is empty.

Returns:



# File 'ext/rpm/db.c'

static VALUE
db_s_open(int argc, VALUE* argv, VALUE obj)
{
    VALUE db;
    rpm_db_t* rdb;
    int writable = 0;
    const char* root = "";

    switch (argc) {
    case 0:
        break;

    case 1:
        writable = RTEST(argv[0]);
        break;

    case 2:
        if (!NIL_P(argv[1])) {
if (TYPE(argv[1]) != T_STRING) {
    rb_raise(rb_eTypeError, "illegal argument type");
}

+ (RPM::DB) open

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

Parameters:

  • writable (Boolean)

    Whether the database is writable. Default is false.

  • root (String)

    Root path for the database, default is empty.

Returns:



# File 'ext/rpm/db.c'

static VALUE
db_s_open(int argc, VALUE* argv, VALUE obj)
{
    VALUE db;
    rpm_db_t* rdb;
    int writable = 0;
    const char* root = "";

    switch (argc) {
    case 0:
        break;

    case 1:
        writable = RTEST(argv[0]);
        break;

    case 2:
        if (!NIL_P(argv[1])) {
if (TYPE(argv[1]) != T_STRING) {
    rb_raise(rb_eTypeError, "illegal argument type");
}

+ (Object) packages(label = nil)

def DB.packages



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

def DB.packages(label=nil)
  packages = []
  if label then
    DB.each_match(RPM::DBI_LABEL, label) {|a| packages.push a}
  else
    packages = DB.packages
  end
  packages
end

+ (Object) rebuild

Rebuild the package database It should reside in root / var / lib /rpm

Parameters:

  • root (String)

    Root path of the database



# File 'ext/rpm/db.c'

static VALUE
db_s_rebuild(int argc, VALUE* argv, VALUE obj)
{
    const char* root = "";
    int ret;

    switch (argc) {
    case 0:
        break;

    case 1:
        if (!NIL_P(argv[0])) {
if (TYPE(argv[0]) != T_STRING) {
    rb_raise(rb_eTypeError, "illegal argument type");
}

Instance Method Details

- (Object) close

Closes the database



# File 'ext/rpm/db.c'

VALUE
rpm_db_close(VALUE db)
{
    db_unref((rpm_db_t*)DATA_PTR(db));
    DATA_PTR(db) = NULL;
    rb_gc();
    return Qnil;
}

- (Boolean) closed?

true if the database is closed

Returns:

  • (Boolean)

    true if the database is closed



# File 'ext/rpm/db.c'

VALUE
rpm_db_is_closed(VALUE vdb)
{
    return DATA_PTR(vdb) ? Qfalse : Qtrue;
}

- (Object) each {|Package| ... }

Examples:

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

Yields:

  • (Package)

    Called for each package in the database



# File 'ext/rpm/db.c'

VALUE
rpm_db_each(VALUE db)
{
    check_closed(db);
    return rpm_db_each_match(db,INT2NUM(RPMDBI_PACKAGES),Qnil);
}

- (Object) each_match {|Package| ... }

Examples:

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

Parameters:

  • key (Number)

    RPM tag key

  • val (String)

    Value to match

Yields:

  • (Package)

    Called for each match



# File 'ext/rpm/db.c'

VALUE
rpm_db_each_match(VALUE db, VALUE key, VALUE val)
{
    VALUE mi;

    check_closed(db);

    mi = rpm_db_init_iterator (db, key, val);

    if (!NIL_P(mi))
        return rpm_mi_each (mi);
        return Qnil;
}

- (String) home

The home path of the database

Returns:

  • (String)

    The home path of the database



# File 'ext/rpm/db.c'

VALUE
rpm_db_get_home(VALUE db)
{
    check_closed(db);
    return rb_str_new2(RPM_DB(db)->db_home);
}

- (Object) init_iterator

- (String) root

The root path of the database

Returns:

  • (String)

    The root path of the database



# File 'ext/rpm/db.c'

VALUE
rpm_db_get_root(VALUE db)
{
    check_closed(db);
    return rb_str_new2(RPM_DB(db)->db_root);
}

- (Object) transaction

- (Boolean) writable?

true if the database is writable

Returns:

  • (Boolean)

    true if the database is writable



# File 'ext/rpm/db.c'

VALUE
rpm_db_is_writable(VALUE db)
{
    check_closed(db);
    return OBJ_FROZEN(db) ? Qfalse : Qtrue;
}