annotate scripts/pkg/private/install.m @ 21615:9ccd64201b4d

pkg: remove excessive number of private function files. pkg() makes use of many subfunctions, themselves with several subfunctions. They used to all be in a single file which became difficult to hack so it was split into one file per function (even though they all remained private). This change merges some of those functions back together so that only the functions used by pkg itself, as well as subfunctions used by more than one of those, remain as separate files. * copy_built_files.m, copy_files.m, create_pkgadddel.m, extract_pkg.m, finish_installation.m, generate_lookfor_cache.m, prepare_installation.m, verify_directory.m: merged this functions into install.m since they are only used by it. * fix_depends.m, fix_version.m: merged this functions into get_description.m since they are only used by it. * getarchprefix.m: merged into create_pkgadddel.m which then got merged into install.m. * is_architecture_dependent.m: merged into copy_built_files.m which then got merged into install.m. * load_package_dirs.m: merged into load_packages_and_dependencies.m * packinfo_copy_file.m, write_index.m: merged into copy_files.m which then then got merged into install.m. * parse_pkg_idx, print_package_description.m: merged into describe.m * shell.m: merged into configure_make.m * pkg/module.mk: update with removed files.
author Carnë Draug <carandraug@octave.org>
date Tue, 12 Apr 2016 17:46:20 +0100
parents 2ee20a290d61
children cf227735d5fd
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: 19596
diff changeset
1 ## Copyright (C) 2005-2015 Søren Hauberg
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
2 ## Copyright (C) 2010 VZLU Prague, a.s.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
3 ##
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
4 ## This file is part of Octave.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
5 ##
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
6 ## Octave is free software; you can redistribute it and/or modify it
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
7 ## under the terms of the GNU General Public License as published by
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
8 ## the Free Software Foundation; either version 3 of the License, or (at
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
9 ## your option) any later version.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
10 ##
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
11 ## Octave is distributed in the hope that it will be useful, but
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
14 ## General Public License for more details.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
15 ##
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
16 ## You should have received a copy of the GNU General Public License
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
17 ## along with Octave; see the file COPYING. If not, see
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
18 ## <http://www.gnu.org/licenses/>.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
19
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
20 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19833
diff changeset
21 ## @deftypefn {} {} install (@var{files}, @var{handle_deps}, @var{autoload}, @var{prefix}, @var{archprefix}, @var{verbose}, @var{local_list}, @var{global_list}, @var{global_install})
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
22 ## Undocumented internal function.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
23 ## @end deftypefn
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
24
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
25 function install (files, handle_deps, autoload, prefix, archprefix, verbose,
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
26 local_list, global_list, global_install)
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
27
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
28 ## Check that the directory in prefix exist. If it doesn't: create it!
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
29 if (! exist (prefix, "dir"))
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
30 warning ("creating installation directory %s", prefix);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
31 [status, msg] = mkdir (prefix);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
32 if (status != 1)
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
33 error ("could not create installation directory: %s", msg);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
34 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
35 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
36
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
37 ## Get the list of installed packages.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
38 [local_packages, global_packages] = installed_packages (local_list,
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
39 global_list);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
40
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
41 installed_pkgs_lst = {local_packages{:}, global_packages{:}};
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
42
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
43 if (global_install)
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
44 packages = global_packages;
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
45 else
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
46 packages = local_packages;
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
47 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
48
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
49 ## Uncompress the packages and read the DESCRIPTION files.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
50 tmpdirs = packdirs = descriptions = {};
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
51 try
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
52 ## Warn about non existent files.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
53 for i = 1:length (files)
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
54 if (isempty (glob (files{i})))
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
55 warning ("file %s does not exist", files{i});
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
56 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
57 endfor
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
58
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
59 ## Unpack the package files and read the DESCRIPTION files.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
60 files = glob (files);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
61 packages_to_uninstall = [];
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
62 for i = 1:length (files)
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
63 tgz = files{i};
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
64
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
65 if (exist (tgz, "file"))
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
66 ## Create a temporary directory.
19278
6ca096827123 Use tempname() rather than tmpnam() in core Octave.
Rik <rik@octave.org>
parents: 17744
diff changeset
67 tmpdir = tempname ();
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
68 tmpdirs{end+1} = tmpdir;
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
69 if (verbose)
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
70 printf ("mkdir (%s)\n", tmpdir);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
71 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
72 [status, msg] = mkdir (tmpdir);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
73 if (status != 1)
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
74 error ("couldn't create temporary directory: %s", msg);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
75 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
76
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
77 ## Uncompress the package.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
78 if (verbose)
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
79 printf ("untar (%s, %s)\n", tgz, tmpdir);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
80 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
81 untar (tgz, tmpdir);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
82
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
83 ## Get the name of the directories produced by tar.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
84 [dirlist, err, msg] = readdir (tmpdir);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
85 if (err)
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
86 error ("couldn't read directory produced by tar: %s", msg);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
87 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
88
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
89 if (length (dirlist) > 3)
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
90 error ("bundles of packages are not allowed");
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
91 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
92 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
93
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
94 ## The filename pointed to an uncompressed package to begin with.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
95 if (exist (tgz, "dir"))
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
96 dirlist = {".", "..", tgz};
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
97 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
98
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
99 if (exist (tgz, "file") || exist (tgz, "dir"))
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
100 ## The two first entries of dirlist are "." and "..".
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
101 if (exist (tgz, "file"))
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
102 packdir = fullfile (tmpdir, dirlist{3});
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
103 else
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14517
diff changeset
104 packdir = fullfile (pwd (), dirlist{3});
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
105 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
106 packdirs{end+1} = packdir;
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
107
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
108 ## Make sure the package contains necessary files.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
109 verify_directory (packdir);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
110
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
111 ## Read the DESCRIPTION file.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
112 filename = fullfile (packdir, "DESCRIPTION");
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
113 desc = get_description (filename);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
114
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
115 ## Verify that package name corresponds with filename.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
116 [dummy, nm] = fileparts (tgz);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
117 if ((length (nm) >= length (desc.name))
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
118 && ! strcmp (desc.name, nm(1:length (desc.name))))
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
119 error ("package name '%s' doesn't correspond to its filename '%s'",
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
120 desc.name, nm);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
121 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
122
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
123 ## Set default installation directory.
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16467
diff changeset
124 desc.dir = fullfile (prefix, [desc.name "-" desc.version]);
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
125
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
126 ## Set default architectire dependent installation directory.
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16467
diff changeset
127 desc.archprefix = fullfile (archprefix, [desc.name "-" desc.version]);
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
128
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
129 ## Save desc.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
130 descriptions{end+1} = desc;
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
131
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
132 ## Are any of the new packages already installed?
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
133 ## If so we'll remove the old version.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
134 for j = 1:length (packages)
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
135 if (strcmp (packages{j}.name, desc.name))
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
136 packages_to_uninstall(end+1) = j;
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
137 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
138 endfor
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
139 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
140 endfor
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
141 catch
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
142 ## Something went wrong, delete tmpdirs.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
143 for i = 1:length (tmpdirs)
14471
d2c095e45196 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14470
diff changeset
144 rmdir (tmpdirs{i}, "s");
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
145 endfor
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
146 rethrow (lasterror ());
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
147 end_try_catch
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
148
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
149 ## Check dependencies.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
150 if (handle_deps)
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
151 ok = true;
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
152 error_text = "";
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
153 for i = 1:length (descriptions)
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
154 desc = descriptions{i};
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
155 idx2 = setdiff (1:length (descriptions), i);
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
156 if (global_install)
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
157 ## Global installation is not allowed to have dependencies on locally
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
158 ## installed packages.
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
159 idx1 = setdiff (1:length (global_packages), packages_to_uninstall);
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
160 pseudo_installed_packages = {global_packages{idx1}, ...
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
161 descriptions{idx2}};
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
162 else
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
163 idx1 = setdiff (1:length (local_packages), packages_to_uninstall);
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
164 pseudo_installed_packages = {local_packages{idx1}, ...
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
165 global_packages{:}, ...
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
166 descriptions{idx2}};
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
167 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
168 bad_deps = get_unsatisfied_deps (desc, pseudo_installed_packages);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
169 ## Are there any unsatisfied dependencies?
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
170 if (! isempty (bad_deps))
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
171 ok = false;
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
172 for i = 1:length (bad_deps)
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
173 dep = bad_deps{i};
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16467
diff changeset
174 error_text = [error_text " " desc.name " needs " ...
17016
a3f6790df115 Fix typos from cstrcat to matrix concatenation changeset (333243133364).
Rik <rik@octave.org>
parents: 16994
diff changeset
175 dep.package " " dep.operator " " dep.version "\n"];
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
176 endfor
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
177 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
178 endfor
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
179
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
180 ## Did we find any unsatisfied dependencies?
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
181 if (! ok)
16467
cc9e2751e073 pkg: Typo correction
Adam H Aitkenhead <adamhaitkenhead@gmail.com>
parents: 14868
diff changeset
182 error ("the following dependencies were unsatisfied:\n %s", error_text);
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
183 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
184 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
185
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
186 ## Prepare each package for installation.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
187 try
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
188 for i = 1:length (descriptions)
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
189 desc = descriptions{i};
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
190 pdir = packdirs{i};
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
191 prepare_installation (desc, pdir);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
192 configure_make (desc, pdir, verbose);
21518
2ee20a290d61 pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents: 20852
diff changeset
193 copy_built_files (desc, pdir, verbose);
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
194 endfor
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
195 catch
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
196 ## Something went wrong, delete tmpdirs.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
197 for i = 1:length (tmpdirs)
14471
d2c095e45196 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14470
diff changeset
198 rmdir (tmpdirs{i}, "s");
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
199 endfor
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
200 rethrow (lasterror ());
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
201 end_try_catch
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
202
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
203 ## Uninstall the packages that will be replaced.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
204 try
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
205 for i = packages_to_uninstall
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
206 if (global_install)
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
207 uninstall ({global_packages{i}.name}, false, verbose, local_list,
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
208 global_list, global_install);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
209 else
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
210 uninstall ({local_packages{i}.name}, false, verbose, local_list,
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
211 global_list, global_install);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
212 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
213 endfor
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
214 catch
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
215 ## Something went wrong, delete tmpdirs.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
216 for i = 1:length (tmpdirs)
14471
d2c095e45196 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14470
diff changeset
217 rmdir (tmpdirs{i}, "s");
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
218 endfor
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
219 rethrow (lasterror ());
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
220 end_try_catch
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
221
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
222 ## Install each package.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
223 try
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
224 for i = 1:length (descriptions)
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
225 desc = descriptions{i};
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
226 pdir = packdirs{i};
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
227 copy_files (desc, pdir, global_install);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
228 create_pkgadddel (desc, pdir, "PKG_ADD", global_install);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
229 create_pkgadddel (desc, pdir, "PKG_DEL", global_install);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
230 finish_installation (desc, pdir, global_install);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
231 generate_lookfor_cache (desc);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
232 endfor
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
233 catch
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
234 ## Something went wrong, delete tmpdirs.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
235 for i = 1:length (tmpdirs)
14471
d2c095e45196 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14470
diff changeset
236 rmdir (tmpdirs{i}, "s");
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
237 endfor
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
238 for i = 1:length (descriptions)
14471
d2c095e45196 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14470
diff changeset
239 rmdir (descriptions{i}.dir, "s");
d2c095e45196 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14470
diff changeset
240 rmdir (getarchdir (descriptions{i}), "s");
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
241 endfor
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
242 rethrow (lasterror ());
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
243 end_try_catch
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
244
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
245 ## Check if the installed directory is empty. If it is remove it
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
246 ## from the list.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
247 for i = length (descriptions):-1:1
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
248 if (dirempty (descriptions{i}.dir, {"packinfo", "doc"})
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
249 && dirempty (getarchdir (descriptions{i})))
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
250 warning ("package %s is empty\n", descriptions{i}.name);
14471
d2c095e45196 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14470
diff changeset
251 rmdir (descriptions{i}.dir, "s");
d2c095e45196 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14470
diff changeset
252 rmdir (getarchdir (descriptions{i}), "s");
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
253 descriptions(i) = [];
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
254 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
255 endfor
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
256
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
257 ## If the package requested that it is autoloaded, or the installer
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
258 ## requested that it is, then mark the package as autoloaded.
14470
aad7ad0e15c1 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14466
diff changeset
259 str_true = {"true", "on", "yes", "1"};
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
260 for i = length (descriptions):-1:1
14470
aad7ad0e15c1 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14466
diff changeset
261
aad7ad0e15c1 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14466
diff changeset
262 desc_autoload = false;
aad7ad0e15c1 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14466
diff changeset
263 if (isfield (descriptions{i}, "autoload"))
aad7ad0e15c1 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14466
diff changeset
264 a = descriptions{i}.autoload;
aad7ad0e15c1 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14466
diff changeset
265 desc_autoload = ((isnumeric (a) && a > 0)
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
266 || (ischar (a)
14470
aad7ad0e15c1 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14466
diff changeset
267 && any (strcmpi (a, str_true))));
aad7ad0e15c1 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14466
diff changeset
268 endif
aad7ad0e15c1 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14466
diff changeset
269
14517
ed2d670a0a50 Restore original behaviour of pkg install -noauto.
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14479
diff changeset
270 if (autoload > 0 || (autoload == 0 && desc_autoload))
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
271 fclose (fopen (fullfile (descriptions{i}.dir, "packinfo",
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
272 ".autoload"), "wt"));
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
273 descriptions{i}.autoload = 1;
14470
aad7ad0e15c1 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14466
diff changeset
274 else
aad7ad0e15c1 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14466
diff changeset
275 descriptions{i}.autoload = 0;
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
276 endif
14470
aad7ad0e15c1 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14466
diff changeset
277
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
278 endfor
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
279
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
280 ## Add the packages to the package list.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
281 try
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
282 if (global_install)
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
283 idx = setdiff (1:length (global_packages), packages_to_uninstall);
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
284 global_packages = save_order ({global_packages{idx}, descriptions{:}});
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
285 save (global_list, "global_packages");
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
286 installed_pkgs_lst = {local_packages{:}, global_packages{:}};
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
287 else
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
288 idx = setdiff (1:length (local_packages), packages_to_uninstall);
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
289 local_packages = save_order ({local_packages{idx}, descriptions{:}});
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
290 save (local_list, "local_packages");
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
291 installed_pkgs_lst = {local_packages{:}, global_packages{:}};
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
292 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
293 catch
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
294 ## Something went wrong, delete tmpdirs.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
295 for i = 1:length (tmpdirs)
14471
d2c095e45196 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14470
diff changeset
296 rmdir (tmpdirs{i}, "s");
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
297 endfor
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
298 for i = 1:length (descriptions)
14471
d2c095e45196 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14470
diff changeset
299 rmdir (descriptions{i}.dir, "s");
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
300 endfor
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
301 if (global_install)
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
302 printf ("error: couldn't append to %s\n", global_list);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
303 else
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
304 printf ("error: couldn't append to %s\n", local_list);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
305 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
306 rethrow (lasterror ());
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
307 end_try_catch
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
308
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
309 ## All is well, let's clean up.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
310 for i = 1:length (tmpdirs)
14471
d2c095e45196 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14470
diff changeset
311 [status, msg] = rmdir (tmpdirs{i}, "s");
d2c095e45196 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14470
diff changeset
312 if (status != 1 && exist (tmpdirs{i}, "dir"))
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
313 warning ("couldn't clean up after my self: %s\n", msg);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
314 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
315 endfor
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
316
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
317 ## Add the newly installed packages to the path, so the user
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
318 ## can begin using them. Only load them if they are marked autoload.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
319 if (length (descriptions) > 0)
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
320 idx = [];
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
321 for i = 1:length (descriptions)
14470
aad7ad0e15c1 maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents: 14466
diff changeset
322 if (descriptions{i}.autoload > 0)
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
323 nm = descriptions{i}.name;
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
324 for j = 1:length (installed_pkgs_lst)
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
325 if (strcmp (nm, installed_pkgs_lst{j}.name))
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
326 idx(end + 1) = j;
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
327 break;
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
328 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
329 endfor
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
330 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
331 endfor
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
332 load_packages_and_dependencies (idx, handle_deps, installed_pkgs_lst,
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
333 global_install);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
334 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
335
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
336 ## If there is a NEWS file, mention it.
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
337 ## Check if desc exists too because it's possible to get to this point
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
338 ## without creating it such as giving an invalid filename for the package
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
339 if (exist ("desc", "var")
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
340 && exist (fullfile (desc.dir, "packinfo", "NEWS"), "file"))
17715
8dd280b64de1 Display usage of news as command after installing a package (patch #7708)
Carnë Draug <carandraug@octave.org>
parents: 17338
diff changeset
341 printf ("For information about changes from previous versions of the %s package, run 'news %s'.\n",
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
342 desc.name, desc.name);
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
343 endif
21615
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
344 endfunction
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
345
21615
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
346
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
347 function pkg = extract_pkg (nm, pat)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
348 fid = fopen (nm, "rt");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
349 pkg = "";
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
350 if (fid >= 0)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
351 while (! feof (fid))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
352 ln = fgetl (fid);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
353 if (ln > 0)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
354 t = regexp (ln, pat, "tokens");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
355 if (! isempty (t))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
356 pkg = [pkg "\n" t{1}{1}];
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
357 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
358 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
359 endwhile
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
360 if (! isempty (pkg))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
361 pkg = [pkg "\n"];
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
362 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
363 fclose (fid);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
364 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
365 endfunction
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
366
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
367
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
368 ## Make sure the package contains the essential files.
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
369 function verify_directory (dir)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
370 needed_files = {"COPYING", "DESCRIPTION"};
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
371 for f = needed_files
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
372 if (! exist (fullfile (dir, f{1}), "file"))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
373 error ("package is missing file: %s", f{1});
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
374 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
375 endfor
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
376 endfunction
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
377
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
378
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
379 function prepare_installation (desc, packdir)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
380 ## Is there a pre_install to call?
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
381 if (exist (fullfile (packdir, "pre_install.m"), "file"))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
382 wd = pwd ();
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
383 try
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
384 cd (packdir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
385 pre_install (desc);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
386 cd (wd);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
387 catch
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
388 cd (wd);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
389 rethrow (lasterror ());
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
390 end_try_catch
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
391 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
392
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
393 ## If the directory "inst" doesn't exist, we create it.
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
394 inst_dir = fullfile (packdir, "inst");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
395 if (! exist (inst_dir, "dir"))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
396 [status, msg] = mkdir (inst_dir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
397 if (status != 1)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
398 rmdir (desc.dir, "s");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
399 error ("the 'inst' directory did not exist and could not be created: %s",
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
400 msg);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
401 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
402 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
403 endfunction
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
404
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
405
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
406 function copy_built_files (desc, packdir, verbose)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
407 src = fullfile (packdir, "src");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
408 if (! exist (src, "dir"))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
409 return
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
410 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
411
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
412 ## Copy files to "inst" and "inst/arch" (this is instead of 'make install').
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
413 files = fullfile (src, "FILES");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
414 instdir = fullfile (packdir, "inst");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
415 archdir = fullfile (packdir, "inst", getarch ());
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
416
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
417 ## Get filenames.
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
418 if (exist (files, "file"))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
419 [fid, msg] = fopen (files, "r");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
420 if (fid < 0)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
421 error ("couldn't open %s: %s", files, msg);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
422 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
423 filenames = char (fread (fid))';
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
424 fclose (fid);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
425 if (filenames(end) == "\n")
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
426 filenames(end) = [];
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
427 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
428 filenames = strtrim (ostrsplit (filenames, "\n"));
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
429 delete_idx = [];
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
430 for i = 1:length (filenames)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
431 if (! all (isspace (filenames{i})))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
432 filenames{i} = fullfile (src, filenames{i});
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
433 else
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
434 delete_idx(end+1) = i;
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
435 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
436 endfor
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
437 filenames(delete_idx) = [];
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
438 else
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
439 m = dir (fullfile (src, "*.m"));
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
440 oct = dir (fullfile (src, "*.oct"));
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
441 mex = dir (fullfile (src, "*.mex"));
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
442
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
443 filenames = cellfun (@(x) fullfile (src, x),
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
444 {m.name, oct.name, mex.name},
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
445 "uniformoutput", false);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
446 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
447
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
448 ## Split into architecture dependent and independent files.
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
449 if (isempty (filenames))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
450 idx = [];
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
451 else
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
452 idx = cellfun ("is_architecture_dependent", filenames);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
453 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
454 archdependent = filenames(idx);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
455 archindependent = filenames(! idx);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
456
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
457 ## Copy the files.
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
458 if (! all (isspace ([filenames{:}])))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
459 if (! exist (instdir, "dir"))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
460 mkdir (instdir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
461 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
462 if (! all (isspace ([archindependent{:}])))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
463 if (verbose)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
464 printf ("copyfile");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
465 printf (" %s", archindependent{:});
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
466 printf ("%s\n", instdir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
467 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
468 [status, output] = copyfile (archindependent, instdir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
469 if (status != 1)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
470 rmdir (desc.dir, "s");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
471 error ("Couldn't copy files from 'src' to 'inst': %s", output);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
472 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
473 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
474 if (! all (isspace ([archdependent{:}])))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
475 if (verbose)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
476 printf ("copyfile");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
477 printf (" %s", archdependent{:});
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
478 printf (" %s\n", archdir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
479 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
480 if (! exist (archdir, "dir"))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
481 mkdir (archdir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
482 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
483 [status, output] = copyfile (archdependent, archdir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
484 if (status != 1)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
485 rmdir (desc.dir, "s");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
486 error ("Couldn't copy files from 'src' to 'inst': %s", output);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
487 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
488 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
489 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
490 endfunction
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
491
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
492
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
493 function dep = is_architecture_dependent (nm)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
494 persistent archdepsuffix = {".oct",".mex",".a",".lib",".so",".so.*",".dll","dylib"};
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
495
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
496 dep = false;
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
497 for i = 1 : length (archdepsuffix)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
498 ext = archdepsuffix{i};
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
499 if (ext(end) == "*")
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
500 isglob = true;
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
501 ext(end) = [];
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
502 else
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
503 isglob = false;
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
504 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
505 pos = strfind (nm, ext);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
506 if (pos)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
507 if (! isglob && (length (nm) - pos(end) != length (ext) - 1))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
508 continue;
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
509 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
510 dep = true;
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
511 break;
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
512 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
513 endfor
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
514 endfunction
17338
1c89599167a6 maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents: 17016
diff changeset
515
21615
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
516
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
517 function copy_files (desc, packdir, global_install)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
518 ## Create the installation directory.
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
519 if (! exist (desc.dir, "dir"))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
520 [status, output] = mkdir (desc.dir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
521 if (status != 1)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
522 error ("couldn't create installation directory %s : %s",
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
523 desc.dir, output);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
524 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
525 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
526
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
527 octfiledir = getarchdir (desc);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
528
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
529 ## Copy the files from "inst" to installdir.
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
530 instdir = fullfile (packdir, "inst");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
531 if (! dirempty (instdir))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
532 [status, output] = copyfile (fullfile (instdir, "*"), desc.dir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
533 if (status != 1)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
534 rmdir (desc.dir, "s");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
535 error ("couldn't copy files to the installation directory");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
536 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
537 if (exist (fullfile (desc.dir, getarch ()), "dir")
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
538 && ! strcmp (fullfile (desc.dir, getarch ()), octfiledir))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
539 if (! exist (octfiledir, "dir"))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
540 ## Can be required to create upto three levels of dirs.
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
541 octm1 = fileparts (octfiledir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
542 if (! exist (octm1, "dir"))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
543 octm2 = fileparts (octm1);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
544 if (! exist (octm2, "dir"))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
545 octm3 = fileparts (octm2);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
546 if (! exist (octm3, "dir"))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
547 [status, output] = mkdir (octm3);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
548 if (status != 1)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
549 rmdir (desc.dir, "s");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
550 error ("couldn't create installation directory %s : %s",
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
551 octm3, output);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
552 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
553 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
554 [status, output] = mkdir (octm2);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
555 if (status != 1)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
556 rmdir (desc.dir, "s");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
557 error ("couldn't create installation directory %s : %s",
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
558 octm2, output);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
559 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
560 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
561 [status, output] = mkdir (octm1);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
562 if (status != 1)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
563 rmdir (desc.dir, "s");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
564 error ("couldn't create installation directory %s : %s",
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
565 octm1, output);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
566 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
567 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
568 [status, output] = mkdir (octfiledir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
569 if (status != 1)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
570 rmdir (desc.dir, "s");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
571 error ("couldn't create installation directory %s : %s",
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
572 octfiledir, output);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
573 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
574 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
575 [status, output] = movefile (fullfile (desc.dir, getarch (), "*"),
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
576 octfiledir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
577 rmdir (fullfile (desc.dir, getarch ()), "s");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
578
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
579 if (status != 1)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
580 rmdir (desc.dir, "s");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
581 rmdir (octfiledir, "s");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
582 error ("couldn't copy files to the installation directory");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
583 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
584 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
585
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
586 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
587
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
588 ## Create the "packinfo" directory.
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
589 packinfo = fullfile (desc.dir, "packinfo");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
590 [status, msg] = mkdir (packinfo);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
591 if (status != 1)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
592 rmdir (desc.dir, "s");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
593 rmdir (octfiledir, "s");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
594 error ("couldn't create packinfo directory: %s", msg);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
595 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
596
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
597 packinfo_copy_file ("DESCRIPTION", "required", packdir, packinfo, desc, octfiledir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
598 packinfo_copy_file ("COPYING", "required", packdir, packinfo, desc, octfiledir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
599 packinfo_copy_file ("CITATION", "optional", packdir, packinfo, desc, octfiledir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
600 packinfo_copy_file ("NEWS", "optional", packdir, packinfo, desc, octfiledir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
601 packinfo_copy_file ("ONEWS", "optional", packdir, packinfo, desc, octfiledir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
602 packinfo_copy_file ("ChangeLog", "optional", packdir, packinfo, desc, octfiledir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
603
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
604 ## Is there an INDEX file to copy or should we generate one?
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
605 index_file = fullfile (packdir, "INDEX");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
606 if (exist (index_file, "file"))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
607 packinfo_copy_file ("INDEX", "required", packdir, packinfo, desc, octfiledir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
608 else
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
609 try
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
610 write_index (desc, fullfile (packdir, "inst"),
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
611 fullfile (packinfo, "INDEX"), global_install);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
612 catch
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
613 rmdir (desc.dir, "s");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
614 rmdir (octfiledir, "s");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
615 rethrow (lasterror ());
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
616 end_try_catch
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
617 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
618
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
619 ## Is there an 'on_uninstall.m' to install?
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
620 packinfo_copy_file ("on_uninstall.m", "optional", packdir, packinfo, desc, octfiledir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
621
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
622 ## Is there a doc/ directory that needs to be installed?
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
623 docdir = fullfile (packdir, "doc");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
624 if (exist (docdir, "dir") && ! dirempty (docdir))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
625 [status, output] = copyfile (docdir, desc.dir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
626 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
627
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
628 ## Is there a bin/ directory that needs to be installed?
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
629 ## FIXME: Need to treat architecture dependent files in bin/
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
630 bindir = fullfile (packdir, "bin");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
631 if (exist (bindir, "dir") && ! dirempty (bindir))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
632 [status, output] = copyfile (bindir, desc.dir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
633 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
634 endfunction
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
635
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
636
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
637 function packinfo_copy_file (filename, requirement, packdir, packinfo, desc, octfiledir)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
638 filepath = fullfile (packdir, filename);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
639 if (! exist (filepath, "file") && strcmpi (requirement, "optional"))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
640 ## do nothing, it's still OK
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
641 else
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
642 [status, output] = copyfile (filepath, packinfo);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
643 if (status != 1)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
644 rmdir (desc.dir, "s");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
645 rmdir (octfiledir, "s");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
646 error ("Couldn't copy %s file: %s", filename, output);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
647 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
648 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
649 endfunction
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
650
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
651
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
652 ## Create an INDEX file for a package that doesn't provide one.
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
653 ## 'desc' describes the package.
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
654 ## 'dir' is the 'inst' directory in temporary directory.
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
655 ## 'index_file' is the name (including path) of resulting INDEX file.
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
656 function write_index (desc, dir, index_file, global_install)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
657 ## Get names of functions in dir
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
658 [files, err, msg] = readdir (dir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
659 if (err)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
660 error ("couldn't read directory %s: %s", dir, msg);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
661 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
662
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
663 ## Get classes in dir
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
664 class_idx = find (strncmp (files, '@', 1));
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
665 for k = 1:length (class_idx)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
666 class_name = files {class_idx(k)};
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
667 class_dir = fullfile (dir, class_name);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
668 if (exist (class_dir, "dir"))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
669 [files2, err, msg] = readdir (class_dir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
670 if (err)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
671 error ("couldn't read directory %s: %s", class_dir, msg);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
672 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
673 files2 = strcat (class_name, filesep (), files2);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
674 files = [files; files2];
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
675 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
676 endfor
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
677
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
678 ## Check for architecture dependent files.
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
679 tmpdir = getarchdir (desc);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
680 if (exist (tmpdir, "dir"))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
681 [files2, err, msg] = readdir (tmpdir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
682 if (err)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
683 error ("couldn't read directory %s: %s", tmpdir, msg);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
684 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
685 files = [files; files2];
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
686 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
687
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
688 functions = {};
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
689 for i = 1:length (files)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
690 file = files{i};
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
691 lf = length (file);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
692 if (lf > 2 && strcmp (file(end-1:end), ".m"))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
693 functions{end+1} = file(1:end-2);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
694 elseif (lf > 4 && strcmp (file(end-3:end), ".oct"))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
695 functions{end+1} = file(1:end-4);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
696 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
697 endfor
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
698
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
699 ## Does desc have a categories field?
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
700 if (! isfield (desc, "categories"))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
701 error ("the DESCRIPTION file must have a Categories field, when no INDEX file is given");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
702 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
703 categories = strtrim (strsplit (desc.categories, ","));
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
704 if (length (categories) < 1)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
705 error ("the Category field is empty");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
706 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
707
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
708 ## Write INDEX.
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
709 fid = fopen (index_file, "w");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
710 if (fid == -1)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
711 error ("couldn't open %s for writing", index_file);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
712 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
713 fprintf (fid, "%s >> %s\n", desc.name, desc.title);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
714 fprintf (fid, "%s\n", categories{1});
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
715 fprintf (fid, " %s\n", functions{:});
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
716 fclose (fid);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
717 endfunction
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
718
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
719
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
720 function create_pkgadddel (desc, packdir, nm, global_install)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
721 instpkg = fullfile (desc.dir, nm);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
722 instfid = fopen (instpkg, "at"); # append to support PKG_ADD at inst/
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
723 ## If it is exists, most of the PKG_* file should go into the
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
724 ## architecture dependent directory so that the autoload/mfilename
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
725 ## commands work as expected. The only part that doesn't is the
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
726 ## part in the main directory.
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
727 archdir = fullfile (getarchprefix (desc, global_install),
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
728 [desc.name "-" desc.version], getarch ());
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
729 if (exist (getarchdir (desc, global_install), "dir"))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
730 archpkg = fullfile (getarchdir (desc, global_install), nm);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
731 archfid = fopen (archpkg, "at");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
732 else
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
733 archpkg = instpkg;
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
734 archfid = instfid;
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
735 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
736
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
737 if (archfid >= 0 && instfid >= 0)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
738 ## Search all dot-m files for PKG commands.
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
739 lst = dir (fullfile (packdir, "inst", "*.m"));
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
740 for i = 1:length (lst)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
741 nam = fullfile (packdir, "inst", lst(i).name);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
742 fwrite (instfid, extract_pkg (nam, ['^[#%][#%]* *' nm ': *(.*)$']));
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
743 endfor
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
744
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
745 ## Search all C++ source files for PKG commands.
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
746 lst = dir (fullfile (packdir, "src", "*.cc"));
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
747 for i = 1:length (lst)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
748 nam = fullfile (packdir, "src", lst(i).name);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
749 fwrite (archfid, extract_pkg (nam, ['^//* *' nm ': *(.*)$']));
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
750 fwrite (archfid, extract_pkg (nam, ['^/\** *' nm ': *(.*) *\*/$']));
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
751 endfor
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
752
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
753 ## Add developer included PKG commands.
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
754 packdirnm = fullfile (packdir, nm);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
755 if (exist (packdirnm, "file"))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
756 fid = fopen (packdirnm, "rt");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
757 if (fid >= 0)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
758 while (! feof (fid))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
759 ln = fgets (fid);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
760 if (ln > 0)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
761 fwrite (archfid, ln);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
762 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
763 endwhile
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
764 fclose (fid);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
765 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
766 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
767
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
768 ## If the files is empty remove it.
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
769 fclose (instfid);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
770 t = dir (instpkg);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
771 if (t.bytes <= 0)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
772 unlink (instpkg);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
773 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
774
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
775 if (instfid != archfid)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
776 fclose (archfid);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
777 t = dir (archpkg);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
778 if (t.bytes <= 0)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
779 unlink (archpkg);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
780 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
781 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
782 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
783 endfunction
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
784
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
785
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
786 function archprefix = getarchprefix (desc, global_install)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
787 if (global_install)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
788 [~, archprefix] = default_prefix (global_install, desc);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
789 else
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
790 archprefix = desc.dir;
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
791 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
792 endfunction
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
793
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
794
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
795 function finish_installation (desc, packdir, global_install)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
796 ## Is there a post-install to call?
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
797 if (exist (fullfile (packdir, "post_install.m"), "file"))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
798 wd = pwd ();
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
799 try
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
800 cd (packdir);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
801 post_install (desc);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
802 cd (wd);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
803 catch
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
804 cd (wd);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
805 rmdir (desc.dir, "s");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
806 rmdir (getarchdir (desc), "s");
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
807 rethrow (lasterror ());
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
808 end_try_catch
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
809 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
810 endfunction
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
811
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
812
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
813 function generate_lookfor_cache (desc)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
814 dirs = strtrim (ostrsplit (genpath (desc.dir), pathsep ()));
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
815 for i = 1 : length (dirs)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
816 doc_cache_create (fullfile (dirs{i}, "doc-cache"), dirs{i});
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
817 endfor
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
818 endfunction