From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-science+bounces-1893-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	by finch.gentoo.org (Postfix) with ESMTP id DC482138247
	for <garchives@archives.gentoo.org>; Mon, 20 Jan 2014 17:54:16 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id A7A90E104F;
	Mon, 20 Jan 2014 17:53:26 +0000 (UTC)
Received: from mail-ee0-f43.google.com (mail-ee0-f43.google.com [74.125.83.43])
	(using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 04E7EE104D
	for <gentoo-science@lists.gentoo.org>; Mon, 20 Jan 2014 17:53:25 +0000 (UTC)
Received: by mail-ee0-f43.google.com with SMTP id c41so3584744eek.16
        for <gentoo-science@lists.gentoo.org>; Mon, 20 Jan 2014 09:53:24 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=from:to:subject:date:message-id:in-reply-to:references;
        bh=M7dVoy5gxBuWB+UasI7kGG2wscmsWg3O98V13vQJ+uU=;
        b=wlbLmMLuSJ0yiXCrJErf31rvdkmQIgJ1vu+0IdEtB3bm4nYYGKGiWpJPWDHvRcgaac
         hkrXs/Uca5KHlZp0lLpY4WK1ojYGKrM/Nad6RcTxtkO8z5ZWY1JCJ4LNlNr468EEnOiu
         do9Hh6rsMBShl5quVNQJLOjcpH6uOOJfx/QBFqEPYGBJNABQ/aKoWmUpVYZQ+pXA8Q7U
         9GyiucS3EhtgC6YvQeGd2IdkqSrp/hQu62TUolmi5Pj/B8m3lfMWFOaEYD4XMxN++QgR
         6NIjC7COAKgjLm+1m9CI79XDOZTrtB2cS/LI5gP3KyM6L0li145j5S9LyBSw2ejwIKKX
         xiiw==
X-Received: by 10.15.23.139 with SMTP id h11mr19194353eeu.25.1390240404622;
        Mon, 20 Jan 2014 09:53:24 -0800 (PST)
Received: from localhost.localdomain (dsl-trebrasgw2-58c0d8-67.dhcp.inet.fi. [88.192.216.67])
        by mx.google.com with ESMTPSA id o47sm5514777eem.21.2014.01.20.09.53.23
        for <gentoo-science@lists.gentoo.org>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 20 Jan 2014 09:53:24 -0800 (PST)
From: Reinis Danne <rei4dan@gmail.com>
To: gentoo-science@lists.gentoo.org
Subject: [gentoo-science] [PATCH 05/10] alternatives-2.eclass: Put commonly used path in local variable
Date: Mon, 20 Jan 2014 19:53:07 +0200
Message-Id: <1390240392-12173-6-git-send-email-rei4dan@gmail.com>
X-Mailer: git-send-email 1.8.5.3
In-Reply-To: <1390240392-12173-1-git-send-email-rei4dan@gmail.com>
References: <1390240392-12173-1-git-send-email-rei4dan@gmail.com>
Precedence: bulk
List-Post: <mailto:gentoo-science@lists.gentoo.org>
List-Help: <mailto:gentoo-science+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-science+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-science+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-science.gentoo.org>
X-BeenThere: gentoo-science@lists.gentoo.org
Reply-to: gentoo-science@lists.gentoo.org
X-Archives-Salt: cd3ad9cc-e4c3-4240-869f-d260c403f676
X-Archives-Hash: 7a9a2c6d5614fa9389fa14c579e2bb1e

---
 eclass/alternatives-2.eclass | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/eclass/alternatives-2.eclass b/eclass/alternatives-2.eclass
index 98317dd..4366601 100644
--- a/eclass/alternatives-2.eclass
+++ b/eclass/alternatives-2.eclass
@@ -108,16 +108,17 @@ cleanup_old_alternatives_module() {
 
 alternatives-2_pkg_postinst() {
 	local a alt provider module_version="20090908"
+	local EAUTO="${EROOT%/}/usr/share/eselect/modules/auto"
 	for a in "${ALTERNATIVES_PROVIDED[@]}"; do
 		alt="${a%:*}"
 		provider="${a#*:}"
-		if [[ ! -f "${EROOT%/}/usr/share/eselect/modules/auto/${alt}.eselect" \
-			|| "$(source "${EROOT%/}/usr/share/eselect/modules/auto/${alt}.eselect" &>/dev/null; echo "${VERSION}")" \
+		if [[ ! -f "${EAUTO}/${alt}.eselect" \
+			|| "$(source "${EAUTO}/${alt}.eselect" &>/dev/null; echo "${VERSION}")" \
 				-ne "${module_version}" ]]; then
-			if [[ ! -d ${EROOT%/}/usr/share/eselect/modules/auto ]]; then
-				install -d "${EROOT%/}"/usr/share/eselect/modules/auto || eerror "Could not create eselect modules dir"
+			if [[ ! -d ${EAUTO} ]]; then
+				install -d "${EAUTO}" || eerror "Could not create eselect modules dir"
 			fi
-			cat > "${EROOT%/}/usr/share/eselect/modules/auto/${alt}.eselect" <<-EOF
+			cat > "${EAUTO}/${alt}.eselect" <<-EOF
 				# This module was automatically generated by alternatives.eclass
 				DESCRIPTION="Alternatives for ${alt}"
 				VERSION="${module_version}"
@@ -139,6 +140,7 @@ alternatives-2_pkg_postinst() {
 
 alternatives-2_pkg_prerm() {
 	local a alt provider ignore
+	local EAUTO="${EROOT%/}/usr/share/eselect/modules/auto"
 	[[ -n ${REPLACED_BY_ID} ]] || ignore=" --ignore"
 	for a in "${ALTERNATIVES_PROVIDED[@]}"; do
 		alt="${a%:*}"
@@ -147,9 +149,9 @@ alternatives-2_pkg_prerm() {
 		einfo "Removed ${provider} alternative module for ${alt}, current is $(eselect ${alt} show)"
 		if [[ $? -eq 2 ]]; then
 			einfo "Cleaning up unused alternatives module for ${alt}"
-			echo rm "${EROOT%/}/usr/share/eselect/modules/auto/${alt}.eselect"
-			rm "${EROOT%/}/usr/share/eselect/modules/auto/${alt}.eselect" ||
-				eerror rm "${EROOT%/}/usr/share/eselect/modules/auto/${alt}.eselect" failed
+			echo rm "${EAUTO}/${alt}.eselect"
+			rm "${EAUTO}/${alt}.eselect" || \
+				eerror rm "${EAUTO}/${alt}.eselect" failed
 		fi
 	done
 }
-- 
1.8.5.3