summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Junghans <ottxor@gentoo.org>2013-09-21 01:03:42 +0000
committerChristoph Junghans <ottxor@gentoo.org>2013-09-21 01:03:42 +0000
commit25655276b3ba92cba81fbb70a2d8fa77be8c5ad5 (patch)
tree83a97040c2decccad5279719855c481529b32f84 /eclass/alternatives.eclass
parentfixed TPACPI_BAT_HIGH_THRESH_STOP (bug #485526, thx to Michael) (diff)
downloadgentoo-2-25655276b3ba92cba81fbb70a2d8fa77be8c5ad5.tar.gz
gentoo-2-25655276b3ba92cba81fbb70a2d8fa77be8c5ad5.tar.bz2
gentoo-2-25655276b3ba92cba81fbb70a2d8fa77be8c5ad5.zip
added prefix support
Diffstat (limited to 'eclass/alternatives.eclass')
-rw-r--r--eclass/alternatives.eclass16
1 files changed, 10 insertions, 6 deletions
diff --git a/eclass/alternatives.eclass b/eclass/alternatives.eclass
index d5e42fdc64cb..a7d6a1b1db78 100644
--- a/eclass/alternatives.eclass
+++ b/eclass/alternatives.eclass
@@ -1,6 +1,6 @@
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/alternatives.eclass,v 1.17 2011/08/22 04:46:31 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/alternatives.eclass,v 1.18 2013/09/21 01:03:42 ottxor Exp $
# @ECLASS: alternatives.eclass
# @AUTHOR:
@@ -53,6 +53,7 @@
# @DESCRIPTION:
# automatic deduction based on a symlink and a regex mask
alternatives_auto_makesym() {
+ has "${EAPI:-0}" 0 1 2 && ! use prefix && EROOT="${ROOT}"
local SYMLINK REGEX ALT myregex
SYMLINK=$1
REGEX=$2
@@ -67,20 +68,22 @@ alternatives_auto_makesym() {
# sort a space delimited string by converting it to a multiline list
# and then run sort -r over it.
- # make sure we use ${ROOT} because otherwise stage-building will break
- ALT="$(for i in $(echo ${ROOT}${myregex}); do echo ${i#${ROOT}}; done | sort -r)"
+ # make sure we use ${EROOT} because otherwise stage-building will break
+ ALT="$(for i in $(echo ${EROOT}${myregex}); do echo ${i#${EROOT}}; done | sort -r)"
alternatives_makesym ${SYMLINK} ${ALT}
}
alternatives_makesym() {
+ has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
local ALTERNATIVES=""
local SYMLINK=""
local alt pref
# usage: alternatives_makesym <resulting symlink> [alternative targets..]
- SYMLINK=$1
+ # make sure it is in the prefix, allow it already to be in the prefix
+ SYMLINK=${EPREFIX}/${1#${EPREFIX}}
# this trick removes the trailing / from ${ROOT}
- pref=$(echo ${ROOT} | sed 's:/$::')
+ pref=${ROOT%/}
shift
ALTERNATIVES=$@
@@ -88,6 +91,7 @@ alternatives_makesym() {
# and if one exists, link it and finish.
for alt in ${ALTERNATIVES}; do
+ alt=${EPREFIX}/${alt#${EPREFIX}}
if [ -f "${pref}${alt}" ]; then
#are files in same directory?
if [ "${alt%/*}" = "${SYMLINK%/*}" ]