diff scripts/pkg/pkg.m @ 11587:c792872f8942

all script files: untabify and strip trailing whitespace
author John W. Eaton <jwe@octave.org>
date Thu, 20 Jan 2011 17:35:29 -0500
parents e1851653d59c
children d5bd2766c640
line wrap: on
line diff
--- a/scripts/pkg/pkg.m	Thu Jan 20 17:24:59 2011 -0500
+++ b/scripts/pkg/pkg.m	Thu Jan 20 17:35:29 2011 -0500
@@ -1,6 +1,6 @@
 ## Copyright (C) 2005-2011 S�ren Hauberg
 ## Copyright (C) 2010 VZLU Prague, a.s.
-## 
+##
 ## This file is part of Octave.
 ##
 ## Octave is free software; you can redistribute it and/or modify it
@@ -40,16 +40,16 @@
 ##
 ## @table @code
 ## @item -nodeps
-## The package manager will disable the dependency checking.  That way it 
-## is possible to install a package even if it depends on another package 
+## The package manager will disable the 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.}
 ##
 ## @item -noauto
-## The package manager will not automatically load the installed package 
+## The package manager will not automatically load the installed package
 ## when starting Octave, even if the package requests that it is.
 ##
 ## @item -auto
-## The package manager will automatically load the installed package when 
+## The package manager will automatically load the installed package when
 ## starting Octave, even if the package requests that it isn't.
 ##
 ## @item -local
@@ -60,7 +60,7 @@
 ## system privileges
 ##
 ## @item -verbose
-## The package manager will print the output of all of the commands that are 
+## The package manager will print the output of all of the commands that are
 ## performed.
 ## @end table
 ##
@@ -204,7 +204,7 @@
 ## @end example
 ##
 ## @item rebuild
-## Rebuilds the package database from the installed directories.  This can 
+## Rebuilds the package database from the installed directories.  This can
 ## be used in cases where for some reason the package database is 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,
@@ -228,7 +228,7 @@
 ## @noindent
 ## where @code{builddir} is the name of a directory where the temporary
 ## installation will be produced and the binary packages will be found.
-## The options @option{-verbose} and @option{-nodeps} are respected, while 
+## The options @option{-verbose} and @option{-nodeps} are respected, while
 ## the other options are ignored.
 ## @end table
 ## @end deftypefn
@@ -260,7 +260,7 @@
 
   available_actions = {"list", "install", "uninstall", "load", ...
                        "unload", "prefix", "local_list", ...
-                       "global_list", "rebuild", "build","describe"}; 
+                       "global_list", "rebuild", "build","describe"};
   ## Handle input
   if (length (varargin) == 0 || ! iscellstr (varargin))
     print_usage ();
@@ -351,7 +351,7 @@
           endif
         endif
 
