aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'postgresql.eselect')
-rw-r--r--postgresql.eselect44
1 files changed, 23 insertions, 21 deletions
diff --git a/postgresql.eselect b/postgresql.eselect
index 36fedb8..84e1167 100644
--- a/postgresql.eselect
+++ b/postgresql.eselect
@@ -15,7 +15,7 @@ E_PATH="${EROOT%/}/etc/eselect/postgresql"
ENV_FILE="${EROOT%/}/etc/env.d/50postgresql"
active_slot() {
- if [[ -r "${E_PATH}"/active && -n "${E_PATH}"/active ]] ; then
+ if [[ -r ${E_PATH}/active && -n ${E_PATH}/active ]] ; then
echo $( <"${E_PATH}"/active )
else
echo "(none)"
@@ -25,10 +25,10 @@ active_slot() {
lib_dir() {
local lib_list=$(list_libdirs)
if [[ ${lib_list} =~ .*lib64.* && \
- "$(ls -d ${B_PATH}/lib64/postgresql-*/lib)" != "" ]] ; then
+ $(ls -d ${B_PATH}/lib64/postgresql-*/lib) != "" ]] ; then
echo "lib64"
elif [[ ${lib_list} =~ .*lib32.* && \
- "$(ls -d ${B_PATH}/lib32/postgresql-*/lib)" != "" ]] ; then
+ $(ls -d ${B_PATH}/lib32/postgresql-*/lib) != "" ]] ; then
echo "lib32"
else
echo "lib"
@@ -52,8 +52,8 @@ linker() {
local link_target="${target_dir%/}/$(basename ${link_source})${suffix}"
# For good measure, remove target before creating the symlink
- [[ -h "${link_target}" ]] && rm -f "${link_target}"
- [[ -e "${link_target}" ]] && \
+ [[ -h ${link_target} ]] && rm -f "${link_target}"
+ [[ -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!"
@@ -66,11 +66,11 @@ linker() {
# - Full path to active links file (e.g. /etc/eselect/postgresql/active.links)
unlinker() {
local active_link_file=$1
- if [ -r "${active_link_file}" ] ; then
+ 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 ${active_links[$i]} ]] && rm -f "${active_links[$i]}"
+ [[ -e ${active_links[$i]} ]] && \
die -q "The target '${active_links[$i]}' still exists and could not be removed!"
done
@@ -102,7 +102,7 @@ do_list() {
local postgres_ebuilds=""
local src
for src in "${E_PATH}"/slots/${slot}/{server,service,base,docs} ; do
- [ -r "${src}" ] && source "${src}"
+ [[ -r ${src} ]] && source "${src}"
done
case "${slot}" in
@@ -113,7 +113,7 @@ do_list() {
esac
done
- [ -z "${postgres_ebuilds}" ] && write_warning_msg "No slots available."
+ [[ -z "${postgres_ebuilds}" ]] && write_warning_msg "No slots available."
fi
}
@@ -143,7 +143,7 @@ describe_set() {
do_set() {
local SLOT=$1
- if [ ! -d "${B_PATH}"/$(lib_dir)/postgresql-${SLOT} ] ; then
+ if [[ ! -d ${B_PATH}/$(lib_dir)/postgresql-${SLOT} ]] ; then
die -q "Not a valid slot."
fi
@@ -174,10 +174,10 @@ do_set() {
local i
for (( i=0; $i < ${#sources[@]}; i++ )) ; do
# Remove target before creating the symlink
- [[ -h "${targets[$i]}" ]] && rm -f "${targets[$i]}"
+ [[ -h ${targets[$i]} ]] && rm -f "${targets[$i]}"
# Check if link_target still exists
- [[ -e "${targets[$i]}" ]] && \
+ [[ -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!"
@@ -187,7 +187,7 @@ do_set() {
# Link modules to /usr/lib{,lib32,lib64}/
local x
for x in $(list_libdirs) ; do
- if [[ -d "${B_PATH}/${x}/postgresql-${SLOT}/${x}" ]] ; then
+ 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"
@@ -218,7 +218,7 @@ describe_unset() {
do_unset() {
local SLOT=$1
- if [[ "${SLOT}" = "$(active_slot)" ]] ; then
+ if [[ ${SLOT} = $(active_slot) ]] ; then
echo -n "Unsetting ${SLOT} as the default installation..."
unlinker "${E_PATH}/active.links"
rm -f "${E_PATH}/active"
@@ -235,7 +235,7 @@ describe_reset() {
do_reset() {
local SLOT=$(active_slot)
- [[ "${SLOT}" = "(none)" ]] && die -q "No active slot to reset."
+ [[ ${SLOT} = "(none)" ]] && die -q "No active slot to reset."
do_unset ${SLOT}
do_set ${SLOT}
}
@@ -248,10 +248,12 @@ describe_update() {
do_update() {
local slot=$(active_slot)
# Check for files managed by postgresql.eselect before 1.0
- [[ -h "${E_PATH}active" ]] && \
- slot="$(basename $(canonicalise ${E_PATH/active))"
+ if [[ -h ${E_PATH}/active ]] ; then
+ slot="$(basename $(canonicalise ${E_PATH}/active)))"
+ rm -f "${E_PATH}/active"
+ fi
# Remove service file outright.
- [[ -h "${E_PATH}/service" ]] && rm -f "${E_PATH}/service"
+ [[ -h ${E_PATH}/service ]] && rm -f "${E_PATH}/service"
local slots=($(get_slots))
local index=${#slots[@]}
@@ -296,7 +298,7 @@ do_update() {
local ldpath
local x
for x in $(list_libdirs) ; do
- [[ -h "${B_PATH}"/${x}/postgresql ]] && \
+ [[ -h ${B_PATH}/${x}/postgresql ]] && \
ldpath+="${B_PATH}/${x}/postgresql:"
done
ldpath="${ldpath%:}"
@@ -305,7 +307,7 @@ do_update() {
local curslot="${slots[$index]}"
echo -n "Refreshing symbolic links for ${curslot} applications (like "
echo -n "/usr/bin/psql${curslot//.})..."
- for x in ${LIB_LIST} ; do
+ for x in $(list_libdirs) ; do
local lib_path="${B_PATH}/${x}/postgresql-${curslot}/${x}/"
[[ -d ${lib_path} ]] && ldpath+=":${lib_path}"
done