Mercurial > octave
changeset 26207:b964092ad9f8
pkg.m: Allow updating a list of supplied packages, instead of all (bug #48151).
* pkg.m: Delete code emitting an error if package names are supplied for
"update" command. Add code to compare list of package names to list
of installed packages and only update installed packages.
author | Nicholas R. Jankowski <jankowskin@asme.org> |
---|---|
date | Tue, 11 Dec 2018 17:08:10 -0800 |
parents | aaa23f9845dd |
children | fc7b842daca1 |
files | scripts/pkg/pkg.m |
diffstat | 1 files changed, 14 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/pkg/pkg.m Tue Dec 11 16:00:43 2018 -0800 +++ b/scripts/pkg/pkg.m Tue Dec 11 17:08:10 2018 -0800 @@ -560,12 +560,21 @@ case "update" installed_pkgs_lst = installed_packages (local_list, global_list); + ## Explicit list of packages to update, rather than all packages if (numel (files) > 0) - ## This was option was broken during two releases and no one - ## notice so we are guessing no one actually uses it. If the - ## user knows the names of the packages to be installed, it - ## might as well call install (which is what update is doing) - error ("pkg: to update individual packages, use 'pkg install -forge'"); + update_lst = {}; + installed_names = cellfun (@(idx) idx.name, installed_pkgs_lst, + "UniformOutput", false); + for i = 1:numel (files) + idx = find (strcmp (files{i}, installed_names), 1); + if (isempty (idx)) + warning ("pkg: package %s is not installed - skipping update", + files{i}); + else + update_lst = [ update_lst, installed_pkgs_lst(idx) ]; + endif + endfor + installed_pkgs_lst = update_lst; endif for i = 1:numel (installed_pkgs_lst)