From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id E02E8139694 for ; Tue, 18 Apr 2017 19:43:44 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 3D66021C096; Tue, 18 Apr 2017 19:43:39 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 0860421C096 for ; Tue, 18 Apr 2017 19:43:39 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 3751F341649 for ; Tue, 18 Apr 2017 19:43:38 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id F170B7436 for ; Tue, 18 Apr 2017 19:43:36 +0000 (UTC) From: "Aaron Swenson" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Aaron Swenson" Message-ID: <1463752516.019fd73a6afaffad2126e617acc6fbd894bfd4db.titanofold@gentoo> Subject: [gentoo-commits] proj/postgresql/eselect:master commit in: / X-VCS-Repository: proj/postgresql/eselect X-VCS-Files: postgresql.eselect X-VCS-Directories: / X-VCS-Committer: titanofold X-VCS-Committer-Name: Aaron Swenson X-VCS-Revision: 019fd73a6afaffad2126e617acc6fbd894bfd4db X-VCS-Branch: master Date: Tue, 18 Apr 2017 19:43:36 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 8eddbc0b-3805-45ea-9175-366ffd3525a8 X-Archives-Hash: f912aed38c8773ea0f18b526b7b22703 commit: 019fd73a6afaffad2126e617acc6fbd894bfd4db Author: Aaron W. Swenson gentoo org> AuthorDate: Fri May 20 13:55:16 2016 +0000 Commit: Aaron Swenson gentoo 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