summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorAlastair Tse <liquidx@gentoo.org>2003-11-01 17:35:59 +0000
committerAlastair Tse <liquidx@gentoo.org>2003-11-01 17:35:59 +0000
commitf10cdcc89062fde166bd2b059a11b347ac15aca7 (patch)
tree7b3303c41da3ed0fdd3777b37deb5071af72fa4a /eclass
parentFixed KEYWORDS (diff)
downloadhistorical-f10cdcc89062fde166bd2b059a11b347ac15aca7.tar.gz
historical-f10cdcc89062fde166bd2b059a11b347ac15aca7.tar.bz2
historical-f10cdcc89062fde166bd2b059a11b347ac15aca7.zip
added changes by drobbins with makesym() to do relative path targets
Diffstat (limited to 'eclass')
-rw-r--r--eclass/alternatives.eclass60
-rw-r--r--eclass/python.eclass6
2 files changed, 39 insertions, 27 deletions
diff --git a/eclass/alternatives.eclass b/eclass/alternatives.eclass
index f1596bf977f3..0fb84bf5eaf1 100644
--- a/eclass/alternatives.eclass
+++ b/eclass/alternatives.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/alternatives.eclass,v 1.3 2003/10/07 20:28:52 liquidx Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/alternatives.eclass,v 1.4 2003/11/01 17:35:59 liquidx Exp $
# Author : Alastair Tse <liquidx@gentoo.org> (03 Oct 2003)
# Short Desc: Creates symlink to the latest version of multiple slotted
@@ -47,25 +47,28 @@ INHERITED="$INHERITED $ECLASS"
# automatic deduction based on a symlink and a regex mask
alternatives_auto_makesym() {
- local SOURCE REGEX ALT
- local unsorted
- SOURCE=$1
+ local SYMLINK REGEX ALT myregex
+ SYMLINK=$1
REGEX=$2
-
- ALT="`ls -1 --color=never ${ROOT}${REGEX} | sed -e "s:^${ROOT}::" | sort -r | xargs`"
- if [ -n "${ALT}" ]; then
- alternatives_makesym ${SOURCE} ${ALT}
+ if [ "${REGEX:0:1}" != "/" ]
+ then
+ #not an absolute path:
+ #inherit the root directory of our main link path for our regex search
+ myregex="${SYMLINK%/*}/${REGEX}"
else
- eerror "regex ${REGEX} doesn't match any files."
- fi
+ myregex=${REGEX}
+ fi
+ ALT="`echo ${myregex} | sort -r`"
+ alternatives_makesym ${SYMLINK} ${ALT}
}
alternatives_makesym() {
local ALTERNATIVES=""
- local SOURCE=""
-
+ local SYMLINK=""
+ local alt pref
# usage: alternatives_makesym <resulting symlink> [alternative targets..]
- SOURCE=$1
+ SYMLINK=$1
+ pref=${ROOT:0:${#ROOT}-1}
shift
ALTERNATIVES=$@
@@ -73,23 +76,32 @@ alternatives_makesym() {
# and if one exists, link it and finish.
for alt in ${ALTERNATIVES}; do
- if [ -f "${ROOT}${alt}" ]; then
- if [ -L "${ROOT}${SOURCE}" ]; then
- rm -f ${ROOT}${SOURCE}
+ if [ -f "${pref}${alt}" ]; then
+ einfo "Linking ${alt} to ${pref}${SYMLINK}"
+ [ -L "${pref}${SYMLINK}" ] && rm -f ${pref}${SYMLINK}
+ #are files in same directory?
+ if [ "${alt%/*}" = "${SYMLINK%/*}" ]
+ then
+ #yes; strip leading dirname from alt to create relative symlink
+ ln -s ${alt##*/} ${pref}${SYMLINK}
+ else
+ #no; keep absolute path
+ ln -s ${pref}${alt} ${pref}${SYMLINK}
fi
- einfo "Linking ${alt} to ${SOURCE}"
- # we do this instead of ${ROOT}${SOURCE} because if
- # ROOT=/, then a symlink to //usr/bin/python confuses distutils
- cd ${ROOT}; ln -s ${alt} ${SOURCE}
break
fi
done
# report any errors
- if [ ! -L ${ROOT}${SOURCE} ]; then
- ewarn "Unable to establish ${SOURCE} symlink"
- elif [ ! -f "`readlink ${ROOT}${SOURCE}`" -a ! -f "${ROOT}`readlink ${ROOT}${SOURE}`" ]; then
- ewarn "${SOURCE} is a dead symlink."
+ if [ ! -L ${pref}${SYMLINK} ]; then
+ ewarn "Unable to establish ${pref}${SYMLINK} symlink"
+ else
+ # we need to check for either the target being in relative path form
+ # or absolute path form
+ if [ ! -f "`dirname ${pref}${SYMLINK}`/`readlink ${pref}${SYMLINK}`" -a \
+ ! -f "`readlink ${pref}${SYMLINK}`" ]; then
+ ewarn "${pref}${SYMLINK} is a dead symlink."
+ fi
fi
}
diff --git a/eclass/python.eclass b/eclass/python.eclass
index aa93218c8203..cd6a484c4b54 100644
--- a/eclass/python.eclass
+++ b/eclass/python.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.7 2003/10/24 07:12:42 pythonhead Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.8 2003/11/01 17:35:59 liquidx Exp $
#
# Author: Alastair Tse <liquidx@gentoo.org>
#
@@ -63,8 +63,8 @@ python_version() {
# to the latest installed version
#
python_makesym() {
- alternatives_auto_makesym "/usr/bin/python" "/usr/bin/python[0-9].[0-9]"
- alternatives_auto_makesym "/usr/bin/python2" "/usr/bin/python[0-9].[0-9]"
+ alternatives_auto_makesym "/usr/bin/python" "python[0-9].[0-9]"
+ alternatives_auto_makesym "/usr/bin/python2" "python2.[0-9]"
}
#