changeset 6258:ea3a7e8469e9

[project @ 2007-01-30 20:17:19 by dbateman]
author dbateman
date Tue, 30 Jan 2007 20:17:19 +0000
parents 44c91c5dfe1d
children 77df53484011
files scripts/ChangeLog scripts/pkg/pkg.m
diffstat 2 files changed, 157 insertions(+), 88 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,86 +1,10 @@
-<<<<<<< ChangeLog
-2007-01-24  David Bateman  <dbateman@free.fr>
-
-	* pkg/pkg.m: Install ChangeLog file if it exists.
-	Delete bare newline in string passed to write_INDEX.
-
-	* sparse/sprandsym.m: Make work for even values of N.
-
-2007-01-24  John W. Eaton  <jwe@octave.org>
-
-	* miscellaneous/news.m: New file.
-
-2007-01-23  Luis F. Ortiz  <lortiz@interactivesupercomputing.com>
-
-	* strings/strncmpi.m: Use strncmp instead of calling strtrunc on args.
-
-	* strings/strncmp.m: Delete (we now have a built-in version).
-
-2007-01-22  Bob Weigel <rweigel@gmu.edu>
-
-	* testfun/test.m: Check for all files in path, use first found.
-
-2007-01-22  David Bateman  <dbateman@free.fr>
-
-	* polynomial/spline.m: Make DG a column instead of a row vector.
-
-2007-01-18  Søren Hauberg  <hauberg@gmail.com>
-
-	* pkg/pkg.m (copy_files): Call write_INDEX with correct target
-	file name.
-
-	* image/ind2rgb.m: Better input checking.  Return 3-d array if
-	nargout is 1.  Handle colormaps that have too few colors.
-
-	* pkg/pkg.m (create_pkgadddel): Call fullfile with nm, not "nm".
-	(configure_make): Use fullfile instead of concatenating with "/".
-
-2007-01-10  Baylis Shanks  <bshanks3@hotmail.com>
-
-	* set/ismember.m: Handle N-d arrays.
-
-2007-01-10  David Bateman  <dbateman@free.fr>
-
-	* elfun/acosd.m, elfun/acotd.m, elfun/acscd.m, elfun/asecd.m,
-	elfun/asind.m, elfun/atand.m, elfun/cosd.m, elfun/cotd.m,
-	elfun/cscd.m, elfun/secd.m, elfun/sind.m, elfun/tand.m:
-	New files.
-
-2007-01-09  Søren Hauberg  <hauberg@gmail.com>
-
-         * pkg/pkg.m: Allow filenames to contain glob patterns.
-
-2007-01-08  Søren Hauberg  <hauberg@gmail.com>
-
-	* pkg/pkg.m: Use copyfile instead of calling system.  Use fullfile
-	instead of concatenating with "/".  Use mlock to ensure that
-	persistent variables are not clobbered if user types clear all.
-
-2007-01-08  John W. Eaton  <jwe@octave.org>
-
-	* miscellaneous/copyfile.m, miscellaneous/movefile.m:
-	Improve handling of file names containing globbing characters.
-	From Søren Hauberg <hauberg@gmail.com>.
-
-2007-01-05  John W. Eaton  <jwe@octave.org>
-
-	* optimization/optimset.m, optimization/__fsolve_defopts__.m:
-	New files.
-
-2006-12-30  John W. Eaton  <jwe@octave.org>
-
-	* sparse/spfun.m: Check for "function_handle" not "function handle".
-	* plot/fplot.m: Likewise.  Use isa instead of strcmp + class.
-
-2006-12-27  Søren Hauberg  <hauberg@gmail.com>
-
-	* image/imshow.m: Strip NaNs from image.
-
-2006-12-08  David Bateman  <dbateman@free.fr>
-
-	* sparse/normest.m: New file.
-
-=======
+2007-01-30  David Bateman  <dbateman@free.fr>
+
+	* pkg/pkg.m (pkg, isautoload, install, load_packages): Add ability
+	to flag a package as to be autoloaded. Add install flags -noauto, 
+	-auto to force autoload behavior.
+	(installed_packages): Make list of installed packages unique.
+
 2007-01-29  John W. Eaton  <jwe@octave.org>
 
 	* plot/subplot.m: Set nextplot property of current figure to "add".
@@ -196,6 +120,31 @@
 	* plot/__uiobject_globals__.m: Call __lock_global__ when
 	initializing each global variable.
 
