RPM-Info
view release on metacpan or search on metacpan
{
@files = ();
foreach $line (@output)
{
chomp $line;
@line = split(/\//,$line);
if (($line =~ m/^$dir/) && (length($line) != length($dir)))
{
push(@files,$line[$#line]);
}
}
$$ref{$dir}{'files'} = [@files];
}
return 0;
}
=head2 getRpmVer()
gets the version of rpm and returns it
=cut
sub getRpmVer()
{
my $self = shift;
my $ver = (`rpm --version`);
chomp $ver;
return $ver;
}
=head2 getRpmInfo((result(Hash Reference), rpmname(scalar))
gets Infos about the specified rpm and saves them into
a Hash of Hashes
returns 0 on succes - 1 on failure
=cut
sub getRpmInfo()
{
my $self = shift;
my $ref = shift;
my $rpmseek = shift;
my @output = `rpm -qi $rpmseek`;
my $line = "";
my $i = 0;
undef %$ref;
if ($#output < 0)
{
return 1;
}
LINE:foreach $line (@output)
{
if ($line =~ /(Name+).*: ([(\/\w].*.[\w\/)]) .*. (Relocations+).*: ([(\/\w].*.[\w\/)])/)
{
$$ref{'name'} = $2;
$$ref{'relocations'} =$4;
next LINE;
}
if ($line =~ /(Version+).*: ([(\/\w].*.[\w\/)]) .*. (Vendor+).*: ([(\/\w].*.[\w\/)])/)
{
$$ref{'version'} = $2;
$$ref{'vendor'} =$4;
next LINE;
}
if ($line =~ /(Release+).*: ([(\/\w].*.[\w\/)]) .*. (Build Date+).*: ([(\/\w].*.[\w\/)])/)
{
$$ref{'release'} = $2;
$$ref{'build_date'} =$4;
next LINE;
}
if ($line =~ /(Install date+).*: ([(\/\w].*.[\w\/)]) .*. (Build Host+).*: ([(\/\w].*.[\w\/)])/)
{
$$ref{'install_date'} = $2;
$$ref{'build_host'} =$4;
next LINE;
}
if ($line =~ /(Group+).*: ([(\/\w].*.[\w\/)]) .*. (Source RPM+).*: ([(\/\w].*.[\w\/)])/)
{
$$ref{'group'} = $2;
$$ref{'source_rpm'} =$4;
next LINE;
}
if ($line =~ /(Size+).*: ([(\/\w].*.[\w\/)]) .*. (License+).*: ([(\/\w].*.[\w\/)])/)
{
$$ref{'size'} = $2;
$$ref{'license'} =$4;
next LINE;
}
if ($line =~ m/(Summary+).*: ([(\/\w].*.[\w\/)])/)
{
$$ref{'summary'} = $2;
next LINE;
}
if ($line =~ m/(URL+).*: ([(\/\w].*.[\w\/)])/)
{
$$ref{'url'} = $2;
next LINE;
}
if ($line =~ m/(Packager+).*: ([(\/\w].*.[\w\/)])/)
{
$$ref{'packager'} = $2;
next LINE;
}
if ($line =~ m/(Distribution+).*: ([(\/\w].*.[\w\/)])/)
{
$$ref{'distribution'} = $2;
next LINE;
}
}
return 0;
}
=head2 getRpmRequirements((result(Array Reference), rpmname(scalar))
gets all the requirements of the specified rpm and saves them into an array
( run in 0.786 second using v1.01-cache-2.11-cpan-5511b514fd6 )