Commits

carandraug committed b919d76

pkg: start support for global, local and external package installations

Comments (0)

Files changed (1)

   confirm_recursive_rmdir (false, "local");
   mlock ();
 
-  ## paths for a file with local and global list installed packages. These
-  ## should not be configurable just like .octaverc is not. It will be possible
-  ## to have pkg use other of this files in addition of this 2 though
-  persistent local_list  = fullfile (tilde_expand ("~"),
-                                     ".octave_packages.db");
-  persistent global_list = fullfile (octave_config_info ("localstartupdir"),
-                                     ".octave_packages.db");
-
   ## There is nothing magic about global and local installs, mainly changes the
   ## file that lists it as installed and therefore is available for different
   ## users at startup. Globally installed packages are always available to pkg,
   ## checking it now, it would not save us the trouble of catching permission
   ## errors later.
   ## To force local install, user will need to use "pkg prefix".
-  persistent fcnprefix archprefix;
+  persistent fcnprefix archprefix pkgdb;
   if (isempty (fcnprefix))
     ## wether other Octave versions are able to run certain .m function is dependent
     ## on the requirements of the package so we can install them on localfcnfiledir
                                             octave_config_info ("canonical_host_type")
                                             )));
     endif
+    ## XXX: rather than having a struct holding only the paths for the .db files,
+    ## maybe we should have the struct keep the contents of the .db files in
+    ## memory?
+    pkgdb.global    = fullfile (octave_config_info ("localstartupdir"),
+                                ".octave_packages.db");
+    pkgdb.local     = fullfile (tilde_expand ("~"),
+                                ".octave_packages.db");
+    ## For external package installations, we keep a struct inside a struct. This
+    ## will save us from someone naming a db "global" for example. Also, we need
+    ## to keep track of the order external dbs were added as this is important
+    ## to decide what package to load when there's multiple installations
+    pkgdb.external  = struct;
+    pkgdb.order     = {};
   endif
 
   action = varargin{1};