-        install (files, deps, auto, prefix, archprefix, verbose, local_list, 
+        install (files, deps, auto, prefix, archprefix, verbose, local_list,
                  global_list, global_install);
 
       unwind_protect_cleanup
@@ -362,7 +362,7 @@
       if (length (files) == 0)
         error ("you must specify at least one package when calling 'pkg uninstall'");
       endif
-      uninstall (files, deps, verbose, local_list, 
+      uninstall (files, deps, verbose, local_list,
                  global_list, global_install);
 
     case "load"
@@ -440,7 +440,7 @@
 
     case "rebuild"
       if (global_install)
-        global_packages = rebuild (prefix, archprefix, global_list, files, 
+        global_packages = rebuild (prefix, archprefix, global_list, files,
                                    auto, verbose);
         global_packages = save_order (global_packages);
         save (global_list, "global_packages");
@@ -448,7 +448,7 @@
           local_packages = global_packages;
         endif
       else
-        local_packages = rebuild (prefix, archprefix, local_list, files, auto, 
+        local_packages = rebuild (prefix, archprefix, local_list, files, auto,
                                   verbose);
         local_packages = save_order (local_packages);
         save (local_list, "local_packages");
@@ -484,7 +484,7 @@
         otherwise
           error ("you can request at most two outputs when calling 'pkg describe'");
       endswitch
-                
+
     otherwise
       error ("you must specify a valid action for 'pkg'. See 'help pkg' for details");
   endswitch
@@ -563,7 +563,7 @@
     endfor
     if (! isempty (dup))
       descriptions (dup) = [];
-    endif  
+    endif
   endif
 endfunction
 
@@ -589,7 +589,7 @@
   endif
   files(1) = [];
   buildlist = fullfile (builddir, "octave_packages");
-  install (files, handle_deps, autoload, installdir, installdir, verbose, 
+  install (files, handle_deps, autoload, installdir, installdir, verbose,
            buildlist, "", false);
   unwind_protect
     repackage (builddir, buildlist);
@@ -604,7 +604,7 @@
   end_unwind_protect
 endfunction
 
-function install (files, handle_deps, autoload, prefix, archprefix, verbose, 
+function install (files, handle_deps, autoload, prefix, archprefix, verbose,
                   local_list, global_list, global_install)
 
   ## Check that the directory in prefix exist. If it doesn't: create it!
@@ -617,10 +617,10 @@
   endif
 
   ## Get the list of installed packages.
-  [local_packages, global_packages] = installed_packages (local_list, 
+  [local_packages, global_packages] = installed_packages (local_list,
                                                           global_list);
 
-  installed_pkgs_lst = {local_packages{:}, global_packages{:}};        
+  installed_pkgs_lst = {local_packages{:}, global_packages{:}};
 
   if (global_install)
     packages = global_packages;
@@ -633,7 +633,7 @@
   try
     ## Warn about non existent files.
     for i = 1:length (files)
-      if (isempty (glob(files{i}))) 
+      if (isempty (glob(files{i})))
         warning ("file %s does not exist", files{i});
       endif
     endfor
@@ -686,32 +686,32 @@
           packdir = fullfile (pwd(), dirlist{3});
         endif
         packdirs{end+1} = packdir;
-        
+
         ## Make sure the package contains necessary files.
         verify_directory (packdir);
-        
+
         ## Read the DESCRIPTION file.
         filename = fullfile (packdir, "DESCRIPTION");
         desc = get_description (filename);
-        
+
         ## Verify that package name corresponds with filename.
-        [dummy, nm] = fileparts (tgz); 
+        [dummy, nm] = fileparts (tgz);
         if ((length (nm) >= length (desc.name))
             && ! strcmp (desc.name, nm(1:length(desc.name))))
-          error ("package name '%s' doesn't correspond to its filename '%s'", 
+          error ("package name '%s' doesn't correspond to its filename '%s'",
                  desc.name, nm);
         endif
-        
+
         ## Set default installation directory.
         desc.dir = fullfile (prefix, cstrcat (desc.name, "-", desc.version));
-        
+
         ## Set default architectire dependent installation directory.
         desc.archprefix = fullfile (archprefix, cstrcat (desc.name, "-",
                                                          desc.version));
-        
+
         ## Save desc.
         descriptions{end+1} = desc;
-        
+
         ## Are any of the new packages already installed?
         ## If so we'll remove the old version.
         for j = 1:length (packages)
@@ -744,7 +744,7 @@
                                      descriptions{idx2}};
       else
         idx1 = setdiff (1:length(local_packages), packages_to_uninstall);
-        pseudo_installed_packages = {local_packages{idx1}, ... 
+        pseudo_installed_packages = {local_packages{idx1}, ...
                                      global_packages{:}, ...
                                      descriptions{idx2}};
       endif
@@ -787,10 +787,10 @@
   try
     for i = packages_to_uninstall
       if (global_install)
-        uninstall ({global_packages{i}.name}, false, verbose, local_list, 
+        uninstall ({global_packages{i}.name}, false, verbose, local_list,
                    global_list, global_install);
       else
-        uninstall ({local_packages{i}.name}, false, verbose, local_list, 
+        uninstall ({local_packages{i}.name}, false, verbose, local_list,
                    global_list, global_install);
       endif
     endfor
@@ -841,7 +841,7 @@
   ## 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", 
+      fclose (fopen (fullfile (descriptions{i}.dir, "packinfo",
                                ".autoload"), "wt"));
       descriptions{i}.autoload = 1;
     endif
@@ -904,10 +904,10 @@
   endif
 endfunction
 
-function uninstall (pkgnames, handle_deps, verbose, local_list, 
+function uninstall (pkgnames, handle_deps, verbose, local_list,
                     global_list, global_install)
   ## Get the list of installed packages.
-  [local_packages, global_packages] = installed_packages(local_list, 
+  [local_packages, global_packages] = installed_packages(local_list,
                                                          global_list);
   if (global_install)
     installed_pkgs_lst = {local_packages{:}, global_packages{:}};
@@ -1028,13 +1028,13 @@
 
 endfunction
 
-function [pkg_desc_list, flag] = describe (pkgnames, verbose, 
+function [pkg_desc_list, flag] = describe (pkgnames, verbose,
                                            local_list, global_list)
 
   ## Get the list of installed packages.
   installed_pkgs_lst = installed_packages(local_list, global_list);
   num_packages = length (installed_pkgs_lst);
-  
+
 
   describe_all = false;
   if (any (strcmp ("all", pkgnames)))
@@ -1075,7 +1075,7 @@
       non_inst_str = sprintf (" %s ", pkgnames{non_inst});
       error ("some packages are not installed: %s", non_inst_str);
     else
-      pkg_desc_list{non_inst} = struct ("name", {}, "description",  
+      pkg_desc_list{non_inst} = struct ("name", {}, "description",
                                         {}, "provides", {});
     endif
   endif
@@ -1084,7 +1084,7 @@
     for i = 1:num_pkgnames
       print_package_description (pkg_desc_list{i}.name,
                                  pkg_desc_list{i}.version,
-                                 pkg_desc_list{i}.provides,  
+                                 pkg_desc_list{i}.provides,
                                  pkg_desc_list{i}.description,
                                  flag{i}, verbose);
     endfor
@@ -1101,12 +1101,12 @@
 
   if (! exist (index_file, "file"))
     error ("could not find any INDEX file in directory %s, try 'pkg rebuild all' to generate missing INDEX files", packdir);
-  endif    
+  endif
 
-    
+
   [fid, msg] = fopen (index_file, "r");
   if (fid == -1)
-    error ("the INDEX file %s could not be read: %s", 
+    error ("the INDEX file %s could not be read: %s",
            index_file, msg);
   endif
 
@@ -1121,7 +1121,7 @@
 
   while (! feof (fid) || line != -1)
     if (! any (! isspace (line)) || line(1) == "#" || any (line == "="))
-      ## Comments,  blank lines or comments about unimplemented 
+      ## Comments,  blank lines or comments about unimplemented
       ## functions: do nothing
       ## FIXME: probably comments and pointers to external functions
       ## could be treated better when printing to screen?
@@ -1146,7 +1146,7 @@
   fclose (fid);
 endfunction
 
-function print_package_description (pkg_name, pkg_ver, pkg_idx_struct, 
+function print_package_description (pkg_name, pkg_ver, pkg_idx_struct,
                                     pkg_desc, status, verbose)
 
   printf ("---\nPackage name:\n\t%s\n", pkg_name);
@@ -1154,7 +1154,7 @@
   printf ("Short description:\n\t%s\n", pkg_desc);
   printf ("Status:\n\t%s\n", status);
   if (verbose)
-    printf ("---\nProvides:\n");    
+    printf ("---\nProvides:\n");
     for i = 1:length(pkg_idx_struct)
       if (! isempty (pkg_idx_struct{i}.functions))
         printf ("%s\n", pkg_idx_struct{i}.category);
@@ -1209,26 +1209,26 @@
           unlink (fullfile (pack.name, "inst", "PKG_DEL"));
         endif
         if (exist (fullfile (archdir, "PKG_ADD"), "file"))
-          movefile (fullfile (archdir, "PKG_ADD"), 
+          movefile (fullfile (archdir, "PKG_ADD"),
                     fullfile (pack.name, "PKG_ADD"));
         endif
         if (exist (fullfile (archdir, "PKG_DEL"), "file"))
-          movefile (fullfile (archdir, "PKG_DEL"), 
-                    fullfile (pack.name, "PKG_DEL")); 
+          movefile (fullfile (archdir, "PKG_DEL"),
+                    fullfile (pack.name, "PKG_DEL"));
         endif
       else
         if (exist (fullfile (pack.name, "inst", "PKG_ADD"), "file"))
-          movefile (fullfile (pack.name, "inst", "PKG_ADD"), 
+          movefile (fullfile (pack.name, "inst", "PKG_ADD"),
                     fullfile (pack.name, "PKG_ADD"));
-        endif 
+        endif
         if (exist (fullfile (pack.name, "inst", "PKG_DEL"), "file"))
-          movefile (fullfile (pack.name, "inst", "PKG_DEL"), 
-                    fullfile (pack.name, "PKG_DEL")); 
-        endif   
-      endif     
+          movefile (fullfile (pack.name, "inst", "PKG_DEL"),
+                    fullfile (pack.name, "PKG_DEL"));
+        endif
+      endif
       tfile = cstrcat (pack.name, "-", pack.version, ".tar");
       tar (tfile, pack.name);
-      try 
+      try
         gzip (tfile);
         unlink (tfile);
       catch
@@ -1263,7 +1263,7 @@
     wd = pwd ();
     try
       cd (packdir);
-      pre_install (desc); 
+      pre_install (desc);
       cd (wd);
     catch
       cd (wd);
@@ -1277,13 +1277,13 @@
     [status, msg] = mkdir (inst_dir);
     if (status != 1)
       rm_rf (desc.dir);
-      error ("the 'inst' directory did not exist and could not be created: %s", 
+      error ("the 'inst' directory did not exist and could not be created: %s",
              msg);
     endif
   endif
 endfunction
 
-function configure_make (desc, packdir, verbose)   
+function configure_make (desc, packdir, verbose)
   ## Perform ./configure, make, make install in "src".
   if (exist (fullfile (packdir, "src"), "dir"))
     src = fullfile (packdir, "src");
@@ -1373,7 +1373,7 @@
 
     ## Copy the files.
     if (! all (isspace ([filenames{:}])))
-        if (! exist (instdir, "dir")) 
+        if (! exist (instdir, "dir"))
           mkdir (instdir);
         endif
         if (! all (isspace ([archindependent{:}])))
@@ -1394,7 +1394,7 @@
             printf (" %s", archdependent{:});
             printf (" %s\n", archdir);
           endif
-          if (! exist (archdir, "dir")) 
+          if (! exist (archdir, "dir"))
             mkdir (archdir);
           endif
           [status, output] = copyfile (archdependent, archdir);
@@ -1430,8 +1430,8 @@
 function create_pkgadddel (desc, packdir, nm, global_install)
   instpkg = fullfile (desc.dir, nm);
   instfid = fopen (instpkg, "wt");
-  ## If it is exists, most of the  PKG_* file should go into the 
-  ## architecture dependent directory so that the autoload/mfilename 
+  ## If it is exists, most of the  PKG_* file should go into the
+  ## architecture dependent directory so that the autoload/mfilename
   ## commands work as expected. The only part that doesn't is the
   ## part in the main directory.
   archdir = fullfile (getarchprefix (desc), cstrcat (desc.name, "-",
@@ -1497,7 +1497,7 @@
   if (! exist (desc.dir, "dir"))
     [status, output] = mkdir (desc.dir);
     if (status != 1)
-      error ("couldn't create installation directory %s : %s", 
+      error ("couldn't create installation directory %s : %s",
       desc.dir, output);
     endif
   endif
@@ -1525,32 +1525,32 @@
               [status, output] = mkdir (octm3);
               if (status != 1)
                 rm_rf (desc.dir);
-                error ("couldn't create installation directory %s : %s", 
+                error ("couldn't create installation directory %s : %s",
                        octm3, output);
               endif
             endif
             [status, output] = mkdir (octm2);
             if (status != 1)
               rm_rf (desc.dir);
-              error ("couldn't create installation directory %s : %s", 
+              error ("couldn't create installation directory %s : %s",
                      octm2, output);
             endif
           endif
           [status, output] = mkdir (octm1);
           if (status != 1)
             rm_rf (desc.dir);
-            error ("couldn't create installation directory %s : %s", 
+            error ("couldn't create installation directory %s : %s",
                    octm1, output);
           endif
         endif
         [status, output] = mkdir (octfiledir);
         if (status != 1)
           rm_rf (desc.dir);
-          error ("couldn't create installation directory %s : %s", 
+          error ("couldn't create installation directory %s : %s",
           octfiledir, output);
         endif
       endif
-      [status, output] = movefile (fullfile (desc.dir, getarch (), "*"), 
+      [status, output] = movefile (fullfile (desc.dir, getarch (), "*"),
                                    octfiledir);
       rm_rf (fullfile (desc.dir, getarch ()));
 
@@ -1785,7 +1785,7 @@
       version  = fix_version (parts{2});
 
   ## If no version is specified for the dependency
-  ## we say that the version should be greater than 
+  ## we say that the version should be greater than
   ## or equal to "0.0.0".
   else
     package = tolower (strip (dep));
@@ -1849,7 +1849,7 @@
         error ("couldn't read directory %s: %s", class_dir, msg);
       endif
       files2 = strcat (class_name, filesep (), files2);
-      files = [files; files2];    
+      files = [files; files2];
     endif
   endfor
 
@@ -1860,7 +1860,7 @@
     if (err)
       error ("couldn't read directory %s: %s", tmpdir, msg);
     endif
-    files = [files; files2];    
+    files = [files; files2];
   endif
 
   functions = {};
@@ -1957,7 +1957,7 @@
   endfor
   if (! isempty(dup))
     installed_pkgs_lst(dup) = [];
-  endif  
+  endif
 
   ## Now check if the package is loaded.
   tmppath = strrep (path(), "\\", "/");
@@ -2004,9 +2004,9 @@
   h1 = "Package Name";
   h2 = "Version";
   h3 = "Installation directory";
-  max_name_length = length (h1); 
+  max_name_length = length (h1);
   max_version_length = length (h2);
-  names = cell (num_packages, 1); 
+  names = cell (num_packages, 1);
   for i = 1:num_packages
     max_name_length = max (max_name_length,
                            length (installed_pkgs_lst{i}.name));
@@ -2043,7 +2043,7 @@
       first_char = length (cur_dir) - max_dir_length + 4;
       first_filesep = strfind (cur_dir(first_char:end), filesep());
       if (! isempty (first_filesep))
-        cur_dir = cstrcat ("...", 
+        cur_dir = cstrcat ("...",
                           cur_dir((first_char + first_filesep(1) - 1):end));
       else
         cur_dir = cstrcat ("...", cur_dir(first_char:end));
@@ -2073,7 +2073,7 @@
   if (length (files) == 1 && strcmp (files{1}, "all"))
     idx = [1:length(installed_pkgs_lst)];
   ## Load auto.
-  elseif (length (files) == 1 && strcmp (files{1}, "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"))
@@ -2209,7 +2209,7 @@
 
 function archprefix = getarchprefix (desc, global_install)
   if ((nargin == 2 && global_install) || (nargin < 2 && issuperuser ()))
-    archprefix = fullfile (octave_config_info ("libexecdir"), "octave", 
+    archprefix = fullfile (octave_config_info ("libexecdir"), "octave",
                            "packages", cstrcat(desc.name, "-", desc.version));
   else
     archprefix = desc.dir;
@@ -2267,7 +2267,7 @@
           endif
         endfor
       endfor
-      if (! isempty (tmpdesc))                                       
+      if (! isempty (tmpdesc))
         newdesc = {newdesc{:}, save_order(tmpdesc){:}, desc{i}};
       else
         newdesc{end+1} = desc{i};
@@ -2336,7 +2336,7 @@
               endif
             endfor
           endfor
-          idx = load_package_dirs (tmplidx, idx, handle_deps, 
+          idx = load_package_dirs (tmplidx, idx, handle_deps,
                                  installed_pkgs_lst);
         endif
       endif