Mercurial > octave
annotate scripts/pkg/private/uninstall.m @ 29936:79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
* scripts/pkg/private/uninstall.m: Add warnings for packages not uninstalled
because they are global or not found. Fix pkg uninstall not installing any
packages if some could not be found. Minor overhaul of coding style.
author | Neeraj Battan <neeraj.battan@research.iiit.ac.in> |
---|---|
date | Thu, 17 Mar 2016 10:50:22 +0530 |
parents | 7854d5752dd2 |
children | 796f54d4ddbf |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
29358
0a5b15007766
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
3 ## Copyright (C) 2005-2021 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27707
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
7 ## |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
8 ## 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
|
9 ## |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
14 ## |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
15 ## 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
|
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
14466
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 ## 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
|
21 ## along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
25 |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
26 ## -*- texinfo -*- |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19933
diff
changeset
|
27 ## @deftypefn {} {} uninstall (@var{pkgnames}, @var{handle_deps}, @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
|
28 ## Undocumented internal function. |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
29 ## @end deftypefn |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
30 |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
31 function uninstall (pkgnames, handle_deps, verbose, local_list, |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
32 global_list, global_install) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
33 |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
34 ## Get the list of installed packages. |
28503
f480103d8333
Fix unlink() calls in package m-files for new syntax (bug #57830)
Rik <rik@octave.org>
parents:
28087
diff
changeset
|
35 [local_packages, global_packages] = installed_packages (local_list, |
f480103d8333
Fix unlink() calls in package m-files for new syntax (bug #57830)
Rik <rik@octave.org>
parents:
28087
diff
changeset
|
36 global_list); |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
37 if (global_install) |
29936
79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
Neeraj Battan <neeraj.battan@research.iiit.ac.in>
parents:
29359
diff
changeset
|
38 installed_pkgs_lst = [local_packages, global_packages]; |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
39 else |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
40 installed_pkgs_lst = local_packages; |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
41 endif |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
42 |
29936
79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
Neeraj Battan <neeraj.battan@research.iiit.ac.in>
parents:
29359
diff
changeset
|
43 all_pkgs_list = [local_packages, global_packages]; |
79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
Neeraj Battan <neeraj.battan@research.iiit.ac.in>
parents:
29359
diff
changeset
|
44 all_installed_pkgs_lst = cellfun (@(x) x.name, all_pkgs_list, ... |
79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
Neeraj Battan <neeraj.battan@research.iiit.ac.in>
parents:
29359
diff
changeset
|
45 "uniformoutput", false); |
79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
Neeraj Battan <neeraj.battan@research.iiit.ac.in>
parents:
29359
diff
changeset
|
46 num_packages = numel (installed_pkgs_lst); |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
47 delete_idx = []; |
29936
79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
Neeraj Battan <neeraj.battan@research.iiit.ac.in>
parents:
29359
diff
changeset
|
48 available_packages = intersect (all_installed_pkgs_lst, pkgnames); |
79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
Neeraj Battan <neeraj.battan@research.iiit.ac.in>
parents:
29359
diff
changeset
|
49 |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
50 for i = 1:num_packages |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
51 cur_name = installed_pkgs_lst{i}.name; |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
52 if (any (strcmp (cur_name, pkgnames))) |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
53 delete_idx(end+1) = i; |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
54 endif |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
55 endfor |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
56 |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
57 ## Are all the packages that should be uninstalled already installed? |
29936
79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
Neeraj Battan <neeraj.battan@research.iiit.ac.in>
parents:
29359
diff
changeset
|
58 if (numel (available_packages) != numel (pkgnames)) |
79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
Neeraj Battan <neeraj.battan@research.iiit.ac.in>
parents:
29359
diff
changeset
|
59 pkgs_not_installed = setxor (available_packages, pkgnames); |
79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
Neeraj Battan <neeraj.battan@research.iiit.ac.in>
parents:
29359
diff
changeset
|
60 for idx = 1:numel (pkgs_not_installed) |
79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
Neeraj Battan <neeraj.battan@research.iiit.ac.in>
parents:
29359
diff
changeset
|
61 warning ("package %s is not installed\n", pkgs_not_installed{idx}); |
79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
Neeraj Battan <neeraj.battan@research.iiit.ac.in>
parents:
29359
diff
changeset
|
62 endfor |
79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
Neeraj Battan <neeraj.battan@research.iiit.ac.in>
parents:
29359
diff
changeset
|
63 endif |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
64 |
29936
79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
Neeraj Battan <neeraj.battan@research.iiit.ac.in>
parents:
29359
diff
changeset
|
65 ## inform user if any global packages can't be uninstalled |
79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
Neeraj Battan <neeraj.battan@research.iiit.ac.in>
parents:
29359
diff
changeset
|
66 if (! global_install) |
79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
Neeraj Battan <neeraj.battan@research.iiit.ac.in>
parents:
29359
diff
changeset
|
67 for i = 1:numel (global_packages) |
79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
Neeraj Battan <neeraj.battan@research.iiit.ac.in>
parents:
29359
diff
changeset
|
68 if (any (strcmp (global_packages{i}.name, pkgnames))) |
79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
Neeraj Battan <neeraj.battan@research.iiit.ac.in>
parents:
29359
diff
changeset
|
69 warning ("%s is a global package and cannot be removed locally\n", ... |
79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
Neeraj Battan <neeraj.battan@research.iiit.ac.in>
parents:
29359
diff
changeset
|
70 global_packages{i}.name); |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
71 endif |
29936
79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
Neeraj Battan <neeraj.battan@research.iiit.ac.in>
parents:
29359
diff
changeset
|
72 endfor |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
73 endif |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
74 |
19933
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
75 if (isempty (delete_idx)) |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
76 warning ("no packages will be uninstalled"); |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
77 else |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
78 |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
79 ## Compute the packages that will remain installed. |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
80 idx = setdiff (1:num_packages, delete_idx); |
29936
79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
Neeraj Battan <neeraj.battan@research.iiit.ac.in>
parents:
29359
diff
changeset
|
81 remaining_packages = installed_pkgs_lst(idx); |
79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
Neeraj Battan <neeraj.battan@research.iiit.ac.in>
parents:
29359
diff
changeset
|
82 to_delete_packages = installed_pkgs_lst(delete_idx); |
19933
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
83 |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
84 ## Check dependencies. |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
85 if (handle_deps) |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
86 error_text = ""; |
29936
79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
Neeraj Battan <neeraj.battan@research.iiit.ac.in>
parents:
29359
diff
changeset
|
87 for i = 1:numel (remaining_packages) |
19933
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
88 desc = remaining_packages{i}; |
27597
352cead49726
Don't break uninstalling a package due to unrelated dependencies (bug #51722)
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
27573
diff
changeset
|
89 bad_deps = get_unsatisfied_deps (desc, to_delete_packages, true); |
19933
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
90 |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
91 ## Will the uninstallation break any dependencies? |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
92 if (! isempty (bad_deps)) |
29936
79c6a29dd384
pkg: Better warning messages for packages not being uninstalled (bug #31946).
Neeraj Battan <neeraj.battan@research.iiit.ac.in>
parents:
29359
diff
changeset
|
93 for i = 1:numel (bad_deps) |
19933
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
94 dep = bad_deps{i}; |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
95 error_text = [error_text " " desc.name " needs " ... |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
96 dep.package " " dep.operator " " dep.version "\n"]; |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
97 endfor |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
98 endif |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
99 endfor |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
100 |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
101 if (! isempty (error_text)) |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
102 error ("the following dependencies where unsatisfied:\n %s", error_text); |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
103 endif |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
104 endif |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
105 |
19933
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
106 ## Delete the directories containing the packages. |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
107 for i = delete_idx |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
108 desc = installed_pkgs_lst{i}; |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
109 ## If an 'on_uninstall.m' exist, call it! |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
110 if (exist (fullfile (desc.dir, "packinfo", "on_uninstall.m"), "file")) |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
111 wd = pwd (); |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
112 cd (fullfile (desc.dir, "packinfo")); |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
113 on_uninstall (desc); |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
114 cd (wd); |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
115 endif |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
116 ## Do the actual deletion. |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
117 if (desc.loaded) |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
118 rmpath (desc.dir); |
25787
3293cd2651fb
prefer 'isfolder' over 'exist (..., "dir")' in Octave functions
Mike Miller <mtmiller@octave.org>
parents:
25054
diff
changeset
|
119 if (isfolder (getarchdir (desc))) |
19933
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
120 rmpath (getarchdir (desc)); |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
121 endif |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
122 endif |
25787
3293cd2651fb
prefer 'isfolder' over 'exist (..., "dir")' in Octave functions
Mike Miller <mtmiller@octave.org>
parents:
25054
diff
changeset
|
123 if (isfolder (desc.dir)) |
28693
2bb050267d74
maint: Remove trailing spaces from code base.
Rik <rik@octave.org>
parents:
28503
diff
changeset
|
124 ## FIXME: If first call to rmdir fails, then error() will |
28087
9cb04a9e81ec
rmdir: throw an error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
125 ## stop further processing of getarchdir & archprefix. |
9cb04a9e81ec
rmdir: throw an error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
126 ## If this is, in fact, correct, then calls should |
9cb04a9e81ec
rmdir: throw an error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
127 ## just be shortened to rmdir (...) and let rmdir() |
9cb04a9e81ec
rmdir: throw an error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
128 ## report failure and reason for failure. |
19933
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
129 [status, msg] = rmdir (desc.dir, "s"); |
25787
3293cd2651fb
prefer 'isfolder' over 'exist (..., "dir")' in Octave functions
Mike Miller <mtmiller@octave.org>
parents:
25054
diff
changeset
|
130 if (status != 1 && isfolder (desc.dir)) |
19933
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
131 error ("couldn't delete directory %s: %s", desc.dir, msg); |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
132 endif |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
133 [status, msg] = rmdir (getarchdir (desc), "s"); |
25787
3293cd2651fb
prefer 'isfolder' over 'exist (..., "dir")' in Octave functions
Mike Miller <mtmiller@octave.org>
parents:
25054
diff
changeset
|
134 if (status != 1 && isfolder (getarchdir (desc))) |
19933
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
135 error ("couldn't delete directory %s: %s", getarchdir (desc), msg); |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
136 endif |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
137 if (dirempty (desc.archprefix)) |
28087
9cb04a9e81ec
rmdir: throw an error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
138 sts = rmdir (desc.archprefix, "s"); |
19933
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
139 endif |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
140 else |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
141 warning ("directory %s previously lost", desc.dir); |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
142 endif |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
143 endfor |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
144 |
19933
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
145 ## Write a new ~/.octave_packages. |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
146 if (global_install) |
28503
f480103d8333
Fix unlink() calls in package m-files for new syntax (bug #57830)
Rik <rik@octave.org>
parents:
28087
diff
changeset
|
147 if (numel (remaining_packages) == 0) |
f480103d8333
Fix unlink() calls in package m-files for new syntax (bug #57830)
Rik <rik@octave.org>
parents:
28087
diff
changeset
|
148 [~] = unlink (global_list); |
19933
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
149 else |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
150 global_packages = save_order (remaining_packages); |
27573
0cedd1e23c1f
Adapt path styles for pkg.m on Windows (bug #57083)
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
26376
diff
changeset
|
151 if (ispc) |
0cedd1e23c1f
Adapt path styles for pkg.m on Windows (bug #57083)
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
26376
diff
changeset
|
152 ## On Windows ensure LFN paths are saved rather than 8.3 style paths |
0cedd1e23c1f
Adapt path styles for pkg.m on Windows (bug #57083)
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
26376
diff
changeset
|
153 global_packages = standardize_paths (global_packages); |
0cedd1e23c1f
Adapt path styles for pkg.m on Windows (bug #57083)
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
26376
diff
changeset
|
154 endif |
27707
377f069841c1
Make packages installation dirs in global octave_packages file relative
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
27597
diff
changeset
|
155 global_packages = make_rel_paths (global_packages); |
19933
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
156 save (global_list, "global_packages"); |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
157 endif |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
158 else |
28503
f480103d8333
Fix unlink() calls in package m-files for new syntax (bug #57830)
Rik <rik@octave.org>
parents:
28087
diff
changeset
|
159 if (numel (remaining_packages) == 0) |
f480103d8333
Fix unlink() calls in package m-files for new syntax (bug #57830)
Rik <rik@octave.org>
parents:
28087
diff
changeset
|
160 [~] = unlink (local_list); |
19933
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
161 else |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
162 local_packages = save_order (remaining_packages); |
27573
0cedd1e23c1f
Adapt path styles for pkg.m on Windows (bug #57083)
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
26376
diff
changeset
|
163 if (ispc) |
0cedd1e23c1f
Adapt path styles for pkg.m on Windows (bug #57083)
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
26376
diff
changeset
|
164 local_packages = standardize_paths (local_packages); |
0cedd1e23c1f
Adapt path styles for pkg.m on Windows (bug #57083)
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
26376
diff
changeset
|
165 endif |
19933
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
166 save (local_list, "local_packages"); |
6670df97456c
Check if pkgs were found to uninstall before attempting uninstall (Bug #44524).
John Donoghue
parents:
19697
diff
changeset
|
167 endif |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
168 endif |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
169 endif |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
170 |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
171 endfunction |