Added package_files function
authorJamie Cameron <jcameron@webmin.com>
Sun, 11 Jan 2009 07:45:34 +0000 (07:45 +0000)
committerJamie Cameron <jcameron@webmin.com>
Sun, 11 Jan 2009 07:45:34 +0000 (07:45 +0000)
software/CHANGELOG
software/debian-lib.pl
software/freebsd-lib.pl
software/rpm-lib.pl
software/slackware-lib.pl

index 2762e80..7aadebb 100644 (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.
index 466b307..6d63d82 100644 (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
index f02ad50..1ac18e8 100644 (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
index 6a56c4e..95611fc 100644 (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
index ae5c25d..a4c339a 100644 (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