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

Diff of /eclass/alternatives.eclass

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

Revision 1.4 Revision 1.7
1# Copyright 1999-2003 Gentoo Technologies, Inc. 1# Copyright 1999-2003 Gentoo Technologies, Inc.
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.4 2003/11/01 17:35:59 liquidx Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/alternatives.eclass,v 1.7 2003/11/24 10:57:06 liquidx Exp $
4 4
5# Author : Alastair Tse <liquidx@gentoo.org> (03 Oct 2003) 5# Author : Alastair Tse <liquidx@gentoo.org> (03 Oct 2003)
6# Short Desc: Creates symlink to the latest version of multiple slotted 6# Short Desc: Creates symlink to the latest version of multiple slotted
7# packages. 7# packages.
8# 8#
56 #inherit the root directory of our main link path for our regex search 56 #inherit the root directory of our main link path for our regex search
57 myregex="${SYMLINK%/*}/${REGEX}" 57 myregex="${SYMLINK%/*}/${REGEX}"
58 else 58 else
59 myregex=${REGEX} 59 myregex=${REGEX}
60 fi 60 fi
61 ALT="`echo ${myregex} | sort -r`" 61
62 # sort a space delimited string by converting it to a multiline list
63 # and then run sort -r over it.
64 ALT="$(for i in $(echo ${myregex}); do echo $i; done | sort -r)"
62 alternatives_makesym ${SYMLINK} ${ALT} 65 alternatives_makesym ${SYMLINK} ${ALT}
63} 66}
64 67
65alternatives_makesym() { 68alternatives_makesym() {
66 local ALTERNATIVES="" 69 local ALTERNATIVES=""
76 # and if one exists, link it and finish. 79 # and if one exists, link it and finish.
77 80
78 for alt in ${ALTERNATIVES}; do 81 for alt in ${ALTERNATIVES}; do
79 if [ -f "${pref}${alt}" ]; then 82 if [ -f "${pref}${alt}" ]; then
80 einfo "Linking ${alt} to ${pref}${SYMLINK}" 83 einfo "Linking ${alt} to ${pref}${SYMLINK}"
81 [ -L "${pref}${SYMLINK}" ] && rm -f ${pref}${SYMLINK}
82 #are files in same directory? 84 #are files in same directory?
83 if [ "${alt%/*}" = "${SYMLINK%/*}" ] 85 if [ "${alt%/*}" = "${SYMLINK%/*}" ]
84 then 86 then
85 #yes; strip leading dirname from alt to create relative symlink 87 #yes; strip leading dirname from alt to create relative symlink
86 ln -s ${alt##*/} ${pref}${SYMLINK} 88 ln -sf ${alt##*/} ${pref}${SYMLINK}
87 else 89 else
88 #no; keep absolute path 90 #no; keep absolute path
89 ln -s ${pref}${alt} ${pref}${SYMLINK} 91 ln -sf ${pref}${alt} ${pref}${SYMLINK}
90 fi 92 fi
91 break 93 break
92 fi 94 fi
93 done 95 done
94 96

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.7

  ViewVC Help
Powered by ViewVC 1.1.20