Added package_files function

This commit is contained in:
Jamie Cameron
2009-01-11 07:45:34 +00:00
parent d6665191e8
commit effb16ee49
5 changed files with 71 additions and 0 deletions

View File

@@ -25,3 +25,4 @@ Added detection of epochs for RPMs and packages from YUM.
Added an Upgrade All button for CSW packages.
---- Changes since 1.440 ----
Added a Module Config option to not use any update system, even if YUM or APT are installed.
Added the function package_files for other modules to call, when only a list of files in some package is needed.

View File

@@ -90,6 +90,22 @@ while($file = <PKGINFO>) {
return $i;
}
# package_files(package)
# Returns a list of all files in some package
sub package_files
{
local ($pkg) = @_;
local $qn = quotemeta($pkg);
local @rv;
&open_execute_command(RPM, "dpkg --listfiles $qn", 1, 1);
while(<RPM>) {
s/\r|\n//g;
push(@rv, $_);
}
close(RPM);
return @rv;
}
# installed_file(file)
# Given a filename, fills %file with details of the given file and returns 1.
# If the file is not known to the package system, returns 0

View File

@@ -70,6 +70,24 @@ while($file = <PKGINFO>) {
return $i;
}
# package_files(package)
# Returns a list of all files in some package
sub package_files
{
local ($pkg) = @_;
local $qn = quotemeta($pkg);
local @rv;
&open_execute_command(RPM, "pkg_info -L $qn", 1, 1);
while(<RPM>) {
s/\r|\n//g;
if (/^\//) {
push(@rv, $_);
}
}
close(RPM);
return @rv;
}
# installed_file(file)
# Given a filename, fills %file with details of the given file and returns 1.
# If the file is not known to the package system, returns 0

View File

@@ -285,6 +285,22 @@ close(RPM);
return $i;
}
# package_files(package, [version])
# Returns a list of all files in some package
sub package_files
{
local ($pkg, $version) = @_;
local $qn = quotemeta($version ? "$pkg-$version" : $pkg);
local @rv;
&open_execute_command(RPM, "rpm -q -l $qn", 1, 1);
while(<RPM>) {
s/\r|\n//g;
push(@rv, $_);
}
close(RPM);
return @rv;
}
# installed_file(file)
# Given a filename, fills %file with details of the given file and returns 1.
# If the file is not known to the package system, returns 0

View File

@@ -120,6 +120,26 @@ while($file = <PKG>) {
return $i;
}
# package_files(package)
# Returns a list of all files in some package
sub package_files
{
local ($pkg) = @_;
local @rv;
&open_readfile(PKG, "$package_dir/$_[0]");
while(<PKG>) {
last if (/^FILE LIST:/i);
}
while(my $file = <PKG>) {
$file =~ s/\r|\n//g;
next if ($file eq "./");
$file = '/'.$file;
push(@rv, $file);
}
close(PKG);
return @rv;
}
# installed_file(file)
# Given a filename, fills %file with details of the given file and returns 1.
# If the file is not known to the package system, returns 0