diff options
author | 2019-03-11 01:42:52 +0100 | |
---|---|---|
committer | 2019-03-11 05:54:36 +0100 | |
commit | 99577f8e98440da176709b6e4b988b40ae42b8d1 (patch) | |
tree | c8a260de3aa5e382fdc21e66b2b8576a5a43f9da | |
parent | Use variables for common used paths (diff) | |
download | eselect-rust-99577f8e98440da176709b6e4b988b40ae42b8d1.tar.gz eselect-rust-99577f8e98440da176709b6e4b988b40ae42b8d1.tar.bz2 eselect-rust-99577f8e98440da176709b6e4b988b40ae42b8d1.zip |
Add and make use of find_missing_broken_symlinks()
dev-lang/rust or dev-lang/rust-bin install more than one binary (program),
just checking for "rustc" is not enough.
In addition, set of installed programs depends on USE flags.
This new (internal) function will check for all provided programs.
Bug: https://bugs.gentoo.org/671182
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
-rw-r--r-- | rust.eselect.in | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/rust.eselect.in b/rust.eselect.in index 02f7b75..d0f3361 100644 --- a/rust.eselect.in +++ b/rust.eselect.in @@ -10,6 +10,28 @@ BIN_DIR="${EROOT%/}/usr/bin" inherit package-manager path-manipulation +# find a list of missing or broken symlinks +# each compiler installs a list of provided programs. +# this function checks if a symlink for a provided program +# is missing or broken for the current active Rust implementation +find_missing_broken_symlinks() { + local -a missing_symlinks + local required_symlinks=( "/usr/bin/rustc" $(get_last_set_symlinks) ) + + for i in "${required_symlinks[@]}"; do + local symlink="${EROOT%/}${i}" + + if [[ -L "${symlink}" && -e "${symlink}" ]]; then + # existing symlink + continue + else + missing_symlinks+=( "${symlink}" ) + fi + done + + echo "${missing_symlinks[@]}" +} + # find a list of installed rust compilers # each compiler provider should install # a config file named provider-$pkgname-$pkgver @@ -219,8 +241,13 @@ do_update() { shift done - if [[ "${if_unset}" == "1" && -f "${BIN_DIR}/rustc" ]]; then - return + if [[ "${if_unset}" == "1" ]]; then + local missing_symlinks=( $(find_missing_broken_symlinks) ) + if [[ ${#missing_symlinks[@]} -eq 0 ]]; then + return + else + echo "Not all symlinks set. Will switch to the most recent Rust compiler!" + fi fi local targets=( $(find_targets) ) @@ -251,8 +278,13 @@ do_unset() { shift done - if [[ "${if_invalid}" == "1" && -e "${BIN_DIR}/rustc" ]]; then - return + if [[ "${if_invalid}" == "1" ]]; then + local missing_symlinks=( $(find_missing_broken_symlinks) ) + if [[ ${#missing_symlinks[@]} -eq 0 ]]; then + return + else + echo "Not all symlinks set. Will unset current symlinked Rust binaries!" + fi fi unset_version || die -q "Couldn't unset active version" |