From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id AD1C8138334 for ; Mon, 11 Mar 2019 05:02:49 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C3C4EE0C12; Mon, 11 Mar 2019 05:02:48 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 96EABE0C12 for ; Mon, 11 Mar 2019 05:02:48 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 47838335D3B for ; Mon, 11 Mar 2019 05:02:46 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id E06BE567 for ; Mon, 11 Mar 2019 05:02:44 +0000 (UTC) From: "Thomas Deutschmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Thomas Deutschmann" Message-ID: <1552280076.99577f8e98440da176709b6e4b988b40ae42b8d1.whissi@gentoo> Subject: [gentoo-commits] proj/eselect-rust:master commit in: / X-VCS-Repository: proj/eselect-rust X-VCS-Files: rust.eselect.in X-VCS-Directories: / X-VCS-Committer: whissi X-VCS-Committer-Name: Thomas Deutschmann X-VCS-Revision: 99577f8e98440da176709b6e4b988b40ae42b8d1 X-VCS-Branch: master Date: Mon, 11 Mar 2019 05:02:44 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 5bd54166-aeee-40d1-9aa8-d33df331b304 X-Archives-Hash: 7a3700bb6d6401bc71e91970fe941fbd commit: 99577f8e98440da176709b6e4b988b40ae42b8d1 Author: Thomas Deutschmann gentoo org> AuthorDate: Mon Mar 11 00:42:52 2019 +0000 Commit: Thomas Deutschmann gentoo org> CommitDate: Mon Mar 11 04:54:36 2019 +0000 URL: https://gitweb.gentoo.org/proj/eselect-rust.git/commit/?id=99577f8e 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 gentoo.org> rust.eselect.in | 40 ++++++++++++++++++++++++++++++++++++---- 1 file 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"