| 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.6 2003/11/01 18:33:58 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 | # |
| … | |
… | |
| 79 | # and if one exists, link it and finish. |
79 | # and if one exists, link it and finish. |
| 80 | |
80 | |
| 81 | for alt in ${ALTERNATIVES}; do |
81 | for alt in ${ALTERNATIVES}; do |
| 82 | if [ -f "${pref}${alt}" ]; then |
82 | if [ -f "${pref}${alt}" ]; then |
| 83 | einfo "Linking ${alt} to ${pref}${SYMLINK}" |
83 | einfo "Linking ${alt} to ${pref}${SYMLINK}" |
| 84 | [ -L "${pref}${SYMLINK}" ] && rm -f ${pref}${SYMLINK} |
|
|
| 85 | #are files in same directory? |
84 | #are files in same directory? |
| 86 | if [ "${alt%/*}" = "${SYMLINK%/*}" ] |
85 | if [ "${alt%/*}" = "${SYMLINK%/*}" ] |
| 87 | then |
86 | then |
| 88 | #yes; strip leading dirname from alt to create relative symlink |
87 | #yes; strip leading dirname from alt to create relative symlink |
| 89 | ln -s ${alt##*/} ${pref}${SYMLINK} |
88 | ln -sf ${alt##*/} ${pref}${SYMLINK} |
| 90 | else |
89 | else |
| 91 | #no; keep absolute path |
90 | #no; keep absolute path |
| 92 | ln -s ${pref}${alt} ${pref}${SYMLINK} |
91 | ln -sf ${pref}${alt} ${pref}${SYMLINK} |
| 93 | fi |
92 | fi |
| 94 | break |
93 | break |
| 95 | fi |
94 | fi |
| 96 | done |
95 | done |
| 97 | |
96 | |