annotate test/indent/octave.m @ 112414:4b27e6d58d2c

* nsterm.m (constrainFrameRect): Only constrain the first time called.
author Jan D. <jan.h.d@swipnet.se>
date Sat, 22 Jan 2011 12:33:32 +0100
parents a8b7e7d8b686
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
110038
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1 ## -*- octave -*-
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
3 function res = tcomp (fn)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
4 %% res = tcomp (fn)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
5 %% imports components and rearranges them.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
6
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
7 if nargin ~= 1
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
8 print_usage()
110417
8a3552ec7934 * lisp/indent.el (indent-according-to-mode): Apply syntax-propertize.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110305
diff changeset
9 end
110038
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
10
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
11 data = dlmread(fn, 3, 0);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
12
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
13 x = data(:,2:end);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
14 y = 'hello';
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
15 z = y';
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
16
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
17 cnty = repmat(x(:,1)(:), 10, 1);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
18
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
19 pop = x(:,1:10)(:);
111207
a8b7e7d8b686 * test/indent/octave.m: Add a test to ensure indentation is local.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110417
diff changeset
20 ## Here and below, we test if the indentation aligns with a previous
a8b7e7d8b686 * test/indent/octave.m: Add a test to ensure indentation is local.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110417
diff changeset
21 ## fixindented line. This is important so as to make it easier for the
a8b7e7d8b686 * test/indent/octave.m: Add a test to ensure indentation is local.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110417
diff changeset
22 ## user to verride some indentation somewhere, and also because it
a8b7e7d8b686 * test/indent/octave.m: Add a test to ensure indentation is local.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110417
diff changeset
23 ## reflects the fact that the indentation decision is taken with a minimum
a8b7e7d8b686 * test/indent/octave.m: Add a test to ensure indentation is local.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110417
diff changeset
24 ## amount of work (i.e. in the present case, without having to walk back
a8b7e7d8b686 * test/indent/octave.m: Add a test to ensure indentation is local.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110417
diff changeset
25 ## until the `function' line).
a8b7e7d8b686 * test/indent/octave.m: Add a test to ensure indentation is local.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110417
diff changeset
26 bir = x(:,11:20)(:); # fixindent
a8b7e7d8b686 * test/indent/octave.m: Add a test to ensure indentation is local.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110417
diff changeset
27 dth = x(:,21:30)(:);
a8b7e7d8b686 * test/indent/octave.m: Add a test to ensure indentation is local.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110417
diff changeset
28 imig = x(:,31:40)(:);
a8b7e7d8b686 * test/indent/octave.m: Add a test to ensure indentation is local.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110417
diff changeset
29 dmig = x(:,41:50)(:);
a8b7e7d8b686 * test/indent/octave.m: Add a test to ensure indentation is local.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110417
diff changeset
30 gq = x(:,51:60)(:);
110038
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
31
111207
a8b7e7d8b686 * test/indent/octave.m: Add a test to ensure indentation is local.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110417
diff changeset
32 yrs = repmat(2000:2009, 39, 1)(:);
a8b7e7d8b686 * test/indent/octave.m: Add a test to ensure indentation is local.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110417
diff changeset
33
a8b7e7d8b686 * test/indent/octave.m: Add a test to ensure indentation is local.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110417
diff changeset
34 res = [yrs, cnty, pop, bir, dth, imig, dmig, gq];
110038
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
35
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
36 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
37
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
38 ## Copyright (C) 2005, 2006, 2007, 2008, 2009 S�ren Hauberg
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
39 ##
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
40 ## This file is part of Octave.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
41 ##
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
42 ## Octave is free software; you can redistribute it and/or modify it
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
43 ## under the terms of the GNU General Public License as published by
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
44 ## the Free Software Foundation; either version 3 of the License, or (at
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
45 ## your option) any later version.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
46 ##
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
47 ## Octave is distributed in the hope that it will be useful, but
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
48 ## WITHOUT ANY WARRANTY; without even the implied warranty of
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
49 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
50 ## General Public License for more details.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
51 ##
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
52 ## You should have received a copy of the GNU General Public License
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
53 ## along with Octave; see the file COPYING. If not, see
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
54 ## <http://www.gnu.org/licenses/>.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
55
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
56 ## -*- texinfo -*-
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
57 ## @deftypefn {Command} pkg @var{command} @var{pkg_name}
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
58 ## @deftypefnx {Command} pkg @var{command} @var{option} @var{pkg_name}
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
59 ## This command interacts with the package manager. Different actions will
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
60 ## be taken depending on the value of @var{command}.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
61 ##
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
62 ## @table @samp
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
63 ## @item install
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
64 ## Install named packages. For example,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
65 ## @example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
66 ## pkg install image-1.0.0.tar.gz
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
67 ## @end example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
68 ## @noindent
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
69 ## installs the package found in the file @file{image-1.0.0.tar.gz}.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
70 ##
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
71 ## The @var{option} variable can contain options that affect the manner
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
72 ## in which a package is installed. These options can be one or more of
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
73 ##
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
74 ## @table @code
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
75 ## @item -nodeps
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
76 ## The package manager will disable the dependency checking. That way it
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
77 ## is possible to install a package even if it depends on another package
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
78 ## that's not installed on the system. @strong{Use this option with care.}
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
79 ##
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
80 ## @item -noauto
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
81 ## The package manager will not automatically load the installed package
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
82 ## when starting Octave, even if the package requests that it is.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
83 ##
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
84 ## @item -auto
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
85 ## The package manager will automatically load the installed package when
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
86 ## starting Octave, even if the package requests that it isn't.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
87 ##
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
88 ## @item -local
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
89 ## A local installation is forced, even if the user has system privileges.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
90 ##
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
91 ## @item -global
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
92 ## A global installation is forced, even if the user doesn't normally have
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
93 ## system privileges
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
94 ##
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
95 ## @item -verbose
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
96 ## The package manager will print the output of all of the commands that are
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
97 ## performed.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
98 ## @end table
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
99 ##
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
100 ## @item uninstall
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
101 ## Uninstall named packages. For example,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
102 ## @example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
103 ## pkg uninstall image
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
104 ## @end example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
105 ## @noindent
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
106 ## removes the @code{image} package from the system. If another installed
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
107 ## package depends on the @code{image} package an error will be issued.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
108 ## The package can be uninstalled anyway by using the @code{-nodeps} option.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
109 ## @item load
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
110 ## Add named packages to the path. After loading a package it is
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
111 ## possible to use the functions provided by the package. For example,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
112 ## @example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
113 ## pkg load image
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
114 ## @end example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
115 ## @noindent
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
116 ## adds the @code{image} package to the path. It is possible to load all
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
117 ## installed packages at once with the command
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
118 ## @example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
119 ## pkg load all
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
120 ## @end example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
121 ## @item unload
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
122 ## Removes named packages from the path. After unloading a package it is
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
123 ## no longer possible to use the functions provided by the package.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
124 ## This command behaves like the @code{load} command.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
125 ## @item list
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
126 ## Show a list of the currently installed packages. By requesting one or two
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
127 ## output argument it is possible to get a list of the currently installed
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
128 ## packages. For example,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
129 ## @example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
130 ## installed_packages = pkg list;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
131 ## @end example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
132 ## @noindent
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
133 ## returns a cell array containing a structure for each installed package.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
134 ## The command
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
135 ## @example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
136 ## [@var{user_packages}, @var{system_packages}] = pkg list
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
137 ## @end example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
138 ## @noindent
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
139 ## splits the list of installed packages into those who are installed by
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
140 ## the current user, and those installed by the system administrator.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
141 ## @item describe
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
142 ## Show a short description of the named installed packages, with the option
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
143 ## '-verbose' also list functions provided by the package, e.g.:
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
144 ## @example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
145 ## pkg describe -verbose all
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
146 ## @end example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
147 ## @noindent
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
148 ## will describe all installed packages and the functions they provide.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
149 ## If one output is requested a cell of structure containing the
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
150 ## description and list of functions of each package is returned as
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
151 ## output rather than printed on screen:
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
152 ## @example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
153 ## desc = pkg ("describe", "secs1d", "image")
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
154 ## @end example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
155 ## @noindent
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
156 ## If any of the requested packages is not installed, pkg returns an
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
157 ## error, unless a second output is requested:
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
158 ## @example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
159 ## [ desc, flag] = pkg ("describe", "secs1d", "image")
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
160 ## @end example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
161 ## @noindent
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
162 ## @var{flag} will take one of the values "Not installed", "Loaded" or
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
163 ## "Not loaded" for each of the named packages.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
164 ## @item prefix
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
165 ## Set the installation prefix directory. For example,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
166 ## @example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
167 ## pkg prefix ~/my_octave_packages
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
168 ## @end example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
169 ## @noindent
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
170 ## sets the installation prefix to @file{~/my_octave_packages}.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
171 ## Packages will be installed in this directory.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
172 ##
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
173 ## It is possible to get the current installation prefix by requesting an
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
174 ## output argument. For example,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
175 ## @example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
176 ## p = pkg prefix
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
177 ## @end example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
178 ##
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
179 ## The location in which to install the architecture dependent files can be
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
180 ## independent specified with an addition argument. For example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
181 ##
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
182 ## @example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
183 ## pkg prefix ~/my_octave_packages ~/my_arch_dep_pkgs
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
184 ## @end example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
185 ## @item local_list
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
186 ## Set the file in which to look for information on the locally
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
187 ## installed packages. Locally installed packages are those that are
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
188 ## typically available only to the current user. For example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
189 ## @example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
190 ## pkg local_list ~/.octave_packages
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
191 ## @end example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
192 ## It is possible to get the current value of local_list with the following
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
193 ## @example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
194 ## pkg local_list
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
195 ## @end example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
196 ## @item global_list
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
197 ## Set the file in which to look for, for information on the globally
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
198 ## installed packages. Globally installed packages are those that are
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
199 ## typically available to all users. For example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
200 ## @example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
201 ## pkg global_list /usr/share/octave/octave_packages
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
202 ## @end example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
203 ## It is possible to get the current value of global_list with the following
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
204 ## @example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
205 ## pkg global_list
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
206 ## @end example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
207 ## @item rebuild
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
208 ## Rebuilds the package database from the installed directories. This can
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
209 ## be used in cases where for some reason the package database is corrupted.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
210 ## It can also take the @code{-auto} and @code{-noauto} options to allow the
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
211 ## autoloading state of a package to be changed. For example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
212 ##
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
213 ## @example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
214 ## pkg rebuild -noauto image
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
215 ## @end example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
216 ##
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
217 ## will remove the autoloading status of the image package.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
218 ## @item build
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
219 ## Builds a binary form of a package or packages. The binary file produced
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
220 ## will itself be an Octave package that can be installed normally with
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
221 ## @code{pkg}. The form of the command to build a binary package is
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
222 ##
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
223 ## @example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
224 ## pkg build builddir image-1.0.0.tar.gz @dots{}
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
225 ## @end example
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
226 ##
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
227 ## @noindent
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
228 ## where @code{builddir} is the name of a directory where the temporary
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
229 ## installation will be produced and the binary packages will be found.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
230 ## The options @code{-verbose} and @code{-nodeps} are respected, while
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
231 ## the other options are ignored.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
232 ## @end table
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
233 ## @end deftypefn
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
234
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
235 function [local_packages, global_packages] = pkg (varargin)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
236 ## Installation prefix (FIXME: what should these be on windows?)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
237 persistent user_prefix = false;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
238 persistent prefix = -1;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
239 persistent archprefix = -1;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
240 persistent local_list = tilde_expand (fullfile ("~", ".octave_packages"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
241 persistent global_list = fullfile (OCTAVE_HOME (), "share", "octave",
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
242 "octave_packages");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
243 mlock ();
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
244
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
245 global_install = issuperuser ();
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
246
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
247 if (prefix == -1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
248 if (global_install)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
249 prefix = fullfile (OCTAVE_HOME (), "share", "octave", "packages");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
250 archprefix = fullfile (octave_config_info ("libexecdir"),
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
251 "octave", "packages");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
252 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
253 prefix = fullfile ("~", "octave");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
254 archprefix = prefix;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
255 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
256 prefix = tilde_expand (prefix);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
257 archprefix = tilde_expand (archprefix);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
258 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
259
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
260 available_actions = {"list", "install", "uninstall", "load", ...
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
261 "unload", "prefix", "local_list", ...
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
262 "global_list", "rebuild", "build","describe"};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
263 ## Handle input
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
264 if (length (varargin) == 0 || ! iscellstr (varargin))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
265 print_usage ();
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
266 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
267 files = {};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
268 deps = true;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
269 auto = 0;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
270 action = "none";
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
271 verbose = false;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
272 for i = 1:length (varargin)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
273 switch (varargin{i})
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
274 case "-nodeps"
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
275 deps = false;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
276 case "-noauto"
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
277 auto = -1;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
278 case "-auto"
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
279 auto = 1;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
280 case "-verbose"
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
281 verbose = true;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
282 case "-local"
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
283 global_install = false;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
284 if (! user_prefix)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
285 prefix = tilde_expand (fullfile ("~", "octave"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
286 archprefix = prefix;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
287 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
288 case "-global"
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
289 global_install = true;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
290 if (! user_prefix)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
291 prefix = fullfile (OCTAVE_HOME (), "share", "octave", "packages");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
292 archprefix = fullfile (octave_config_info ("libexecdir"),
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
293 "octave", "packages");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
294 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
295 case available_actions
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
296 if (strcmp (action, "none"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
297 action = varargin{i};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
298 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
299 error ("more than one action specified");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
300 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
301 otherwise
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
302 files{end+1} = varargin{i};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
303 endswitch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
304 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
305
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
306 ## Take action
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
307 switch (action)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
308 case "list"
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
309 if (nargout == 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
310 installed_packages (local_list, global_list);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
311 elseif (nargout == 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
312 local_packages = installed_packages (local_list, global_list);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
313 elseif (nargout == 2)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
314 [local_packages, global_packages] = installed_packages (local_list,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
315 global_list);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
316 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
317 error ("too many output arguments requested");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
318 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
319
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
320 case "install"
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
321 if (length (files) == 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
322 error ("you must specify at least one filename when calling 'pkg install'");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
323 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
324 install (files, deps, auto, prefix, archprefix, verbose, local_list,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
325 global_list, global_install);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
326
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
327 case "uninstall"
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
328 if (length (files) == 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
329 error ("you must specify at least one package when calling 'pkg uninstall'");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
330 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
331 uninstall (files, deps, verbose, local_list,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
332 global_list, global_install);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
333
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
334 case "load"
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
335 if (length (files) == 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
336 error ("you must specify at least one package, 'all' or 'auto' when calling 'pkg load'");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
337 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
338 load_packages (files, deps, local_list, global_list);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
339
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
340 case "unload"
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
341 if (length (files) == 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
342 error ("you must specify at least one package or 'all' when calling 'pkg unload'");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
343 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
344 unload_packages (files, deps, local_list, global_list);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
345
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
346 case "prefix"
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
347 if (length (files) == 0 && nargout == 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
348 printf ("Installation prefix: %s\n", prefix);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
349 printf ("Architecture dependent prefix: %s\n", archprefix);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
350 elseif (length (files) == 0 && nargout >= 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
351 local_packages = prefix;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
352 global_packages = archprefix;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
353 elseif (length (files) >= 1 && nargout <= 2 && ischar (files{1}))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
354 prefix = files{1};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
355 prefix = absolute_pathname (prefix);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
356 local_packages = prefix;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
357 user_prefix = true;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
358 if (length (files) >= 2 && ischar (files{2}))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
359 archprefix = files{2};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
360 try
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
361 archprefix = absolute_pathname (archprefix);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
362 catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
363 mkdir (archprefix);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
364 warning ("creating the directory %s\n", archprefix);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
365 archprefix = absolute_pathname (archprefix);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
366 end_try_catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
367 global_packages = archprefix;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
368 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
369 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
370 error ("you must specify a prefix directory, or request an output argument");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
371 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
372
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
373 case "local_list"
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
374 if (length (files) == 0 && nargout == 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
375 disp (local_list);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
376 elseif (length (files) == 0 && nargout == 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
377 local_packages = local_list;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
378 elseif (length (files) == 1 && nargout == 0 && ischar (files{1}))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
379 try
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
380 local_list = absolute_pathname (files{1});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
381 catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
382 ## Force file to be created
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
383 fclose (fopen (files{1}, "wt"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
384 local_list = absolute_pathname (files{1});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
385 end_try_catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
386 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
387 error ("you must specify a local_list file, or request an output argument");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
388 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
389
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
390 case "global_list"
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
391 if (length (files) == 0 && nargout == 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
392 disp(global_list);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
393 elseif (length (files) == 0 && nargout == 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
394 local_packages = global_list;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
395 elseif (length (files) == 1 && nargout == 0 && ischar (files{1}))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
396 try
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
397 global_list = absolute_pathname (files{1});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
398 catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
399 ## Force file to be created
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
400 fclose (fopen (files{1}, "wt"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
401 global_list = absolute_pathname (files{1});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
402 end_try_catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
403 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
404 error ("you must specify a global_list file, or request an output argument");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
405 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
406
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
407 case "rebuild"
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
408 if (global_install)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
409 global_packages = rebuild (prefix, archprefix, global_list, files,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
410 auto, verbose);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
411 global_packages = save_order (global_packages);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
412 save (global_list, "global_packages");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
413 if (nargout > 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
414 local_packages = global_packages;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
415 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
416 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
417 local_packages = rebuild (prefix, archprefix, local_list, files, auto,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
418 verbose);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
419 local_packages = save_order (local_packages);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
420 save (local_list, "local_packages");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
421 if (nargout == 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
422 clear ("local_packages");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
423 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
424 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
425
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
426 case "build"
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
427 if (length (files) < 2)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
428 error ("you must specify at least the build directory and one filename\nwhen calling 'pkg build'");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
429 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
430 build (files, deps, auto, verbose);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
431
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
432 case "describe"
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
433 if (length (files) == 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
434 error ("you must specify at least one package or 'all' when calling 'pkg describe'");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
435 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
436 ## FIXME: the name of the output variables is inconsistent
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
437 ## with their content
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
438 switch (nargout)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
439 case 0
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
440 describe (files, verbose, local_list, global_list);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
441 case 1
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
442 pkg_desc_list = describe (files, verbose, local_list, ...
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
443 global_list);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
444 local_packages = pkg_desc_list;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
445 case 2
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
446 [pkg_desc_list, flag] = describe (files, verbose, local_list, ...
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
447 global_list);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
448 local_packages = pkg_desc_list;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
449 global_packages = flag;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
450 otherwise
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
451 error ("you can request at most two outputs when calling 'pkg describe'");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
452 endswitch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
453
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
454 otherwise
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
455 error ("you must specify a valid action for 'pkg'. See 'help pkg' for details");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
456 endswitch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
457 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
458
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
459 function descriptions = rebuild (prefix, archprefix, list, files, auto, verbose)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
460 if (isempty (files))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
461 [dirlist, err, msg] = readdir (prefix);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
462 if (err)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
463 error ("couldn't read directory %s: %s", prefix, msg);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
464 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
465 ## the two first entries of dirlist are "." and ".."
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
466 dirlist([1,2]) = [];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
467 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
468 old_descriptions = installed_packages (list, list);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
469 wd = pwd ();
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
470 unwind_protect
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
471 cd (prefix);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
472 dirlist = glob (cellfun(@(x) cstrcat(x, '-*'), files, 'UniformOutput', 0));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
473 unwind_protect_cleanup
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
474 cd (wd);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
475 end_unwind_protect
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
476 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
477 descriptions = {};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
478 for k = 1:length (dirlist)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
479 descfile = fullfile (prefix, dirlist{k}, "packinfo", "DESCRIPTION");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
480 if (verbose)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
481 printf ("recreating package description from %s\n", dirlist{k});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
482 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
483 if (exist (descfile, "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
484 desc = get_description (descfile);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
485 desc.dir = fullfile (prefix, dirlist{k});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
486 desc.archprefix = fullfile (archprefix, cstrcat (desc.name, "-",
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
487 desc.version));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
488 if (auto != 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
489 if (exist (fullfile (desc.dir, "packinfo", ".autoload"), "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
490 unlink (fullfile (desc.dir, "packinfo", ".autoload"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
491 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
492 if (auto < 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
493 desc.autoload = 0;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
494 elseif (auto > 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
495 desc.autoload = 1;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
496 fclose (fopen (fullfile (desc.dir, "packinfo", ".autoload"), "wt"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
497 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
498 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
499 if (exist (fullfile (desc.dir, "packinfo", ".autoload"), "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
500 desc.autoload = 1;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
501 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
502 desc.autoload = 0;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
503 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
504 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
505 descriptions{end + 1} = desc;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
506 elseif (verbose)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
507 warning ("directory %s is not a valid package", dirlist{k});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
508 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
509 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
510
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
511 if (! isempty (files))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
512 ## We are rebuilding for a particular package(s) so we should take
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
513 ## care to keep the other untouched packages in the descriptions
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
514 descriptions = {descriptions{:}, old_descriptions{:}};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
515
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
516 dup = [];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
517 for i = 1:length (descriptions)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
518 if (find (dup, i))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
519 continue;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
520 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
521 for j = (i+1):length (descriptions)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
522 if (find (dup, j))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
523 continue;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
524 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
525 if (strcmp (descriptions{i}.name, descriptions{j}.name))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
526 dup = [dup, j];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
527 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
528 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
529 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
530 if (! isempty (dup))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
531 descriptions (dup) = [];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
532 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
533 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
534 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
535
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
536 function build (files, handle_deps, autoload, verbose)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
537 if (length (files) < 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
538 error ("insufficient number of files");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
539 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
540 builddir = files{1};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
541 if (! exist (builddir, "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
542 warning ("creating build directory %s", builddir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
543 [status, msg] = mkdir (builddir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
544 if (status != 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
545 error ("could not create installation directory: %s", msg);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
546 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
547 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
548 builddir = absolute_pathname (builddir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
549 installdir = fullfile (builddir, "install");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
550 if (! exist (installdir, "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
551 [status, msg] = mkdir (installdir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
552 if (status != 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
553 error ("could not create installation directory: %s", msg);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
554 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
555 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
556 files(1) = [];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
557 buildlist = fullfile (builddir, "octave_packages");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
558 install (files, handle_deps, autoload, installdir, installdir, verbose,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
559 buildlist, "", false);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
560 unwind_protect
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
561 repackage (builddir, buildlist);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
562 unwind_protect_cleanup
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
563 unload_packages ({"all"}, handle_deps, buildlist, "");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
564 if (exist (installdir, "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
565 rm_rf (installdir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
566 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
567 if (exist (buildlist, "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
568 unlink (buildlist);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
569 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
570 end_unwind_protect
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
571 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
572
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
573 function install (files, handle_deps, autoload, prefix, archprefix, verbose,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
574 local_list, global_list, global_install)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
575
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
576 ## Check that the directory in prefix exist. If it doesn't: create it!
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
577 if (! exist (prefix, "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
578 warning ("creating installation directory %s", prefix);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
579 [status, msg] = mkdir (prefix);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
580 if (status != 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
581 error ("could not create installation directory: %s", msg);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
582 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
583 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
584
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
585 ## Get the list of installed packages.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
586 [local_packages, global_packages] = installed_packages (local_list,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
587 global_list);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
588
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
589 installed_pkgs_lst = {local_packages{:}, global_packages{:}};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
590
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
591 if (global_install)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
592 packages = global_packages;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
593 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
594 packages = local_packages;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
595 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
596
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
597 ## Uncompress the packages and read the DESCRIPTION files.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
598 tmpdirs = packdirs = descriptions = {};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
599 try
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
600 ## Warn about non existent files.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
601 for i = 1:length (files)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
602 if (isempty (glob(files{i})))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
603 warning ("file %s does not exist", files{i});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
604 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
605 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
606
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
607 ## Unpack the package files and read the DESCRIPTION files.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
608 files = glob (files);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
609 packages_to_uninstall = [];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
610 for i = 1:length (files)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
611 tgz = files{i};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
612
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
613 if (exist (tgz, "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
614 ## Create a temporary directory.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
615 tmpdir = tmpnam ();
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
616 tmpdirs{end+1} = tmpdir;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
617 if (verbose)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
618 printf ("mkdir (%s)\n", tmpdir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
619 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
620 [status, msg] = mkdir (tmpdir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
621 if (status != 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
622 error ("couldn't create temporary directory: %s", msg);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
623 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
624
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
625 ## Uncompress the package.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
626 if (verbose)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
627 printf ("untar (%s, %s)\n", tgz, tmpdir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
628 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
629 untar (tgz, tmpdir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
630
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
631 ## Get the name of the directories produced by tar.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
632 [dirlist, err, msg] = readdir (tmpdir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
633 if (err)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
634 error ("couldn't read directory produced by tar: %s", msg);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
635 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
636
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
637 if (length (dirlist) > 3)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
638 error ("bundles of packages are not allowed")
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
639 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
640 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
641
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
642 ## The filename pointed to an uncompressed package to begin with.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
643 if (exist (tgz, "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
644 dirlist = {".", "..", tgz};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
645 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
646
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
647 if (exist (tgz, "file") || exist (tgz, "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
648 ## The two first entries of dirlist are "." and "..".
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
649 if (exist (tgz, "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
650 packdir = fullfile (tmpdir, dirlist{3});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
651 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
652 packdir = fullfile (pwd(), dirlist{3});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
653 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
654 packdirs{end+1} = packdir;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
655
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
656 ## Make sure the package contains necessary files.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
657 verify_directory (packdir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
658
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
659 ## Read the DESCRIPTION file.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
660 filename = fullfile (packdir, "DESCRIPTION");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
661 desc = get_description (filename);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
662
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
663 ## Verify that package name corresponds with filename.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
664 [dummy, nm] = fileparts (tgz);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
665 if ((length (nm) >= length (desc.name))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
666 && ! strcmp (desc.name, nm(1:length(desc.name))))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
667 error ("package name '%s' doesn't correspond to its filename '%s'",
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
668 desc.name, nm);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
669 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
670
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
671 ## Set default installation directory.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
672 desc.dir = fullfile (prefix, cstrcat (desc.name, "-", desc.version));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
673
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
674 ## Set default architectire dependent installation directory.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
675 desc.archprefix = fullfile (archprefix, cstrcat (desc.name, "-",
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
676 desc.version));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
677
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
678 ## Save desc.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
679 descriptions{end+1} = desc;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
680
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
681 ## Are any of the new packages already installed?
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
682 ## If so we'll remove the old version.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
683 for j = 1:length (packages)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
684 if (strcmp (packages{j}.name, desc.name))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
685 packages_to_uninstall(end+1) = j;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
686 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
687 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
688 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
689 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
690 catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
691 ## Something went wrong, delete tmpdirs.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
692 for i = 1:length (tmpdirs)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
693 rm_rf (tmpdirs{i});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
694 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
695 rethrow (lasterror ());
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
696 end_try_catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
697
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
698 ## Check dependencies.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
699 if (handle_deps)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
700 ok = true;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
701 error_text = "";
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
702 for i = 1:length (descriptions)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
703 desc = descriptions{i};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
704 idx2 = complement (i, 1:length(descriptions));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
705 if (global_install)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
706 ## Global installation is not allowed to have dependencies on locally
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
707 ## installed packages.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
708 idx1 = complement (packages_to_uninstall,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
709 1:length(global_packages));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
710 pseudo_installed_packages = {global_packages{idx1}, ...
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
711 descriptions{idx2}};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
712 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
713 idx1 = complement (packages_to_uninstall,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
714 1:length(local_packages));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
715 pseudo_installed_packages = {local_packages{idx1}, ...
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
716 global_packages{:}, ...
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
717 descriptions{idx2}};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
718 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
719 bad_deps = get_unsatisfied_deps (desc, pseudo_installed_packages);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
720 ## Are there any unsatisfied dependencies?
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
721 if (! isempty (bad_deps))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
722 ok = false;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
723 for i = 1:length (bad_deps)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
724 dep = bad_deps{i};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
725 error_text = cstrcat (error_text, " ", desc.name, " needs ",
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
726 dep.package, " ", dep.operator, " ",
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
727 dep.version, "\n");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
728 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
729 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
730 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
731
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
732 ## Did we find any unsatisfied dependencies?
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
733 if (! ok)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
734 error ("the following dependencies where unsatisfied:\n %s", error_text);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
735 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
736 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
737
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
738 ## Prepare each package for installation.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
739 try
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
740 for i = 1:length (descriptions)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
741 desc = descriptions{i};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
742 pdir = packdirs{i};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
743 prepare_installation (desc, pdir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
744 configure_make (desc, pdir, verbose);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
745 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
746 catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
747 ## Something went wrong, delete tmpdirs.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
748 for i = 1:length (tmpdirs)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
749 rm_rf (tmpdirs{i});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
750 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
751 rethrow (lasterror ());
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
752 end_try_catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
753
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
754 ## Uninstall the packages that will be replaced.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
755 try
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
756 for i = packages_to_uninstall
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
757 if (global_install)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
758 uninstall ({global_packages{i}.name}, false, verbose, local_list,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
759 global_list, global_install);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
760 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
761 uninstall ({local_packages{i}.name}, false, verbose, local_list,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
762 global_list, global_install);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
763 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
764 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
765 catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
766 ## Something went wrong, delete tmpdirs.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
767 for i = 1:length (tmpdirs)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
768 rm_rf (tmpdirs{i});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
769 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
770 rethrow (lasterror ());
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
771 end_try_catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
772
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
773 ## Install each package.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
774 try
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
775 for i = 1:length (descriptions)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
776 desc = descriptions{i};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
777 pdir = packdirs{i};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
778 copy_files (desc, pdir, global_install);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
779 create_pkgadddel (desc, pdir, "PKG_ADD", global_install);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
780 create_pkgadddel (desc, pdir, "PKG_DEL", global_install);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
781 finish_installation (desc, pdir, global_install);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
782 generate_lookfor_cache (desc);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
783 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
784 catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
785 ## Something went wrong, delete tmpdirs.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
786 for i = 1:length (tmpdirs)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
787 rm_rf (tmpdirs{i});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
788 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
789 for i = 1:length (descriptions)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
790 rm_rf (descriptions{i}.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
791 rm_rf (getarchdir (descriptions{i}));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
792 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
793 rethrow (lasterror ());
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
794 end_try_catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
795
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
796 ## Check if the installed directory is empty. If it is remove it
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
797 ## from the list.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
798 for i = length (descriptions):-1:1
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
799 if (dirempty (descriptions{i}.dir, {"packinfo", "doc"}) &&
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
800 dirempty (getarchdir (descriptions{i})))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
801 warning ("package %s is empty\n", descriptions{i}.name);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
802 rm_rf (descriptions{i}.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
803 rm_rf (getarchdir (descriptions{i}));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
804 descriptions(i) = [];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
805 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
806 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
807
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
808 ## If the package requested that it is autoloaded, or the installer
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
809 ## requested that it is, then mark the package as autoloaded.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
810 for i = length (descriptions):-1:1
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
811 if (autoload > 0 || (autoload == 0 && isautoload (descriptions(i))))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
812 fclose (fopen (fullfile (descriptions{i}.dir, "packinfo",
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
813 ".autoload"), "wt"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
814 descriptions{i}.autoload = 1;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
815 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
816 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
817
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
818 ## Add the packages to the package list.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
819 try
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
820 if (global_install)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
821 idx = complement (packages_to_uninstall, 1:length(global_packages));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
822 global_packages = save_order ({global_packages{idx}, descriptions{:}});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
823 save (global_list, "global_packages");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
824 installed_pkgs_lst = {local_packages{:}, global_packages{:}};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
825 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
826 idx = complement (packages_to_uninstall, 1:length(local_packages));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
827 local_packages = save_order ({local_packages{idx}, descriptions{:}});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
828 save (local_list, "local_packages");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
829 installed_pkgs_lst = {local_packages{:}, global_packages{:}};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
830 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
831 catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
832 ## Something went wrong, delete tmpdirs.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
833 for i = 1:length (tmpdirs)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
834 rm_rf (tmpdirs{i});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
835 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
836 for i = 1:length (descriptions)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
837 rm_rf (descriptions{i}.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
838 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
839 if (global_install)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
840 printf ("error: couldn't append to %s\n", global_list);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
841 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
842 printf ("error: couldn't append to %s\n", local_list);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
843 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
844 rethrow (lasterror ());
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
845 end_try_catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
846
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
847 ## All is well, let's clean up.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
848 for i = 1:length (tmpdirs)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
849 [status, msg] = rm_rf (tmpdirs{i});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
850 if (status != 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
851 warning ("couldn't clean up after my self: %s\n", msg);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
852 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
853 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
854
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
855 ## Add the newly installed packages to the path, so the user
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
856 ## can begin using them. Only load them if they are marked autoload.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
857 if (length (descriptions) > 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
858 idx = [];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
859 for i = 1:length (descriptions)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
860 if (isautoload (descriptions(i)))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
861 nm = descriptions{i}.name;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
862 for j = 1:length (installed_pkgs_lst)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
863 if (strcmp (nm, installed_pkgs_lst{j}.name))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
864 idx (end + 1) = j;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
865 break;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
866 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
867 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
868 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
869 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
870 load_packages_and_dependencies (idx, handle_deps, installed_pkgs_lst,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
871 global_install);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
872 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
873 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
874
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
875 function uninstall (pkgnames, handle_deps, verbose, local_list,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
876 global_list, global_install)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
877 ## Get the list of installed packages.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
878 [local_packages, global_packages] = installed_packages(local_list,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
879 global_list);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
880 if (global_install)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
881 installed_pkgs_lst = {local_packages{:}, global_packages{:}};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
882 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
883 installed_pkgs_lst = local_packages;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
884 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
885
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
886 num_packages = length (installed_pkgs_lst);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
887 delete_idx = [];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
888 for i = 1:num_packages
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
889 cur_name = installed_pkgs_lst{i}.name;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
890 if (any (strcmp (cur_name, pkgnames)))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
891 delete_idx(end+1) = i;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
892 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
893 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
894
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
895 ## Are all the packages that should be uninstalled already installed?
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
896 if (length (delete_idx) != length (pkgnames))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
897 if (global_install)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
898 ## Try again for a locally installed package.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
899 installed_pkgs_lst = local_packages;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
900
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
901 num_packages = length (installed_pkgs_lst);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
902 delete_idx = [];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
903 for i = 1:num_packages
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
904 cur_name = installed_pkgs_lst{i}.name;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
905 if (any (strcmp (cur_name, pkgnames)))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
906 delete_idx(end+1) = i;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
907 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
908 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
909 if (length (delete_idx) != length (pkgnames))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
910 ## FIXME: We should have a better error message.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
911 warning ("some of the packages you want to uninstall are not installed");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
912 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
913 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
914 ## FIXME: We should have a better error message.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
915 warning ("some of the packages you want to uninstall are not installed");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
916 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
917 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
918
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
919 ## Compute the packages that will remain installed.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
920 idx = complement (delete_idx, 1:num_packages);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
921 remaining_packages = {installed_pkgs_lst{idx}};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
922
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
923 ## Check dependencies.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
924 if (handle_deps)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
925 error_text = "";
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
926 for i = 1:length (remaining_packages)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
927 desc = remaining_packages{i};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
928 bad_deps = get_unsatisfied_deps (desc, remaining_packages);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
929
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
930 ## Will the uninstallation break any dependencies?
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
931 if (! isempty (bad_deps))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
932 for i = 1:length (bad_deps)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
933 dep = bad_deps{i};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
934 error_text = cstrcat (error_text, " ", desc.name, " needs ",
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
935 dep.package, " ", dep.operator, " ",
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
936 dep.version, "\n");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
937 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
938 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
939 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
940
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
941 if (! isempty (error_text))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
942 error ("the following dependencies where unsatisfied:\n %s", error_text);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
943 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
944 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
945
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
946 ## Delete the directories containing the packages.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
947 for i = delete_idx
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
948 desc = installed_pkgs_lst{i};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
949 ## If an 'on_uninstall.m' exist, call it!
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
950 if (exist (fullfile (desc.dir, "packinfo", "on_uninstall.m"), "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
951 wd = pwd ();
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
952 cd (fullfile (desc.dir, "packinfo"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
953 on_uninstall (desc);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
954 cd (wd);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
955 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
956 ## Do the actual deletion.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
957 if (desc.loaded)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
958 rmpath (desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
959 if (exist (getarchdir (desc)))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
960 rmpath (getarchdir (desc));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
961 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
962 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
963 if (exist (desc.dir, "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
964 [status, msg] = rm_rf (desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
965 if (status != 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
966 error ("couldn't delete directory %s: %s", desc.dir, msg);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
967 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
968 [status, msg] = rm_rf (getarchdir (desc));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
969 if (status != 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
970 error ("couldn't delete directory %s: %s", getarchdir (desc), msg);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
971 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
972 if (dirempty (desc.archprefix))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
973 rm_rf (desc.archprefix);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
974 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
975 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
976 warning ("directory %s previously lost", desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
977 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
978 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
979
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
980 ## Write a new ~/.octave_packages.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
981 if (global_install)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
982 if (length (remaining_packages) == 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
983 unlink (global_list);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
984 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
985 global_packages = save_order (remaining_packages);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
986 save (global_list, "global_packages");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
987 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
988 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
989 if (length (remaining_packages) == 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
990 unlink (local_list);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
991 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
992 local_packages = save_order (remaining_packages);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
993 save (local_list, "local_packages");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
994 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
995 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
996
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
997 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
998
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
999 function [pkg_desc_list, flag] = describe (pkgnames, verbose,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1000 local_list, global_list)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1001
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1002 ## Get the list of installed packages.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1003 installed_pkgs_lst = installed_packages(local_list, global_list);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1004 num_packages = length (installed_pkgs_lst);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1005
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1006
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1007 describe_all = false;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1008 if (any (strcmp ("all", pkgnames)))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1009 describe_all = true;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1010 flag(1:num_packages) = {"Not Loaded"};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1011 num_pkgnames = num_packages;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1012 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1013 num_pkgnames = length (pkgnames);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1014 flag(1:num_pkgnames) = {"Not installed"};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1015 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1016
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1017 for i = 1:num_packages
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1018 curr_name = installed_pkgs_lst{i}.name;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1019 if (describe_all)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1020 name_pos = i;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1021 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1022 name_pos = find(strcmp (curr_name, pkgnames));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1023 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1024
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1025 if (! isempty (name_pos))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1026 if (installed_pkgs_lst{i}.loaded)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1027 flag{name_pos} = "Loaded";
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1028 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1029 flag{name_pos} = "Not loaded";
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1030 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1031
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1032 pkg_desc_list{name_pos}.name = installed_pkgs_lst{i}.name;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1033 pkg_desc_list{name_pos}.version = installed_pkgs_lst{i}.version;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1034 pkg_desc_list{name_pos}.description = installed_pkgs_lst{i}.description;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1035 pkg_desc_list{name_pos}.provides = parse_pkg_idx (installed_pkgs_lst{i}.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1036
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1037 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1038 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1039
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1040 non_inst = find (strcmp (flag, "Not installed"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1041 if (! isempty (non_inst))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1042 if (nargout < 2)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1043 non_inst_str = sprintf (" %s ", pkgnames{non_inst});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1044 error ("some packages are not installed: %s", non_inst_str);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1045 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1046 pkg_desc_list{non_inst} = struct ("name", {}, "description",
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1047 {}, "provides", {});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1048 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1049 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1050
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1051 if (nargout == 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1052 for i = 1:num_pkgnames
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1053 print_package_description (pkg_desc_list{i}.name,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1054 pkg_desc_list{i}.version,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1055 pkg_desc_list{i}.provides,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1056 pkg_desc_list{i}.description,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1057 flag{i}, verbose);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1058 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1059 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1060
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1061 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1062
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1063 ## AUXILIARY FUNCTIONS
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1064
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1065 ## Read an INDEX file.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1066 function [pkg_idx_struct] = parse_pkg_idx (packdir)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1067
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1068 index_file = fullfile (packdir, "packinfo", "INDEX");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1069
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1070 if (! exist (index_file, "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1071 error ("could not find any INDEX file in directory %s, try 'pkg rebuild all' to generate missing INDEX files", packdir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1072 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1073
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1074
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1075 [fid, msg] = fopen (index_file, "r");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1076 if (fid == -1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1077 error ("the INDEX file %s could not be read: %s",
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1078 index_file, msg);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1079 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1080
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1081 cat_num = 1;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1082 pkg_idx_struct{1}.category = "Uncategorized";
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1083 pkg_idx_struct{1}.functions = {};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1084
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1085 line = fgetl (fid);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1086 while (isempty (strfind (line, ">>")) && ! feof (fid))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1087 line = fgetl (fid);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1088 endwhile
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1089
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1090 while (! feof (fid) || line != -1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1091 if (! any (! isspace (line)) || line(1) == "#" || any (line == "="))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1092 ## Comments, blank lines or comments about unimplemented
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1093 ## functions: do nothing
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1094 ## FIXME: probably comments and pointers to external functions
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1095 ## could be treated better when printing to screen?
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1096 elseif (! isempty (strfind (line, ">>")))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1097 ## Skip package name and description as they are in DESCRIPTION
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1098 ## already.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1099 elseif (! isspace (line(1)))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1100 ## Category.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1101 if (! isempty (pkg_idx_struct{cat_num}.functions))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1102 pkg_idx_struct{++cat_num}.functions = {};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1103 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1104 pkg_idx_struct{cat_num}.category = deblank (line);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1105 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1106 ## Function names.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1107 while (any (! isspace (line)))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1108 [fun_name, line] = strtok (line);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1109 pkg_idx_struct{cat_num}.functions{end+1} = deblank (fun_name);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1110 endwhile
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1111 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1112 line = fgetl (fid);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1113 endwhile
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1114 fclose (fid);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1115 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1116
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1117 function print_package_description (pkg_name, pkg_ver, pkg_idx_struct,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1118 pkg_desc, status, verbose)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1119
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1120 printf ("---\nPackage name:\n\t%s\n", pkg_name);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1121 printf ("Version:\n\t%s\n", pkg_ver);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1122 printf ("Short description:\n\t%s\n", pkg_desc);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1123 printf ("Status:\n\t%s\n", status);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1124 if (verbose)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1125 printf ("---\nProvides:\n");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1126 for i = 1:length(pkg_idx_struct)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1127 if (! isempty (pkg_idx_struct{i}.functions))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1128 printf ("%s\n", pkg_idx_struct{i}.category);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1129 for j = 1:length(pkg_idx_struct{i}.functions)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1130 printf ("\t%s\n", pkg_idx_struct{i}.functions{j});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1131 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1132 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1133 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1134 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1135
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1136 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1137
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1138
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1139 function pth = absolute_pathname (pth)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1140 [status, msg, msgid] = fileattrib (pth);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1141 if (status != 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1142 error ("could not find the file or path %s", pth);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1143 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1144 pth = msg.Name;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1145 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1146 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1147
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1148 function repackage (builddir, buildlist)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1149 packages = installed_packages (buildlist, buildlist);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1150
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1151 wd = pwd();
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1152 for i = 1 : length(packages)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1153 pack = packages{i};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1154 unwind_protect
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1155 cd (builddir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1156 mkdir (pack.name);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1157 mkdir (fullfile (pack.name, "inst"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1158 copyfile (fullfile (pack.dir, "*"), fullfile (pack.name, "inst"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1159 movefile (fullfile (pack.name, "inst","packinfo", "*"), pack.name);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1160 if (exist (fullfile (pack.name, "inst","packinfo", ".autoload"), "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1161 unlink (fullfile (pack.name, "inst","packinfo", ".autoload"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1162 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1163 rmdir (fullfile (pack.name, "inst", "packinfo"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1164 if (exist (fullfile (pack.name, "inst", "doc"), "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1165 movefile (fullfile (pack.name, "inst", "doc"), pack.name);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1166 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1167 if (exist (fullfile (pack.name, "inst", "bin"), "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1168 movefile (fullfile (pack.name, "inst", "bin"), pack.name);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1169 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1170 archdir = fullfile (pack.archprefix, cstrcat (pack.name, "-",
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1171 pack.version), getarch ());
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1172 if (exist (archdir, "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1173 if (exist (fullfile (pack.name, "inst", "PKG_ADD"), "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1174 unlink (fullfile (pack.name, "inst", "PKG_ADD"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1175 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1176 if (exist (fullfile (pack.name, "inst", "PKG_DEL"), "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1177 unlink (fullfile (pack.name, "inst", "PKG_DEL"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1178 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1179 if (exist (fullfile (archdir, "PKG_ADD"), "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1180 movefile (fullfile (archdir, "PKG_ADD"),
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1181 fullfile (pack.name, "PKG_ADD"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1182 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1183 if (exist (fullfile (archdir, "PKG_DEL"), "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1184 movefile (fullfile (archdir, "PKG_DEL"),
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1185 fullfile (pack.name, "PKG_DEL"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1186 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1187 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1188 if (exist (fullfile (pack.name, "inst", "PKG_ADD"), "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1189 movefile (fullfile (pack.name, "inst", "PKG_ADD"),
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1190 fullfile (pack.name, "PKG_ADD"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1191 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1192 if (exist (fullfile (pack.name, "inst", "PKG_DEL"), "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1193 movefile (fullfile (pack.name, "inst", "PKG_DEL"),
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1194 fullfile (pack.name, "PKG_DEL"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1195 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1196 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1197 tfile = cstrcat (pack.name, "-", pack.version, ".tar");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1198 tar (tfile, pack.name);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1199 try
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1200 gzip (tfile);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1201 unlink (tfile);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1202 catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1203 warning ("failed to compress %s", tfile);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1204 end_try_catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1205 unwind_protect_cleanup
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1206 if (exist (pack.name, "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1207 rm_rf (pack.name);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1208 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1209 cd (wd);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1210 end_unwind_protect
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1211 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1212 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1213
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1214 function auto = isautoload (desc)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1215 auto = false;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1216 if (isfield (desc{1}, "autoload"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1217 a = desc{1}.autoload;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1218 if ((isnumeric (a) && a > 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1219 || (ischar (a) && (strcmpi (a, "true")
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1220 || strcmpi (a, "on")
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1221 || strcmpi (a, "yes")
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1222 || strcmpi (a, "1"))))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1223 auto = true;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1224 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1225 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1226 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1227
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1228 function prepare_installation (desc, packdir)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1229 ## Is there a pre_install to call?
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1230 if (exist (fullfile (packdir, "pre_install.m"), "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1231 wd = pwd ();
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1232 try
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1233 cd (packdir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1234 pre_install (desc);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1235 cd (wd);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1236 catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1237 cd (wd);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1238 rethrow (lasterror ());
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1239 end_try_catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1240 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1241
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1242 ## If the directory "inst" doesn't exist, we create it.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1243 inst_dir = fullfile (packdir, "inst");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1244 if (! exist (inst_dir, "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1245 [status, msg] = mkdir (inst_dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1246 if (status != 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1247 rm_rf (desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1248 error ("the 'inst' directory did not exist and could not be created: %s",
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1249 msg);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1250 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1251 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1252 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1253
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1254 function configure_make (desc, packdir, verbose)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1255 ## Perform ./configure, make, make install in "src".
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1256 if (exist (fullfile (packdir, "src"), "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1257 src = fullfile (packdir, "src");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1258 ## Configure.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1259 if (exist (fullfile (src, "configure"), "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1260 flags = "";
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1261 if (isempty (getenv ("CC")))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1262 flags = cstrcat (flags, " CC=\"", octave_config_info ("CC"), "\"");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1263 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1264 if (isempty (getenv ("CXX")))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1265 flags = cstrcat (flags, " CXX=\"", octave_config_info ("CXX"), "\"");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1266 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1267 if (isempty (getenv ("AR")))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1268 flags = cstrcat (flags, " AR=\"", octave_config_info ("AR"), "\"");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1269 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1270 if (isempty (getenv ("RANLIB")))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1271 flags = cstrcat (flags, " RANLIB=\"", octave_config_info ("RANLIB"), "\"");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1272 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1273 [status, output] = shell (strcat ("cd '", src, "'; ./configure --prefix=\"",
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1274 desc.dir, "\"", flags));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1275 if (status != 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1276 rm_rf (desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1277 error ("the configure script returned the following error: %s", output);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1278 elseif (verbose)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1279 printf("%s", output);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1280 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1281
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1282 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1283
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1284 ## Make.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1285 if (exist (fullfile (src, "Makefile"), "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1286 [status, output] = shell (cstrcat ("export INSTALLDIR=\"", desc.dir,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1287 "\"; make -C '", src, "'"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1288 if (status != 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1289 rm_rf (desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1290 error ("'make' returned the following error: %s", output);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1291 elseif (verbose)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1292 printf("%s", output);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1293 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1294 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1295
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1296 ## Copy files to "inst" and "inst/arch" (this is instead of 'make
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1297 ## install').
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1298 files = fullfile (src, "FILES");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1299 instdir = fullfile (packdir, "inst");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1300 archdir = fullfile (packdir, "inst", getarch ());
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1301
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1302 ## Get file names.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1303 if (exist (files, "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1304 [fid, msg] = fopen (files, "r");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1305 if (fid < 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1306 error ("couldn't open %s: %s", files, msg);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1307 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1308 filenames = char (fread (fid))';
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1309 fclose (fid);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1310 if (filenames(end) == "\n")
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1311 filenames(end) = [];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1312 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1313 filenames = split_by (filenames, "\n");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1314 delete_idx = [];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1315 for i = 1:length (filenames)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1316 if (! all (isspace (filenames{i})))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1317 filenames{i} = fullfile (src, filenames{i});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1318 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1319 delete_idx(end+1) = i;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1320 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1321 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1322 filenames(delete_idx) = [];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1323 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1324 m = dir (fullfile (src, "*.m"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1325 oct = dir (fullfile (src, "*.oct"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1326 mex = dir (fullfile (src, "*.mex"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1327
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1328 filenames = cellfun (@(x) fullfile (src, x),
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1329 {m.name, oct.name, mex.name},
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1330 "UniformOutput", false);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1331 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1332
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1333 ## Split into architecture dependent and independent files.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1334 if (isempty (filenames))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1335 idx = [];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1336 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1337 idx = cellfun (@is_architecture_dependent, filenames);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1338 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1339 archdependent = filenames (idx);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1340 archindependent = filenames (!idx);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1341
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1342 ## Copy the files.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1343 if (! all (isspace ([filenames{:}])))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1344 if (! exist (instdir, "dir")) # fixindent
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1345 mkdir (instdir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1346 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1347 if (! all (isspace ([archindependent{:}])))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1348 if (verbose)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1349 printf ("copyfile");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1350 printf (" %s", archindependent{:});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1351 printf ("%s\n", instdir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1352 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1353 [status, output] = copyfile (archindependent, instdir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1354 if (status != 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1355 rm_rf (desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1356 error ("Couldn't copy files from 'src' to 'inst': %s", output);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1357 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1358 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1359 if (! all (isspace ([archdependent{:}])))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1360 if (verbose)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1361 printf ("copyfile");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1362 printf (" %s", archdependent{:});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1363 printf (" %s\n", archdir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1364 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1365 if (! exist (archdir, "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1366 mkdir (archdir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1367 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1368 [status, output] = copyfile (archdependent, archdir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1369 if (status != 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1370 rm_rf (desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1371 error ("Couldn't copy files from 'src' to 'inst': %s", output);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1372 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1373 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1374 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1375 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1376 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1377
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1378 function pkg = extract_pkg (nm, pat)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1379 fid = fopen (nm, "rt");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1380 pkg = "";
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1381 if (fid >= 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1382 while (! feof (fid))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1383 ln = fgetl (fid);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1384 if (ln > 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1385 t = regexp (ln, pat, "tokens");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1386 if (! isempty (t))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1387 pkg = cstrcat (pkg, "\n", t{1}{1});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1388 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1389 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1390 endwhile
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1391 if (! isempty (pkg))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1392 pkg = cstrcat (pkg, "\n");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1393 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1394 fclose (fid);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1395 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1396 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1397
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1398 function create_pkgadddel (desc, packdir, nm, global_install)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1399 instpkg = fullfile (desc.dir, nm);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1400 instfid = fopen (instpkg, "wt");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1401 ## If it is exists, most of the PKG_* file should go into the
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1402 ## architecture dependent directory so that the autoload/mfilename
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1403 ## commands work as expected. The only part that doesn't is the
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1404 ## part in the main directory.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1405 archdir = fullfile (getarchprefix (desc), cstrcat (desc.name, "-",
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1406 desc.version), getarch ());
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1407 if (exist (getarchdir (desc, global_install), "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1408 archpkg = fullfile (getarchdir (desc, global_install), nm);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1409 archfid = fopen (archpkg, "at");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1410 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1411 archpkg = instpkg;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1412 archfid = instfid;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1413 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1414
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1415 if (archfid >= 0 && instfid >= 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1416 ## Search all dot-m files for PKG commands.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1417 lst = dir (fullfile (packdir, "inst", "*.m"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1418 for i = 1:length (lst)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1419 nam = fullfile (packdir, "inst", lst(i).name);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1420 fwrite (instfid, extract_pkg (nam, ['^[#%][#%]* *' nm ': *(.*)$']));
110417
8a3552ec7934 * lisp/indent.el (indent-according-to-mode): Apply syntax-propertize.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110305
diff changeset
1421 endfor
110038
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1422
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1423 ## Search all C++ source files for PKG commands.
110305
b10051866f51 New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110038
diff changeset
1424 lst = dir (fullfile (packdir, "src", "*.cc"));
110038
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1425 for i = 1:length (lst)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1426 nam = fullfile (packdir, "src", lst(i).name);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1427 fwrite (archfid, extract_pkg (nam, ['^//* *' nm ': *(.*)$']));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1428 fwrite (archfid, extract_pkg (nam, ['^/\** *' nm ': *(.*) *\*/$']));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1429 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1430
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1431 ## Add developer included PKG commands.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1432 packdirnm = fullfile (packdir, nm);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1433 if (exist (packdirnm, "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1434 fid = fopen (packdirnm, "rt");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1435 if (fid >= 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1436 while (! feof (fid))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1437 ln = fgets (fid);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1438 if (ln > 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1439 fwrite (archfid, ln);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1440 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1441 endwhile
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1442 fclose (fid);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1443 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1444 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1445
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1446 ## If the files is empty remove it.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1447 fclose (instfid);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1448 t = dir (instpkg);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1449 if (t.bytes <= 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1450 unlink (instpkg);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1451 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1452
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1453 if (instfid != archfid)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1454 fclose (archfid);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1455 t = dir (archpkg);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1456 if (t.bytes <= 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1457 unlink (archpkg);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1458 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1459 endif
110305
b10051866f51 New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110038
diff changeset
1460 endif
b10051866f51 New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110038
diff changeset
1461 endfunction
110038
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1462
110305
b10051866f51 New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110038
diff changeset
1463 function copy_files (desc, packdir, global_install)
110038
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1464 ## Create the installation directory.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1465 if (! exist (desc.dir, "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1466 [status, output] = mkdir (desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1467 if (status != 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1468 error ("couldn't create installation directory %s : %s",
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1469 desc.dir, output);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1470 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1471 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1472
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1473 octfiledir = getarchdir (desc);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1474
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1475 ## Copy the files from "inst" to installdir.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1476 instdir = fullfile (packdir, "inst");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1477 if (! dirempty (instdir))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1478 [status, output] = copyfile (fullfile (instdir, "*"), desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1479 if (status != 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1480 rm_rf (desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1481 error ("couldn't copy files to the installation directory");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1482 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1483 if (exist (fullfile (desc.dir, getarch ()), "dir") &&
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1484 ! strcmp (fullfile (desc.dir, getarch ()), octfiledir))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1485 if (! exist (octfiledir, "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1486 ## Can be required to create upto three levels of dirs.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1487 octm1 = fileparts (octfiledir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1488 if (! exist (octm1, "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1489 octm2 = fileparts (octm1);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1490 if (! exist (octm2, "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1491 octm3 = fileparts (octm2);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1492 if (! exist (octm3, "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1493 [status, output] = mkdir (octm3);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1494 if (status != 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1495 rm_rf (desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1496 error ("couldn't create installation directory %s : %s",
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1497 octm3, output);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1498 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1499 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1500 [status, output] = mkdir (octm2);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1501 if (status != 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1502 rm_rf (desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1503 error ("couldn't create installation directory %s : %s",
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1504 octm2, output);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1505 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1506 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1507 [status, output] = mkdir (octm1);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1508 if (status != 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1509 rm_rf (desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1510 error ("couldn't create installation directory %s : %s",
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1511 octm1, output);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1512 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1513 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1514 [status, output] = mkdir (octfiledir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1515 if (status != 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1516 rm_rf (desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1517 error ("couldn't create installation directory %s : %s",
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1518 octfiledir, output);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1519 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1520 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1521 [status, output] = movefile (fullfile (desc.dir, getarch (), "*"),
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1522 octfiledir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1523 rm_rf (fullfile (desc.dir, getarch ()));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1524
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1525 if (status != 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1526 rm_rf (desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1527 rm_rf (octfiledir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1528 error ("couldn't copy files to the installation directory");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1529 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1530 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1531
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1532 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1533
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1534 ## Create the "packinfo" directory.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1535 packinfo = fullfile (desc.dir, "packinfo");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1536 [status, msg] = mkdir (packinfo);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1537 if (status != 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1538 rm_rf (desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1539 rm_rf (octfiledir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1540 error ("couldn't create packinfo directory: %s", msg);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1541 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1542
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1543 ## Copy DESCRIPTION.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1544 [status, output] = copyfile (fullfile (packdir, "DESCRIPTION"), packinfo);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1545 if (status != 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1546 rm_rf (desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1547 rm_rf (octfiledir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1548 error ("couldn't copy DESCRIPTION: %s", output);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1549 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1550
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1551 ## Copy COPYING.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1552 [status, output] = copyfile (fullfile (packdir, "COPYING"), packinfo);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1553 if (status != 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1554 rm_rf (desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1555 rm_rf (octfiledir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1556 error ("couldn't copy COPYING: %s", output);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1557 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1558
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1559 ## If the file ChangeLog exists, copy it.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1560 changelog_file = fullfile (packdir, "ChangeLog");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1561 if (exist (changelog_file, "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1562 [status, output] = copyfile (changelog_file, packinfo);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1563 if (status != 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1564 rm_rf (desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1565 rm_rf (octfiledir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1566 error ("couldn't copy ChangeLog file: %s", output);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1567 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1568 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1569
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1570 ## Is there an INDEX file to copy or should we generate one?
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1571 index_file = fullfile (packdir, "INDEX");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1572 if (exist(index_file, "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1573 [status, output] = copyfile (index_file, packinfo);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1574 if (status != 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1575 rm_rf (desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1576 rm_rf (octfiledir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1577 error ("couldn't copy INDEX file: %s", output);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1578 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1579 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1580 try
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1581 write_index (desc, fullfile (packdir, "inst"),
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1582 fullfile (packinfo, "INDEX"), global_install);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1583 catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1584 rm_rf (desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1585 rm_rf (octfiledir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1586 rethrow (lasterror ());
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1587 end_try_catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1588 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1589
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1590 ## Is there an 'on_uninstall.m' to install?
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1591 fon_uninstall = fullfile (packdir, "on_uninstall.m");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1592 if (exist (fon_uninstall, "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1593 [status, output] = copyfile (fon_uninstall, packinfo);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1594 if (status != 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1595 rm_rf (desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1596 rm_rf (octfiledir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1597 error ("couldn't copy on_uninstall.m: %s", output);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1598 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1599 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1600
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1601 ## Is there a doc/ directory that needs to be installed?
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1602 docdir = fullfile (packdir, "doc");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1603 if (exist (docdir, "dir") && ! dirempty (docdir))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1604 [status, output] = copyfile (docdir, desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1605 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1606
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1607 ## Is there a bin/ directory that needs to be installed?
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1608 ## FIXME: Need to treat architecture dependent files in bin/
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1609 bindir = fullfile (packdir, "bin");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1610 if (exist (bindir, "dir") && ! dirempty (bindir))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1611 [status, output] = copyfile (bindir, desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1612 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1613 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1614
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1615 function finish_installation (desc, packdir, global_install)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1616 ## Is there a post-install to call?
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1617 if (exist (fullfile (packdir, "post_install.m"), "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1618 wd = pwd ();
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1619 try
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1620 cd (packdir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1621 post_install (desc);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1622 cd (wd);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1623 catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1624 cd (wd);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1625 rm_rf (desc.dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1626 rm_rf (getarchdir (desc), global_install);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1627 rethrow (lasterror ());
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1628 end_try_catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1629 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1630 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1631
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1632 function generate_lookfor_cache (desc)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1633 dirs = split_by (genpath (desc.dir), pathsep ());
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1634 for i = 1 : length (dirs)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1635 gen_doc_cache (fullfile (dirs{i}, "doc-cache"), dirs{i});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1636 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1637 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1638
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1639 ## Make sure the package contains the essential files.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1640 function verify_directory (dir)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1641 needed_files = {"COPYING", "DESCRIPTION"};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1642 for f = needed_files
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1643 if (! exist (fullfile (dir, f{1}), "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1644 error ("package is missing file: %s", f{1});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1645 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1646 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1647 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1648
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1649 ## Parse the DESCRIPTION file.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1650 function desc = get_description (filename)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1651 [fid, msg] = fopen (filename, "r");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1652 if (fid == -1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1653 error ("the DESCRIPTION file %s could not be read: %s", filename, msg);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1654 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1655
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1656 desc = struct ();
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1657
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1658 line = fgetl (fid);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1659 while (line != -1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1660 if (line(1) == "#")
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1661 ## Comments, do nothing.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1662 elseif (isspace(line(1)))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1663 ## Continuation lines
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1664 if (exist ("keyword", "var") && isfield (desc, keyword))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1665 desc.(keyword) = cstrcat (desc.(keyword), " ", rstrip(line));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1666 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1667 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1668 ## Keyword/value pair
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1669 colon = find (line == ":");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1670 if (length (colon) == 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1671 disp ("skipping line");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1672 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1673 colon = colon(1);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1674 keyword = tolower (strip (line(1:colon-1)));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1675 value = strip (line (colon+1:end));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1676 if (length (value) == 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1677 fclose (fid);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1678 error ("the keyword %s has an empty value", desc.keywords{end});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1679 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1680 desc.(keyword) = value;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1681 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1682 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1683 line = fgetl (fid);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1684 endwhile
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1685 fclose (fid);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1686
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1687 ## Make sure all is okay.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1688 needed_fields = {"name", "version", "date", "title", ...
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1689 "author", "maintainer", "description"};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1690 for f = needed_fields
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1691 if (! isfield (desc, f{1}))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1692 error ("description is missing needed field %s", f{1});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1693 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1694 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1695 desc.version = fix_version (desc.version);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1696 if (isfield (desc, "depends"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1697 desc.depends = fix_depends (desc.depends);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1698 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1699 desc.depends = "";
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1700 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1701 desc.name = tolower (desc.name);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1702 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1703
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1704 ## Make sure the version string v is a valid x.y.z version string
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1705 ## Examples: "0.1" => "0.1.0", "monkey" => error(...).
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1706 function out = fix_version (v)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1707 dots = find (v == ".");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1708 if (length (dots) == 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1709 major = str2num (v(1:dots-1));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1710 minor = str2num (v(dots+1:end));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1711 if (length (major) != 0 && length (minor) != 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1712 out = sprintf ("%d.%d.0", major, minor);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1713 return;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1714 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1715 elseif (length (dots) == 2)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1716 major = str2num (v(1:dots(1)-1));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1717 minor = str2num (v(dots(1)+1:dots(2)-1));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1718 rev = str2num (v(dots(2)+1:end));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1719 if (length (major) != 0 && length (minor) != 0 && length (rev) != 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1720 out = sprintf ("%d.%d.%d", major, minor, rev);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1721 return;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1722 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1723 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1724 error ("bad version string: %s", v);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1725 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1726
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1727 ## Make sure the depends field is of the right format.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1728 ## This function returns a cell of structures with the following fields:
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1729 ## package, version, operator
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1730 function deps_cell = fix_depends (depends)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1731 deps = split_by (tolower (depends), ",");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1732 deps_cell = cell (1, length (deps));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1733
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1734 ## For each dependency.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1735 for i = 1:length (deps)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1736 dep = deps{i};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1737 lpar = find (dep == "(");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1738 rpar = find (dep == ")");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1739 ## Does the dependency specify a version
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1740 ## Example: package(>= version).
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1741 if (length (lpar) == 1 && length (rpar) == 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1742 package = tolower (strip (dep(1:lpar-1)));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1743 sub = dep(lpar(1)+1:rpar(1)-1);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1744 parts = strsplit (sub, " ", true);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1745 if (length (parts) != 2)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1746 error ("incorrect syntax for dependency `%s' in the DESCRIPTION file\n",
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1747 dep);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1748 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1749 operator = parts{1};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1750 if (! any (strcmp (operator, {">", ">=", "<=", "<", "=="})))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1751 error ("unsupported operator: %s", operator);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1752 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1753 version = fix_version (parts{2});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1754
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1755 ## If no version is specified for the dependency
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1756 ## we say that the version should be greater than
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1757 ## or equal to "0.0.0".
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1758 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1759 package = tolower (strip (dep));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1760 operator = ">=";
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1761 version = "0.0.0";
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1762 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1763 deps_cell{i} = struct ("package", package, "operator", operator,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1764 "version", version);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1765 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1766 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1767
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1768 ## Strip the text of spaces from the right
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1769 ## Example: " hello world " => " hello world"
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1770 ## FIXME -- is this the same as deblank?
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1771 function text = rstrip (text)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1772 chars = find (! isspace (text));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1773 if (length (chars) > 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1774 ## FIXME: shouldn't it be text = text(1:chars(end));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1775 text = text (chars(1):end);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1776 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1777 text = "";
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1778 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1779 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1780
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1781 ## Strip the text of spaces from the left and the right.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1782 ## Example: " hello world " => "hello world"
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1783 function text = strip (text)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1784 chars = find (! isspace (text));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1785 if (length (chars) > 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1786 text = text(chars(1):chars(end));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1787 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1788 text = "";
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1789 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1790 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1791
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1792 ## Split the text into a cell array of strings by sep.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1793 ## Example: "A, B" => {"A", "B"} (with sep = ",")
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1794 function out = split_by (text, sep)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1795 out = strtrim (strsplit (text, sep));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1796 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1797
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1798 ## Create an INDEX file for a package that doesn't provide one.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1799 ## 'desc' describes the package.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1800 ## 'dir' is the 'inst' directory in temporary directory.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1801 ## 'index_file' is the name (including path) of resulting INDEX file.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1802 function write_index (desc, dir, index_file, global_install)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1803 ## Get names of functions in dir
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1804 [files, err, msg] = readdir (dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1805 if (err)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1806 error ("couldn't read directory %s: %s", dir, msg);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1807 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1808
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1809 ## Check for architecture dependent files.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1810 tmpdir = getarchdir (desc);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1811 if (exist (tmpdir, "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1812 [files2, err, msg] = readdir (tmpdir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1813 if (err)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1814 error ("couldn't read directory %s: %s", tmpdir, msg);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1815 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1816 files = [files; files2];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1817 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1818
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1819 functions = {};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1820 for i = 1:length (files)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1821 file = files{i};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1822 lf = length (file);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1823 if (lf > 2 && strcmp (file(end-1:end), ".m"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1824 functions{end+1} = file(1:end-2);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1825 elseif (lf > 4 && strcmp (file(end-3:end), ".oct"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1826 functions{end+1} = file(1:end-4);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1827 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1828 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1829
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1830 ## Does desc have a categories field?
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1831 if (! isfield (desc, "categories"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1832 error ("the DESCRIPTION file must have a Categories field, when no INDEX file is given");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1833 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1834 categories = split_by (desc.categories, ",");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1835 if (length (categories) < 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1836 error ("the Category field is empty");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1837 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1838
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1839 ## Write INDEX.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1840 fid = fopen (index_file, "w");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1841 if (fid == -1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1842 error ("couldn't open %s for writing.", index_file);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1843 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1844 fprintf (fid, "%s >> %s\n", desc.name, desc.title);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1845 fprintf (fid, "%s\n", categories{1});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1846 fprintf (fid, " %s\n", functions{:});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1847 fclose (fid);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1848 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1849
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1850 function bad_deps = get_unsatisfied_deps (desc, installed_pkgs_lst)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1851 bad_deps = {};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1852
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1853 ## For each dependency.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1854 for i = 1:length (desc.depends)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1855 dep = desc.depends{i};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1856
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1857 ## Is the current dependency Octave?
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1858 if (strcmp (dep.package, "octave"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1859 if (! compare_versions (OCTAVE_VERSION, dep.version, dep.operator))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1860 bad_deps{end+1} = dep;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1861 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1862 ## Is the current dependency not Octave?
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1863 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1864 ok = false;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1865 for i = 1:length (installed_pkgs_lst)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1866 cur_name = installed_pkgs_lst{i}.name;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1867 cur_version = installed_pkgs_lst{i}.version;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1868 if (strcmp (dep.package, cur_name)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1869 && compare_versions (cur_version, dep.version, dep.operator))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1870 ok = true;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1871 break;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1872 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1873 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1874 if (! ok)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1875 bad_deps{end+1} = dep;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1876 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1877 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1878 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1879 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1880
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1881 function [out1, out2] = installed_packages (local_list, global_list)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1882 ## Get the list of installed packages.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1883 try
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1884 local_packages = load (local_list).local_packages;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1885 catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1886 local_packages = {};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1887 end_try_catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1888 try
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1889 global_packages = load (global_list).global_packages;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1890 catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1891 global_packages = {};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1892 end_try_catch
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1893 installed_pkgs_lst = {local_packages{:}, global_packages{:}};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1894
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1895 ## Eliminate duplicates in the installed package list.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1896 ## Locally installed packages take precedence.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1897 dup = [];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1898 for i = 1:length (installed_pkgs_lst)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1899 if (find (dup, i))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1900 continue;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1901 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1902 for j = (i+1):length (installed_pkgs_lst)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1903 if (find (dup, j))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1904 continue;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1905 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1906 if (strcmp (installed_pkgs_lst{i}.name, installed_pkgs_lst{j}.name))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1907 dup = [dup, j];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1908 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1909 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1910 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1911 if (! isempty(dup))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1912 installed_pkgs_lst(dup) = [];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1913 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1914
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1915 ## Now check if the package is loaded.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1916 tmppath = strrep (path(), "\\", "/");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1917 for i = 1:length (installed_pkgs_lst)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1918 if (findstr (tmppath, strrep (installed_pkgs_lst{i}.dir, "\\", "/")))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1919 installed_pkgs_lst{i}.loaded = true;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1920 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1921 installed_pkgs_lst{i}.loaded = false;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1922 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1923 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1924 for i = 1:length (local_packages)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1925 if (findstr (tmppath, strrep (local_packages{i}.dir, "\\", "/")))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1926 local_packages{i}.loaded = true;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1927 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1928 local_packages{i}.loaded = false;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1929 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1930 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1931 for i = 1:length (global_packages)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1932 if (findstr (tmppath, strrep (global_packages{i}.dir, "\\", "/")))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1933 global_packages{i}.loaded = true;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1934 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1935 global_packages{i}.loaded = false;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1936 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1937 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1938
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1939 ## Should we return something?
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1940 if (nargout == 2)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1941 out1 = local_packages;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1942 out2 = global_packages;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1943 return;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1944 elseif (nargout == 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1945 out1 = installed_pkgs_lst;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1946 return;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1947 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1948
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1949 ## We shouldn't return something, so we'll print something.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1950 num_packages = length (installed_pkgs_lst);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1951 if (num_packages == 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1952 printf ("no packages installed.\n");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1953 return;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1954 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1955
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1956 ## Compute the maximal lengths of name, version, and dir.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1957 h1 = "Package Name";
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1958 h2 = "Version";
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1959 h3 = "Installation directory";
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1960 max_name_length = length (h1);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1961 max_version_length = length (h2);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1962 names = cell (num_packages, 1);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1963 for i = 1:num_packages
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1964 max_name_length = max (max_name_length,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1965 length (installed_pkgs_lst{i}.name));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1966 max_version_length = max (max_version_length,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1967 length (installed_pkgs_lst{i}.version));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1968 names{i} = installed_pkgs_lst{i}.name;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1969 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1970 max_dir_length = terminal_size()(2) - max_name_length - ...
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1971 max_version_length - 7;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1972 if (max_dir_length < 20)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1973 max_dir_length = Inf;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1974 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1975
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1976 h1 = postpad (h1, max_name_length + 1, " ");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1977 h2 = postpad (h2, max_version_length, " ");;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1978
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1979 ## Print a header.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1980 header = sprintf("%s | %s | %s\n", h1, h2, h3);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1981 printf (header);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1982 tmp = sprintf (repmat ("-", 1, length(header)-1));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1983 tmp(length(h1)+2) = "+";
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1984 tmp(length(h1)+length(h2)+5) = "+";
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1985 printf ("%s\n", tmp);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1986
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1987 ## Print the packages.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1988 format = sprintf ("%%%ds %%1s| %%%ds | %%s\n", max_name_length,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1989 max_version_length);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1990 [dummy, idx] = sort (names);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1991 for i = 1:num_packages
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1992 cur_name = installed_pkgs_lst{idx(i)}.name;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1993 cur_version = installed_pkgs_lst{idx(i)}.version;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1994 cur_dir = installed_pkgs_lst{idx(i)}.dir;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1995 if (length (cur_dir) > max_dir_length)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1996 first_char = length (cur_dir) - max_dir_length + 4;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1997 first_filesep = strfind (cur_dir(first_char:end), filesep());
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1998 if (! isempty (first_filesep))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1999 cur_dir = cstrcat ("...",
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2000 cur_dir((first_char + first_filesep(1) - 1):end));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2001 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2002 cur_dir = cstrcat ("...", cur_dir(first_char:end));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2003 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2004 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2005 if (installed_pkgs_lst{idx(i)}.loaded)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2006 cur_loaded = "*";
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2007 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2008 cur_loaded = " ";
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2009 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2010 printf (format, cur_name, cur_loaded, cur_version, cur_dir);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2011 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2012 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2013
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2014 function load_packages (files, handle_deps, local_list, global_list)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2015 installed_pkgs_lst = installed_packages (local_list, global_list);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2016 num_packages = length (installed_pkgs_lst);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2017
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2018 ## Read package names and installdirs into a more convenient format.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2019 pnames = pdirs = cell (1, num_packages);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2020 for i = 1:num_packages
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2021 pnames{i} = installed_pkgs_lst{i}.name;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2022 pdirs{i} = installed_pkgs_lst{i}.dir;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2023 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2024
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2025 ## Load all.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2026 if (length (files) == 1 && strcmp (files{1}, "all"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2027 idx = [1:length(installed_pkgs_lst)];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2028 ## Load auto.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2029 elseif (length (files) == 1 && strcmp (files{1}, "auto"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2030 idx = [];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2031 for i = 1:length (installed_pkgs_lst)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2032 if (exist (fullfile (pdirs{i}, "packinfo", ".autoload"), "file"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2033 idx (end + 1) = i;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2034 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2035 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2036 ## Load package_name1 ...
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2037 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2038 idx = [];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2039 for i = 1:length (files)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2040 idx2 = find (strcmp (pnames, files{i}));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2041 if (! any (idx2))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2042 error ("package %s is not installed", files{i});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2043 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2044 idx (end + 1) = idx2;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2045 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2046 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2047
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2048 ## Load the packages, but take care of the ordering of dependencies.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2049 load_packages_and_dependencies (idx, handle_deps, installed_pkgs_lst, true);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2050 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2051
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2052 function unload_packages (files, handle_deps, local_list, global_list)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2053 installed_pkgs_lst = installed_packages (local_list, global_list);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2054 num_packages = length (installed_pkgs_lst);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2055
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2056 ## Read package names and installdirs into a more convenient format.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2057 pnames = pdirs = cell (1, num_packages);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2058 for i = 1:num_packages
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2059 pnames{i} = installed_pkgs_lst{i}.name;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2060 pdirs{i} = installed_pkgs_lst{i}.dir;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2061 pdeps{i} = installed_pkgs_lst{i}.depends;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2062 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2063
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2064 ## Get the current octave path.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2065 p = split_by (path(), pathsep ());
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2066
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2067 if (length (files) == 1 && strcmp (files{1}, "all"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2068 ## Unload all.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2069 dirs = pdirs;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2070 desc = installed_pkgs_lst;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2071 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2072 ## Unload package_name1 ...
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2073 dirs = {};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2074 desc = {};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2075 for i = 1:length (files)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2076 idx = strcmp (pnames, files{i});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2077 if (! any (idx))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2078 error ("package %s is not installed", files{i});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2079 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2080 dirs{end+1} = pdirs{idx};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2081 desc{end+1} = installed_pkgs_lst{idx};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2082 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2083 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2084
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2085 ## Check for architecture dependent directories.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2086 archdirs = {};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2087 for i = 1:length (dirs)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2088 tmpdir = getarchdir (desc{i});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2089 if (exist (tmpdir, "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2090 archdirs{end+1} = dirs{i};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2091 archdirs{end+1} = tmpdir;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2092 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2093 archdirs{end+1} = dirs{i};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2094 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2095 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2096
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2097 ## Unload the packages.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2098 for i = 1:length (archdirs)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2099 d = archdirs{i};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2100 idx = strcmp (p, d);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2101 if (any (idx))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2102 rmpath (d);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2103 ## FIXME: We should also check if we need to remove items from
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2104 ## EXEC_PATH.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2105 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2106 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2107 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2108
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2109 function [status_out, msg_out] = rm_rf (dir)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2110 if (exist (dir))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2111 crr = confirm_recursive_rmdir ();
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2112 unwind_protect
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2113 confirm_recursive_rmdir (false);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2114 [status, msg] = rmdir (dir, "s");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2115 unwind_protect_cleanup
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2116 confirm_recursive_rmdir (crr);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2117 end_unwind_protect
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2118 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2119 status = 1;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2120 msg = "";
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2121 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2122 if (nargout > 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2123 status_out = status;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2124 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2125 if (nargout > 1)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2126 msg_out = msg;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2127 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2128 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2129
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2130 function emp = dirempty (nm, ign)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2131 if (exist (nm, "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2132 if (nargin < 2)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2133 ign = {".", ".."};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2134 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2135 ign = [{".", ".."}, ign];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2136 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2137 l = dir (nm);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2138 for i = 1:length (l)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2139 found = false;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2140 for j = 1:length (ign)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2141 if (strcmp (l(i).name, ign{j}))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2142 found = true;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2143 break;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2144 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2145 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2146 if (! found)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2147 emp = false;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2148 return
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2149 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2150 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2151 emp = true;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2152 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2153 emp = true;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2154 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2155 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2156
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2157 function arch = getarch ()
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2158 persistent _arch = cstrcat (octave_config_info("canonical_host_type"), ...
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2159 "-", octave_config_info("api_version"));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2160 arch = _arch;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2161 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2162
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2163 function archprefix = getarchprefix (desc, global_install)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2164 if ((nargin == 2 && global_install) || (nargin < 2 && issuperuser ()))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2165 archprefix = fullfile (octave_config_info ("libexecdir"), "octave",
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2166 "packages", cstrcat(desc.name, "-", desc.version));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2167 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2168 archprefix = desc.dir;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2169 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2170 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2171
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2172 function archdir = getarchdir (desc)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2173 archdir = fullfile (desc.archprefix, getarch());
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2174 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2175
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2176 function s = issuperuser ()
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2177 if ((ispc () && ! isunix ()) || (geteuid() == 0))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2178 s = true;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2179 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2180 s = false;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2181 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2182 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2183
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2184 function [status, output] = shell (cmd)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2185 persistent have_sh;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2186
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2187 cmd = strrep (cmd, "\\", "/");
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2188 if (ispc () && ! isunix ())
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2189 if (isempty(have_sh))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2190 if (system("sh.exe -c \"exit\""))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2191 have_sh = false;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2192 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2193 have_sh = true;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2194 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2195 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2196 if (have_sh)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2197 [status, output] = system (cstrcat ("sh.exe -c \"", cmd, "\""));
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2198 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2199 error ("Can not find the command shell")
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2200 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2201 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2202 [status, output] = system (cmd);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2203 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2204 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2205
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2206 function newdesc = save_order (desc)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2207 newdesc = {};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2208 for i = 1 : length(desc)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2209 deps = desc{i}.depends;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2210 if (isempty (deps) || (length (deps) == 1 &&
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2211 strcmp(deps{1}.package, "octave")))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2212 newdesc {end + 1} = desc{i};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2213 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2214 tmpdesc = {};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2215 for k = 1 : length (deps)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2216 for j = 1 : length (desc)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2217 if (strcmp (desc{j}.name, deps{k}.package))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2218 tmpdesc{end+1} = desc{j};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2219 break;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2220 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2221 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2222 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2223 if (! isempty (tmpdesc))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2224 newdesc = {newdesc{:}, save_order(tmpdesc){:}, desc{i}};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2225 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2226 newdesc{end+1} = desc{i};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2227 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2228 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2229 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2230 ## Eliminate the duplicates.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2231 idx = [];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2232 for i = 1 : length (newdesc)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2233 for j = (i + 1) : length (newdesc)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2234 if (strcmp (newdesc{i}.name, newdesc{j}.name))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2235 idx (end + 1) = j;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2236 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2237 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2238 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2239 newdesc(idx) = [];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2240 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2241
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2242 function load_packages_and_dependencies (idx, handle_deps, installed_pkgs_lst,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2243 global_install)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2244 idx = load_package_dirs (idx, [], handle_deps, installed_pkgs_lst);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2245 dirs = {};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2246 execpath = EXEC_PATH ();
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2247 for i = idx;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2248 ndir = installed_pkgs_lst{i}.dir;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2249 dirs{end+1} = ndir;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2250 if (exist (fullfile (dirs{end}, "bin"), "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2251 execpath = cstrcat (fullfile (dirs{end}, "bin"), ":", execpath);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2252 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2253 tmpdir = getarchdir (installed_pkgs_lst{i});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2254 if (exist (tmpdir, "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2255 dirs{end + 1} = tmpdir;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2256 if (exist (fullfile (dirs{end}, "bin"), "dir"))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2257 execpath = cstrcat (fullfile (dirs{end}, "bin"), ":", execpath);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2258 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2259 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2260 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2261
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2262 ## Load the packages.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2263 if (length (dirs) > 0)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2264 addpath (dirs{:});
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2265 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2266
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2267 ## Add the binaries to exec_path.
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2268 if (! strcmp (EXEC_PATH, execpath))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2269 EXEC_PATH (execpath);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2270 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2271 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2272
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2273 function idx = load_package_dirs (lidx, idx, handle_deps, installed_pkgs_lst)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2274 for i = lidx
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2275 if (isfield (installed_pkgs_lst{i}, "loaded") &&
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2276 installed_pkgs_lst{i}.loaded)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2277 continue;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2278 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2279 if (handle_deps)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2280 deps = installed_pkgs_lst{i}.depends;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2281 if ((length (deps) > 1) || (length (deps) == 1 &&
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2282 ! strcmp(deps{1}.package, "octave")))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2283 tmplidx = [];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2284 for k = 1 : length (deps)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2285 for j = 1 : length (installed_pkgs_lst)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2286 if (strcmp (installed_pkgs_lst{j}.name, deps{k}.package))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2287 tmplidx (end + 1) = j;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2288 break;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2289 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2290 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2291 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2292 idx = load_package_dirs (tmplidx, idx, handle_deps,
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2293 installed_pkgs_lst);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2294 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2295 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2296 if (isempty (find(idx == i)))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2297 idx (end + 1) = i;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2298 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2299 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2300 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2301 endfunction
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2302
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2303 function dep = is_architecture_dependent (nm)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2304 persistent archdepsuffix = {".oct",".mex",".a",".lib",".so",".so.*",".dll","dylib"};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2305
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2306 dep = false;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2307 for i = 1 : length (archdepsuffix)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2308 ext = archdepsuffix{i};
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2309 if (ext(end) == "*")
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2310 isglob = true;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2311 ext(end) = [];
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2312 else
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2313 isglob = false;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2314 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2315 pos = findstr (nm, ext);
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2316 if (pos)
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2317 if (! isglob && (length(nm) - pos(end) != length(ext) - 1))
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2318 continue;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2319 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2320 dep = true;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2321 break;
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2322 endif
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2323 endfor
6939db1ee97b Use SMIE for octave-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2324 endfunction