diff options
author | 2016-05-20 09:55:16 -0400 | |
---|---|---|
committer | 2016-05-20 09:55:16 -0400 | |
commit | 019fd73a6afaffad2126e617acc6fbd894bfd4db (patch) | |
tree | a3df5c2504392fbb54c5615982f8288c0aae7053 | |
parent | Stateless: No longer rely on an 'active' file (diff) | |
download | eselect-019fd73a6afaffad2126e617acc6fbd894bfd4db.tar.gz eselect-019fd73a6afaffad2126e617acc6fbd894bfd4db.tar.bz2 eselect-019fd73a6afaffad2126e617acc6fbd894bfd4db.zip |
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.
-rw-r--r-- | postgresql.eselect | 36 |
1 files 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 |