octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch for a pkg update command


From: Lukas Reichlin
Subject: Patch for a pkg update command
Date: Thu, 7 Jul 2011 17:06:05 +0200

Dear Octave community

I've just extended the "pkg" command by an "update" option.  It checks against 
OctaveForge whether any installed packages are outdated and updates them if 
necessary.  If this feature is of any interest, I could work on a more 
elaborated version (print a version table similar to "pkg list", "pkg list 
-outdated", ...)

Best regards
Lukas


--- pkg_original.m      2011-07-07 15:50:20.000000000 +0200
+++ pkg.m       2011-07-07 16:45:34.000000000 +0200
@@ -267,7 +267,8 @@
 
   available_actions = {"list", "install", "uninstall", "load", ...
                        "unload", "prefix", "local_list", ...
-                       "global_list", "rebuild", "build","describe"};
+                       "global_list", "rebuild", "build", ...
+                       "describe", "update"};
   ## Handle input
   if (length (varargin) == 0 || ! iscellstr (varargin))
     print_usage ();
@@ -492,6 +493,21 @@
           error ("you can request at most two outputs when calling 'pkg 
describe'");
       endswitch
 
+    case "update"
+      if (nargout == 0)
+        installed_pkgs_lst = installed_packages (local_list, global_list);
+        for i = 1:length (installed_pkgs_lst)
+          installed_pkg_name = installed_pkgs_lst{i}.name;
+          installed_pkg_version = installed_pkgs_lst{i}.version;
+          forge_pkg_version = get_forge_pkg (installed_pkg_name);
+          if (compare_versions (forge_pkg_version, installed_pkg_version, ">"))
+            feval (@pkg, "install", "-forge", installed_pkg_name);
+          endif
+        endfor
+      else
+        error ("no output arguments available");
+      endif
+
     otherwise
       error ("you must specify a valid action for 'pkg'. See 'help pkg' for 
details");
   endswitch



Attachment: pkg_update_patch
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]