+2007-01-24  David Bateman  <dbateman@free.fr>
+
+	* pkg/pkg.m: Install ChangeLog file if it exists.
+	Delete bare newline in string passed to write_INDEX.
+
+	* sparse/sprandsym.m: Make work for even values of N.
+
+2007-01-24  John W. Eaton  <jwe@octave.org>
+
+	* miscellaneous/news.m: New file.
+
+2007-01-23  Luis F. Ortiz  <lortiz@interactivesupercomputing.com>
+
+	* strings/strncmpi.m: Use strncmp instead of calling strtrunc on args.
+
+	* strings/strncmp.m: Delete (we now have a built-in version).
+
+2007-01-22  Bob Weigel <rweigel@gmu.edu>
+
+	* testfun/test.m: Check for all files in path, use first found.
+
+2007-01-22  David Bateman  <dbateman@free.fr>
+
+	* polynomial/spline.m: Make DG a column instead of a row vector.
+
 2007-01-18  John W. Eaton  <jwe@octave.org>
 
 	* plot/__uiobject_globals__.m (__uiobject_handles_free_list__,
@@ -210,6 +159,17 @@
 	handles here.  Return figure handle.
 	* plot/figure.m: Call __uiobject_init_figure__ to allocate handle.
 
+2007-01-18  Søren Hauberg  <hauberg@gmail.com>
+
+	* pkg/pkg.m (copy_files): Call write_INDEX with correct target
+	file name.
+
+	* image/ind2rgb.m: Better input checking.  Return 3-d array if
+	nargout is 1.  Handle colormaps that have too few colors.
+
+	* pkg/pkg.m (create_pkgadddel): Call fullfile with nm, not "nm".
+	(configure_make): Use fullfile instead of concatenating with "/".
+
 2007-01-11  John W. Eaton  <jwe@octave.org>
 
 	* plot/__uiobject_draw_axes__.m: Use "%g", not "%.4g" when writing
@@ -250,6 +210,51 @@
 	* plot/clf.m, plot/closereq.m, plot/newplot.m: No need to remove
 	and free child.
 
+2007-01-10  Baylis Shanks  <bshanks3@hotmail.com>
+
+	* set/ismember.m: Handle N-d arrays.
+
+2007-01-10  David Bateman  <dbateman@free.fr>
+
+	* elfun/acosd.m, elfun/acotd.m, elfun/acscd.m, elfun/asecd.m,
+	elfun/asind.m, elfun/atand.m, elfun/cosd.m, elfun/cotd.m,
+	elfun/cscd.m, elfun/secd.m, elfun/sind.m, elfun/tand.m:
+	New files.
+
+2007-01-09  Søren Hauberg  <hauberg@gmail.com>
+
+         * pkg/pkg.m: Allow filenames to contain glob patterns.
+
+2007-01-08  Søren Hauberg  <hauberg@gmail.com>
+
+	* pkg/pkg.m: Use copyfile instead of calling system.  Use fullfile
+	instead of concatenating with "/".  Use mlock to ensure that
+	persistent variables are not clobbered if user types clear all.
+
+2007-01-08  John W. Eaton  <jwe@octave.org>
+
+	* miscellaneous/copyfile.m, miscellaneous/movefile.m:
+	Improve handling of file names containing globbing characters.
+	From Søren Hauberg <hauberg@gmail.com>.
+
+2007-01-05  John W. Eaton  <jwe@octave.org>
+
+	* optimization/optimset.m, optimization/__fsolve_defopts__.m:
+	New files.
+
+2006-12-30  John W. Eaton  <jwe@octave.org>
+
+	* sparse/spfun.m: Check for "function_handle" not "function handle".
+	* plot/fplot.m: Likewise.  Use isa instead of strcmp + class.
+
+2006-12-27  Søren Hauberg  <hauberg@gmail.com>
+
+	* image/imshow.m: Strip NaNs from image.
+
+2006-12-08  David Bateman  <dbateman@free.fr>
+
+	* sparse/normest.m: New file.
+
 2006-12-08  John W. Eaton  <jwe@octave.org>
 
 	* plot/gcf.m: Check if the root figure object's currentfigure
@@ -304,7 +309,6 @@
 	plot/contour.m, plot/mplot.m, plot/multiplot.m, plot/oneplot.m,
 	plot/plot_border.m, plot/subwindow.m: Delete.
 
->>>>>>> 1.656.2.18
 2006-12-06  Michael Goffioul  <michael.goffioul@swing.be>.
 
 	* miscellaneous/copyfile.m, miscellaneous/movefile.m:
--- a/scripts/pkg/pkg.m
+++ b/scripts/pkg/pkg.m
@@ -33,6 +33,14 @@
 ## dependency checking. That way it is possible to install a package even
 ## if it depends on another package that's not installed on the system.
 ## @strong{Use this option with care.}
+##
+## If @var{option} is @code{-noauto} the package manager will not
+## automatically load the installed package when starting Octave,
+## even if the package requests that it is.
+##
+## If @var{option} is @code{-auto} the package manager will
+## automatically load the installed package when starting Octave,
+## even if the package requests that it isn't.
 ## @item uninstall
 ## Uninstall named packages.  For example,
 ## @example
@@ -114,6 +122,7 @@
 ## @end deftypefn
 
 ## PKG_ADD: mark_as_command pkg
+## PKG_ADD: pkg ("load", "auto");
 
 function [local_packages, global_packages] = pkg(varargin)
     ## Installation prefix (XXX: what should these be on windows?)
@@ -137,11 +146,16 @@
     endif
     files = {};
     deps = true;
+    auto = 0;
     action = "none";
     for i = 1:length(varargin)
         switch (varargin{i})
             case "-nodeps"
                 deps = false;
+            case "-noauto"
+	        auto = -1;
+            case "-auto"
+	        auto = 1;
             case {"list", "install", "uninstall", "load", "unload", ...
                   "prefix", "local_list", "global_list"}
                 action = varargin{i};
@@ -166,7 +180,7 @@
             if (length(files) == 0)
                 error("You must specify at least one filename when calling 'pkg install'");
             endif
-            install(files, deps, prefix, local_list, global_list);
+            install(files, deps, auto, prefix, local_list, global_list);
         case "uninstall"
             if (length(files) == 0)
                 error("You must specify at least one package when calling 'pkg uninstall'");
@@ -174,7 +188,7 @@
             uninstall(files, deps, local_list, global_list);
         case "load"
             if (length(files) == 0)
-                error("You must specify at least one package or 'all' when calling 'pkg load'");
+              error("You must specify at least one package, 'all' or 'auto' when calling 'pkg load'");
             endif
             load_packages(files, deps, local_list, global_list);
         case "unload"
@@ -218,7 +232,21 @@
     endswitch
 endfunction
 
-function install(files, handle_deps, prefix, local_list, global_list)
+function auto = isautoload(desc)
+  auto = false;
+  if (isfield(desc{1},"autoload"))
+    a = desc{1}.autoload;
+    if ((isnumeric(a) && a > 0) || 
+	(ischar(a) && (strcmp(tolower(a),"true") || 
+		       strcmp(tolower(a),"on") || 
+		       strcmp(tolower(a),"yes") ||
+		       strcmp(tolower(a),"1"))))
+      auto = true;
+    endif
+  endif
+endfunction
+
+function install(files, handle_deps, autoload, prefix, local_list, global_list)
     global_install = issuperuser();
  
     # Check that the directory in prefix exist. If it doesn't: create it!
@@ -400,6 +428,15 @@
       endif
     endfor
 
+    ## If the package requested that it is autoloaded, or the installer
+    ## requested that it is, then mark the package as autoloaded.
+    for i = length(descriptions):-1:1
+      if (autoload > 0 || (autoload == 0 && isautoload(descriptions(i))))
+	fclose(fopen(fullfile(descriptions{i}.dir, "packinfo", 
+			      ".autoload"),"wt"));
+      endif
+    endfor
+
     ## Add the packages to the package list
     try
 	    if (global_install)
@@ -1094,7 +1131,27 @@
         global_packages = {};
     end_try_catch
     installed_packages = {local_packages{:} global_packages{:}};        
-    
+
+    ## Eliminate duplicates in the installed package list.
+    ## Locally installed packages take precedence
+    dup = [];
+    for i=1:length(installed_packages)
+      if (find(dup,i))
+	continue;
+      endif
+      for j=(i+1):length(installed_packages)
+        if (find(dup,j))
+	  continue;
+        endif
+        if (strcmp(installed_packages{i}.name,installed_packages{j}.name))
+	  dup = [dup, j];
+	endif
+      endfor
+    endfor
+    if (! isempty(dup))
+      installed_packages(dup) = [];
+    endif  
+  
     ## Should we return something?
     if (nargout == 2)
         out1 = local_packages;
@@ -1162,6 +1219,14 @@
     ## load all
     if (length(files) == 1 && strcmp(files{1}, "all"))
         dirs = pdirs;
+    ## load auto
+    elseif (length(files) == 1 && strcmp(files{1}, "auto"))
+      dirs = {};
+      for i = 1:length(installed_packages)
+        if (exist(fullfile(pdirs{i}, "packinfo", ".autoload"), "file"))
+	  dirs{end+1} = pdirs{i};
+        endif
+      endfor
     ## load package_name1 ...
     else
         dirs = {};