[gentoo-commits] proj/postgresql/eselect:master commit in: /

2018-10-21 Thread Aaron Swenson
commit: d6f5ae7a05ef4f6d17676b4475ab8fd43aa5979b
Author: Aaron W. Swenson  grandmasfridge  org>
AuthorDate: Mon Aug 13 10:15:14 2018 +
Commit: Aaron Swenson  gentoo  org>
CommitDate: Mon Aug 13 10:15:14 2018 +
URL:
https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=d6f5ae7a

Bump to 2.4

 postgresql.eselect | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/postgresql.eselect b/postgresql.eselect
index f648956..3614202 100644
--- a/postgresql.eselect
+++ b/postgresql.eselect
@@ -5,7 +5,7 @@ inherit config multilib
 
 DESCRIPTION="Manage active PostgreSQL client applications and libraries"
 MAINTAINER="pgsql-b...@gentoo.org"
-VERSION="2.3"
+VERSION="2.4"
 
 # We do a lot of things in /usr and it's a bit of a pain to write this
 # constantly.



[gentoo-commits] proj/postgresql/eselect:master commit in: /

2018-10-21 Thread Aaron Swenson
commit: 1cf8648293a946af9989c1a6094708160bbe38da
Author: Aaron W. Swenson  grandmasfridge  org>
AuthorDate: Sun Oct 21 10:57:46 2018 +
Commit: Aaron Swenson  gentoo  org>
CommitDate: Sun Oct 21 10:57:46 2018 +
URL:
https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=1cf86482

Do not dereference links

In some conditions, ln will follow symlinks it isn’t supposed to. Add
the -n switch to keep that from happening.

Closes: https://bugs.gentoo.org/662810

 postgresql.eselect | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/postgresql.eselect b/postgresql.eselect
index 3614202..4283ee9 100644
--- a/postgresql.eselect
+++ b/postgresql.eselect
@@ -94,7 +94,7 @@ linker() {
# 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 -sf "${rel_source}" "${link_target}" || \
+   ln -sfn "${rel_source}" "${link_target}" || \
die -q "SYMLINK FAILED: ${rel_source} -> ${link_target}"
done
 }
