diff --git a/software/CHANGELOG b/software/CHANGELOG index 2762e80c4..7aadebbc9 100644 --- a/software/CHANGELOG +++ b/software/CHANGELOG @@ -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. diff --git a/software/debian-lib.pl b/software/debian-lib.pl index 466b30735..6d63d8236 100644 --- a/software/debian-lib.pl +++ b/software/debian-lib.pl @@ -90,6 +90,22 @@ while($file = ) { 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() { + 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 diff --git a/software/freebsd-lib.pl b/software/freebsd-lib.pl index f02ad504e..1ac18e8eb 100644 --- a/software/freebsd-lib.pl +++ b/software/freebsd-lib.pl @@ -70,6 +70,24 @@ while($file = ) { 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() { + 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 diff --git a/software/rpm-lib.pl b/software/rpm-lib.pl index 6a56c4ea2..95611fcec 100644 --- a/software/rpm-lib.pl +++ b/software/rpm-lib.pl @@ -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() { + 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 diff --git a/software/slackware-lib.pl b/software/slackware-lib.pl index ae5c25d42..a4c339aca 100644 --- a/software/slackware-lib.pl +++ b/software/slackware-lib.pl @@ -120,6 +120,26 @@ while($file = ) { 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() { + last if (/^FILE LIST:/i); + } +while(my $file = ) { + $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