RPM2
view release on metacpan or search on metacpan
lib/RPM2.pm view on Meta::CPAN
}
sub next {
my $self = shift;
return unless $self->{c_iter};
my ($hdr, $offset) = $self->{c_iter}->_iterator_next();
return unless $hdr;
my $ret = RPM2::Header->_new_raw($hdr, undef, $offset);
return $ret;
}
sub expand_iter {
my $self = shift;
my @ret;
while (my $h = $self->next) {
push @ret, $h;
}
return @ret;
}
# make sure c_iter is destroyed before {db} so that we always free an
# iterator before we free the db it came from
sub DESTROY {
my $self = shift;
delete $self->{c_iter};
}
package RPM2::Transaction;
our $VERSION = $RPM2::VERSION;
sub _new_raw {
my $class = shift;
my $c_transaction = shift;
my $self = bless { }, $class;
$self->{c_transaction} = $c_transaction;
return $self;
}
sub add_install {
my $self = shift;
my $h = shift;
my $upgrade = shift || 0;
my $fn;
#
# Must have a header to add
return 0 if(!defined($h));
#
# Get filename
$fn = $h->filename();
# XXX: Need to add relocations at some point, but I think we live
# without this for now (until I need it (-;).
return RPM2::C::Transaction::_add_install($self->{'c_transaction'},
$h->{'c_header'}, $fn, $upgrade)
}
sub add_erase {
my $self = shift;
my $h = shift;
my $db_offset;
my $fn;
#
# Must have a header to add
return 0 if(!defined($h));
#
# Get record offset
$db_offset = $h->offset();
return 0 if(!defined($db_offset));
# XXX: Need to add relocations at some point, but I think we live
# without this for now (until I need it (-;).
return RPM2::C::Transaction::_add_delete($self->{'c_transaction'},
$h->{'c_header'}, $db_offset)
}
sub element_count {
my $self = shift;
return $self->{'c_transaction'}->_element_count();
}
sub close_db {
my $self = shift;
return $self->{'c_transaction'}->_close_db();
}
sub check {
my $self = shift;
return $self->{'c_transaction'}->_check();
}
sub order {
my $self = shift;
return $self->{'c_transaction'}->_order();
}
sub elements {
my $self = shift;
my $type = shift;
$type = 0 if(!defined($type));
return $self->{'c_transaction'}->_elements($type);
}
sub run {
my $self = shift;
my $ok_probs = shift || '';
my $ignore_probs = shift || 0;
return RPM2::C::Transaction::_run($self->{'c_transaction'}, $ok_probs,
$ignore_probs);
}
# Preloaded methods go here.
1;
__END__
# Below is stub documentation for your module. You better edit it!
=head1 NAME
RPM2 - Perl bindings for the RPM Package Manager API
=head1 SYNOPSIS
use RPM2;
( run in 0.403 second using v1.01-cache-2.11-cpan-71847e10f99 )