Gentoo Archives: gentoo-commits

From: Aaron Swenson <titanofold@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/postgresql/eselect:master commit in: /
Date: Tue, 18 Apr 2017 19:43:44
Message-Id: 1463752516.019fd73a6afaffad2126e617acc6fbd894bfd4db.titanofold@gentoo
1 commit: 019fd73a6afaffad2126e617acc6fbd894bfd4db
2 Author: Aaron W. Swenson <titanofold <AT> gentoo <DOT> org>
3 AuthorDate: Fri May 20 13:55:16 2016 +0000
4 Commit: Aaron Swenson <titanofold <AT> gentoo <DOT> org>
5 CommitDate: Fri May 20 13:55:16 2016 +0000
6 URL: https://gitweb.gentoo.org/proj/postgresql/eselect.git/commit/?id=019fd73a
7
8 Use pg_config to get version numbers
9
10 Now that the ebuilds are unified, we don't really need a bunch of files
11 laying around containing version number and which ebuild is providing
12 it.
13
14 And, pg_config can give us the version number anyway. Sure, we miss out
15 on revision numbers, but people really shouldn't be using this tool to
16 get that detailed.
17
18 So, given that, rework the do_list.
19
20 postgresql.eselect | 36 +++++++++++++++++++++++-------------
21 1 file changed, 23 insertions(+), 13 deletions(-)
22
23 diff --git a/postgresql.eselect b/postgresql.eselect
24 index 1e9ff3b..8d816dc 100644
25 --- a/postgresql.eselect
26 +++ b/postgresql.eselect
27 @@ -122,28 +122,36 @@ describe_list() {
28 }
29
30 do_list() {
31 - write_list_start "Available PostgreSQL Slots"
32 -
33 if $(is_output_mode brief) ; then
34 echo $(get_slots)
35 else
36 + write_list_start "Available PostgreSQL Slots"
37 +
38 + local provider
39 local slot
40 + local bindir
41 for slot in $(get_slots) ; do
42 - local postgres_ebuilds=""
43 - local src
44 - for src in "${E_PATH}"/slots/${slot}/{server,service,base,docs} ; do
45 - [[ -r ${src} ]] && source "${src}"
46 - done
47 + bindir="${B_PATH}/$(lib_dir)/postgresql-${slot}/bin"
48 +
49 + # The output of `pg_config --version` also includes "PostgreSQL" in
50 + # the string, which is a bit redundant.
51 + provider=$("${bindir}"/pg_config --version | \
52 + sed 's/[^0-9]*\(.*\)/\1/')
53 +
54 + # Unless a file exists that's controlled by the 'server' use flag,
55 + # report that it's client only.
56 + [[ -e "${bindir}/postmaster" ]] || provider+=' (Clients Only)'
57
58 case "${slot}" in
59 - "$(active_slot)" ) write_kv_list_entry \
60 - "$(highlight_marker ${slot})" "${postgres_ebuilds//postgresql-/}";;
61 - * ) write_kv_list_entry \
62 - "${slot}" "${postgres_ebuilds//postgresql-/}";;
63 + "$(active_slot)" )
64 + write_kv_list_entry \
65 + "$(highlight_marker ${slot})" "${provider}";;
66 + * )
67 + write_kv_list_entry "${slot}" "${provider}";;
68 esac
69 done
70
71 - [[ -z ${postgres_ebuilds} ]] && write_warning_msg "No slots available."
72 + [[ -z "$(get_slots)" ]] && write_warning_msg "No slots available."
73 fi
74 }
75
76 @@ -292,8 +300,10 @@ do_update() {
77 local slot=$(active_slot)
78
79 # Remove some files outright as they're entirely useless now.
80 + # ${E_PATH}/active: Contents was the active slot (e.g., 9.5)
81 + # ${E_PATH}/service: Told the initscript which slot to start
82 local f
83 - for f in "${E_PATH}/active" "${E_PATH}/service"; do
84 + for f in "${E_PATH}/active" "${E_PATH}/service" ; do
85 [[ -e "${f}" ]] && rm -f "${f}"
86 done