annotate test/indent/octave.m @ 110628:19b118dd1498

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