1 |
commit: 99577f8e98440da176709b6e4b988b40ae42b8d1 |
2 |
Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Mar 11 00:42:52 2019 +0000 |
4 |
Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Mar 11 04:54:36 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/eselect-rust.git/commit/?id=99577f8e |
7 |
|
8 |
Add and make use of find_missing_broken_symlinks() |
9 |
|
10 |
dev-lang/rust or dev-lang/rust-bin install more than one binary (program), |
11 |
just checking for "rustc" is not enough. |
12 |
|
13 |
In addition, set of installed programs depends on USE flags. |
14 |
|
15 |
This new (internal) function will check for all provided programs. |
16 |
|
17 |
Bug: https://bugs.gentoo.org/671182 |
18 |
Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org> |
19 |
|
20 |
rust.eselect.in | 40 ++++++++++++++++++++++++++++++++++++---- |
21 |
1 file changed, 36 insertions(+), 4 deletions(-) |
22 |
|
23 |
diff --git a/rust.eselect.in b/rust.eselect.in |
24 |
index 02f7b75..d0f3361 100644 |
25 |
--- a/rust.eselect.in |
26 |
+++ b/rust.eselect.in |
27 |
@@ -10,6 +10,28 @@ BIN_DIR="${EROOT%/}/usr/bin" |
28 |
|
29 |
inherit package-manager path-manipulation |
30 |
|
31 |
+# find a list of missing or broken symlinks |
32 |
+# each compiler installs a list of provided programs. |
33 |
+# this function checks if a symlink for a provided program |
34 |
+# is missing or broken for the current active Rust implementation |
35 |
+find_missing_broken_symlinks() { |
36 |
+ local -a missing_symlinks |
37 |
+ local required_symlinks=( "/usr/bin/rustc" $(get_last_set_symlinks) ) |
38 |
+ |
39 |
+ for i in "${required_symlinks[@]}"; do |
40 |
+ local symlink="${EROOT%/}${i}" |
41 |
+ |
42 |
+ if [[ -L "${symlink}" && -e "${symlink}" ]]; then |
43 |
+ # existing symlink |
44 |
+ continue |
45 |
+ else |
46 |
+ missing_symlinks+=( "${symlink}" ) |
47 |
+ fi |
48 |
+ done |
49 |
+ |
50 |
+ echo "${missing_symlinks[@]}" |
51 |
+} |
52 |
+ |
53 |
# find a list of installed rust compilers |
54 |
# each compiler provider should install |
55 |
# a config file named provider-$pkgname-$pkgver |
56 |
@@ -219,8 +241,13 @@ do_update() { |
57 |
shift |
58 |
done |
59 |
|
60 |
- if [[ "${if_unset}" == "1" && -f "${BIN_DIR}/rustc" ]]; then |
61 |
- return |
62 |
+ if [[ "${if_unset}" == "1" ]]; then |
63 |
+ local missing_symlinks=( $(find_missing_broken_symlinks) ) |
64 |
+ if [[ ${#missing_symlinks[@]} -eq 0 ]]; then |
65 |
+ return |
66 |
+ else |
67 |
+ echo "Not all symlinks set. Will switch to the most recent Rust compiler!" |
68 |
+ fi |
69 |
fi |
70 |
|
71 |
local targets=( $(find_targets) ) |
72 |
@@ -251,8 +278,13 @@ do_unset() { |
73 |
shift |
74 |
done |
75 |
|
76 |
- if [[ "${if_invalid}" == "1" && -e "${BIN_DIR}/rustc" ]]; then |
77 |
- return |
78 |
+ if [[ "${if_invalid}" == "1" ]]; then |
79 |
+ local missing_symlinks=( $(find_missing_broken_symlinks) ) |
80 |
+ if [[ ${#missing_symlinks[@]} -eq 0 ]]; then |
81 |
+ return |
82 |
+ else |
83 |
+ echo "Not all symlinks set. Will unset current symlinked Rust binaries!" |
84 |
+ fi |
85 |
fi |
86 |
|
87 |
unset_version || die -q "Couldn't unset active version" |