changeset 21624:cf227735d5fd

pkg: remove support for autoload (automatically loading package at start). * pkg.m, pkg/private/install.m, pkg/private/load_packages.m, pkg/private/rebuild.m: remove support for automatically loading packages. Having octave itself and the package manager automatically load packages is a bad idea. If a user wants to load a package at startup then it should specify it on its octaverc file. This can also be done on the system-wide octaverc file. This also simplifies pkg (this patch only removes code). * startup/version-rcfile: do not run 'pkg ("load", "auto")' at startup. * doc/interpreter/package.txi: remove mention of package autoload from the manual.
author Carnë Draug <carandraug@octave.org>
date Sun, 10 Apr 2016 23:00:07 +0100
parents 555b6c78d677
children 3cadca91e390
files doc/interpreter/package.txi scripts/pkg/pkg.m scripts/pkg/private/install.m scripts/pkg/private/load_packages.m scripts/pkg/private/rebuild.m scripts/startup/version-rcfile
diffstat 6 files changed, 15 insertions(+), 108 deletions(-) [+]
line wrap: on
line diff
--- a/doc/interpreter/package.txi	Thu Apr 14 10:27:07 2016 +1000
+++ b/doc/interpreter/package.txi	Sun Apr 10 23:00:07 2016 +0100
@@ -386,13 +386,6 @@
 @item Url
 Optional list of homepages related to the package.
 
-@item Autoload
-Optional field that sets the default loading behavior for the package.
-If set to @code{yes}, @code{true} or @code{on}, then Octave will
-automatically load the package when starting.  Otherwise the package
-must be manually loaded with the pkg load command.  This default
-behavior can be overridden when the package is installed.
-
 @item Depends
 A list of other Octave packages that this package depends on.  This can
 include dependencies on particular versions, with a format
--- a/scripts/pkg/pkg.m	Thu Apr 14 10:27:07 2016 +1000
+++ b/scripts/pkg/pkg.m	Sun Apr 10 23:00:07 2016 +0100
@@ -48,14 +48,6 @@
 ## is possible to install a package even when it depends on another package
 ## which is not installed on the system.  @strong{Use this option with care.}
 ##
-## @item -noauto
-## The package manager will not automatically load the installed package
-## when starting Octave.  This overrides any setting within the package.
-##
-## @item -auto
-## The package manager will automatically load the installed package when
-## starting Octave.  This overrides any setting within the package.
-##
 ## @item -local
 ## A local installation (package available only to current user) is forced,
 ## even if the user has system privileges.
@@ -271,15 +263,6 @@
 ## @item rebuild
 ## Rebuild the package database from the installed directories.  This can
 ## be used in cases where the package database has been corrupted.
-## It can also take the @option{-auto} and @option{-noauto} options to allow
-## the autoloading state of a package to be changed.  For example,
-##
-## @example
-## pkg rebuild -noauto image
-## @end example
-##
-## @noindent
-## will remove the autoloading status of the image package.
 ##
 ## @end table
 ## @seealso{ver, news}
@@ -320,7 +303,6 @@
   endif
   files = {};
   deps = true;
-  auto = 0;
   action = "none";
   verbose = false;
   octave_forge = false;
@@ -328,10 +310,15 @@
     switch (varargin{i})
       case "-nodeps"
         deps = false;
+      ## TODO completely remove these warnings after some releases.
       case "-noauto"
-        auto = -1;
+        warning ("Octave:deprecated-option",
+                 ["pkg: autoload is no longer supported.  The -noauto "...
+                  "option is no longer required."]);
       case "-auto"
-        auto = 1;
+        warning ("Octave:deprecated-option",
+                 ["pkg: autoload is no longer supported.  Add a "...
+                  "'pkg load ...' command to octaverc instead."]);
       case "-verbose"
         verbose = true;
         ## Send verbose output to pager immediately.  Change setting locally.
@@ -407,7 +394,7 @@
           endif
         endif
 
-        install (files, deps, auto, prefix, archprefix, verbose, local_list,
+        install (files, deps, prefix, archprefix, verbose, local_list,
                  global_list, global_install);
 
       unwind_protect_cleanup
@@ -422,7 +409,7 @@
 
     case "load"
       if (isempty (files))
-        error ("pkg: load action requires at least one package, 'all', or 'auto'");
+        error ("pkg: load action requires at least one package or 'all'");
       endif
       load_packages (files, deps, local_list, global_list);
 
@@ -508,7 +495,7 @@
     case "rebuild"
       if (global_install)
         global_packages = rebuild (prefix, archprefix, global_list, files,
-                                   auto, verbose);
+                                   verbose);
         global_packages = save_order (global_packages);
         save (global_list, "global_packages");
         if (nargout)
@@ -516,7 +503,7 @@
         endif
       else
         local_packages = rebuild (prefix, archprefix, local_list, files,
-                                  auto, verbose);
+                                  verbose);
         local_packages = save_order (local_packages);
         save (local_list, "local_packages");
         if (! nargout)
@@ -571,4 +558,3 @@
   endswitch
 
 endfunction
-
--- a/scripts/pkg/private/install.m	Thu Apr 14 10:27:07 2016 +1000
+++ b/scripts/pkg/private/install.m	Sun Apr 10 23:00:07 2016 +0100
@@ -18,11 +18,11 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {} {} install (@var{files}, @var{handle_deps}, @var{autoload}, @var{prefix}, @var{archprefix}, @var{verbose}, @var{local_list}, @var{global_list}, @var{global_install})
+## @deftypefn {} {} install (@var{files}, @var{handle_deps}, @var{prefix}, @var{archprefix}, @var{verbose}, @var{local_list}, @var{global_list}, @var{global_install})
 ## Undocumented internal function.
 ## @end deftypefn
 
