1 |
commit: 47ad9a4eeb74a053d1fbc854fca7d13c96fb1a5b |
2 |
Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Mar 11 01:11:16 2019 +0000 |
4 |
Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Mar 11 04:54:44 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/eselect-rust.git/commit/?id=47ad9a4e |
7 |
|
8 |
Add cleanup action |
9 |
|
10 |
Cleanup action will make use of new find_missing_broken_symlinks() function |
11 |
and should be called by ebuild during package removal. |
12 |
|
13 |
If we detect a missing or broken symlink, we will automatically mark latest |
14 |
available version as default (which will basically fix missing or broken |
15 |
symlinks). |
16 |
|
17 |
Bug: https://bugs.gentoo.org/671182 |
18 |
Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org> |
19 |
|
20 |
rust.eselect.in | 27 +++++++++++++++++++++++++++ |
21 |
1 file changed, 27 insertions(+) |
22 |
|
23 |
diff --git a/rust.eselect.in b/rust.eselect.in |
24 |
index d0f3361..1360dc2 100644 |
25 |
--- a/rust.eselect.in |
26 |
+++ b/rust.eselect.in |
27 |
@@ -177,6 +177,33 @@ set_version() { |
28 |
die -q "symlink list copying failed" |
29 |
} |
30 |
|
31 |
+### cleanup action ### |
32 |
+describe_cleanup() { |
33 |
+ echo "This action is not to be called manually." |
34 |
+} |
35 |
+ |
36 |
+do_cleanup() { |
37 |
+ [[ -z ${@} ]] || die -q "This function does not expect any arguments" |
38 |
+ |
39 |
+ # Do we need to clean up? |
40 |
+ local missing_symlinks=( $(find_missing_broken_symlinks) ) |
41 |
+ if [[ ${#missing_symlinks[@]} -eq 0 ]]; then |
42 |
+ echo "Nothing to clean up." |
43 |
+ return |
44 |
+ fi |
45 |
+ |
46 |
+ unset_version |
47 |
+ |
48 |
+ local targets=( $(find_targets) ) |
49 |
+ |
50 |
+ if [[ ${#targets[@]} -ne 0 ]]; then |
51 |
+ echo "Marking the latest still installed version as default..." |
52 |
+ do_set ${#targets[@]} |
53 |
+ else |
54 |
+ echo "No Rust profiles left on the system. Stale symlinks removed." |
55 |
+ fi |
56 |
+} |
57 |
+ |
58 |
### list action ### |
59 |
|
60 |
describe_list() { |