diff options
author | Aaron W. Swenson <titanofold@gentoo.org> | 2016-10-30 14:27:49 -0400 |
---|---|---|
committer | Aaron W. Swenson <titanofold@gentoo.org> | 2016-10-30 14:27:49 -0400 |
commit | bf55487f97abc7370d1ac4acefa521ef6baeecb8 (patch) | |
tree | 850dfcc9eed64a4510a51d99ebfbd344cafaad90 | |
parent | Fix typo (diff) | |
download | eselect-bf55487f97abc7370d1ac4acefa521ef6baeecb8.tar.gz eselect-bf55487f97abc7370d1ac4acefa521ef6baeecb8.tar.bz2 eselect-bf55487f97abc7370d1ac4acefa521ef6baeecb8.zip |
Add pkg-config support
Among some other cleanups, add pkg-config support.
-rw-r--r-- | postgresql.eselect | 59 |
1 files changed, 25 insertions, 34 deletions
diff --git a/postgresql.eselect b/postgresql.eselect index 9bb009a..7ff9b83 100644 --- a/postgresql.eselect +++ b/postgresql.eselect @@ -103,19 +103,6 @@ linker() { done } -### TODO: Refactor so that it searches source directories for removal targets, -### and move the old stuff into do_update - -### Unlinker Function ### -# Takes one argument: -# - Full path to active links file (e.g. /etc/eselect/postgresql/active.links) -unlinker() { - local dir - local pattern - local findings - -} - ### Get Slots Function ### # Find all available slots in the preferred lib_dir() and return them. get_slots() { @@ -123,8 +110,8 @@ get_slots() { local found_slots for slot in $(find "${USR_PATH}/$(lib_dir)/" -maxdepth 1 -type d \ - -regex '.*postgresql-[0-9][0-9]*\.[0-9][0-9]*' | \ - sed -re 's#.*([0-9]+\.[0-9]+)$#\1#' | sort -n) + -regex '.*/postgresql-[1-9][0-9]*\.*[0-9]*' | \ + sed -re 's#.*([1-9][0-9]*\.*[0-9]*)$#\1#' | sort -n) do # Check that pg_config exists for this slot, otherwise we have # a false positive. @@ -282,19 +269,13 @@ describe_unset() { # Undo everything done by do_set(). do_unset() { local SLOT=$1 - if [[ ${SLOT} = $(active_slot) ]] ; then - echo -n "Unsetting ${SLOT} as the default installation..." - - echo "done." - echo "Setting a new slot as the default." - do_update - else - echo "Inactive slot selected. No work to do." + if [[ ${SLOT} != $(active_slot) ]] ; then + echo "Slot already inactive; no work to do." + return 0 fi local l for l in ${INCLUDE_TARGETS[@]} "${USR_PATH}/share/postgresql" ; do - # Remove target before creating the symlink [[ -h ${l} ]] && rm -f "${l}" # Check if include target still exists @@ -302,16 +283,19 @@ do_unset() { die -q "The target '${l}' exists and could not be removed!" done + for l in $(find "${USR_PATH}/bin" -type l) ; do + if [[ $(realpath ${l} | grep -c postgresql) -ge 1 ]] ; then + rm "${l}" + fi + done + for x in $(list_libdirs) ; do - if [[ -d ${USR_PATH}/${x}/postgresql-${SLOT}/${x} ]] ; then - if [[ -h "${USR_PATH}/${x}/postgresql" ]] ; then - rm -f "${USR_PATH}/${x}/postgresql" - [[ -e "${USR_PATH}/${x}/postgresql" ]] && \ - die -q "Unable to remove '${USR_PATH}/${x}/postgresql'" - fi - - unlinker "${USR_PATH}/${x}/postgresql-${SLOT}/${x}/" \ - "-name lib*" "${USR_PATH}/${x}" + if [[ -h "${USR_PATH}/${x}/postgresql" ]] ; then + for l in $(find "${USR_PATH}/${x}" -type l) ; do + if [[ $(realpath ${l} | grep -c postgresql) -ge 1 ]] ; then + rm "${l}" + fi + done fi done } @@ -401,18 +385,24 @@ do_update() { # Update paths to libs and man pages local ldpath + local pcpath local x for x in $(list_libdirs) ; do - [[ -h ${USR_PATH}/${x}/postgresql ]] && \ + if [[ -h ${USR_PATH}/${x}/postgresql ]] ; then ldpath+="${USR_PATH}/${x}/postgresql:" + pcpath+="${USR_PATH}/${x}/postgresql/pkgconfig:" + fi done ldpath="${ldpath%:}" + pcdpath="${pcpath%:}" local manpath="${USR_PATH}/share/postgresql/man/" while [[ $[--index] -gt -1 ]] ; do local curslot="${slots[$index]}" for x in $(list_libdirs) ; do local lib_path="${USR_PATH}/${x}/postgresql-${curslot}/${x}/" + local pkg_path="${lib_path}/pkgconfig" [[ -d ${lib_path} ]] && ldpath+=":${lib_path}" + [[ -d ${pkg_path} ]] && pcpath+=":${pcpath}" done local tmp_manpath="${USR_PATH}/share/postgresql-${curslot}/man/" [[ -d ${tmp_manpath} ]] && manpath+=":${tmp_manpath}" @@ -421,5 +411,6 @@ do_update() { store_config "${ENV_FILE}" LDPATH "${ldpath}" store_config "${ENV_FILE}" MANPATH "${manpath}" + store_config "${ENV_FILE}" PKG_CONFIG_PATH "${pcpath}" do_action env update &> /dev/null } |