diff options
author | Aaron W. Swenson <titanofold@gentoo.org> | 2013-01-20 23:39:42 +0000 |
---|---|---|
committer | Aaron W. Swenson <titanofold@gentoo.org> | 2013-01-20 23:39:42 +0000 |
commit | fa27c26198160cad1f0debf752ba3a6e1b003dad (patch) | |
tree | 5dcc7b632c7f6ec57ea2df3fa54b329a11130248 | |
parent | Removed SVN_DATE. (diff) | |
download | eselect-fa27c26198160cad1f0debf752ba3a6e1b003dad.tar.gz eselect-fa27c26198160cad1f0debf752ba3a6e1b003dad.tar.bz2 eselect-fa27c26198160cad1f0debf752ba3a6e1b003dad.zip |
Use relative paths instead of absolute paths. Fix bug 321114.
-rw-r--r-- | postgresql.eselect | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/postgresql.eselect b/postgresql.eselect index 6b1591e..7e97ed8 100644 --- a/postgresql.eselect +++ b/postgresql.eselect @@ -47,6 +47,7 @@ linker() { local suffix=$4 local link_source local findings + local rel_source # Prevent passed patterns from being globbed # If this module is run in /usr, '-name lib*' ends up globbing 'lib*', @@ -64,8 +65,11 @@ linker() { [[ -e ${link_target} ]] && \ die -q "The target '${link_target}' still exists and could not be removed!" - ln -s "${link_source}" "${link_target}" || die -q "Unable to create link!" - echo "${link_target}" >> "${E_PATH}"/active.links${suffix} + # Create relative links so that they work both here and inside the new + # root if $ROOT is not "/". + rel_source=$(relative_name "${link_source}" "${target_dir}") + ln -s "${rel_source}" "${link_target}" || die -q "Unable to create link!" + echo "${link_target##${ROOT%/}/}" >> "${E_PATH}"/active.links${suffix} done } @@ -77,8 +81,9 @@ unlinker() { if [[ -r ${active_link_file} ]] ; then local active_links=($(<"${active_link_file}")) for (( i=0; $i < ${#active_links[@]}; i++ )) ; do - [[ -h ${active_links[$i]} ]] && rm -f "${active_links[$i]}" - [[ -e ${active_links[$i]} ]] && \ + [[ -h "${ROOT%/}/${active_links[$i]}" ]] && \ + rm -f "${ROOT%/}/${active_links[$i]}" + [[ -e "${ROOT%/}/${active_links[$i]}" ]] && \ die -q "The target '${active_links[$i]}' still exists and could not be removed!" done @@ -178,7 +183,9 @@ do_set() { "${B_PATH}"/include/libpq "${B_PATH}"/include/postgres_ext.h ) + # The linker function cannot accomadate this special purpose. + local rel_source local i for (( i=0; $i < ${#sources[@]}; i++ )) ; do # Remove target before creating the symlink @@ -188,8 +195,12 @@ do_set() { [[ -e ${targets[$i]} ]] && \ die -q "The target '${targets[$i]}' exists and could not be removed!" - ln -s "${sources[$i]}" "${targets[$i]}" || die -q "Unable to create link!" - echo "${targets[$i]}" >> "${E_PATH}"/active.links + # Create relative links so that they work both here and inside the new + # root if $ROOT is not "/" + rel_source=$(relative_name "${sources[$i]}" "$(dirname "${target[$i]}")") + + ln -s "$rel_source" "${targets[$i]}" || die -q "Unable to create link!" + echo "${targets[$i]##${ROOT%/}/}" >> "${E_PATH}"/active.links done # Link modules to /usr/lib{,32,64}/ @@ -197,9 +208,10 @@ do_set() { for x in $(list_libdirs) ; do if [[ -d ${B_PATH}/${x}/postgresql-${SLOT}/${x} ]] ; then # 'linker' function doesn't work for linking directories. - # Default lib path - ln -s "${B_PATH}/${x}/postgresql-${SLOT}/${x}" "${B_PATH}/${x}/postgresql" - echo "${B_PATH}/${x}/postgresql" >> "${E_PATH}"/active.links + # Default lib path - create a relative link + ln -s "postgresql-${SLOT}/${x}" "${B_PATH}/${x}/postgresql" + echo "${B_PATH##${ROOT%/}/}/${x}/postgresql" >> \ + "${E_PATH}"/active.links # Linker works for files linker "${B_PATH}/${x}/postgresql-${SLOT}/${x}/" \ "-name lib*" "${B_PATH}/${x}" @@ -210,9 +222,10 @@ do_set() { linker "${B_PATH}/$(lib_dir)/postgresql-${SLOT}/bin/" \ "-type f" "${B_PATH}/bin" - # Default share path - ln -s "${B_PATH}/share/postgresql-${SLOT}" "${B_PATH}/share/postgresql" - echo "${B_PATH}/share/postgresql" >> "${E_PATH}/active.links" + # Default share path - use a relative link here by just specifying the + # base name + ln -s "postgresql-${SLOT}" "${B_PATH}/share/postgresql" + echo "${B_PATH##${ROOT%/}/}/share/postgresql" >> "${E_PATH}/active.links" echo ${SLOT} > "${E_PATH}/active" echo "done." |