1 |
commit: 5799b7ee8492860b6dfc5542d04a2d2a2e3f7d56 |
2 |
Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Mar 10 03:33:35 2019 +0000 |
4 |
Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Mar 11 04:18:33 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/eselect-rust.git/commit/?id=5799b7ee |
7 |
|
8 |
Use variables for common used paths |
9 |
|
10 |
Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org> |
11 |
|
12 |
rust.eselect.in | 37 ++++++++++++++++++++----------------- |
13 |
1 file changed, 20 insertions(+), 17 deletions(-) |
14 |
|
15 |
diff --git a/rust.eselect.in b/rust.eselect.in |
16 |
index 96fba74..02f7b75 100644 |
17 |
--- a/rust.eselect.in |
18 |
+++ b/rust.eselect.in |
19 |
@@ -5,17 +5,20 @@ DESCRIPTION="Manage the Rust compiler versions" |
20 |
MAINTAINER="rust@g.o" |
21 |
VERSION="@VERSION@" |
22 |
|
23 |
+ENV_D_PATH="${EROOT%/}/etc/env.d" |
24 |
+BIN_DIR="${EROOT%/}/usr/bin" |
25 |
+ |
26 |
inherit package-manager path-manipulation |
27 |
|
28 |
# find a list of installed rust compilers |
29 |
# each compiler provider should install |
30 |
# a config file named provider-$pkgname-$pkgver |
31 |
-# in "${EROOT}"/etc/env.d/rust directory |
32 |
+# in "${ENV_D_PATH}/rust" directory |
33 |
# this function prints list of $pkgname-$pkgver values |
34 |
find_targets() { |
35 |
local f |
36 |
local -a providers |
37 |
- for f in "${EROOT}"/etc/env.d/rust/provider-*; do |
38 |
+ for f in "${ENV_D_PATH}"/rust/provider-*; do |
39 |
[[ -f ${f} ]] || continue |
40 |
providers=("${providers[@]}" "${f##*/provider-}") |
41 |
done |
42 |
@@ -33,7 +36,7 @@ get_current_target() { |
43 |
local i targets=( $(find_targets) ) |
44 |
for (( i = 0; i < ${#targets[@]}; i++ )); do |
45 |
[[ rustc-$(get_postfix ${targets[i]}) = \ |
46 |
- $(basename "$(canonicalise "${EROOT}/usr/bin/rustc")") ]] \ |
47 |
+ $(basename "$(canonicalise "${BIN_DIR}/rustc")") ]] \ |
48 |
&& echo $i && return 0 |
49 |
done |
50 |
echo "NOT_SET" |
51 |
@@ -60,7 +63,7 @@ get_symlinks_from_file() { |
52 |
|
53 |
#get last set symlinks |
54 |
get_last_set_symlinks() { |
55 |
- local symlinks=( $(get_symlinks_from_file "${EROOT}/etc/env.d/rust/last-set") ) |
56 |
+ local symlinks=( $(get_symlinks_from_file "${ENV_D_PATH}/rust/last-set") ) |
57 |
echo "${symlinks[@]}" |
58 |
} |
59 |
|
60 |
@@ -76,7 +79,7 @@ get_symlinks() { |
61 |
target=${targets[target]} |
62 |
fi |
63 |
|
64 |
- local symlinks=( $(get_symlinks_from_file "${EROOT}/etc/env.d/rust/provider-${target}") ) |
65 |
+ local symlinks=( $(get_symlinks_from_file "${ENV_D_PATH}/rust/provider-${target}") ) |
66 |
echo "${symlinks[@]}" |
67 |
} |
68 |
|
69 |
@@ -112,17 +115,17 @@ set_symlink() { |
70 |
unset_version() { |
71 |
local symlinks=( $(get_last_set_symlinks) ) |
72 |
for i in "${symlinks[@]}"; do |
73 |
- remove_symlink "${EROOT}${i}" |
74 |
+ remove_symlink "${EROOT%/}${i}" |
75 |
done |
76 |
- remove_symlink "${EROOT}/usr/bin/rustc" |
77 |
- rm -f "${EROOT}/etc/env.d/rust/last-set" \ |
78 |
- || die -q "rm -f ${EROOT}/etc/env.d/rust/last-set failed" |
79 |
+ remove_symlink "${BIN_DIR}/rustc" |
80 |
+ rm -f "${ENV_D_PATH}/rust/last-set" \ |
81 |
+ || die -q "rm -f ${ENV_D_PATH}/rust/last-set failed" |
82 |
} |
83 |
|
84 |
# set the rust version |
85 |
# each compiler provider should install |
86 |
# files named rustc-$postfix and rustdoc-$postfix |
87 |
-# in ${EROOT}/usr/bin directory |
88 |
+# in ${BIN_DIR} directory |
89 |
# $postfix is defined as the part of $pkgname-$pkgver after the first - |
90 |
# for dev-lang/rust-bin-9999 ebuild it would be bin-9999 |
91 |
set_version() { |
92 |
@@ -135,20 +138,20 @@ set_version() { |
93 |
|
94 |
target_postfix=$(get_postfix ${target}) |
95 |
|
96 |
- [[ -z ${target_postfix} || ! -x "${EROOT}/usr/bin/rustc-${target_postfix}" ]] \ |
97 |
+ [[ -z ${target_postfix} || ! -x "${BIN_DIR}/rustc-${target_postfix}" ]] \ |
98 |
&& die -q "Target \"$1\" doesn't appear to be valid!" |
99 |
|
100 |
unset_version |
101 |
|
102 |
- set_symlink "${EROOT}/usr/bin/rustc-${target_postfix}" "${EROOT}/usr/bin/rustc" |
103 |
+ set_symlink "${BIN_DIR}/rustc-${target_postfix}" "${BIN_DIR}/rustc" |
104 |
|
105 |
local symlinks=( $(get_symlinks ${target}) ) |
106 |
for i in "${symlinks[@]}"; do |
107 |
- set_symlink "${EROOT}${i}-${target_postfix}" "${EROOT}${i}" |
108 |
+ set_symlink "${EROOT%/}${i}-${target_postfix}" "${EROOT%/}${i}" |
109 |
done |
110 |
|
111 |
- cp "${EROOT}/etc/env.d/rust/provider-${target}" \ |
112 |
- "${EROOT}/etc/env.d/rust/last-set" || \ |
113 |
+ cp "${ENV_D_PATH}/rust/provider-${target}" \ |
114 |
+ "${ENV_D_PATH}/rust/last-set" || \ |
115 |
die -q "symlink list copying failed" |
116 |
} |
117 |
|
118 |
@@ -216,7 +219,7 @@ do_update() { |
119 |
shift |
120 |
done |
121 |
|
122 |
- if [[ "${if_unset}" == "1" && -f "${EROOT}"/usr/bin/rustc ]]; then |
123 |
+ if [[ "${if_unset}" == "1" && -f "${BIN_DIR}/rustc" ]]; then |
124 |
return |
125 |
fi |
126 |
|
127 |
@@ -248,7 +251,7 @@ do_unset() { |
128 |
shift |
129 |
done |
130 |
|
131 |
- if [[ "${if_invalid}" == "1" && -e "${EROOT}"/usr/bin/rustc ]]; then |
132 |
+ if [[ "${if_invalid}" == "1" && -e "${BIN_DIR}/rustc" ]]; then |
133 |
return |
134 |
fi |