aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--postgresql.eselect24
1 files changed, 12 insertions, 12 deletions
diff --git a/postgresql.eselect b/postgresql.eselect
index 6468ab6..1e9ff3b 100644
--- a/postgresql.eselect
+++ b/postgresql.eselect
@@ -14,8 +14,11 @@ 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
- echo $( <"${E_PATH}"/active )
+ # ${B_PATH}/share/postgresql is a symlink. See if it's there, then
+ # find out where it links to
+ if [[ -h "${B_PATH}/share/postgresql" ]] ; then
+ canonicalise "${B_PATH}/share/postgresql" | \
+ sed 's|.*postgresql-\([1-9][0-9.]*\)|\1|'
else
echo "(none)"
fi
@@ -246,7 +249,6 @@ do_set() {
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."
echo "Setting ${SLOT} as default was successful!"
}
@@ -261,7 +263,6 @@ do_unset() {
if [[ ${SLOT} = $(active_slot) ]] ; then
echo -n "Unsetting ${SLOT} as the default installation..."
unlinker "${E_PATH}/active.links"
- rm -f "${E_PATH}/active"
echo "done."
echo "Setting a new slot as the default."
do_update
@@ -289,13 +290,13 @@ describe_update() {
do_update() {
local slot=$(active_slot)
- # Check for files managed by postgresql.eselect before 1.0
- 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"
+
+ # Remove some files outright as they're entirely useless now.
+ local f
+ for f in "${E_PATH}/active" "${E_PATH}/service"; do
+ [[ -e "${f}" ]] && rm -f "${f}"
+ done
+
local slots=($(get_slots))
local index=${#slots[@]}
@@ -313,7 +314,6 @@ do_update() {
for sym_links in "${E_PATH}"/active.links* ; do
unlinker "${sym_links}"
done
- rm -f "${E_PATH}/active"
rm -f "${ENV_FILE}"
do_action env update &> /dev/null
echo "Done!"