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 4FD3B1396D0 for ; Tue, 5 Sep 2017 17:01:27 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 96D03E0D90; Tue, 5 Sep 2017 17:01:26 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 6584FE0D90 for ; Tue, 5 Sep 2017 17:01:26 +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 220CA33BEAE for ; Tue, 5 Sep 2017 17:01:25 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id C28D58D3D for ; Tue, 5 Sep 2017 17:01:23 +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: <1504630784.2345402051e4b0c12cbc7b3a16fd20decbd0d4b3.titanofold@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/postgres-multi.eclass eclass/postgres.eclass X-VCS-Directories: eclass/ X-VCS-Committer: titanofold X-VCS-Committer-Name: Aaron Swenson X-VCS-Revision: 2345402051e4b0c12cbc7b3a16fd20decbd0d4b3 X-VCS-Branch: master Date: Tue, 5 Sep 2017 17:01:23 +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: e76f4210-c3ec-4c93-931c-d011b2d0f05b X-Archives-Hash: 6c63617fca2eba871c3403d0a2ed83d9 commit: 2345402051e4b0c12cbc7b3a16fd20decbd0d4b3 Author: Aaron W. Swenson gentoo org> AuthorDate: Tue Sep 5 16:59:44 2017 +0000 Commit: Aaron Swenson gentoo org> CommitDate: Tue Sep 5 16:59:44 2017 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=23454020 postgres{,-multi}.eclass: Improvements and bug fix Improve documentation comments to eliminate warnings and make the resulting man pages look better. Use a simple sort instead of the external sort program because calling external commands during metadata regen is forbidden by PMS and breaks new secure cache regen. Gentoo-Bug: 629226 eclass/postgres-multi.eclass | 32 +++++++++++------------ eclass/postgres.eclass | 61 +++++++++++++++++++++++++++++++------------- 2 files changed, 59 insertions(+), 34 deletions(-) diff --git a/eclass/postgres-multi.eclass b/eclass/postgres-multi.eclass index 5d40a0e7c8b..39f0837a868 100644 --- a/eclass/postgres-multi.eclass +++ b/eclass/postgres-multi.eclass @@ -27,7 +27,11 @@ esac # @DESCRIPTION: # A Bash array containing a list of compatible PostgreSQL slots as # defined by the developer. Must be declared before inheriting this -# eclass. Example: POSTGRES_COMPAT=( 9.4 9.{5,6} ) +# eclass. Example: +#@CODE +#POSTGRES_COMPAT=( 9.2 9.3 9.4 9.5 9.6 10 ) +#POSTGRES_COMPAT=( 9.{2,3} 9.{4..6} 10 ) # Same as previous +#@CODE if ! declare -p POSTGRES_COMPAT &>/dev/null; then die 'Required variable POSTGRES_COMPAT not declared.' fi @@ -40,8 +44,8 @@ fi export _POSTGRES_INTERSECT_SLOTS=( ) # @FUNCTION: _postgres-multi_multibuild_wrapper +# @USAGE: [arg ...] # @INTERNAL -# @USAGE: _postgres-multi_multibuild_wrapper [ ...] # @DESCRIPTION: # For the given variant, set the values of the PG_SLOT, PG_CONFIG, and # PKG_CONFIG_PATH environment variables accordingly and replace any @@ -62,16 +66,16 @@ _postgres-multi_multibuild_wrapper() { } # @FUNCTION: postgres-multi_foreach -# @USAGE: postgres-multi_foreach [ ...] +# @USAGE: [arg ...] # @DESCRIPTION: # Run the given command in the package's build directory for each # PostgreSQL slot in the intersect of POSTGRES_TARGETS and -# POSTGRES_COMPAT and user-enabled slots. The PG_CONFIG and -# PKG_CONFIG_PATH environment variables are updated on each iteration to -# point to the matching pg_config command and pkg-config metadata files, -# respectively, for the current slot. Any appearance of @PG_SLOT@ in the -# command or arguments will be substituted with the slot (e.g., 9.5) of -# the current iteration. +# POSTGRES_COMPAT. The PG_CONFIG and PKG_CONFIG_PATH environment +# variables are updated on each iteration to point to the matching +# pg_config command and pkg-config metadata files, respectively, for the +# current slot. Any appearance of @PG_SLOT@ in the command or arguments +# will be substituted with the slot (e.g., 9.5) of the current +# iteration. postgres-multi_foreach() { local MULTIBUILD_VARIANTS=("${_POSTGRES_INTERSECT_SLOTS[@]}") @@ -80,7 +84,7 @@ postgres-multi_foreach() { } # @FUNCTION: postgres-multi_forbest -# @USAGE: postgres-multi_forbest [ ...] +# @USAGE: [arg ...] # @DESCRIPTION: # Run the given command in the package's build directory for the highest # slot in the intersect of POSTGRES_COMPAT and POSTGRES_TARGETS. The @@ -98,14 +102,14 @@ postgres-multi_forbest() { } # @FUNCTION: postgres-multi_pkg_setup -# @USAGE: postgres-multi_pkg_setup # @DESCRIPTION: # Initialize internal environment variable(s). This is required if # pkg_setup() is declared in the ebuild. postgres-multi_pkg_setup() { local user_slot - for user_slot in "${POSTGRES_COMPAT[@]}"; do + # _POSTGRES_COMPAT is created in postgres.eclass + for user_slot in "${_POSTGRES_COMPAT[@]}"; do use "postgres_targets_postgres${user_slot/\./_}" && \ _POSTGRES_INTERSECT_SLOTS+=( "${user_slot}" ) done @@ -118,7 +122,6 @@ postgres-multi_pkg_setup() { } # @FUNCTION: postgres-multi_src_prepare -# @USAGE: postgres-multi_src_prepare # @DESCRIPTION: # Calls eapply_user then copies ${S} into a build directory for each # intersect of POSTGRES_TARGETS and POSTGRES_COMPAT. @@ -151,7 +154,6 @@ postgres-multi_src_prepare() { } # @FUNCTION: postgres-multi_src_compile -# @USAGE: postgres-multi_src_compile # @DESCRIPTION: # Runs `emake' in each build directory postgres-multi_src_compile() { @@ -159,7 +161,6 @@ postgres-multi_src_compile() { } # @FUNCTION: postgres-multi_src_install -# @USAGE: postgres-multi_src_install # @DESCRIPTION: # Runs `emake install DESTDIR="${D}"' in each build directory. postgres-multi_src_install() { @@ -167,7 +168,6 @@ postgres-multi_src_install() { } # @FUNCTION: postgres-multi_src_test -# @USAGE: postgres-multi_src_test # @DESCRIPTION: # Runs `emake installcheck' in each build directory. postgres-multi_src_test() { diff --git a/eclass/postgres.eclass b/eclass/postgres.eclass index 13483a9ec12..2f89da15c93 100644 --- a/eclass/postgres.eclass +++ b/eclass/postgres.eclass @@ -21,41 +21,65 @@ case ${EAPI:-0} in *) die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}" ;; esac +# @ECLASS-VARIABLE: _POSTGRES_ALL_VERSIONS +# @INTERNAL +# @DESCRIPTION: +# List of versions to reverse sort POSTGRES_COMPAT slots + +_POSTGRES_ALL_VERSIONS=( 11 10 9.6 9.5 9.4 9.3 9.2 ) + + # @ECLASS-VARIABLE: POSTGRES_COMPAT # @DEFAULT_UNSET # @DESCRIPTION: # A Bash array containing a list of compatible PostgreSQL slots as # defined by the developer. If declared, must be declared before -# inheriting this eclass. Example: POSTGRES_COMPAT=( 9.4 9.{5,6} ) - -# @ECLASS-VARIABLE: POSTGRES_USEDEP -# @DEFAULT_UNSET -# @DESCRIPTION: -# Add the 2-Style and/or 4-Style use dependencies without brackets to be used -# for POSTGRES_DEP. If declared, must be done before inheriting this eclass. +# inheriting this eclass. Example: +#@CODE +#POSTGRES_COMPAT=( 9.2 9.3 9.4 9.5 9.6 10 ) +#POSTGRES_COMPAT=( 9.{2,3} 9.{4..6} 10 ) # Same as previous +#@CODE # @ECLASS-VARIABLE: POSTGRES_DEP # @DESCRIPTION: # An automatically generated dependency string suitable for use in # DEPEND and RDEPEND declarations. +POSTGRES_DEP="dev-db/postgresql:=" + +# @ECLASS-VARIABLE: POSTGRES_USEDEP +# @DEFAULT_UNSET +# @DESCRIPTION: +# Add the 2-Style and/or 4-Style use dependencies without brackets to be used +# for POSTGRES_DEP. If declared, must be declared before inheriting this eclass. +declare -p POSTGRES_USEDEP &>/dev/null && POSTGRES_DEP+="[${POSTGRES_USEDEP}]" # @ECLASS-VARIABLE: POSTGRES_REQ_USE +# @DEFAULT_UNSET # @DESCRIPTION: # An automatically generated REQUIRED_USE-compatible string built upon # POSTGRES_COMPAT. REQUIRED_USE="... ${POSTGRES_REQ_USE}" is only # required if the package must build against one of the PostgreSQL slots # declared in POSTGRES_COMPAT. +# @ECLASS-VARIABLE: _POSTGRES_COMPAT +# @INTERNAL +# @DESCRIPTION: +# Copy of POSTGRES_COMPAT, reverse sorted +_POSTGRES_COMPAT=() + + if declare -p POSTGRES_COMPAT &> /dev/null ; then # Reverse sort the given POSTGRES_COMPAT so that the most recent # slot is preferred over an older slot. # -- do we care if dependencies are deterministic by USE flags? - readarray -t POSTGRES_COMPAT < <(printf '%s\n' "${POSTGRES_COMPAT[@]}" | sort -nr) + for i in ${_POSTGRES_ALL_VERSIONS[@]} ; do + has ${i} ${POSTGRES_COMPAT[@]} && _POSTGRES_COMPAT+=( ${i} ) + done POSTGRES_DEP="" POSTGRES_REQ_USE=" || (" - for slot in "${POSTGRES_COMPAT[@]}" ; do + for slot in "${_POSTGRES_COMPAT[@]}" ; do POSTGRES_DEP+=" postgres_targets_postgres${slot/\./_}? ( dev-db/postgresql:${slot}=" declare -p POSTGRES_USEDEP &>/dev/null && \ POSTGRES_DEP+="[${POSTGRES_USEDEP}]" @@ -65,10 +89,6 @@ if declare -p POSTGRES_COMPAT &> /dev/null ; then POSTGRES_REQ_USE+=" postgres_targets_postgres${slot/\./_}" done POSTGRES_REQ_USE+=" )" -else - POSTGRES_DEP="dev-db/postgresql:=" - declare -p POSTGRES_USEDEP &>/dev/null && \ - POSTGRES_DEP+="[${POSTGRES_USEDEP}]" fi @@ -96,10 +116,16 @@ postgres_check_slot() { } # @FUNCTION: postgres_new_user +# @USAGE: [user [(uid|-1) [(shell|-1) [(homedir|-1) [groups]]]]] # @DESCRIPTION: # Creates the "postgres" system group and user -- which is separate from -# the database user -- in addition to the developer defined user. Takes -# the same arguments as "enewuser". +# the database user -- and, optionally, the developer defined user. There +# are no required parameters. +# +# When given a user to create, it'll be created with the next available +# uid, default shell set to /bin/false, default homedir is /dev/null, +# and added to the "postgres" system group. You can use "-1" to skip any +# parameter except user or groups. postgres_new_user() { enewgroup postgres 70 enewuser postgres 70 /bin/bash /var/lib/postgresql postgres @@ -116,7 +142,6 @@ postgres_new_user() { } # @FUNCTION: postgres_pkg_setup -# @USAGE: postgres_pkg_setup # @DESCRIPTION: # Initialize environment variable(s) according to the best # installed version of PostgreSQL that is also in POSTGRES_COMPAT. This @@ -127,7 +152,7 @@ postgres_pkg_setup() { local compat_slot local best_slot - for compat_slot in "${POSTGRES_COMPAT[@]}"; do + for compat_slot in "${_POSTGRES_COMPAT[@]}"; do if use "postgres_targets_postgres${compat_slot/\./_}"; then best_slot="${compat_slot}" break @@ -136,7 +161,7 @@ postgres_pkg_setup() { if [[ -z "${best_slot}" ]]; then local flags f - for f in "${POSTGRES_COMPAT[@]}"; do + for f in "${_POSTGRES_COMPAT[@]}"; do flags+=" postgres${f/./_}" done