Support pkgutil for blastwave packages, where available
authorJamie Cameron <jcameron@webmin.com>
Fri, 24 Apr 2009 22:20:18 +0000 (22:20 +0000)
committerJamie Cameron <jcameron@webmin.com>
Fri, 24 Apr 2009 22:20:18 +0000 (22:20 +0000)
software/CHANGELOG
software/csw-lib.pl

index 5c1dc4a..e8ededf 100644 (file)
@@ -27,3 +27,5 @@ Added an Upgrade All button for CSW packages.
 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.
 The selected package and update systems are now checked when the module is opened, and an error message displayed if any needed commands are missing.
+---- Changes since 1.480 ----
+On Solaris, added support for the pkgutil command from Blastwave for installing packages, which replaces the old pkg-get.
index 44b070e..05342de 100644 (file)
@@ -1,8 +1,10 @@
 # csw-lib.pl
 # Functions for installing packages from Blastwave
 
-$pkg_get = -x "/opt/csw/bin/pkg-get" ? "/opt/csw/bin/pkg-get"
-                                    : &has_command("pkg-get");
+$pkg_get = -x "/opt/csw/bin/pkgutil" ? "/opt/csw/bin/pkgutil" :
+          -x "/opt/csw/bin/pkg-get" ? "/opt/csw/bin/pkg-get" :
+          &has_command("pkgutil") ? &has_command("pkgutil") :
+                                    &has_command("pkg-get");
 
 sub list_update_system_commands
 {
@@ -28,12 +30,14 @@ do {
                # Don't try the same update twice
                last;
                }
+       local $flag = $pkg_get =~ /pkgutil$/ ? "-y" : "-f";
        print "<b>",&text('csw_install',
-                       "<tt>$pkg_get -i -f $update</tt>"),"</b><p>\n";
+                       "<tt>$pkg_get -i $flag $update</tt>"),"</b><p>\n";
        $failed = 0;
        $retry = 0;
        print "<pre>";
-       &open_execute_command(PKGGET, "$pkg_get -i -f ".quotemeta($update), 2);
+       &open_execute_command(PKGGET,
+               "$pkg_get -i $flag ".quotemeta($update), 2);
        while(<PKGGET>) {
                if (!/^\s*\d+\%\s+\[/) {
                        # Output everything except download lines
@@ -95,7 +99,13 @@ while(<PKG>) {
        s/\r|\n//g;
        s/#.*$//;
        next if (/^\s*WARNING:/);
-       if (/^\s*(\S+)\s+(\S+)/) {
+       if (/^\s*(\S+)\s+(\S+)\s+(\d\S+)\s+([0-9\.]+)\s+(KB|MB|GB)/i) {
+               # New pkgutil format
+               push(@rv, { 'name' => $1, 'version' => $3,
+                           'select' => "$1-$3" });
+               }
+       elsif (/^\s*(\S+)\s+(\S+)/) {
+               # Old pkg-get format
                push(@rv, { 'name' => $1, 'version' => $2,
                            'select' => "$1-$2" });
                }