-function install (files, handle_deps, autoload, prefix, archprefix, verbose,
+function install (files, handle_deps, prefix, archprefix, verbose,
                   local_list, global_list, global_install)
 
   ## Check that the directory in prefix exist. If it doesn't: create it!
@@ -254,29 +254,6 @@
     endif
   endfor
 
-  ## If the package requested that it is autoloaded, or the installer
-  ## requested that it is, then mark the package as autoloaded.
-  str_true = {"true", "on", "yes", "1"};
-  for i = length (descriptions):-1:1
-
-    desc_autoload = false;
-    if (isfield (descriptions{i}, "autoload"))
-      a = descriptions{i}.autoload;
-      desc_autoload = ((isnumeric (a) && a > 0)
-                       || (ischar (a)
-                           && any (strcmpi (a, str_true))));
-    endif
-
-    if (autoload > 0 || (autoload == 0 && desc_autoload))
-      fclose (fopen (fullfile (descriptions{i}.dir, "packinfo",
-                               ".autoload"), "wt"));
-      descriptions{i}.autoload = 1;
-    else
-      descriptions{i}.autoload = 0;
-    endif
-
-  endfor
-
   ## Add the packages to the package list.
   try
     if (global_install)
@@ -314,25 +291,6 @@
     endif
   endfor
 
-  ## Add the newly installed packages to the path, so the user
-  ## can begin using them. Only load them if they are marked autoload.
-  if (length (descriptions) > 0)
-    idx = [];
-    for i = 1:length (descriptions)
-      if (descriptions{i}.autoload > 0)
-        nm = descriptions{i}.name;
-        for j = 1:length (installed_pkgs_lst)
-          if (strcmp (nm, installed_pkgs_lst{j}.name))
-            idx(end + 1) = j;
-            break;
-          endif
-        endfor
-      endif
-    endfor
-    load_packages_and_dependencies (idx, handle_deps, installed_pkgs_lst,
-                                    global_install);
-  endif
-
   ## If there is a NEWS file, mention it.
   ## Check if desc exists too because it's possible to get to this point
   ## without creating it such as giving an invalid filename for the package
--- a/scripts/pkg/private/load_packages.m	Thu Apr 14 10:27:07 2016 +1000
+++ b/scripts/pkg/private/load_packages.m	Sun Apr 10 23:00:07 2016 +0100
@@ -36,15 +36,6 @@
   ## Load all.
   if (length (files) == 1 && strcmp (files{1}, "all"))
     idx = [1:length(installed_pkgs_lst)];
-  ## Load auto.
-  elseif (length (files) == 1 && strcmp (files{1}, "auto"))
-    idx = [];
-    for i = 1:length (installed_pkgs_lst)
-      if (exist (fullfile (pdirs{i}, "packinfo", ".autoload"), "file"))
-        idx(end + 1) = i;
-      endif
-    endfor
-  ## Load package_name1 ...
   else
     idx = [];
     for i = 1:length (files)
--- a/scripts/pkg/private/rebuild.m	Thu Apr 14 10:27:07 2016 +1000
+++ b/scripts/pkg/private/rebuild.m	Sun Apr 10 23:00:07 2016 +0100
@@ -18,11 +18,11 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {} {@var{descriptions} =} rebuild (@var{prefix}, @var{archprefix}, @var{list}, @var{files}, @var{auto}, @var{verbose})
+## @deftypefn {} {@var{descriptions} =} rebuild (@var{prefix}, @var{archprefix}, @var{list}, @var{files}, @var{verbose})
 ## Undocumented internal function.
 ## @end deftypefn
 
-function descriptions = rebuild (prefix, archprefix, list, files, auto, verbose)
+function descriptions = rebuild (prefix, archprefix, list, files, verbose)
   if (isempty (files))
     [dirlist, err, msg] = readdir (prefix);
     if (err)
@@ -50,23 +50,6 @@
       desc = get_description (descfile);
       desc.dir = fullfile (prefix, dirlist{k});
       desc.archprefix = fullfile (archprefix, [desc.name "-" desc.version]);
-      if (auto != 0)
-        if (exist (fullfile (desc.dir, "packinfo", ".autoload"), "file"))
-          unlink (fullfile (desc.dir, "packinfo", ".autoload"));
-        endif
-        if (auto < 0)
-          desc.autoload = 0;
-        elseif (auto > 0)
-          desc.autoload = 1;
-          fclose (fopen (fullfile (desc.dir, "packinfo", ".autoload"), "wt"));
-        endif
-      else
-        if (exist (fullfile (desc.dir, "packinfo", ".autoload"), "file"))
-          desc.autoload = 1;
-        else
-          desc.autoload = 0;
-        endif
-      endif
       descriptions{end + 1} = desc;
     elseif (verbose)
       warning ("directory %s is not a valid package", dirlist{k});
--- a/scripts/startup/version-rcfile	Thu Apr 14 10:27:07 2016 +1000
+++ b/scripts/startup/version-rcfile	Sun Apr 10 23:00:07 2016 +0100
@@ -16,10 +16,6 @@
   PAGER_FLAGS ('-e -X -P"-- less ?pB(%pB\\%):--. (f)orward, (b)ack, (q)uit$"');
 endif
 
-## This appears here instead of in the pkg/PKG_ADD file so that --norc
-## will also skip automatic loading of packages.
-pkg ("load", "auto");
-
 ## For Matlab compatibility, run startup.m when starting Octave.
 if (exist ("startup", "file"))
   startup;  # No arg list here since startup might be a script.