I have an issue with the way the prefix has been implemented in the
package manager in 2.9.9+... Basically, the issue is that for temporary
installations, for cases such as "make check" in octave-forge or rpm
builds, there is an installation to a temporary location and then the
temporary build location is removed. Previously setting the global
variable OCTAVE_PACKAGE_PREFIX also forced the .octave_packages file to
be in this sub-directory so the this forces any installed packages to be
ignored in the build (necessary for correct sandboxing) and the cleanup
to be a simple "rm -fr" of the temporary location.
However, with the new "pkg('prefix',<prefix>)" method, the local and
global package files are always looked for in the locatations
~/.octave_packages and /usr/share/octave/octave_packages, independent of
what the prefix is set too. This breaks the sandboxing of the make check
and build, will remove any installed packages that conflict with the
temporary build and make the removal of the temporary directory difficult...
We might allow the setting of the prefix to also force the global_list
and local_list variables of pkg to look in the defined directory for
.octave_packages, or we might define a means of setting the locations of
the global and local package lists. I think the second option is the
better one and propose the attached patch. This allows the temporary
directory for sandboxing to be set like
pkg('prefix',[pwd(),'/install']);
pkg('local_list',[pwd(),'/install/.octave_packages']);
pkg('global_list',[pwd(),'/install/.octave_packages']);
and then the relevant install, and load instructions can be run. In
general, these flags will only be needed by the RPM/DEB or octave-forge
package maintainers... However, perhaps Soren might like to comment on
this patch prior to it being accepted..
Regards
D.
------------------------------------------------------------------------
*** scripts/pkg/pkg.m.~1.24.~ 2006-11-07 21:00:16.000000000 +0100
--- scripts/pkg/pkg.m 2006-11-24 17:19:09.076460818 +0100
***************
*** 84,89 ****
--- 84,113 ----
## @example
## p = pkg prefix
## @end example
+ ## @item local_list
+ ## Set the file it which to look for information on the locally
+ ## installed packages. Locally installed packages are those that are
+ ## typically available only to the user. For example
+ ## @example
+ ## pkg local_list ~/.octave_packages
+ ## @end example
+ ## It is possible to get the current value of local_list with the following
+ ## @example
+ ## pkg local_list
+ ## @end example
+ ## @item global_list
+ ## Set the file it which to look for, for information on the globally
+ ## installed packages. Globally installed packages are those that are
+ ## typically available to all users. For example
+ ## @example
+ ## pkg global_list /usr/share/octave/octave_packages
+ ## @end example
+ ## It is possible to get the current value of global_list with the following
+ ## @example
+ ## pkg global_list
+ ## @end example
+
+
## @end table
## @end deftypefn
***************
*** 92,97 ****
--- 116,124 ----
function [local_packages, global_packages] = pkg(varargin)
## Installation prefix
persistent prefix = -1;
+ persistent local_list = tilde_expand("~/.octave_packages");
+ persistent global_list = fullfile (OCTAVE_HOME (),
"/share/octave/octave_packages");
+
if (prefix == -1)
if (issuperuser())
prefix = fullfile (OCTAVE_HOME (), "/share/octave/packages/");
***************
*** 100,106 ****
endif
endif
prefix = tilde_expand(prefix);
!
## Handle input
if (length(varargin) == 0 || !iscellstr(varargin))
print_usage();
--- 127,133 ----
endif
endif
prefix = tilde_expand(prefix);
!
## Handle input
if (length(varargin) == 0 || !iscellstr(varargin))
print_usage();
***************
*** 112,118 ****
switch (varargin{i})
case "-nodeps"
deps = false;
! case {"list", "install", "uninstall", "load", "prefix"}
action = varargin{i};
otherwise
files{end+1} = varargin{i};
--- 139,145 ----
switch (varargin{i})
case "-nodeps"
deps = false;
! case {"list", "install", "uninstall", "load", "prefix", "local_list",
"global_list"}
action = varargin{i};
otherwise
files{end+1} = varargin{i};
***************
*** 123,133 ****
switch (action)
case "list"
if (nargout == 0)
! installed_packages();
elseif (nargout == 1)
! local_packages = installed_packages();
elseif (nargout == 2)
! [local_packages, global_packages] = installed_packages();
else
error("Too many output arguments requested.");
endif
--- 150,160 ----
switch (action)
case "list"
if (nargout == 0)
! installed_packages(local_list, global_list);
elseif (nargout == 1)
! local_packages = installed_packages(local_list, global_list);
elseif (nargout == 2)
! [local_packages, global_packages] =
installed_packages(local_list, global_list);
else
error("Too many output arguments requested.");
endif
***************
*** 135,151 ****
if (length(files) == 0)
error("You must specify at least one filename when calling 'pkg
install'");
endif
! install(files, deps, prefix);
case "uninstall"
if (length(files) == 0)
error("You must specify at least one package when calling 'pkg
uninstall'");
endif
! uninstall(files, deps);
case "load"
if (length(files) == 0)
error("You must specify at least one package or 'all' when calling
'pkg load'");
endif
! load_packages(files, deps);
case "prefix"
if (length(files) == 0 && nargout == 0)
disp(prefix);
--- 162,178 ----
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);
case "uninstall"
if (length(files) == 0)
error("You must specify at least one package when calling 'pkg
uninstall'");
endif
! 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'");
endif
! load_packages(files, deps, local_list, global_list);
case "prefix"
if (length(files) == 0 && nargout == 0)
disp(prefix);
***************
*** 155,173 ****
prefix = files{1};
if (!strcmp(prefix(end), "/")) prefix(end+1) = "/"; endif
else
! error("You must specify a prefix directory, or request an output
arguement");
endif
otherwise
error("You must specify a valid action for 'pkg'. See 'help pkg' for
details");
endswitch
endfunction
! function install(files, handle_deps, prefix)
! ## Set parameters depending on wether or not the installation
! ## is system-wide (global) or local.
! local_list = tilde_expand("~/.octave_packages");
! global_list = fullfile (OCTAVE_HOME (), "/share/octave/octave_packages");
!
global_install = issuperuser();
# Check that the directory in prefix exist. If it doesn't: create it!
--- 182,215 ----
prefix = files{1};
if (!strcmp(prefix(end), "/")) prefix(end+1) = "/"; endif
else
! error("You must specify a prefix directory, or request an output
argument");
! endif
! case "local_list"
! if (length(files) == 0 && nargout == 0)
! disp(local_list);
! elseif (length(files) == 0 && nargout == 1)
! local_packages = local_list;
! elseif (length(files) == 1 && nargout == 0 && ischar(files{1}))
! local_list = files{1};
! else
! error("You must specify a local_list file, or request an output
argument");
! endif
! case "global_list"
! if (length(files) == 0 && nargout == 0)
! disp(global_list);
! elseif (length(files) == 0 && nargout == 1)
! local_packages = global_list;
! elseif (length(files) == 1 && nargout == 0 && ischar(files{1}))
! global_list = files{1};
! else
! error("You must specify a global_list file, or request an output
argument");
endif
otherwise
error("You must specify a valid action for 'pkg'. See 'help pkg' for
details");
endswitch
endfunction
! function install(files, handle_deps, prefix, local_list, global_list)
global_install = issuperuser();
# Check that the directory in prefix exist. If it doesn't: create it!
***************
*** 180,187 ****
endif
## Get the list of installed packages
! [local_packages, global_packages] = installed_packages();
! installed_packages = {local_packages{:} global_packages{:}};
if (global_install)
packages = global_packages;
--- 222,230 ----
endif
## Get the list of installed packages
! [local_packages, global_packages] = installed_packages(local_list,
! global_list);
! installed_packages = {local_packages{:}, global_packages{:}};
if (global_install)
packages = global_packages;
***************
*** 306,312 ****
## Uninstall the packages that will be replaced
try
for i = packages_to_uninstall
! uninstall({installed_packages{i}.name}, false);
endfor
catch
## Something went wrong, delete tmpdirs
--- 349,356 ----
## Uninstall the packages that will be replaced
try
for i = packages_to_uninstall
! uninstall({installed_packages{i}.name}, false, local_list,
! global_list);
endfor
catch
## Something went wrong, delete tmpdirs
***************
*** 391,403 ****
endif
endfunction
! function uninstall(pkgnames, handle_deps)
! local_list = tilde_expand("~/.octave_packages");
! global_list = fullfile (OCTAVE_HOME (), "/share/octave/octave_packages");
## Get the list of installed packages
! [local_packages, global_packages] = installed_packages();
if (issuperuser())
! installed_packages = global_packages;
else
installed_packages = local_packages;
endif
--- 435,446 ----
endif
endfunction
! function uninstall(pkgnames, handle_deps, local_list, global_list)
## Get the list of installed packages
! [local_packages, global_packages] = installed_packages(local_list,
! global_list);
if (issuperuser())
! installed_packages = {local_packages{:}, global_packages{:}};
else
installed_packages = local_packages;
endif
***************
*** 413,420 ****
## Are all the packages that should be uninstalled already installed?
if (length(delete_idx) != length(pkgnames))
! # XXX: We should have a better error message
! error("Some of the packages you want to uninstall are not
installed.");
endif
## Compute the packages that will remain installed
--- 456,484 ----
## Are all the packages that should be uninstalled already installed?
if (length(delete_idx) != length(pkgnames))
! delete_idx
! pkgnames
!
! if (issuperuser())
! ## Try again for a locally installed package
! installed_packages = local_packages
!
! num_packages = length(installed_packages);
! delete_idx = [];
! for i = 1:num_packages
! cur_name = installed_packages{i}.name;
! if (any(strcmp(cur_name, pkgnames)))
! delete_idx(end+1) = i;
! endif
! endfor
! if (length(delete_idx) != length(pkgnames))
! ## XXX: We should have a better error message
! error("Some of the packages you want to uninstall are not
installed.");
! endif
! else
! ## XXX: We should have a better error message
! error("Some of the packages you want to uninstall are not installed.");
! endif
endif
## Compute the packages that will remain installed
***************
*** 982,990 ****
endfor
endfunction
! function [out1, out2] = installed_packages()
! local_list = tilde_expand("~/.octave_packages");
! global_list = fullfile (OCTAVE_HOME (), "/share/octave/octave_packages");
## Get the list of installed packages
try
local_packages = load(local_list).local_packages;
--- 1046,1052 ----
endfor
endfunction
! function [out1, out2] = installed_packages(local_list, global_list)
## Get the list of installed packages
try
local_packages = load(local_list).local_packages;
***************
*** 992,998 ****
local_packages = {};
end_try_catch
try
! global_packages = load(global_list).global_packages;
catch
global_packages = {};
end_try_catch
--- 1054,1064 ----
local_packages = {};
end_try_catch
try
! if (strcmp(local_list, global_list))
! global_packages = {};
! else
! global_packages = load(global_list).global_packages;
! endif
catch
global_packages = {};
end_try_catch
***************
*** 1050,1057 ****
endfor
endfunction
! function load_packages(files, handle_deps)
! installed_packages = installed_packages();
num_packages = length(installed_packages);
## Read package names and installdirs into a more convenient format
--- 1116,1123 ----
endfor
endfunction
! function load_packages(files, handle_deps, local_list, global_list)
! installed_packages = installed_packages(local_list, global_list);
num_packages = length(installed_packages);
## Read package names and installdirs into a more convenient format