--- a/opengl.eselect 2009-09-12 05:27:47.000000000 +0000 +++ b/opengl.eselect 2009-09-12 15:31:22.000000000 +0000 @@ -60,11 +60,24 @@ echo ${ret} } +relpath() { + local src=$2 + local dst=$1 + local curpath="." + + while [ "${dst#${src}}" == "${dst}" ]; do + curpath=${curpath}/.. + src=$(readlink -f ${src}/${curpath}) + done + + echo ${curpath}${dst#${src}} +} + setup_lib_symlinks() { local profile_libdir=${1} local libdir=${2} local file - local rootfile + local file_relpath mkdir -p "${libdir}" || die "Failed to create ${libdir}" @@ -80,11 +93,7 @@ # loader knows to look in the profile dir, and the # linked just needs the .so for file in ${profile_libdir}/libGL{,core}.{so,a,la}; do - if [[ ${ROOT} != / ]] ; then - rootfile="${file//${ROOT}}" - else - rootfile="${file}" - fi + file_relpath=$(relpath ${file} ${libdir}) [[ -f ${file} ]] || continue if [[ -f $(basename "${file}") ]] ; then rm -f "$(basename "${file}")" || die -q "Failed to delete ${libdir}/$(basename "${file}")" @@ -94,7 +103,7 @@ if [[ ${file%.la} != ${file} ]] ; then sed "s:${profile_libdir}:${libdir}:g" "${file}" > "$(basename "${file}")" || die -q "Failed to create ${libdir}/$(basename "${file}")" else - ln -s "${rootfile}" || die -q "Failed to create ${libdir}/$(basename "${file}")" + ln -s "${file_relpath}" || die -q "Failed to create ${libdir}/$(basename "${file}")" fi done popd &> /dev/null