annotate scripts/pkg/pkg.m @ 20475:7fa1970a655d

pkg.m: drop check of nargout value, the interpreter already does that. * scripts/pkg/pkg.m: the interpreter already checks if there was any variable that got no value assigned, there's no need to make the code more complicated to cover that. Also, there's no point in calling describe() with different nargout since it doesn't check nargout.
author Carnë Draug <carandraug@octave.org>
date Thu, 03 Sep 2015 16:21:08 +0100
parents 9fc020886ae9
children ad7fe3cb6fd2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19597
diff changeset
1 ## Copyright (C) 2005-2015 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.
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14446
diff changeset
3 ## Copyright (C) 2012 Carlo de Falco
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11547
diff changeset
4 ##
6440
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6378
diff changeset
5 ## This file is part of Octave.
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6378
diff changeset
6 ##
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6378
diff changeset
7 ## Octave is free software; you can redistribute it and/or modify it
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6378
diff changeset
8 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6950
diff changeset
9 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6950
diff changeset
10 ## your option) any later version.
6440
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6378
diff changeset
11 ##
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6378
diff changeset
12 ## Octave is distributed in the hope that it will be useful, but
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6378
diff changeset
13 ## WITHOUT ANY WARRANTY; without even the implied warranty of
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6378
diff changeset
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6378
diff changeset
15 ## General Public License for more details.
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6378
diff changeset
16 ##
5801
70013c9f3ccc [project @ 2006-05-10 16:53:03 by jwe]
jwe
parents:
diff changeset
17 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6950
diff changeset
18 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6950
diff changeset
19 ## <http://www.gnu.org/licenses/>.
5801
70013c9f3ccc [project @ 2006-05-10 16:53:03 by jwe]
jwe
parents:
diff changeset
20
70013c9f3ccc [project @ 2006-05-10 16:53:03 by jwe]
jwe
parents:
diff changeset
21 ## -*- texinfo -*-
11547
e1851653d59c Eliminate @deffn macros.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
22 ## @deftypefn {Command} {} pkg @var{command} @var{pkg_name}
e1851653d59c Eliminate @deffn macros.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
23 ## @deftypefnx {Command} {} pkg @var{command} @var{option} @var{pkg_name}
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
24 ## Manage packages (groups of add-on functions) for Octave.
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
25 ##
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
26 ## Different actions 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
27 ##
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
28 ## Available commands:
6032
dcecca0396e6 [project @ 2006-10-04 17:35:15 by jwe]
jwe
parents: 6025
diff changeset
29 ##
dcecca0396e6 [project @ 2006-10-04 17:35:15 by jwe]
jwe
parents: 6025
diff changeset
30 ## @table @samp
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
31 ##
6032
dcecca0396e6 [project @ 2006-10-04 17:35:15 by jwe]
jwe
parents: 6025
diff changeset
32 ## @item install
6070
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
33 ## Install named packages. For example,
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
34 ##
6070
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
35 ## @example
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
36 ## pkg install image-1.0.0.tar.gz
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
37 ## @end example
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
38 ##
6070
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
39 ## @noindent
9307
c2923c27c877 Various documentation improvements
Rik <rdrider0-list@yahoo.com>
parents: 9258
diff changeset
40 ## installs the package found in the file @file{image-1.0.0.tar.gz}.
6070
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
41 ##
6645
81eb28d50cee [project @ 2007-05-21 21:05:54 by dbateman]
dbateman
parents: 6634
diff changeset
42 ## 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
43 ## in which a package is installed. These options can be one or more of
6645
81eb28d50cee [project @ 2007-05-21 21:05:54 by dbateman]
dbateman
parents: 6634
diff changeset
44 ##
81eb28d50cee [project @ 2007-05-21 21:05:54 by dbateman]
dbateman
parents: 6634
diff changeset
45 ## @table @code
81eb28d50cee [project @ 2007-05-21 21:05:54 by dbateman]
dbateman
parents: 6634
diff changeset
46 ## @item -nodeps
12779
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
47 ## 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
48 ## 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
49 ## which is not installed on the system. @strong{Use this option with care.}
6645
81eb28d50cee [project @ 2007-05-21 21:05:54 by dbateman]
dbateman
parents: 6634
diff changeset
50 ##
81eb28d50cee [project @ 2007-05-21 21:05:54 by dbateman]
dbateman
parents: 6634
diff changeset
51 ## @item -noauto
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11547
diff changeset
52 ## 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
53 ## when starting Octave. This overrides any setting within the package.
6258
ea3a7e8469e9 [project @ 2007-01-30 20:17:19 by dbateman]
dbateman
parents: 6254
diff changeset
54 ##
6645
81eb28d50cee [project @ 2007-05-21 21:05:54 by dbateman]
dbateman
parents: 6634
diff changeset
55 ## @item -auto
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11547
diff changeset
56 ## 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
57 ## starting Octave. This overrides any setting within the package.
6645
81eb28d50cee [project @ 2007-05-21 21:05:54 by dbateman]
dbateman
parents: 6634
diff changeset
58 ##
81eb28d50cee [project @ 2007-05-21 21:05:54 by dbateman]
dbateman
parents: 6634
diff changeset
59 ## @item -local
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 12931
diff changeset
60 ## 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
61 ## even if the user has system privileges.
6258
ea3a7e8469e9 [project @ 2007-01-30 20:17:19 by dbateman]
dbateman
parents: 6254
diff changeset
62 ##
6645
81eb28d50cee [project @ 2007-05-21 21:05:54 by dbateman]
dbateman
parents: 6634
diff changeset
63 ## @item -global
12779
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
64 ## 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
65 ## 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
66 ##
12561
0ade5992e374 Add documentation for '-forge' option (bug #32464).
Rik <octave@nomad.inbox5.com>
parents: 12167
diff changeset
67 ## @item -forge
0ade5992e374 Add documentation for '-forge' option (bug #32464).
Rik <octave@nomad.inbox5.com>
parents: 12167
diff changeset
68 ## 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
69 ## requires an internet connection and the cURL library.
6614
3a53d0f3e0e4 [project @ 2007-05-12 05:50:03 by dbateman]
dbateman
parents: 6500
diff changeset
70 ##
6645
81eb28d50cee [project @ 2007-05-21 21:05:54 by dbateman]
dbateman
parents: 6634
diff changeset
71 ## @item -verbose
12779
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
72 ## 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
73 ## they are performed.
6645
81eb28d50cee [project @ 2007-05-21 21:05:54 by dbateman]
dbateman
parents: 6634
diff changeset
74 ## @end table
81eb28d50cee [project @ 2007-05-21 21:05:54 by dbateman]
dbateman
parents: 6634
diff changeset
75 ##
12779
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
76 ## @item update
13931
9de488c6c59c doc: Spellcheck documentation before 3.6.0 release
Rik <octave@nomad.inbox5.com>
parents: 13864
diff changeset
77 ## 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
78 ## 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
79 ## Usage:
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
80 ##
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
81 ## @example
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
82 ## pkg update
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
83 ## @end example
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
84 ##
6032
dcecca0396e6 [project @ 2006-10-04 17:35:15 by jwe]
jwe
parents: 6025
diff changeset
85 ## @item uninstall
6070
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
86 ## Uninstall named packages. For example,
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
87 ##
6070
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
88 ## @example
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
89 ## pkg uninstall image
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
90 ## @end example
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
91 ##
6070
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
92 ## @noindent
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 8942
diff changeset
93 ## removes the @code{image} package from the system. If another installed
6070
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
94 ## 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
95 ## 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
96 ##
6032
dcecca0396e6 [project @ 2006-10-04 17:35:15 by jwe]
jwe
parents: 6025
diff changeset
97 ## @item load
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 8942
diff changeset
98 ## 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
99 ## 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
100 ##
6070
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
101 ## @example
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
102 ## pkg load image
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
103 ## @end example
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
104 ##
6070
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
105 ## @noindent
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 8942
diff changeset
106 ## 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
107 ## 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
108 ##
6070
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
109 ## @example
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
110 ## pkg load all
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
111 ## @end example
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
112 ##
6203
512d72ee321f [project @ 2006-12-06 18:00:13 by jwe]
jwe
parents: 6189
diff changeset
113 ## @item unload
12779
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
114 ## 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
115 ## 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
116 ## 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
117 ## @samp{all}. Usage:
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
118 ##
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
119 ## @example
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
120 ## pkg unload all
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
121 ## @end example
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
122 ##
6032
dcecca0396e6 [project @ 2006-10-04 17:35:15 by jwe]
jwe
parents: 6025
diff changeset
123 ## @item list
12779
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
124 ## 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
125 ##
6070
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
126 ## @example
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
127 ## pkg list
6070
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
128 ## @end example
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
129 ##
6070
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
130 ## @noindent
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
131 ## will produce a short report with the package name, version, and installation
19597
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
132 ## directory for each installed package. Supply a package name to limit
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
133 ## reporting to a particular package. For example:
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
134 ##
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
135 ## @example
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
136 ## pkg list image
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
137 ## @end example
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
138 ##
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
139 ## If a single return argument is requested then @code{pkg} returns a cell
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
140 ## array where each element is a structure with information on a single
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
141 ## package.
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
142 ##
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
143 ## @example
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
144 ## installed_packages = pkg ("list")
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
145 ## @end example
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
146 ##
12779
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
147 ## 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
148 ## 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
149 ## 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
150 ##
6070
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
151 ## @example
12779
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
152 ## [user_packages, system_packages] = pkg ("list")
6070
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
153 ## @end example
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
154 ##
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
155 ## The @qcode{"-forge"} option lists packages available at the Octave-Forge
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
156 ## repository. This requires an internet connection and the cURL library.
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17243
diff changeset
157 ## For example:
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
158 ##
12779
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
159 ## @example
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
160 ## oct_forge_pkgs = pkg ("list", "-forge")
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
161 ## @end example
12561
0ade5992e374 Add documentation for '-forge' option (bug #32464).
Rik <octave@nomad.inbox5.com>
parents: 12167
diff changeset
162 ##
7497
bb7cc90cdc5e added describe command to pkg
carlo@guglielmo.local
parents: 7329
diff changeset
163 ## @item describe
bb7cc90cdc5e added describe command to pkg
carlo@guglielmo.local
parents: 7329
diff changeset
164 ## Show a short description of the named installed packages, with the option
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17243
diff changeset
165 ## @qcode{"-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
166 ##
7497
bb7cc90cdc5e added describe command to pkg
carlo@guglielmo.local
parents: 7329
diff changeset
167 ## @example
12779
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
168 ## pkg describe -verbose all
7497
bb7cc90cdc5e added describe command to pkg
carlo@guglielmo.local
parents: 7329
diff changeset
169 ## @end example
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
170 ##
7497
bb7cc90cdc5e added describe command to pkg
carlo@guglielmo.local
parents: 7329
diff changeset
171 ## @noindent
bb7cc90cdc5e added describe command to pkg
carlo@guglielmo.local
parents: 7329
diff changeset
172 ## will describe all installed packages and the functions they provide.
bb7cc90cdc5e added describe command to pkg
carlo@guglielmo.local
parents: 7329
diff changeset
173 ## If one output is requested a cell of structure containing the
bb7cc90cdc5e added describe command to pkg
carlo@guglielmo.local
parents: 7329
diff changeset
174 ## description and list of functions of each package is returned as
bb7cc90cdc5e added describe command to pkg
carlo@guglielmo.local
parents: 7329
diff changeset
175 ## output rather than printed on screen:
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
176 ##
7497
bb7cc90cdc5e added describe command to pkg
carlo@guglielmo.local
parents: 7329
diff changeset
177 ## @example
12779
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
178 ## desc = pkg ("describe", "secs1d", "image")
7497
bb7cc90cdc5e added describe command to pkg
carlo@guglielmo.local
parents: 7329
diff changeset
179 ## @end example
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
180 ##
7497
bb7cc90cdc5e added describe command to pkg
carlo@guglielmo.local
parents: 7329
diff changeset
181 ## @noindent
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
182 ## If any of the requested packages is not installed, @code{pkg} returns an
7497
bb7cc90cdc5e added describe command to pkg
carlo@guglielmo.local
parents: 7329
diff changeset
183 ## error, unless a second output is requested:
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
184 ##
7497
bb7cc90cdc5e added describe command to pkg
carlo@guglielmo.local
parents: 7329
diff changeset
185 ## @example
12779
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
186 ## [desc, flag] = pkg ("describe", "secs1d", "image")
7497
bb7cc90cdc5e added describe command to pkg
carlo@guglielmo.local
parents: 7329
diff changeset
187 ## @end example
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
188 ##
7497
bb7cc90cdc5e added describe command to pkg
carlo@guglielmo.local
parents: 7329
diff changeset
189 ## @noindent
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17243
diff changeset
190 ## @var{flag} will take one of the values @qcode{"Not installed"},
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17243
diff changeset
191 ## @qcode{"Loaded"}, or
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17243
diff changeset
192 ## @qcode{"Not loaded"} for each of the named packages.
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
193 ##
6034
5cbbf96b52da [project @ 2006-10-04 18:45:43 by jwe]
jwe
parents: 6033
diff changeset
194 ## @item prefix
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 8942
diff changeset
195 ## Set the installation prefix directory. For example,
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
196 ##
6070
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
197 ## @example
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
198 ## pkg prefix ~/my_octave_packages
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
199 ## @end example
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
200 ##
6070
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
201 ## @noindent
9307
c2923c27c877 Various documentation improvements
Rik <rdrider0-list@yahoo.com>
parents: 9258
diff changeset
202 ## sets the installation prefix to @file{~/my_octave_packages}.
6070
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
203 ## Packages will be installed in this directory.
6034
5cbbf96b52da [project @ 2006-10-04 18:45:43 by jwe]
jwe
parents: 6033
diff changeset
204 ##
6070
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
205 ## 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
206 ## output argument. For example:
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
207 ##
6070
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
208 ## @example
12779
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
209 ## pfx = pkg ("prefix")
6070
df821c22355c [project @ 2006-10-23 19:01:04 by jwe]
jwe
parents: 6055
diff changeset
210 ## @end example
6925
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6820
diff changeset
211 ##
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6820
diff changeset
212 ## 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
213 ## independently specified with an addition argument. For example:
6925
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6820
diff changeset
214 ##
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6820
diff changeset
215 ## @example
9153
5247e89688e1 Eliminate most overfull errors when running texi2pdf for generating pdf documentation
Rik <rdrider0-list@yahoo.com>
parents: 9079
diff changeset
216 ## pkg prefix ~/my_octave_packages ~/my_arch_dep_pkgs
6925
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6820
diff changeset
217 ## @end example
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
218 ##
6189
0d23b0c0ce1a [project @ 2006-11-29 21:01:05 by dbateman]
dbateman
parents: 6143
diff changeset
219 ## @item local_list
12779
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
220 ## 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
221 ## 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
222 ## available only to the current user. For example:
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
223 ##
6189
0d23b0c0ce1a [project @ 2006-11-29 21:01:05 by dbateman]
dbateman
parents: 6143
diff changeset
224 ## @example
0d23b0c0ce1a [project @ 2006-11-29 21:01:05 by dbateman]
dbateman
parents: 6143
diff changeset
225 ## pkg local_list ~/.octave_packages
0d23b0c0ce1a [project @ 2006-11-29 21:01:05 by dbateman]
dbateman
parents: 6143
diff changeset
226 ## @end example
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
227 ##
6189
0d23b0c0ce1a [project @ 2006-11-29 21:01:05 by dbateman]
dbateman
parents: 6143
diff changeset
228 ## 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
229 ##
6189
0d23b0c0ce1a [project @ 2006-11-29 21:01:05 by dbateman]
dbateman
parents: 6143
diff changeset
230 ## @example
0d23b0c0ce1a [project @ 2006-11-29 21:01:05 by dbateman]
dbateman
parents: 6143
diff changeset
231 ## pkg local_list
0d23b0c0ce1a [project @ 2006-11-29 21:01:05 by dbateman]
dbateman
parents: 6143
diff changeset
232 ## @end example
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
233 ##
6189
0d23b0c0ce1a [project @ 2006-11-29 21:01:05 by dbateman]
dbateman
parents: 6143
diff changeset
234 ## @item global_list
12779
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
235 ## 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
236 ## 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
237 ## available to all users. For example:
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
238 ##
6189
0d23b0c0ce1a [project @ 2006-11-29 21:01:05 by dbateman]
dbateman
parents: 6143
diff changeset
239 ## @example
0d23b0c0ce1a [project @ 2006-11-29 21:01:05 by dbateman]
dbateman
parents: 6143
diff changeset
240 ## pkg global_list /usr/share/octave/octave_packages
0d23b0c0ce1a [project @ 2006-11-29 21:01:05 by dbateman]
dbateman
parents: 6143
diff changeset
241 ## @end example
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
242 ##
6189
0d23b0c0ce1a [project @ 2006-11-29 21:01:05 by dbateman]
dbateman
parents: 6143
diff changeset
243 ## 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
244 ##
6189
0d23b0c0ce1a [project @ 2006-11-29 21:01:05 by dbateman]
dbateman
parents: 6143
diff changeset
245 ## @example
0d23b0c0ce1a [project @ 2006-11-29 21:01:05 by dbateman]
dbateman
parents: 6143
diff changeset
246 ## pkg global_list
0d23b0c0ce1a [project @ 2006-11-29 21:01:05 by dbateman]
dbateman
parents: 6143
diff changeset
247 ## @end example
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
248 ##
6675
f938c7018d28 [project @ 2007-05-31 19:31:14 by dbateman]
dbateman
parents: 6663
diff changeset
249 ## @item build
12779
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
250 ## Build a binary form of a package or packages. The binary file produced
6675
f938c7018d28 [project @ 2007-05-31 19:31:14 by dbateman]
dbateman
parents: 6663
diff changeset
251 ## 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
252 ## @code{pkg}. The form of the command to build a binary package is
6675
f938c7018d28 [project @ 2007-05-31 19:31:14 by dbateman]
dbateman
parents: 6663
diff changeset
253 ##
f938c7018d28 [project @ 2007-05-31 19:31:14 by dbateman]
dbateman
parents: 6663
diff changeset
254 ## @example
f938c7018d28 [project @ 2007-05-31 19:31:14 by dbateman]
dbateman
parents: 6663
diff changeset
255 ## pkg build builddir image-1.0.0.tar.gz @dots{}
f938c7018d28 [project @ 2007-05-31 19:31:14 by dbateman]
dbateman
parents: 6663
diff changeset
256 ## @end example
f938c7018d28 [project @ 2007-05-31 19:31:14 by dbateman]
dbateman
parents: 6663
diff changeset
257 ##
f938c7018d28 [project @ 2007-05-31 19:31:14 by dbateman]
dbateman
parents: 6663
diff changeset
258 ## @noindent
9079
4d610aba7347 Cleanup documentation for system.texi, package.texi
Rik <rdrider0-list@yahoo.com>
parents: 9051
diff changeset
259 ## where @code{builddir} is the name of a directory where the temporary
6675
f938c7018d28 [project @ 2007-05-31 19:31:14 by dbateman]
dbateman
parents: 6663
diff changeset
260 ## 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
261 ## 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
262 ## all other options are ignored.
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
263 ##
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
264 ## @item rebuild
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
265 ## 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
266 ## 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
267 ## 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
268 ## 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
269 ##
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
270 ## @example
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
271 ## pkg rebuild -noauto image
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
272 ## @end example
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
273 ##
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
274 ## @noindent
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
275 ## will remove the autoloading status of the image package.
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
276 ##
6032
dcecca0396e6 [project @ 2006-10-04 17:35:15 by jwe]
jwe
parents: 6025
diff changeset
277 ## @end table
19192
8a8a7bc2a09d Improve docstrings and mark documentation m-files as tested in miscellaneous/ dir.
Rik <rik@octave.org>
parents: 19187
diff changeset
278 ## @seealso{ver, news}
11547
e1851653d59c Eliminate @deffn macros.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
279 ## @end deftypefn
5947
009fa69b6182 [project @ 2006-08-21 16:15:20 by jwe]
jwe
parents: 5928
diff changeset
280
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
281 function [local_packages, global_packages] = pkg (varargin)
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
282
8202
cf59d542f33e replace all TODOs and XXXs with FIXMEs
Jaroslav Hajek <highegg@gmail.com>
parents: 8174
diff changeset
283 ## Installation prefix (FIXME: what should these be on windows?)
6645
81eb28d50cee [project @ 2007-05-21 21:05:54 by dbateman]
dbateman
parents: 6634
diff changeset
284 persistent user_prefix = false;
16304
c8e1b0213e34 pkg.m: Fix str-to-num warnings (bug #37785)
Rik <rik@octave.org>
parents: 16173
diff changeset
285 persistent prefix = false;
6925
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6820
diff changeset
286 persistent archprefix = -1;
7498
a939fb03a137 pkg.m style fixes
John W. Eaton <jwe@octave.org>
parents: 7497
diff changeset
287 persistent local_list = tilde_expand (fullfile ("~", ".octave_packages"));
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
288 persistent global_list = fullfile (OCTAVE_HOME (), "share", "octave",
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
289 "octave_packages");
14471
d2c095e45196 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14466
diff changeset
290
14472
045a5b85495d maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14471
diff changeset
291 ## If user is superuser set global_istall to true
045a5b85495d maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14471
diff changeset
292 ## FIXME: is it OK to set this always true on windows?
045a5b85495d maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14471
diff changeset
293 global_install = ((ispc () && ! isunix ()) || (geteuid () == 0));
6683
a2f697dca2a4 [project @ 2007-06-01 23:10:24 by dbateman]
dbateman
parents: 6675
diff changeset
294
16304
c8e1b0213e34 pkg.m: Fix str-to-num warnings (bug #37785)
Rik <rik@octave.org>
parents: 16173
diff changeset
295 if (isbool (prefix))
18448
b26d6be1767a Move definifion of default package paths to separate function.
Carlo de Falco <cdf@users.sourceforge.net>
parents: 17744
diff changeset
296 [prefix, archprefix] = default_prefix (global_install);
6645
81eb28d50cee [project @ 2007-05-21 21:05:54 by dbateman]
dbateman
parents: 6634
diff changeset
297 prefix = tilde_expand (prefix);
6925
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6820
diff changeset
298 archprefix = tilde_expand (archprefix);
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
299 endif
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
300
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
301 mlock ();
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
302
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
303 confirm_recursive_rmdir (false, "local");
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
304
7498
a939fb03a137 pkg.m style fixes
John W. Eaton <jwe@octave.org>
parents: 7497
diff changeset
305 available_actions = {"list", "install", "uninstall", "load", ...
12779
095fd5c8b7e1 doc: Update docstring for pkg()
Rik <octave@nomad.inbox5.com>
parents: 12778
diff changeset
306 "unload", "prefix", "local_list", ...
12778
0ca5672d5f1a Implement pkg update command
Lukas Reichlin <lukas.reichlin@gmail.com>
parents: 12710
diff changeset
307 "global_list", "rebuild", "build", ...
0ca5672d5f1a Implement pkg update command
Lukas Reichlin <lukas.reichlin@gmail.com>
parents: 12710
diff changeset
308 "describe", "update"};
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
309
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
310 ## Parse input arguments
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
311 if (isempty (varargin) || ! iscellstr (varargin))
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
312 print_usage ();
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
313 endif
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
314 files = {};
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
315 deps = true;
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
316 auto = 0;
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
317 action = "none";
6614
3a53d0f3e0e4 [project @ 2007-05-12 05:50:03 by dbateman]
dbateman
parents: 6500
diff changeset
318 verbose = false;
10684
76aba4305f1f support pkg install -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10549
diff changeset
319 octave_forge = false;
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
320 for i = 1:numel (varargin)
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
321 switch (varargin{i})
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
322 case "-nodeps"
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
323 deps = false;
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
324 case "-noauto"
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
325 auto = -1;
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
326 case "-auto"
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
327 auto = 1;
6614
3a53d0f3e0e4 [project @ 2007-05-12 05:50:03 by dbateman]
dbateman
parents: 6500
diff changeset
328 case "-verbose"
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
329 verbose = true;
13275
635db52feab4 pkg.m: Display verbose output immediately rather than buffering it.
Rik <octave@nomad.inbox5.com>
parents: 13141
diff changeset
330 ## 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
331 page_output_immediately (true, "local");
10684
76aba4305f1f support pkg install -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10549
diff changeset
332 case "-forge"
15184
0b29c16a2645 pkg: check cURL library when using -forge
Carnë Draug <carandraug+dev@gmail.com>
parents: 15058
diff changeset
333 if (! octave_config_info ("CURL_LIBS"))
15202
f3b5cadfd6d5 fix missing semicolons in various .m files
John W. Eaton <jwe@octave.org>
parents: 15184
diff changeset
334 error ("pkg: can't download from forge without the cURL library");
15184
0b29c16a2645 pkg: check cURL library when using -forge
Carnë Draug <carandraug+dev@gmail.com>
parents: 15058
diff changeset
335 endif
10684
76aba4305f1f support pkg install -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10549
diff changeset
336 octave_forge = true;
6645
81eb28d50cee [project @ 2007-05-21 21:05:54 by dbateman]
dbateman
parents: 6634
diff changeset
337 case "-local"
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
338 global_install = false;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
339 if (! user_prefix)
18448
b26d6be1767a Move definifion of default package paths to separate function.
Carlo de Falco <cdf@users.sourceforge.net>
parents: 17744
diff changeset
340 [prefix, archprefix] = default_prefix (global_install);
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
341 endif
6645
81eb28d50cee [project @ 2007-05-21 21:05:54 by dbateman]
dbateman
parents: 6634
diff changeset
342 case "-global"
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
343 global_install = true;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
344 if (! user_prefix)
18448
b26d6be1767a Move definifion of default package paths to separate function.
Carlo de Falco <cdf@users.sourceforge.net>
parents: 17744
diff changeset
345 [prefix, archprefix] = default_prefix (global_install);
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
346 endif
7497
bb7cc90cdc5e added describe command to pkg
carlo@guglielmo.local
parents: 7329
diff changeset
347 case available_actions
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
348 if (! strcmp (action, "none"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
349 error ("more than one action specified");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
350 endif
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
351 action = varargin{i};
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
352 otherwise
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
353 files{end+1} = varargin{i};
5801
70013c9f3ccc [project @ 2006-05-10 16:53:03 by jwe]
jwe
parents:
diff changeset
354 endswitch
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
355 endfor
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
356
10685
81a43049dee2 support pkg list -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10684
diff changeset
357 if (octave_forge && ! any (strcmp (action, {"install", "list"})))
81a43049dee2 support pkg list -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10684
diff changeset
358 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
359 endif
76aba4305f1f support pkg install -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10549
diff changeset
360
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
361 ## Take action
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
362 switch (action)
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
363 case "list"
10685
81a43049dee2 support pkg list -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10684
diff changeset
364 if (octave_forge)
20475
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
365 if (nargout)
10685
81a43049dee2 support pkg list -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10684
diff changeset
366 local_packages = list_forge_packages ();
81a43049dee2 support pkg list -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10684
diff changeset
367 else
81a43049dee2 support pkg list -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10684
diff changeset
368 list_forge_packages ();
81a43049dee2 support pkg list -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10684
diff changeset
369 endif
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
370 else
20475
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
371 if (nargout)
10685
81a43049dee2 support pkg list -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10684
diff changeset
372 [local_packages, global_packages] = installed_packages (local_list,
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
373 global_list,
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
374 files);
10685
81a43049dee2 support pkg list -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10684
diff changeset
375 else
20475
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
376 installed_packages (local_list, global_list, files);
10685
81a43049dee2 support pkg list -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10684
diff changeset
377 endif
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
378 endif
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
379
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
380 case "install"
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
381 if (isempty (files))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
382 error ("you must specify at least one filename when calling 'pkg install'");
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
383 endif
10684
76aba4305f1f support pkg install -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10549
diff changeset
384
76aba4305f1f support pkg install -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10549
diff changeset
385 local_files = {};
76aba4305f1f support pkg install -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10549
diff changeset
386 unwind_protect
76aba4305f1f support pkg install -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10549
diff changeset
387
76aba4305f1f support pkg install -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10549
diff changeset
388 if (octave_forge)
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
389 [urls, local_files] = cellfun ("get_forge_download", files,
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
390 "uniformoutput", false);
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
391 [files, succ] = cellfun ("urlwrite", urls, local_files,
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
392 "uniformoutput", false);
10684
76aba4305f1f support pkg install -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10549
diff changeset
393 succ = [succ{:}];
76aba4305f1f support pkg install -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10549
diff changeset
394 if (! all (succ))
76aba4305f1f support pkg install -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10549
diff changeset
395 i = find (! succ, 1);
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
396 error ("could not download file %s from url %s",
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
397 local_files{i}, urls{i});
10684
76aba4305f1f support pkg install -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10549
diff changeset
398 endif
76aba4305f1f support pkg install -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10549
diff changeset
399 endif
76aba4305f1f support pkg install -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10549
diff changeset
400
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11547
diff changeset
401 install (files, deps, auto, prefix, archprefix, verbose, local_list,
10684
76aba4305f1f support pkg install -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10549
diff changeset
402 global_list, global_install);
76aba4305f1f support pkg install -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10549
diff changeset
403
76aba4305f1f support pkg install -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10549
diff changeset
404 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
405 cellfun ("unlink", local_files);
10684
76aba4305f1f support pkg install -forge
Jaroslav Hajek <highegg@gmail.com>
parents: 10549
diff changeset
406 end_unwind_protect
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
407
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
408 case "uninstall"
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
409 if (isempty (files))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
410 error ("you must specify at least one package when calling 'pkg uninstall'");
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
411 endif
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
412 uninstall (files, deps, verbose, local_list, global_list, global_install);
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
413
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
414 case "load"
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
415 if (isempty (files))
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
416 error ("you must specify at least one package, 'all', or 'auto' when calling 'pkg load'");
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
417 endif
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
418 load_packages (files, deps, local_list, global_list);
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
419
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
420 case "unload"
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
421 if (isempty (files))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
422 error ("you must specify at least one package or 'all' when calling 'pkg unload'");
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
423 endif
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
424 unload_packages (files, deps, local_list, global_list);
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
425
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
426 case "prefix"
20475
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
427 if (isempty (files) && ! nargout)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
428 printf ("Installation prefix: %s\n", prefix);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
429 printf ("Architecture dependent prefix: %s\n", archprefix);
20475
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
430 elseif (isempty (files) && nargout)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
431 local_packages = prefix;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
432 global_packages = archprefix;
20475
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
433 elseif (numel (files) >= 1 && ischar (files{1}))
16173
40a9a4e0d12a pkg.m: Restore ability to use '~' in specifying prefix directories.
Rik <rik@octave.org>
parents: 15966
diff changeset
434 prefix = tilde_expand (files{1});
15000
4c8ddf57fcda remove redundant private function absolute_pathname
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14860
diff changeset
435 if (! exist (prefix, "dir"))
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
436 [status, msg] = mkdir (prefix);
14858
a82fcd612c8f pkg.m: Check if the prefix directory can be created; don't fail silently
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14857
diff changeset
437 if (status == 0)
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
438 error ("cannot create prefix %s: %s", prefix, msg);
14858
a82fcd612c8f pkg.m: Check if the prefix directory can be created; don't fail silently
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14857
diff changeset
439 endif
14857
7371e127c351 pkg.m: create prefix directory, if it does not exist
Rafael Laboissiere <rafael@laboissiere.net>
parents: 14472
diff changeset
440 warning ("creating the directory %s\n", prefix);
15000
4c8ddf57fcda remove redundant private function absolute_pathname
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14860
diff changeset
441 endif
15058
3691a606283e Fix typo in pkg.m reported in bug #36994.
Muhali <muhali@shaw.ca>
parents: 15000
diff changeset
442 local_packages = prefix = canonicalize_file_name (prefix);
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
443 user_prefix = true;
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
444 if (numel (files) >= 2 && ischar (files{2}))
16173
40a9a4e0d12a pkg.m: Restore ability to use '~' in specifying prefix directories.
Rik <rik@octave.org>
parents: 15966
diff changeset
445 archprefix = tilde_expand (files{2});
15000
4c8ddf57fcda remove redundant private function absolute_pathname
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14860
diff changeset
446 if (! exist (archprefix, "dir"))
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
447 [status, msg] = mkdir (archprefix);
14858
a82fcd612c8f pkg.m: Check if the prefix directory can be created; don't fail silently
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14857
diff changeset
448 if (status == 0)
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
449 error ("cannot create archprefix %s: %s", archprefix, msg);
14858
a82fcd612c8f pkg.m: Check if the prefix directory can be created; don't fail silently
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14857
diff changeset
450 endif
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
451 warning ("creating the directory %s\n", archprefix);
15000
4c8ddf57fcda remove redundant private function absolute_pathname
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14860
diff changeset
452 global_packages = archprefix = canonicalize_file_name (archprefix);
4c8ddf57fcda remove redundant private function absolute_pathname
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14860
diff changeset
453 endif
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
454 endif
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
455 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
456 error ("you must specify a prefix directory, or request an output argument");
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
457 endif
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
458
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
459 case "local_list"
20475
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
460 if (isempty (files) && ! nargout)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
461 disp (local_list);
20475
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
462 elseif (isempty (files) && nargout)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
463 local_packages = local_list;
20475
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
464 elseif (numel (files) == 1 && ! nargout && ischar (files{1}))
15000
4c8ddf57fcda remove redundant private function absolute_pathname
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14860
diff changeset
465 local_list = files{1};
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
466 if (! exist (local_list, "file"))
15000
4c8ddf57fcda remove redundant private function absolute_pathname
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14860
diff changeset
467 try
4c8ddf57fcda remove redundant private function absolute_pathname
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14860
diff changeset
468 ## Force file to be created
4c8ddf57fcda remove redundant private function absolute_pathname
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14860
diff changeset
469 fclose (fopen (local_list, "wt"));
4c8ddf57fcda remove redundant private function absolute_pathname
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14860
diff changeset
470 catch
4c8ddf57fcda remove redundant private function absolute_pathname
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14860
diff changeset
471 error ("cannot create file %s", local_list);
4c8ddf57fcda remove redundant private function absolute_pathname
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14860
diff changeset
472 end_try_catch
4c8ddf57fcda remove redundant private function absolute_pathname
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14860
diff changeset
473 endif
4c8ddf57fcda remove redundant private function absolute_pathname
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14860
diff changeset
474 local_list = canonicalize_file_name (local_list);
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
475 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
476 error ("you must specify a local_list file, or request an output argument");
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
477 endif
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
478
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
479 case "global_list"
20475
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
480 if (isempty (files) && ! nargout)
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
481 disp (global_list);
20475
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
482 elseif (isempty (files) && nargout)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
483 local_packages = global_list;
20475
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
484 elseif (numel (files) == 1 && ! nargout && ischar (files{1}))
15000
4c8ddf57fcda remove redundant private function absolute_pathname
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14860
diff changeset
485 global_list = files{1};
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
486 if (! exist (global_list, "file"))
15000
4c8ddf57fcda remove redundant private function absolute_pathname
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14860
diff changeset
487 try
4c8ddf57fcda remove redundant private function absolute_pathname
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14860
diff changeset
488 ## Force file to be created
4c8ddf57fcda remove redundant private function absolute_pathname
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14860
diff changeset
489 fclose (fopen (files{1}, "wt"));
4c8ddf57fcda remove redundant private function absolute_pathname
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14860
diff changeset
490 catch
4c8ddf57fcda remove redundant private function absolute_pathname
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14860
diff changeset
491 error ("cannot create file %s", global_list);
4c8ddf57fcda remove redundant private function absolute_pathname
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14860
diff changeset
492 end_try_catch
4c8ddf57fcda remove redundant private function absolute_pathname
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14860
diff changeset
493 endif
4c8ddf57fcda remove redundant private function absolute_pathname
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14860
diff changeset
494 global_list = canonicalize_file_name (global_list);
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
495 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
496 error ("you must specify a global_list file, or request an output argument");
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
497 endif
6645
81eb28d50cee [project @ 2007-05-21 21:05:54 by dbateman]
dbateman
parents: 6634
diff changeset
498
81eb28d50cee [project @ 2007-05-21 21:05:54 by dbateman]
dbateman
parents: 6634
diff changeset
499 case "rebuild"
81eb28d50cee [project @ 2007-05-21 21:05:54 by dbateman]
dbateman
parents: 6634
diff changeset
500 if (global_install)
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11547
diff changeset
501 global_packages = rebuild (prefix, archprefix, global_list, files,
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
502 auto, verbose);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
503 global_packages = save_order (global_packages);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
504 save (global_list, "global_packages");
20475
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
505 if (nargout)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
506 local_packages = global_packages;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
507 endif
6645
81eb28d50cee [project @ 2007-05-21 21:05:54 by dbateman]
dbateman
parents: 6634
diff changeset
508 else
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
509 local_packages = rebuild (prefix, archprefix, local_list, files,
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
510 auto, verbose);
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
511 local_packages = save_order (local_packages);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
512 save (local_list, "local_packages");
20475
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
513 if (! nargout)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
514 clear ("local_packages");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
515 endif
6645
81eb28d50cee [project @ 2007-05-21 21:05:54 by dbateman]
dbateman
parents: 6634
diff changeset
516 endif
81eb28d50cee [project @ 2007-05-21 21:05:54 by dbateman]
dbateman
parents: 6634
diff changeset
517
6675
f938c7018d28 [project @ 2007-05-31 19:31:14 by dbateman]
dbateman
parents: 6663
diff changeset
518 case "build"
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
519 if (numel (files) < 2)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
520 error ("you must specify at least the build directory and one filename\nwhen calling 'pkg build'");
6675
f938c7018d28 [project @ 2007-05-31 19:31:14 by dbateman]
dbateman
parents: 6663
diff changeset
521 endif
f938c7018d28 [project @ 2007-05-31 19:31:14 by dbateman]
dbateman
parents: 6663
diff changeset
522 build (files, deps, auto, verbose);
f938c7018d28 [project @ 2007-05-31 19:31:14 by dbateman]
dbateman
parents: 6663
diff changeset
523
7497
bb7cc90cdc5e added describe command to pkg
carlo@guglielmo.local
parents: 7329
diff changeset
524 case "describe"
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
525 if (isempty (files))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10401
diff changeset
526 error ("you must specify at least one package or 'all' when calling 'pkg describe'");
7497
bb7cc90cdc5e added describe command to pkg
carlo@guglielmo.local
parents: 7329
diff changeset
527 endif
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
528 ## FIXME: name of the output variables is inconsistent with their content
20475
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
529 if (nargout)
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
530 [local_packages, global_packages] = describe (files, verbose,
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
531 local_list, global_list);
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
532 else
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
533 describe (files, verbose, local_list, global_list);
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
534 endif
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11547
diff changeset
535
12778
0ca5672d5f1a Implement pkg update command
Lukas Reichlin <lukas.reichlin@gmail.com>
parents: 12710
diff changeset
536 case "update"
20475
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
537 installed_pkgs_lst = installed_packages (local_list, global_list);
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
538 if (numel (files) > 0)
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
539 update_lst = {};
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
540 installed_names = {installed_pkgs_list.name}';
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
541 for i = 1:numel (files)
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
542 idx = find (strcmp (files{i}, installed_names), 1);
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
543 if (isempty (idx))
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
544 warning ("Package %s is not installed - not updating this package", files{i});
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
545 else
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
546 update_lst = { update_lst, installed_pkgs_lst{idx} };
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
547 endif
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
548 endfor
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
549 installed_pkgs_lst = update_lst;
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
550 endif
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
551 for i = 1:numel (installed_pkgs_lst)
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
552 installed_pkg_name = installed_pkgs_lst{i}.name;
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
553 installed_pkg_version = installed_pkgs_lst{i}.version;
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
554 forge_pkg_version = get_forge_pkg (installed_pkg_name);
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
555 if (compare_versions (forge_pkg_version, installed_pkg_version, ">"))
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
556 feval (@pkg, "install", "-forge", installed_pkg_name);
18556
4daf647c86c3 Implement pkg update pkgnametoupdate (Bug #41732)
John Donoghue <john.donoghue@ieee.org>
parents: 17744
diff changeset
557 endif
20475
7fa1970a655d pkg.m: drop check of nargout value, the interpreter already does that.
Carnë Draug <carandraug@octave.org>
parents: 19833
diff changeset
558 endfor
12778
0ca5672d5f1a Implement pkg update command
Lukas Reichlin <lukas.reichlin@gmail.com>
parents: 12710
diff changeset
559
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
560 otherwise
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
561 error ("you must specify a valid action for 'pkg'. See 'help pkg' for details");
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
562 endswitch
19187
b54093acb8fe ver.m: Overhaul function.
Rik <rik@octave.org>
parents: 18576
diff changeset
563
6496
e0acfe7c3f7b [project @ 2007-04-05 17:19:30 by jwe]
jwe
parents: 6440
diff changeset
564 endfunction
17338
1c89599167a6 maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents: 17281
diff changeset
565