RPM4
view release on metacpan or search on metacpan
lib/RPM4.pm view on Meta::CPAN
if ($rc == 0) {
if (defined($ar) && !defined($br)) {
return 1;
} elsif (!defined($ar) && defined($br)) {
return -1;
} elsif (!defined($ar) && !defined($br)) {
return 0;
} else {
return RPM4::rpmvercmp($ar, $br);
}
} else {
return $rc;
}
} else {
return $rc;
}
}
}
# parse* function
# callback => function
# (
# header => the header (undef on error)
# file => actual source
# )
# files => []
# flags => ??
sub parserpms {
my (%options) = @_;
my $db = newdb();
$db->vsflags($options{checkrpms} ? [ "NOSIGNATURES" ] : [ qw(NOSIGNATURES NOPAYLOAD NODIGESTS) ]);
foreach my $rpm (@{$options{rpms} || []}) {
my $header = $db->rpm2header($options{path} ? "$options{path}/$rpm" : $rpm);
defined($options{callback}) and
$options{callback}->(
header => $header,
dir => $options{path} ? "$options{path}/" : "",
rpm => $rpm,
);
}
}
sub format_rpmpb {
my (@msgs) = @_;
my @ret;
foreach my $p (@msgs) {
$p->{pb} eq "BADARCH" and do {
push @ret, N("package %s is intended for a different architecture", $p->{pkg});
next;
};
$p->{pb} eq "BADOS" and do {
push @ret, N("package %s is intended for a different operating system", $p->{pkg});
next;
};
$p->{pb} eq "PKG_INSTALLED" and do {
push @ret, N("package %s is allready installed", $p->{pkg});
next;
};
$p->{pb} eq "BADRELOCATE" and do {
push @ret, N("path %s in package %s is not relocatable", $p->{path}, $p->{pkg});
next;
};
$p->{pb} eq "NEW_FILE_CONFLICT" and do {
push @ret, N("file %s conflicts between attempted installs of %s and %s", $p->{file}, $p->{pkg}, $p->{pkg2});
next;
};
$p->{pb} eq "FILE_CONFLICT" and do {
push @ret, N("file %s from install of %s conflicts with file from package %s", $p->{file}, $p->{pkg}, $p->{pkg2});
next;
};
$p->{pb} eq "OLDPACKAGE" and do {
push @ret, N("package %s (which is newer than %s) is already installed", $p->{pkg2}, $p->{pkg});
next;
};
$p->{pb} eq "DISKSPACE" and do {
push @ret, N("installing package %s needs %sB on the %s filesystem", $p->{pkg},
($p->{size} > 1024 * 1024
? ($p->{size} + 1024 * 1024 - 1) / (1024 * 1024)
: ($p->{size} + 1023) / 1024) .
($p->{size} > 1024 * 1024 ? 'M' : 'K'),
$p->{filesystem});
next;
};
$p->{pb} eq "DISKNODES" and do {
push @ret, N("installing package %s needs %ld inodes on the %s filesystem", $p->{pkg}, $p->{nodes}, $p->{filesystem});
next;
};
$p->{pb} eq "BADPRETRANS" and do {
push @ret, N("package %s pre-transaction syscall(s): %s failed: %s", $p->{pkg}, $p->{syscall}, $p->{error});
next;
};
$p->{pb} eq "REQUIRES" and do {
push @ret, N("%s is needed by %s%s", $p->{pkg2},
defined($p->{installed}) ? N("(installed) ") : "",
$p->{pkg});
next;
};
$p->{pb} eq "CONFLICT" and do {
push @ret, N("%s conflicts with %s%s", $p->{pkg2},
defined($p->{val2}) ? N("(installed) ") : "",
$p->{pkg});
next;
};
}
@ret;
}
##########################
# Alias for compatiblity #
##########################
sub specnew { newspec(@_) }
sub add_macro { addmacro(@_) }
sub del_macro { delmacro(@_) }
1;
__END__
( run in 0.778 second using v1.01-cache-2.11-cpan-71847e10f99 )