@@ -223,7 +223,7 @@ do_set() {
# root if $ROOT is not "/"
rel_source=$(relative_name "${include_sources[$i]}" "$(dirname 
"${INCLUDE_TARGETS[$i]}")")
 
-   ln -sf "$rel_source" "${INCLUDE_TARGETS[$i]}" || \
+   ln -sfn "$rel_source" "${INCLUDE_TARGETS[$i]}" || \
die -q "SYMLINK FAILED: $rel_source -> 
${INCLUDE_TARGETS[$i]}"
done
 
@@ -233,7 +233,7 @@ do_set() {
if [[ -d "${USR_PATH}/${x}/postgresql-${slot}/${x}" ]] ; then
# 'linker' function doesn't work for linking 
directories.
# Default lib path - create a relative link
-   ln -sf "postgresql-${slot}/${x}" 
"${USR_PATH}/${x}/postgresql" || \
+   ln -sfn "postgresql-${slot}/${x}" 
"${USR_PATH}/${x}/postgresql" || \
die -q "SYMLINK FAILED: postgresql-${slot}/${x} 
-> ${USR_PATH}/${x}/postgresql"
 
# Linker works for files
@@ -263,7 +263,7 @@ do_set() {
 
# Default share path - use a relative link here by just specifying the
# base name
-   ln -sf "postgresql-${slot}" "${USR_PATH}/share/postgresql" || \
+   ln -sfn "postgresql-${slot}" "${USR_PATH}/share/postgresql" || \
die -q "SYMLINK FAILED: postgresql-${slot} -> 
${USR_PATH}/share/postgresql"
 
echo "success!"



[gentoo-commits] proj/postgresql/eselect:master commit in: /

2018-01-14 Thread Aaron Swenson
commit: ba6b5e21ec7a85eb7521d0ae5c705ed791045104
Author: Aaron W. Swenson  grandmasfridge  org>
AuthorDate: Sun Jan 14 16:43:18 2018 +
Commit: Aaron Swenson  gentoo  org>
CommitDate: Sun Jan 14 16:43:18 2018 +
URL:
https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=ba6b5e21

Rename is_slot_link to is_active_slot_link

 postgresql.eselect | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/postgresql.eselect b/postgresql.eselect
index 18b411b..f648956 100644
--- a/postgresql.eselect
+++ b/postgresql.eselect
@@ -285,7 +285,7 @@ do_unset() {
# Get the file path that the link is pointing to. If it has the string
# "postgresql-${slot}" somewhere in it, then it's a link that this 
module is
# handling.
-   is_slot_link() {
+   is_active_slot_link() {
if [[ $(canonicalise -m "$1") == *postgresql-${slot}* ]] ; then
return 0 # yes
else
@@ -319,7 +319,7 @@ do_unset() {
for path in "${paths[@]}" ; do
# If $path is a link that belongs to the active slot, it can be 
removed
# without invoking find.
-   if [[ -h "${path}" ]] && is_slot_link "${path}" ; then
+   if [[ -h "${path}" ]] && is_active_slot_link "${path}" ; then
rm "${path}" || write_warning_msg "Couldn't remove: 
${path}"
continue
fi
@@ -331,7 +331,7 @@ do_unset() {
[[ ${l} == ${USR_PATH}/bin/*${slot/.} ]] && continue
[[ ${l} == ${USR_PATH}/share/man/man?/*${slot/.}* ]] && 
continue
 
-   if is_slot_link "${l}" ; then
+   if is_active_slot_link "${l}" ; then
rm "${l}" || write_warning_msg "Couldn't 
remove: ${l}"
fi
done



[gentoo-commits] proj/postgresql/eselect:master commit in: /

2018-01-14 Thread Aaron Swenson
commit: 8a6a81e3624107f2536e7784bded7ea10a960018
Author: Aaron W. Swenson  grandmasfridge  org>
AuthorDate: Sun Jan 14 16:38:56 2018 +
Commit: Aaron Swenson  gentoo  org>
CommitDate: Sun Jan 14 16:38:56 2018 +
URL:
https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=8a6a81e3

Bump version to 2.3

 postgresql.eselect | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/postgresql.eselect b/postgresql.eselect
index 099cbda..18b411b 100644
--- a/postgresql.eselect
+++ b/postgresql.eselect
@@ -5,7 +5,7 @@ inherit config multilib
 
 DESCRIPTION="Manage active PostgreSQL client applications and libraries"
 MAINTAINER="pgsql-b...@gentoo.org"
-VERSION="2.2"
+VERSION="2.3"
 
 # We do a lot of things in /usr and it's a bit of a pain to write this
 # constantly.



[gentoo-commits] proj/postgresql/eselect:master commit in: /

2018-01-14 Thread Aaron Swenson
commit: ac185cf15ec0c3276511786fffc871c64c81312c
Author: Aaron W. Swenson  grandmasfridge  org>
AuthorDate: Sun Jan 14 16:37:23 2018 +
Commit: Aaron Swenson  gentoo  org>
CommitDate: Sun Jan 14 16:37:23 2018 +
URL:
https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=ac185cf1

Die if we can’t remove badsym

If badsym can’t be removed, it’ll gum up the works later when trying
to create links, especially since they don’t point anywhere.

 postgresql.eselect | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/postgresql.eselect b/postgresql.eselect
index 84a6e0d..099cbda 100644
--- a/postgresql.eselect
+++ b/postgresql.eselect
@@ -389,7 +389,8 @@ do_update() {
for badsym in $(find "${USR_PATH}"/include/postgresql-* -type l \
 -exec test ! -e {} \; -print)
do
-   rm "${badsym}"
+   # If $badsym can't be removed, we're gonna have a bad time
+   rm "${badsym}" || die -q "Manual rm required: ${badsym}"
done
 
## End Antiquity Clean Up



[gentoo-commits] proj/postgresql/eselect:master commit in: /

2018-01-14 Thread Aaron Swenson
commit: 3e4f034603522c95427c26fc0e9b93002397c749
Author: Aaron W. Swenson  grandmasfridge  org>
AuthorDate: Sun Jan 14 16:26:53 2018 +
Commit: Aaron Swenson  gentoo  org>
CommitDate: Sun Jan 14 16:26:53 2018 +
URL:
https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=3e4f0346

Just try to update symlink

ln now removes an existing symlink when it tries to create one. This
makes it unnecessary to first try to remove the symlink.

 postgresql.eselect | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/postgresql.eselect b/postgresql.eselect
index d05f724..84a6e0d 100644
--- a/postgresql.eselect
+++ b/postgresql.eselect
@@ -80,19 +80,16 @@ linker() {
local pattern=$2
local target_dir=$3
local suffix=$4
-   local link_source
+
local findings
+   local link_source
+   local link_target
local rel_source
 
findings=$(finder "${source_dir}" "${pattern}")
 
for link_source in ${findings} ; do
-   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} ]] && \
-   die -q "The target '${link_target}' still exists and 
could not be removed!"
+   link_target="${target_dir%/}/$(basename 
${link_source})${suffix}"
 
# Create relative links so that they work both here and inside 
the new
# root if $ROOT is not "/".



[gentoo-commits] proj/postgresql/eselect:master commit in: /

2018-01-14 Thread Aaron Swenson
commit: 620d893f7e52f810e40b470761e00f5454fdae36
Author: Aaron W. Swenson  grandmasfridge  org>
AuthorDate: Sun Jan 14 16:19:12 2018 +
Commit: Aaron Swenson  gentoo  org>
CommitDate: Sun Jan 14 16:19:12 2018 +
URL:
https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=620d893f

More concise die messages

 postgresql.eselect | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/postgresql.eselect b/postgresql.eselect
index aa89b49..d05f724 100644
--- a/postgresql.eselect
+++ b/postgresql.eselect
@@ -97,7 +97,8 @@ linker() {
# 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 -sf "${rel_source}" "${link_target}" || die -q "Unable to 
create link!"
+   ln -sf "${rel_source}" "${link_target}" || \
+   die -q "SYMLINK FAILED: ${rel_source} -> ${link_target}"
done
 }
 
@@ -226,7 +227,7 @@ do_set() {
rel_source=$(relative_name "${include_sources[$i]}" "$(dirname 
"${INCLUDE_TARGETS[$i]}")")
 
ln -sf "$rel_source" "${INCLUDE_TARGETS[$i]}" || \
-   die -q "Unable to create link! $rel_source -> 
${INCLUDE_TARGETS[$i]}"
+   die -q "SYMLINK FAILED: $rel_source -> 
${INCLUDE_TARGETS[$i]}"
done
 
# Link modules to /usr/lib{,32,64}/
@@ -235,7 +236,8 @@ do_set() {
if [[ -d "${USR_PATH}/${x}/postgresql-${slot}/${x}" ]] ; then
# 'linker' function doesn't work for linking 
directories.
# Default lib path - create a relative link
-   ln -sf "postgresql-${slot}/${x}" 
"${USR_PATH}/${x}/postgresql"
+   ln -sf "postgresql-${slot}/${x}" 
"${USR_PATH}/${x}/postgresql" || \
+   die -q "SYMLINK FAILED: postgresql-${slot}/${x} 
-> ${USR_PATH}/${x}/postgresql"
 
# Linker works for files
linker "${USR_PATH}/${x}/postgresql-${slot}/${x}/" \
@@ -264,7 +266,8 @@ do_set() {
 
# Default share path - use a relative link here by just specifying the
# base name
-   ln -sf "postgresql-${slot}" "${USR_PATH}/share/postgresql"
+   ln -sf "postgresql-${slot}" "${USR_PATH}/share/postgresql" || \
+   die -q "SYMLINK FAILED: postgresql-${slot} -> 
${USR_PATH}/share/postgresql"
 
echo "success!"
 }



[gentoo-commits] proj/postgresql/eselect:master commit in: /

2018-01-14 Thread Aaron Swenson
commit: f0f07f3166c116b5dcd56f15e482eefdfc84b9f5
Author: Aaron W. Swenson  grandmasfridge  org>
AuthorDate: Sun Jan 14 15:47:05 2018 +
Commit: Aaron Swenson  gentoo  org>
CommitDate: Sun Jan 14 15:47:05 2018 +
URL:
https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=f0f07f31

Force symlinks

Any symlink we’re trying to make should only be handled by us. We may
come across a symlink we missed in some previous clean up, but really
should be set properly rather than failing because it exists.

 postgresql.eselect | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/postgresql.eselect b/postgresql.eselect
index 51d7f50..aa89b49 100644
--- a/postgresql.eselect
+++ b/postgresql.eselect
@@ -97,7 +97,7 @@ linker() {
# 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!"
+   ln -sf "${rel_source}" "${link_target}" || die -q "Unable to 
create link!"
done
 }
 
@@ -225,7 +225,7 @@ do_set() {
# root if $ROOT is not "/"
rel_source=$(relative_name "${include_sources[$i]}" "$(dirname 
"${INCLUDE_TARGETS[$i]}")")
 
-   ln -s "$rel_source" "${INCLUDE_TARGETS[$i]}" || \
+   ln -sf "$rel_source" "${INCLUDE_TARGETS[$i]}" || \
die -q "Unable to create link! $rel_source -> 
${INCLUDE_TARGETS[$i]}"
done
 
@@ -235,7 +235,7 @@ do_set() {
if [[ -d "${USR_PATH}/${x}/postgresql-${slot}/${x}" ]] ; then
# 'linker' function doesn't work for linking 
directories.
# Default lib path - create a relative link
-   ln -s "postgresql-${slot}/${x}" 
"${USR_PATH}/${x}/postgresql"
+   ln -sf "postgresql-${slot}/${x}" 
"${USR_PATH}/${x}/postgresql"
 
# Linker works for files
linker "${USR_PATH}/${x}/postgresql-${slot}/${x}/" \
@@ -264,7 +264,7 @@ do_set() {
 
# Default share path - use a relative link here by just specifying the
# base name
-   ln -s "postgresql-${slot}" "${USR_PATH}/share/postgresql"
+   ln -sf "postgresql-${slot}" "${USR_PATH}/share/postgresql"
 
echo "success!"
 }



[gentoo-commits] proj/postgresql/eselect:master commit in: /

2018-01-14 Thread Aaron Swenson
commit: c4bb082cab28210b16b44e001f213f9a5ad7d47b
Author: Aaron W. Swenson  grandmasfridge  org>
AuthorDate: Sun Jan 14 15:32:31 2018 +
Commit: Aaron Swenson  gentoo  org>
CommitDate: Sun Jan 14 15:32:31 2018 +
URL:
https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=c4bb082c

Cleanup senseless symlinks

Look for broken symlinks in the /usr/include/postgresql-${SLOT}
directories. These were made by 2.1. So now we try to clean them up.

 postgresql.eselect | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/postgresql.eselect b/postgresql.eselect
index 5c90b4b..51d7f50 100644
--- a/postgresql.eselect
+++ b/postgresql.eselect
@@ -382,6 +382,16 @@ do_update() {
echo "It should be safe for you to remove '${etc_path}'"
fi
fi
+
+   # 2.1 would make some bad symlinks where it shouldn't have. We
+   # attempt to clean them up here.
+   local badsym
+   for badsym in $(find "${USR_PATH}"/include/postgresql-* -type l \
+-exec test ! -e {} \; -print)
+   do
+   rm "${badsym}"
+   done
+
## End Antiquity Clean Up
 
local active_slot=$(active_slot)



[gentoo-commits] proj/postgresql/eselect:master commit in: /

2017-07-21 Thread Aaron Swenson
commit: 9439064794d85b96f7f75e166ab9a3277f128ca6
Author: Aaron W. Swenson  gentoo  org>
AuthorDate: Fri Jul 21 18:48:46 2017 +
Commit: Aaron Swenson  gentoo  org>
CommitDate: Fri Jul 21 18:48:46 2017 +
URL:
https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=94390647

Remove $Id and Bump Version

 postgresql.eselect | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/postgresql.eselect b/postgresql.eselect
index 84d08af..5c90b4b 100644
--- a/postgresql.eselect
+++ b/postgresql.eselect
@@ -1,12 +1,11 @@
 # Copyright 1999-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: $
 
 inherit config multilib
 
 DESCRIPTION="Manage active PostgreSQL client applications and libraries"
 MAINTAINER="pgsql-b...@gentoo.org"
-VERSION="2.1"
+VERSION="2.2"
 
 # We do a lot of things in /usr and it's a bit of a pain to write this
 # constantly.



[gentoo-commits] proj/postgresql/eselect:master commit in: /

2017-07-21 Thread Aaron Swenson
commit: 1ce72c8f890d9effe502d6d103bca10c6e4b56c4
Author: Aaron W. Swenson  gentoo  org>
AuthorDate: Fri Jul 21 18:31:29 2017 +
Commit: Aaron Swenson  gentoo  org>
CommitDate: Fri Jul 21 18:31:29 2017 +
URL:
https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=1ce72c8f

Canonicalise even if nonexistent

canoncalise() returns the absolute path a symbolic link points to,
except when the path no longer exists. Adding the -m option – which is
the same for both realpath and readlink – makes it ignore nonexistent
portions of the path.

Bug: https://bugs.gentoo.org/625368

 postgresql.eselect | 25 -
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/postgresql.eselect b/postgresql.eselect
index 9203a97..84d08af 100644
--- a/postgresql.eselect
+++ b/postgresql.eselect
@@ -30,7 +30,7 @@ active_slot() {
 # ${USR_PATH}/share/postgresql is a symlink to the active
 # slot. See if it's there, then find out where it links to.
if [[ -h "${USR_PATH}/share/postgresql" ]] ; then
-   canonicalise "${USR_PATH}/share/postgresql" | \
+   canonicalise -m "${USR_PATH}/share/postgresql" | \
sed -re 's#.*([1-9][0-9.]+)$#\1#'
else
echo "(none)"
@@ -283,6 +283,17 @@ do_unset() {
return 0
fi
 
+   # Get the file path that the link is pointing to. If it has the string
+   # "postgresql-${slot}" somewhere in it, then it's a link that this 
module is
+   # handling.
+   is_slot_link() {
+   if [[ $(canonicalise -m "$1") == *postgresql-${slot}* ]] ; then
+   return 0 # yes
+   else
+   return 1 # no
+   fi
+}
+
# Start with some known locations that are, or will contain, symlinks.
local paths=(
"${INCLUDE_TARGETS[@]}"
@@ -307,10 +318,9 @@ do_unset() {
 
local l path
for path in "${paths[@]}" ; do
-   # If path is a link that belongs to the slot in question, it 
can be
-   # removed without invoking find.
-   if [[ -h "${path}" && \
-   $(canonicalise "${path}") == 
*postgresql-${slot}* ]] ; then
+   # If $path is a link that belongs to the active slot, it can be 
removed
+   # without invoking find.
+   if [[ -h "${path}" ]] && is_slot_link "${path}" ; then
rm "${path}" || write_warning_msg "Couldn't remove: 
${path}"
continue
fi
@@ -322,10 +332,7 @@ do_unset() {
[[ ${l} == ${USR_PATH}/bin/*${slot/.} ]] && continue
[[ ${l} == ${USR_PATH}/share/man/man?/*${slot/.}* ]] && 
continue
 
-   # Get the file path that the link is pointing to. If it 
has the
-   # string "postgresql-${slot}" somewhere in it, then 
it's a link that
-   # needs to be removed.
-   if [[ $(canonicalise "${l}") == *postgresql-${slot}* ]] 
; then
+   if is_slot_link "${l}" ; then
rm "${l}" || write_warning_msg "Couldn't 
remove: ${l}"
fi
done



[gentoo-commits] proj/postgresql/eselect:master commit in: /

2017-05-19 Thread Aaron Swenson
commit: 1cd1ea127a9ef179845d8aacb94b00c6974802b3
Author: Aaron W. Swenson  gentoo  org>
AuthorDate: Fri May 19 14:21:42 2017 +
Commit: Aaron Swenson  gentoo  org>
CommitDate: Fri May 19 14:21:42 2017 +
URL:
https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=1cd1ea12

Bump Version

 postgresql.eselect | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/postgresql.eselect b/postgresql.eselect
index db669cc..9203a97 100644
--- a/postgresql.eselect
+++ b/postgresql.eselect
@@ -6,7 +6,7 @@ inherit config multilib
 
 DESCRIPTION="Manage active PostgreSQL client applications and libraries"
 MAINTAINER="pgsql-b...@gentoo.org"
-VERSION="2.0"
+VERSION="2.1"
 
 # We do a lot of things in /usr and it's a bit of a pain to write this
 # constantly.



[gentoo-commits] proj/postgresql/eselect:master commit in: /

2017-05-19 Thread Aaron Swenson
commit: f2de7834a881e387b7d26978848d754ee56b1e07
Author: Aaron W. Swenson  gentoo  org>
AuthorDate: Fri May 19 14:10:28 2017 +
Commit: Aaron Swenson  gentoo  org>
CommitDate: Fri May 19 14:10:28 2017 +
URL:
https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=f2de7834

Add support for FEATURES="noman"

In such case the user enabled FEATURES="noman" on Portage, there won’t
be a manpage directory to link to. The module now checks that the
directory exists before trying to use it.

 postgresql.eselect | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/postgresql.eselect b/postgresql.eselect
index d7229e5..db669cc 100644
--- a/postgresql.eselect
+++ b/postgresql.eselect
@@ -256,7 +256,11 @@ do_set() {
local mandir mansec
for mandir in "${USR_PATH}"/share/postgresql-${slot}/man/man{1,3,7} ; do
mansec=$(basename "${mandir}")
-   linker "${mandir}" "" "${USR_PATH}/share/man/${mansec}"
+   # Because the user could have FEATURES="noman", check the 
directory
+   # exists before using it. (https://bugs.gentoo.org/618294)
+   if [[ -d ${USR_PATH}/share/man/${mansec} ]] ; then
+   linker "${mandir}" "" "${USR_PATH}/share/man/${mansec}"
+   fi
done
 
# Default share path - use a relative link here by just specifying the



[gentoo-commits] proj/postgresql/eselect:master commit in: /

2017-05-19 Thread Aaron Swenson
commit: 48d3ec37b7cad46148b8b32d9294c505d2e4614a
Author: Aaron W. Swenson  gentoo  org>
AuthorDate: Fri May 19 14:18:05 2017 +
Commit: Aaron Swenson  gentoo  org>
CommitDate: Fri May 19 14:18:05 2017 +
URL:
https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=48d3ec37

Merge branch 'bug-618294'

 postgresql.eselect | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)



[gentoo-commits] proj/postgresql/eselect:master commit in: /

2017-04-18 Thread Aaron Swenson
commit: c92b58550953bdb5d82b1068bfb99225efd65e29
Author: Aaron W. Swenson  gmail  com>
AuthorDate: Sat Feb  4 21:10:28 2017 +
Commit: Aaron Swenson  gentoo  org>
CommitDate: Sat Feb  4 21:10:28 2017 +
URL:
https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=c92b5855

Huge Changes

No longer use an environment file. All links are in locations that are
searched by default by man and pkgconfig.

Remove several files outright in /etc/eselect/postgresql as they’re
unnecessary.

Added linking for man pages and pkgconfig files.

Rename ${SLOT} to ${slot} as it isn’t a global variable.

Now compatible with the upcoming slot scheme where there is no
dot. (Release 10.0 is just 10.)

 postgresql.eselect | 262 ++---
 1 file changed, 129 insertions(+), 133 deletions(-)

diff --git a/postgresql.eselect b/postgresql.eselect
index 7ff9b83..b8ecbe1 100644
--- a/postgresql.eselect
+++ b/postgresql.eselect
@@ -1,4 +1,4 @@
-# Copyright 1999-2013 Gentoo Foundation
+# Copyright 1999-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id: $
 
@@ -6,12 +6,11 @@ inherit config multilib
 
 DESCRIPTION="Manage active PostgreSQL client applications and libraries"
 MAINTAINER="pgsql-b...@gentoo.org"
-VERSION="1.3"
+VERSION="2.0"
 
-# Global Data
+# We do a lot of things in /usr and it's a bit of a pain to write this
+# constantly.
 USR_PATH="${EROOT%/}/usr"
-ETC_PATH="${EROOT%/}/etc/eselect/postgresql"
-ENV_FILE="${EROOT%/}/etc/env.d/50postgresql"
 
 # This list of files/directories are the symbolic link targets that need to be
 # created when a slot is set.
@@ -28,11 +27,11 @@ INCLUDE_TARGETS=(
 )
 
 active_slot() {
-# ${USR_PATH}/share/postgresql is a symlink. See if it's there, then
-# find out where it links to
+# ${USR_PATH}/share/postgresql is a symlink to the active
+# slot. See if it's there, then find out where it links to.
if [[ -h "${USR_PATH}/share/postgresql" ]] ; then
canonicalise "${USR_PATH}/share/postgresql" | \
-sed 's|.*postgresql-\([1-9][0-9.]*\)|\1|'
+   sed -re 's#.*([1-9][0-9.]+)$#\1#'
else
echo "(none)"
fi
@@ -86,7 +85,7 @@ linker() {
local findings
local rel_source
 
-   findings=$(finder "${source_dir}" ${pattern})
+   findings=$(finder "${source_dir}" "${pattern}")
 
for link_source in ${findings} ; do
local link_target="${target_dir%/}/$(basename 
${link_source})${suffix}"
@@ -109,9 +108,9 @@ get_slots() {
local slot
local found_slots
 
-   for slot in $(find "${USR_PATH}/$(lib_dir)/" -maxdepth 1 -type d \
-   -regex '.*/postgresql-[1-9][0-9]*\.*[0-9]*' | \
-   sed -re 's#.*([1-9][0-9]*\.*[0-9]*)$#\1#' | sort -n)
+   for slot in $(find "${USR_PATH}/$(lib_dir)/" \
+  -mindepth 1 -maxdepth 1 -type d 
-name 'postgresql-*' | \
+sed -re 
's#.*([1-9][0-9.]+)$#\1#' | sort -n)
do
# Check that pg_config exists for this slot, otherwise we have
# a false positive.
@@ -186,24 +185,21 @@ describe_set() {
 }
 
 do_set() {
-   local SLOT=$1
+   local slot=$1
 
-   if [[ ! -d ${USR_PATH}/$(lib_dir)/postgresql-${SLOT} ]] ; then
+   if [[ ! -d ${USR_PATH}/$(lib_dir)/postgresql-${slot} ]] ; then
die -q "Not a valid slot."
fi
 
# If there's an active slot, unset that one first
-   if [[  "$(active_slot)" == "${SLOT}" ]] ; then
-   echo $(highlight "No work to do.")
-   echo "If you think the links need to be reset, use the reset 
action."
-   return 0
-   elif [[ "$(active_slot)" != "(none)" ]] ; then
-   echo -ne "\tRemoving old links..."
-   do_unset $(active_slot)
+   local active_slot=$(active_slot)
+   if [[ "${active_slot}" != "(none)" ]] ; then
+   echo -ne "Unsetting ${active_slot} as default..."
+   do_unset ${active_slot}
echo "done."
fi
 
-   echo "Setting ${SLOT} as the default installation..."
+   echo "Setting ${slot} as the default..."
 
echo -ne "\tGenerating new links..."
# Sources for header files
@@ -212,12 +208,12 @@ do_set() {
# If you change this list, you must change the INCLUDE_TARGETS list,
# too. And, they must be listed in the same order.
local include_sources=(
-   "${USR_PATH}"/include/postgresql-${SLOT}
-   "${USR_PATH}"/include/postgresql-${SLOT}/libpq-fe.h
-   "${USR_PATH}"/include/postgresql-${SLOT}/pg_config_ext.h
-   "${USR_PATH}"/include/postgresql-${SLOT}/pg_config_manual.h
-   "${USR_PATH}"/include/postgresql-${SLOT}/libpq
-   

[gentoo-commits] proj/postgresql/eselect:master commit in: /

2017-04-18 Thread Aaron Swenson
commit: 2ab66cffbfd5ff7111244eca0e4f7e06dcf7cae7
Author: Aaron W. Swenson  gentoo  org>
AuthorDate: Mon Aug  8 22:39:19 2016 +
Commit: Aaron Swenson  gentoo  org>
CommitDate: Mon Aug  8 22:39:19 2016 +
URL:
https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=2ab66cff

Rename global variables to something sensible

Decoding those 1 character prefixes is exhausting!

 postgresql.eselect | 102 ++---
 1 file changed, 51 insertions(+), 51 deletions(-)

diff --git a/postgresql.eselect b/postgresql.eselect
index 8463344..93dc723 100644
--- a/postgresql.eselect
+++ b/postgresql.eselect
@@ -9,8 +9,8 @@ MAINTAINER="pgsql-b...@gentoo.org"
 VERSION="1.3"
 
 # Global Data
-B_PATH="${EROOT%/}/usr"
-E_PATH="${EROOT%/}/etc/eselect/postgresql"
+USR_PATH="${EROOT%/}/usr"
+ETC_PATH="${EROOT%/}/etc/eselect/postgresql"
 ENV_FILE="${EROOT%/}/etc/env.d/50postgresql"
 
 # This list of files/directories are the symbolic link targets that need to be
@@ -19,19 +19,19 @@ ENV_FILE="${EROOT%/}/etc/env.d/50postgresql"
 # If you change this list, remember to change include_sources in do_set. And,
 # they must be listed in the same order.
 INCLUDE_TARGETS=(
-   "${B_PATH}"/include/postgresql
-   "${B_PATH}"/include/libpq-fe.h
-   "${B_PATH}"/include/pg_config_ext.h
-   "${B_PATH}"/include/pg_config_manual.h
-   "${B_PATH}"/include/libpq
-   "${B_PATH}"/include/postgres_ext.h
+   "${USR_PATH}"/include/postgresql
+   "${USR_PATH}"/include/libpq-fe.h
+   "${USR_PATH}"/include/pg_config_ext.h
+   "${USR_PATH}"/include/pg_config_manual.h
+   "${USR_PATH}"/include/libpq
+   "${USR_PATH}"/include/postgres_ext.h
 )
 
 active_slot() {
-# ${B_PATH}/share/postgresql is a symlink. See if it's there, then
+# ${USR_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" | \
+   if [[ -h "${USR_PATH}/share/postgresql" ]] ; then
+   canonicalise "${USR_PATH}/share/postgresql" | \
 sed 's|.*postgresql-\([1-9][0-9.]*\)|\1|'
else
echo "(none)"
@@ -41,13 +41,13 @@ active_slot() {
 lib_dir() {
local lib_list=$(list_libdirs)
if [[ ${lib_list} =~ .*lib64.* && \
-   -n $(ls -d ${B_PATH}/lib64/postgresql-*/lib64 2> /dev/null) ]] 
; then
+   -n $(ls -d ${USR_PATH}/lib64/postgresql-*/lib64 2> /dev/null) 
]] ; then
echo "lib64"
elif [[ ${lib_list} =~ .*lib32.* && \
-   -n $(ls -d ${B_PATH}/lib32/postgresql-*/lib32 2> /dev/null) ]] 
; then
+   -n $(ls -d ${USR_PATH}/lib32/postgresql-*/lib32 2> /dev/null) 
]] ; then
echo "lib32"
elif [[ ${lib_list} =~ .*libx32.* && \
-   -n $(ls -d ${B_PATH}/libx32/postgresql-*/libx32 2> /dev/null) 
]] ; then
+   -n $(ls -d ${USR_PATH}/libx32/postgresql-*/libx32 2> /dev/null) 
]] ; then
echo "libx32"
else
echo "lib"
@@ -124,13 +124,13 @@ get_slots() {
local slot
local found_slots
 
-   for slot in $(find "${B_PATH}/$(lib_dir)/" -maxdepth 1 -type d \
+   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)
do
# Check that pg_config exists for this slot, otherwise we have
# a false positive.
-   [[ -x "${B_PATH}/$(lib_dir)/postgresql-${slot}/bin/pg_config" 
]] && \
+   [[ -x "${USR_PATH}/$(lib_dir)/postgresql-${slot}/bin/pg_config" 
]] && \
found_slots+=( ${slot} )
done
 
@@ -152,7 +152,7 @@ do_list() {
local slot
local bindir
for slot in $(get_slots) ; do
-   bindir="${B_PATH}/$(lib_dir)/postgresql-${slot}/bin"
+   bindir="${USR_PATH}/$(lib_dir)/postgresql-${slot}/bin"
 
# The output of `pg_config --version` also includes 
"PostgreSQL" in
# the string, which is a bit redundant.
@@ -203,7 +203,7 @@ describe_set() {
 do_set() {
local SLOT=$1
 
-   if [[ ! -d ${B_PATH}/$(lib_dir)/postgresql-${SLOT} ]] ; then
+   if [[ ! -d ${USR_PATH}/$(lib_dir)/postgresql-${SLOT} ]] ; then
die -q "Not a valid slot."
fi
 
@@ -227,12 +227,12 @@ do_set() {
# If you change this list, you must change the INCLUDE_TARGETS list,
# too. And, they must be listed in the same order.
local include_sources=(
-   "${B_PATH}"/include/postgresql-${SLOT}
-   "${B_PATH}"/include/postgresql-${SLOT}/libpq-fe.h
-   "${B_PATH}"/include/postgresql-${SLOT}/pg_config_ext.h

[gentoo-commits] proj/postgresql/eselect:master commit in: /

2017-04-18 Thread Aaron Swenson
commit: 26ee12a9a78bc299518b7151c14b4f89f4d16cbc
Author: Aaron W. Swenson  gentoo  org>
AuthorDate: Mon Aug  8 22:59:52 2016 +
Commit: Aaron Swenson  gentoo  org>
CommitDate: Mon Aug  8 22:59:52 2016 +
URL:
https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=26ee12a9

Fix typo

Whoa, can’t believe I let that go for so long.

 postgresql.eselect | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/postgresql.eselect b/postgresql.eselect
index 2d4b84c..9bb009a 100644
--- a/postgresql.eselect
+++ b/postgresql.eselect
@@ -233,7 +233,7 @@ do_set() {
"${USR_PATH}"/include/postgresql-${SLOT}/postgres_ext.h
)
 
-   # The linker function cannot accomadate this special purpose.
+   # The linker function cannot accommodate this special purpose.
local rel_source
local i
for (( i=0; $i < ${#include_sources[@]}; i++ )) ; do



[gentoo-commits] proj/postgresql/eselect:master commit in: /

2017-04-18 Thread Aaron Swenson
commit: 64844b8bf854a1651efb7e0d0473e808a0f5aa8b
Author: Aaron W. Swenson  gentoo  org>
AuthorDate: Sat May 21 13:22:24 2016 +
Commit: Aaron Swenson  gentoo  org>
CommitDate: Sat May 21 13:22:24 2016 +
URL:
https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=64844b8b

Remove most/all active.links creation points

Refactor do_set so that it doesn't create active.links* files. Will need
to refactor unlinker and move its content into do_update.

do_unset now does a lot more work to look for and remove symlinks
managed by this module.

 postgresql.eselect | 100 -
 1 file changed, 68 insertions(+), 32 deletions(-)

diff --git a/postgresql.eselect b/postgresql.eselect
index 8d816dc..160e60e 100644
--- a/postgresql.eselect
+++ b/postgresql.eselect
@@ -13,6 +13,20 @@ B_PATH="${EROOT%/}/usr"
 E_PATH="${EROOT%/}/etc/eselect/postgresql"
 ENV_FILE="${EROOT%/}/etc/env.d/50postgresql"
 
+# This list of files/directories are the symbolic link targets that need to be
+# created when a slot is set.
+#
+# If you change this list, remember to change include_sources in do_set. And,
+# they must be listed in the same order.
+INCLUDE_TARGETS=(
+   "${B_PATH}"/include/postgresql
+   "${B_PATH}"/include/libpq-fe.h
+   "${B_PATH}"/include/pg_config_ext.h
+   "${B_PATH}"/include/pg_config_manual.h
+   "${B_PATH}"/include/libpq
+   "${B_PATH}"/include/postgres_ext.h
+)
+
 active_slot() {
 # ${B_PATH}/share/postgresql is a symlink. See if it's there, then
 # find out where it links to
@@ -40,6 +54,8 @@ lib_dir() {
fi
 }
 
+### TODO: Refactor to move find into a separate function
+
 ### Linker Function ###
 # Takes four arguments:
 #   - Full source path (e.g. /usr/lib/postgresql-9.0/lib)
@@ -75,10 +91,12 @@ linker() {
# 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
 }
 
+### 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)
@@ -181,20 +199,31 @@ describe_set() {
 
 do_set() {
local SLOT=$1
+
if [[ ! -d ${B_PATH}/$(lib_dir)/postgresql-${SLOT} ]] ; then
die -q "Not a valid slot."
fi
 
-   echo "Setting ${SLOT} as the default installation..."
+   # If there's an active slot, unset that one first
+   if [[  "$(active_slot)" == "${SLOT}" ]] ; then
+   echo $(highlight "No work to do.")
+   echo "If you think the links need to be reset, use the reset 
action."
+   return 0
+   elif [[ "$(active_slot)" != "(none)" ]] ; then
+   echo -ne "\tRemoving old links..."
+   do_unset $(active_slot)
+   echo "done."
+   fi
 
-   # Remove the active links to start a fresh list
-   echo -ne "\tRemoving old links..."
-   unlinker ${E_PATH}/active.links
-   echo "done."
+   echo "Setting ${SLOT} as the default installation..."
 
echo -ne "\tGenerating new links..."
-   # Sources and targets for header files
-   local sources=(
+   # Sources for header files
+   # Targets are listed in the global variable INCLUDE_TARGETS.
+   #
+   # If you change this list, you must change the INCLUDE_TARGETS list,
+   # too. And, they must be listed in the same order.
+   local include_sources=(
"${B_PATH}"/include/postgresql-${SLOT}
"${B_PATH}"/include/postgresql-${SLOT}/libpq-fe.h
"${B_PATH}"/include/postgresql-${SLOT}/pg_config_ext.h
@@ -202,35 +231,20 @@ do_set() {
"${B_PATH}"/include/postgresql-${SLOT}/libpq
"${B_PATH}"/include/postgresql-${SLOT}/postgres_ext.h
)
-   local targets=(
-   "${B_PATH}"/include/postgresql
-   "${B_PATH}"/include/libpq-fe.h
-   "${B_PATH}"/include/pg_config_ext.h
-   "${B_PATH}"/include/pg_config_manual.h
-   "${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
-   [[ -h ${targets[$i]} ]] && rm -f "${targets[$i]}"
-
-   # Check if link_target still exists
-   [[ -e ${targets[$i]} ]] && \
-   die -q "The target '${targets[$i]}' exists and could 
not be removed!"
-
+   for (( i=0; $i < 

[gentoo-commits] proj/postgresql/eselect:master commit in: /

2017-04-18 Thread Aaron Swenson
commit: 2901113fc0cf9f574729af30aef33cea26becbc9
Author: Aaron W. Swenson  gentoo  org>
AuthorDate: Mon Feb  6 11:43:41 2017 +
Commit: Aaron Swenson  gentoo  org>
CommitDate: Mon Feb  6 11:43:41 2017 +
URL:
https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=2901113f

Eliminate some noise

Removed unnecessary echo about generating new links.

 postgresql.eselect | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/postgresql.eselect b/postgresql.eselect
index b8ecbe1..67f7b74 100644
--- a/postgresql.eselect
+++ b/postgresql.eselect
@@ -199,9 +199,8 @@ do_set() {
echo "done."
fi
 
-   echo "Setting ${slot} as the default..."
+   echo -ne "Setting ${slot} as the default..."
 
-   echo -ne "\tGenerating new links..."
# Sources for header files
# Targets are listed in the global variable INCLUDE_TARGETS.
#
@@ -264,8 +263,7 @@ do_set() {
# base name
ln -s "postgresql-${slot}" "${USR_PATH}/share/postgresql"
 
-   echo "done."
-   echo "Setting ${slot} as default was successful!"
+   echo "success!"
 }
 
 ### Unset Action ###



[gentoo-commits] proj/postgresql/eselect:master commit in: /

2017-04-18 Thread Aaron Swenson
commit: cf8d18a608598ed63775ad44c423f7a8e0320399
Author: Aaron W. Swenson  gentoo  org>
AuthorDate: Mon Aug  8 22:53:26 2016 +
Commit: Aaron Swenson  gentoo  org>
CommitDate: Mon Aug  8 22:53:26 2016 +
URL:
https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=cf8d18a6

Remove TODO Refactor out finder

It’s been moved.

 postgresql.eselect | 2 --
 1 file changed, 2 deletions(-)

diff --git a/postgresql.eselect b/postgresql.eselect
index 93dc723..2d4b84c 100644
--- a/postgresql.eselect
+++ b/postgresql.eselect
@@ -71,8 +71,6 @@ finder() {
set +f
 }
 
-### TODO: Refactor to move find into a separate function
-
 ### Linker Function ###
 # Takes four arguments:
 #   - Full source path (e.g. /usr/lib/postgresql-9.0/lib)



[gentoo-commits] proj/postgresql/eselect:master commit in: /

2017-04-18 Thread Aaron Swenson
commit: 1fcb1813d38b60ab79556bf8bc1d464bbeec467e
Author: Aaron W. Swenson  gentoo  org>
AuthorDate: Mon Aug  8 22:35:42 2016 +
Commit: Aaron Swenson  gentoo  org>
CommitDate: Mon Aug  8 22:35:42 2016 +
URL:
https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=1fcb1813

Refactor update to clean out old files and directories that are no longer used.

 postgresql.eselect | 118 +
 1 file changed, 65 insertions(+), 53 deletions(-)

diff --git a/postgresql.eselect b/postgresql.eselect
index 160e60e..8463344 100644
--- a/postgresql.eselect
+++ b/postgresql.eselect
@@ -54,6 +54,23 @@ lib_dir() {
fi
 }
 
+### Finder Function ###
+# Takes two arguments:
+#   - Absolute path to directory to search
+#   - Pattern to search for
+finder() {
+   local source_dir=$1
+   local pattern=$2
+
+   # Prevent passed patterns from being globbed
+   # If this module is run in /usr, '-name lib*' ends up globbing 'lib*',
+   # passing to 'find' the pattern '-name lib lib32 lib64' and find 
interprets
+   # those as path arguments causing failure.
+   set -f
+   find -L "${source_dir}" -maxdepth 1 -mindepth 1 ${pattern}
+   set +f
+}
+
 ### TODO: Refactor to move find into a separate function
 
 ### Linker Function ###
@@ -71,13 +88,7 @@ linker() {
local findings
local rel_source
 
-   # Prevent passed patterns from being globbed
-   # If this module is run in /usr, '-name lib*' ends up globbing 'lib*',
-   # passing to 'find' the pattern '-name lib lib32 lib64' and find 
interprets
-   # those as path arguments causing failure.
-   set -f
-   findings=$(find -L "${source_dir}" -maxdepth 1 -mindepth 1 ${pattern})
-   set +f
+   findings=$(finder "${source_dir}" ${pattern})
 
for link_source in ${findings} ; do
local link_target="${target_dir%/}/$(basename 
${link_source})${suffix}"
@@ -101,18 +112,10 @@ linker() {
 # Takes one argument:
 #   - 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
-   local active_links=($(<"${active_link_file}"))
-   for (( i=0; $i < ${#active_links[@]}; i++ )) ; do
-   [[ -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
+   local dir
+   local pattern
+   local findings
 
-   rm -f "${active_link_file}"
-   fi
 }
 
 ### Get Slots Function ###
@@ -335,54 +338,70 @@ describe_update() {
 do_update() {
local slot=$(active_slot)
 
-   # Remove some files outright as they're entirely useless now.
-   # ${E_PATH}/active: Contents was the active slot (e.g., 9.5)
-   # ${E_PATH}/service: Told the initscript which slot to start
-   local f
-   for f in "${E_PATH}/active" "${E_PATH}/service" ; do
-   [[ -e "${f}" ]] && rm -f "${f}"
-   done
+   ## CLEAN UP ##
+   #
+   # Older versions of this module generated state and environment files of
+   # some sort or another. They're useless now and are just a waste of 
space.
+   # Remove environment files that have been generated by the ebuilds
+   rm -f "${ENV_FILE}"-*
+
+   if [[ -d ${E_PATH} ]] ; then
+   # Remove some files outright as they're entirely useless now.
+   #   ${E_PATH}/active: Contents was the active slot (e.g., 9.5)
+   #   ${E_PATH}/service: Told the initscript which slot to start
+   local f
+   for f in "${E_PATH}/active" "${E_PATH}/service" ; do
+   [[ -e "${f}" ]] && rm -f "${f}"
+   done
+
+   local active_link_file
+   for active_link_file in "${E_PATH}"/active.links* ; do
+   local active_links=($(<"${active_link_file}"))
+   for (( i=0; $i < ${#active_links[@]}; i++ )) ; do
+   [[ -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
+
+   rm "${active_link_file}" || \
+   write_warning_msg "Can't remove 
'${active_link_file}'"
+   done
+
+   local unused_files
+   unused_file=$(find "${E_PATH}" -type f -not -name '.keep*')
+   if [[ -n 

[gentoo-commits] proj/postgresql/eselect:master commit in: /

2017-04-18 Thread Aaron Swenson
commit: fec9c553ad737a3fe6b5fae6f07b02d84ce6f7bc
Author: Aaron W. Swenson  gentoo  org>
AuthorDate: Mon Feb  6 11:49:53 2017 +
Commit: Aaron Swenson  gentoo  org>
CommitDate: Mon Feb  6 11:49:53 2017 +
URL:
https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=fec9c553

Remove useless reset action

The reset action is usless as do_set calls do_unset if active_slot is
something other than (none).

 postgresql.eselect | 16 ++--
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/postgresql.eselect b/postgresql.eselect
index 67f7b74..83db02f 100644
--- a/postgresql.eselect
+++ b/postgresql.eselect
@@ -328,18 +328,6 @@ do_unset() {
done
 }
 
-### Reset Action ###
-describe_reset() {
-   echo "Recreate symbolic links for currently active slot."
-}
-
-do_reset() {
-   local slot=$(active_slot)
-   [[ ${slot} == "(none)" ]] && die -q "No active slot to reset."
-   do_unset ${slot}
-   do_set ${slot}
-}
-
 ### Update Action ###
 describe_update() {
echo "Refreshes all symbolic links managed by this module"
@@ -390,9 +378,9 @@ do_update() {
local slots=($(get_slots))
 
if [[ ${slots[@]} =~ ${active_slot} ]] ; then
-   # If active_slot is in the slots list, do a reset as the 
installation
+   # If active_slot is in the slots list, set it again as the 
installation
# may have changed.
-   do_reset
+   do_set ${active_slot}
elif [[ ${#slots[@]} -ne 0 ]] ; then
# If $slots is not empty but ${active_slot} is set, the 
active_slot
# must have been unmerged and its links need to be cleaned 
before...



[gentoo-commits] proj/postgresql/eselect:master commit in: /

2017-04-18 Thread Aaron Swenson
commit: 7190ae6e3da59f7390b0e00081594d672bffc0db
Author: Aaron W. Swenson  gentoo  org>
AuthorDate: Wed May 18 19:10:19 2016 +
Commit: Aaron Swenson  gentoo  org>
CommitDate: Wed May 18 19:10:19 2016 +
URL:
https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=7190ae6e

Stateless: No longer rely on an 'active' file

Working towards a stateless module, no need to keep track of links or
active slot in a collection of files.

/usr/share/postgresql is symbolic link generated by this module. So, we're
able to determine which real directory it's pointing to, which will be
/usr/share/postgresql-SLOT. A bit of sed magic gets just the slot
portion off the end. Et voila! We no longer need to store the active
slot in a file.

If /usr/share/postgresql doesn't exist, then we haven't set a slot.

 postgresql.eselect | 24 
 1 file 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!"



[gentoo-commits] proj/postgresql/eselect:master commit in: /

2017-04-18 Thread Aaron Swenson
commit: 019fd73a6afaffad2126e617acc6fbd894bfd4db
Author: Aaron W. Swenson  gentoo  org>
AuthorDate: Fri May 20 13:55:16 2016 +
Commit: Aaron Swenson  gentoo  org>
CommitDate: Fri May 20 13:55:16 2016 +
URL:
https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=019fd73a

Use pg_config to get version numbers

Now that the ebuilds are unified, we don't really need a bunch of files
laying around containing version number and which ebuild is providing
it.

And, pg_config can give us the version number anyway. Sure, we miss out
on revision numbers, but people really shouldn't be using this tool to
get that detailed.

So, given that, rework the do_list.

 postgresql.eselect | 36 +++-
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/postgresql.eselect b/postgresql.eselect
index 1e9ff3b..8d816dc 100644
--- a/postgresql.eselect
+++ b/postgresql.eselect
@@ -122,28 +122,36 @@ describe_list() {
 }
 
 do_list() {
-   write_list_start "Available PostgreSQL Slots"
-
if $(is_output_mode brief) ; then
echo $(get_slots)
else
+   write_list_start "Available PostgreSQL Slots"
+
+   local provider
local slot
+   local bindir
for slot in $(get_slots) ; do
-   local postgres_ebuilds=""
-   local src
-   for src in 
"${E_PATH}"/slots/${slot}/{server,service,base,docs} ; do
-   [[ -r ${src} ]] && source "${src}"
-   done
+   bindir="${B_PATH}/$(lib_dir)/postgresql-${slot}/bin"
+
+   # The output of `pg_config --version` also includes 
"PostgreSQL" in
+   # the string, which is a bit redundant.
+   provider=$("${bindir}"/pg_config --version | \
+ sed 
's/[^0-9]*\(.*\)/\1/')
+
+   # Unless a file exists that's controlled by the 
'server' use flag,
+   # report that it's client only.
+   [[ -e "${bindir}/postmaster" ]] || provider+=' (Clients 
Only)'
 
case "${slot}" in
-   "$(active_slot)" ) write_kv_list_entry \
-   "$(highlight_marker ${slot})" 
"${postgres_ebuilds//postgresql-/}";;
-   *) write_kv_list_entry \
-   "${slot}" 
"${postgres_ebuilds//postgresql-/}";;
+   "$(active_slot)" )
+   write_kv_list_entry \
+   "$(highlight_marker ${slot})" 
"${provider}";;
+   * )
+   write_kv_list_entry "${slot}" 
"${provider}";;
esac
done
 
-   [[ -z ${postgres_ebuilds} ]] && write_warning_msg "No slots 
available."
+   [[ -z "$(get_slots)" ]] && write_warning_msg "No slots 
available."
fi
 }
 
@@ -292,8 +300,10 @@ do_update() {
local slot=$(active_slot)
 
# Remove some files outright as they're entirely useless now.
+   # ${E_PATH}/active: Contents was the active slot (e.g., 9.5)
+   # ${E_PATH}/service: Told the initscript which slot to start
local f
-   for f in "${E_PATH}/active" "${E_PATH}/service"; do
+   for f in "${E_PATH}/active" "${E_PATH}/service" ; do
[[ -e "${f}" ]] && rm -f "${f}"
done