/[gentoo-x86]/eclass/alternatives.eclass
Gentoo

Diff of /eclass/alternatives.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.17 Revision 1.18
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2013 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/alternatives.eclass,v 1.17 2011/08/22 04:46:31 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/alternatives.eclass,v 1.18 2013/09/21 01:03:42 ottxor Exp $
4 4
5# @ECLASS: alternatives.eclass 5# @ECLASS: alternatives.eclass
6# @AUTHOR: 6# @AUTHOR:
7# Original author: Alastair Tse <liquidx@gentoo.org> (03 Oct 2003) 7# Original author: Alastair Tse <liquidx@gentoo.org> (03 Oct 2003)
8# @BLURB: Creates symlink to the latest version of multiple slotted packages. 8# @BLURB: Creates symlink to the latest version of multiple slotted packages.
51 51
52# @FUNCTION: alternatives_auto_makesym 52# @FUNCTION: alternatives_auto_makesym
53# @DESCRIPTION: 53# @DESCRIPTION:
54# automatic deduction based on a symlink and a regex mask 54# automatic deduction based on a symlink and a regex mask
55alternatives_auto_makesym() { 55alternatives_auto_makesym() {
56 has "${EAPI:-0}" 0 1 2 && ! use prefix && EROOT="${ROOT}"
56 local SYMLINK REGEX ALT myregex 57 local SYMLINK REGEX ALT myregex
57 SYMLINK=$1 58 SYMLINK=$1
58 REGEX=$2 59 REGEX=$2
59 if [ "${REGEX:0:1}" != "/" ] 60 if [ "${REGEX:0:1}" != "/" ]
60 then 61 then
65 myregex=${REGEX} 66 myregex=${REGEX}
66 fi 67 fi
67 68
68 # sort a space delimited string by converting it to a multiline list 69 # sort a space delimited string by converting it to a multiline list
69 # and then run sort -r over it. 70 # and then run sort -r over it.
70 # make sure we use ${ROOT} because otherwise stage-building will break 71 # make sure we use ${EROOT} because otherwise stage-building will break
71 ALT="$(for i in $(echo ${ROOT}${myregex}); do echo ${i#${ROOT}}; done | sort -r)" 72 ALT="$(for i in $(echo ${EROOT}${myregex}); do echo ${i#${EROOT}}; done | sort -r)"
72 alternatives_makesym ${SYMLINK} ${ALT} 73 alternatives_makesym ${SYMLINK} ${ALT}
73} 74}
74 75
75alternatives_makesym() { 76alternatives_makesym() {
77 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
76 local ALTERNATIVES="" 78 local ALTERNATIVES=""
77 local SYMLINK="" 79 local SYMLINK=""
78 local alt pref 80 local alt pref
79 81
80 # usage: alternatives_makesym <resulting symlink> [alternative targets..] 82 # usage: alternatives_makesym <resulting symlink> [alternative targets..]
81 SYMLINK=$1 83 # make sure it is in the prefix, allow it already to be in the prefix
84 SYMLINK=${EPREFIX}/${1#${EPREFIX}}
82 # this trick removes the trailing / from ${ROOT} 85 # this trick removes the trailing / from ${ROOT}
83 pref=$(echo ${ROOT} | sed 's:/$::') 86 pref=${ROOT%/}
84 shift 87 shift
85 ALTERNATIVES=$@ 88 ALTERNATIVES=$@
86 89
87 # step through given alternatives from first to last 90 # step through given alternatives from first to last
88 # and if one exists, link it and finish. 91 # and if one exists, link it and finish.
89 92
90 for alt in ${ALTERNATIVES}; do 93 for alt in ${ALTERNATIVES}; do
94 alt=${EPREFIX}/${alt#${EPREFIX}}
91 if [ -f "${pref}${alt}" ]; then 95 if [ -f "${pref}${alt}" ]; then
92 #are files in same directory? 96 #are files in same directory?
93 if [ "${alt%/*}" = "${SYMLINK%/*}" ] 97 if [ "${alt%/*}" = "${SYMLINK%/*}" ]
94 then 98 then
95 #yes; strip leading dirname from alt to create relative symlink 99 #yes; strip leading dirname from alt to create relative symlink

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18

  ViewVC Help
Powered by ViewVC 1.1.20