Mercurial > octave
comparison scripts/pkg/pkg.m @ 30419:420608d1d370 stable
Enable pkg update to accept options for install (bug #56128, #60573, #60574)
* scripts/pkg/pkg.m: passes updates to pkg install, limits global/local scope
to global/local files as appropriate.
* NEWS: notes expanded pkg update behavior.
author | Nicholas R. Jankowski <jankowski.nicholas@gmail.com> |
---|---|
date | Thu, 02 Dec 2021 11:24:41 -0500 |
parents | 0fee9e910d84 |
children | 796f54d4ddbf |
comparison
equal
deleted
inserted
replaced
30418:c32b6a3805e7 | 30419:420608d1d370 |
---|---|
162 ## | 162 ## |
163 ## @item update | 163 ## @item update |
164 ## Check installed Octave Forge packages against repository and update any | 164 ## Check installed Octave Forge packages against repository and update any |
165 ## outdated items. Updated packages are installed either globally or locally | 165 ## outdated items. Updated packages are installed either globally or locally |
166 ## depending on whether Octave is running with elevated privileges. This | 166 ## depending on whether Octave is running with elevated privileges. This |
167 ## requires an internet connection and the cURL library. Usage: | 167 ## requires an internet connection and the cURL library. |
168 ## | 168 ## |
169 ## Options for the install command and the names of individual packages to be | |
170 ## checked for updates may be specified as a list following the update | |
171 ## command. If the @option{-local} or @option{-global} option is specified, | |
172 ## @code{pkg update} limits the update check to the local or global installed | |
173 ## packages, and installs updates in that same context. For example, | |
174 ## | |
175 ## Update all packages: | |
169 ## @example | 176 ## @example |
170 ## pkg update | 177 ## pkg update |
171 ## @end example | 178 ## @end example |
172 ## | 179 ## |
173 ## @noindent | 180 ## Update all local packages: |
174 ## To update a single package use @code{pkg install -forge} | 181 ## @example |
175 ## | 182 ## pkg update -local |
176 ## @noindent | 183 ## @end example |
177 ## Updates for multiple packages are sorted alphabetically and not checked for | 184 ## |
178 ## dependencies affected by installation order. If dependency order related | 185 ## Update certain packages, ignore dependencies, max verbosity: |
179 ## @code{pkg update} failures occur, use @code{pkg install -forge} to update | 186 ## @example |
180 ## packages individually. | 187 ## pkg update -verbose -nodeps image signal geometry |
188 ## @end example | |
189 ## | |
190 ## @noindent | |
191 ## Updates for multiple packages are sorted alphabetically and not checked | |
192 ## for dependencies affected by installation order. If dependency order | |
193 ## related @code{pkg update} failure occurs, use @code{pkg update -nodeps} to | |
194 ## ignore dependencies, or @code{pkg install -forge <package_name>} to update | |
195 ## individual packages manually. | |
181 ## | 196 ## |
182 ## @item uninstall | 197 ## @item uninstall |
183 ## Uninstall named packages. For example, | 198 ## Uninstall named packages. For example, |
184 ## | 199 ## |
185 ## @example | 200 ## @example |
714 endif | 729 endif |
715 | 730 |
716 case "update" | 731 case "update" |
717 installed_pkgs_lst = installed_packages (local_list, global_list); | 732 installed_pkgs_lst = installed_packages (local_list, global_list); |
718 | 733 |
734 ## If -global or -local, limit updates to global or local list pkgs | |
735 globalflag = any (strcmp (varargin, "-global")); | |
736 localflag = any (strcmp (varargin, "-local")); | |
737 if (globalflag || localflag) | |
738 if (globalflag && localflag) | |
739 error ("pkg: cannot specify both global and local options.") | |
740 elseif (globalflag) | |
741 [~, installed_pkgs_lst] = installed_packages (local_list, global_list); | |
742 else | |
743 [installed_pkgs_lst, ~] = installed_packages (local_list, global_list); | |
744 endif | |
745 else | |
746 installed_pkgs_lst = installed_packages (local_list, global_list); | |
747 endif | |
748 | |
719 ## Explicit list of packages to update, rather than all packages | 749 ## Explicit list of packages to update, rather than all packages |
720 if (numel (files) > 0) | 750 if (numel (files) > 0) |
721 update_lst = {}; | 751 update_lst = {}; |
722 installed_names = cellfun (@(idx) idx.name, installed_pkgs_lst, | 752 installed_names = cellfun (@(idx) idx.name, installed_pkgs_lst, |
723 "UniformOutput", false); | 753 "UniformOutput", false); |
742 warning ("pkg: package %s not found on Octave Forge - skipping update\n", | 772 warning ("pkg: package %s not found on Octave Forge - skipping update\n", |
743 installed_pkg_name); | 773 installed_pkg_name); |
744 forge_pkg_version = "0"; | 774 forge_pkg_version = "0"; |
745 end_try_catch | 775 end_try_catch |
746 if (compare_versions (forge_pkg_version, installed_pkg_version, ">")) | 776 if (compare_versions (forge_pkg_version, installed_pkg_version, ">")) |
747 feval (@pkg, "install", "-forge", installed_pkg_name); | 777 options_to_pass = varargin (strncmp (varargin, "-", 1)); |
778 options_to_pass(end+1) = "-forge"; | |
779 feval (@pkg, "install", options_to_pass{:}, installed_pkg_name); | |
748 endif | 780 endif |
749 endfor | 781 endfor |
750 | 782 |
751 case "test" | 783 case "test" |
752 if (isempty (files)) | 784 if (isempty (files)) |