public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Thomas Deutschmann" <whissi@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/eselect-rust:master commit in: /
Date: Mon, 11 Mar 2019 05:02:44 +0000 (UTC)	[thread overview]
Message-ID: <1552277913.5799b7ee8492860b6dfc5542d04a2d2a2e3f7d56.whissi@gentoo> (raw)

commit:     5799b7ee8492860b6dfc5542d04a2d2a2e3f7d56
Author:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 10 03:33:35 2019 +0000
Commit:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Mon Mar 11 04:18:33 2019 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-rust.git/commit/?id=5799b7ee

Use variables for common used paths

Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>

 rust.eselect.in | 37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/rust.eselect.in b/rust.eselect.in
index 96fba74..02f7b75 100644
--- a/rust.eselect.in
+++ b/rust.eselect.in
@@ -5,17 +5,20 @@ DESCRIPTION="Manage the Rust compiler versions"
 MAINTAINER="rust@gentoo.org"
 VERSION="@VERSION@"
 
+ENV_D_PATH="${EROOT%/}/etc/env.d"
+BIN_DIR="${EROOT%/}/usr/bin"
+
 inherit package-manager path-manipulation
 
 # find a list of installed rust compilers
 # each compiler provider should install
 # a config file named provider-$pkgname-$pkgver
-# in "${EROOT}"/etc/env.d/rust directory
+# in "${ENV_D_PATH}/rust" directory
 # this function prints list of $pkgname-$pkgver values
 find_targets() {
 	local f
 	local -a providers
-	for f in "${EROOT}"/etc/env.d/rust/provider-*; do
+	for f in "${ENV_D_PATH}"/rust/provider-*; do
 		[[ -f ${f} ]] || continue
 		providers=("${providers[@]}" "${f##*/provider-}")
 	done
@@ -33,7 +36,7 @@ get_current_target() {
 	local i targets=( $(find_targets) )
 	for (( i = 0; i < ${#targets[@]}; i++ )); do
 		[[ rustc-$(get_postfix ${targets[i]}) = \
-			$(basename "$(canonicalise "${EROOT}/usr/bin/rustc")") ]] \
+			$(basename "$(canonicalise "${BIN_DIR}/rustc")") ]] \
 		&& echo $i && return 0
 	done
 	echo "NOT_SET"
@@ -60,7 +63,7 @@ get_symlinks_from_file() {
 
 #get last set symlinks
 get_last_set_symlinks() {
-	local symlinks=( $(get_symlinks_from_file "${EROOT}/etc/env.d/rust/last-set") )
+	local symlinks=( $(get_symlinks_from_file "${ENV_D_PATH}/rust/last-set") )
 	echo "${symlinks[@]}"
 }
 
@@ -76,7 +79,7 @@ get_symlinks() {
 		target=${targets[target]}
 	fi
 
-	local symlinks=( $(get_symlinks_from_file "${EROOT}/etc/env.d/rust/provider-${target}") )
+	local symlinks=( $(get_symlinks_from_file "${ENV_D_PATH}/rust/provider-${target}") )
 	echo "${symlinks[@]}"
 }
 
@@ -112,17 +115,17 @@ set_symlink() {
 unset_version() {
 	local symlinks=( $(get_last_set_symlinks) )
 	for i in "${symlinks[@]}"; do
-		remove_symlink "${EROOT}${i}"
+		remove_symlink "${EROOT%/}${i}"
 	done
-	remove_symlink "${EROOT}/usr/bin/rustc"
-	rm -f "${EROOT}/etc/env.d/rust/last-set" \
-		|| die -q "rm -f ${EROOT}/etc/env.d/rust/last-set failed"
+	remove_symlink "${BIN_DIR}/rustc"
+	rm -f "${ENV_D_PATH}/rust/last-set" \
+		|| die -q "rm -f ${ENV_D_PATH}/rust/last-set failed"
 }
 
 # set the rust version
 # each compiler provider should install
 # files named rustc-$postfix and rustdoc-$postfix
-# in ${EROOT}/usr/bin directory
+# in ${BIN_DIR} directory
 # $postfix is defined as the part of $pkgname-$pkgver after the first -
 # for dev-lang/rust-bin-9999 ebuild it would be bin-9999
 set_version() {
@@ -135,20 +138,20 @@ set_version() {
 
 	target_postfix=$(get_postfix ${target})
 
-	[[ -z ${target_postfix} || ! -x "${EROOT}/usr/bin/rustc-${target_postfix}" ]] \
+	[[ -z ${target_postfix} || ! -x "${BIN_DIR}/rustc-${target_postfix}" ]] \
 		&& die -q "Target \"$1\" doesn't appear to be valid!"
 
 	unset_version
 
-	set_symlink "${EROOT}/usr/bin/rustc-${target_postfix}" "${EROOT}/usr/bin/rustc"
+	set_symlink "${BIN_DIR}/rustc-${target_postfix}" "${BIN_DIR}/rustc"
 
 	local symlinks=( $(get_symlinks ${target}) )
 	for i in "${symlinks[@]}"; do
-		set_symlink "${EROOT}${i}-${target_postfix}" "${EROOT}${i}"
+		set_symlink "${EROOT%/}${i}-${target_postfix}" "${EROOT%/}${i}"
 	done
 
-	cp "${EROOT}/etc/env.d/rust/provider-${target}" \
-	   "${EROOT}/etc/env.d/rust/last-set" || \
+	cp "${ENV_D_PATH}/rust/provider-${target}" \
+	   "${ENV_D_PATH}/rust/last-set" || \
 	    die -q "symlink list copying failed"
 }
 
@@ -216,7 +219,7 @@ do_update() {
 		shift
 	done
 
-	if [[ "${if_unset}" == "1" && -f "${EROOT}"/usr/bin/rustc ]]; then
+	if [[ "${if_unset}" == "1" && -f "${BIN_DIR}/rustc" ]]; then
 		return
 	fi
 
@@ -248,7 +251,7 @@ do_unset() {
 		shift
 	done
 
-	if [[ "${if_invalid}" == "1" && -e "${EROOT}"/usr/bin/rustc ]]; then
+	if [[ "${if_invalid}" == "1" && -e "${BIN_DIR}/rustc" ]]; then
 		return
 	fi
 


             reply	other threads:[~2019-03-11  5:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-11  5:02 Thomas Deutschmann [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-07-03  7:49 [gentoo-commits] proj/eselect-rust:master commit in: / Georgy Yakovlev
2020-04-19  1:21 Thomas Deutschmann
2020-04-19  1:21 Thomas Deutschmann
2020-04-19  1:21 Thomas Deutschmann
2020-01-01 22:25 Thomas Deutschmann
2020-01-01 22:25 Thomas Deutschmann
2020-01-01 22:05 Thomas Deutschmann
2019-03-11  5:02 Thomas Deutschmann
2019-03-11  5:02 Thomas Deutschmann
2019-03-11  5:02 Thomas Deutschmann
2019-03-11  5:02 Thomas Deutschmann
2019-03-11  5:02 Thomas Deutschmann
2019-03-11  5:02 Thomas Deutschmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1552277913.5799b7ee8492860b6dfc5542d04a2d2a2e3f7d56.whissi@gentoo \
    --to=whissi@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox