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