commit:     019fd73a6afaffad2126e617acc6fbd894bfd4db
Author:     Aaron W. Swenson <titanofold <AT> gentoo <DOT> org>
AuthorDate: Fri May 20 13:55:16 2016 +0000
Commit:     Aaron Swenson <titanofold <AT> gentoo <DOT> org>
CommitDate: Fri May 20 13:55:16 2016 +0000
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
 

Reply via email to