annotate scripts/pkg/pkg.m @ 13931:9de488c6c59c

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