From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id BF6EB1382C5 for ; Wed, 22 Jun 2016 23:23:27 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C047394085; Wed, 22 Jun 2016 23:23:19 +0000 (UTC) Received: from mail-io0-f193.google.com (mail-io0-f193.google.com [209.85.223.193]) (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 B49E6141A5 for ; Wed, 22 Jun 2016 23:23:18 +0000 (UTC) Received: by mail-io0-f193.google.com with SMTP id t74so8714015ioi.0 for ; Wed, 22 Jun 2016 16:23:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:subject:to:message-id:date:user-agent:mime-version; bh=0hCDlSyzUodzSzh+tB0uRkUmBDxbjYpu28346nfkovk=; b=qLtRnECN5EI0TMI4CqFIqQLJ05U529hnz/x9vKT/wMkOYtUZCtbCqfpP5eAnpeFeQ9 h4gS3fJQsnVyh4g9qXM7bg0RkNP8RshxR5k5jBNDOAIh6vY2L3+Os0uKw9/3Hq5eeHwi v5pkU4Jm9HkJMDUEzeqpVcx2FASUHGm3Ymy8S5kwoPuXNGFYC6sdG2pTTUhrocxVVLLk zg812avCpz38YATZEkfOixodKg/w753OXEimWNWWg9KYXSLAU9HI420MLzldCGZ6FGMX n1Uoh/Poh3o3QX0bKF0FKbzFRfGEtlef9Ux8ZQe0e6Ifiqg4dmj3Lf7LEQySkkXlrCFD qx/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:subject:to:message-id:date:user-agent :mime-version; bh=0hCDlSyzUodzSzh+tB0uRkUmBDxbjYpu28346nfkovk=; b=jxEE1d4iN2uiVq1q1aqfPRC57ZDjCnoU1Oh3TxdFGj4Aay6VuDvVYxBozdE2Yp6yOf A3PI6ZxKvSk8QhnrtBYt75EUddJkjuvQmUVMr/mlcsvB+sCiP84+dmxDOKVt6GnLxtIJ RYcBaBLTF7kLOJQ51mbBMH7By5kZzTi5OxYA2QUwdH8gnmYElO3Vkod8g6JioTwpxnOf q4/ZdyezF8Qdl6ApLm6/m85z46B3lZ8OcFDH+M8d6eLFtwTq99BjyYamFuZoGKnQMNi9 Gt4xXsmGRfw53eNhl9PCEIE2hT41+beV+OJTM3UQRqpagMmYM8n4NFoZG5wccG6WquKa R6UQ== X-Gm-Message-State: ALyK8tIGwh0p5Uh3Ngj0JaiojZ9VRwUyy7SGlO0Klgtt1oTHfyEi4Oxmf9WqRyLI+Bs0/Q== X-Received: by 10.107.128.194 with SMTP id k63mr47293056ioi.65.1466637797562; Wed, 22 Jun 2016 16:23:17 -0700 (PDT) Received: from [192.168.1.2] (97-127-66-241.mpls.qwest.net. [97.127.66.241]) by smtp.gmail.com with ESMTPSA id p21sm1370761iop.0.2016.06.22.16.23.16 for (version=TLSv1/SSLv3 cipher=OTHER); Wed, 22 Jun 2016 16:23:16 -0700 (PDT) From: Dan Douglas Subject: [gentoo-dev] [PATCH] git-r3.eclass: Make EGIT_LIVE_* associative arrays To: gentoo-dev@lists.gentoo.org Message-ID: <8ab81d74-fc21-cfa7-4606-fbcddf8060fe@gmail.com> Date: Wed, 22 Jun 2016 18:22:38 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Gk79VFmr665RmJEA9mOFEdjr7CMqLc5cF" X-Archives-Salt: a0c657b5-05ed-4c92-85bc-475239f022c2 X-Archives-Hash: a115e43f7ae451d7bd6a2b730b17f8b5 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Gk79VFmr665RmJEA9mOFEdjr7CMqLc5cF Content-Type: multipart/mixed; boundary="QGxiVawCU3i1BOXHSkOUumDGSWo568U6r" From: Dan Douglas To: gentoo-dev@lists.gentoo.org Message-ID: <8ab81d74-fc21-cfa7-4606-fbcddf8060fe@gmail.com> Subject: [PATCH] git-r3.eclass: Make EGIT_LIVE_* associative arrays --QGxiVawCU3i1BOXHSkOUumDGSWo568U6r Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable This creates new associative arrays for each "live" variable if bash4 / eapi6 is available. Mainly for user convenience in a bashrc as an alternative to magic variable names. --- eclass/git-r3.eclass | 68 ++++++++++++++++++++++++++++++----------------= ------ 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass index 0ac9d90..220054e 100644 --- a/eclass/git-r3.eclass +++ b/eclass/git-r3.eclass @@ -112,14 +112,19 @@ fi # @ECLASS-VARIABLE: EGIT_REPO_URI # @REQUIRED # @DESCRIPTION: -# URIs to the repository, e.g. git://foo, https://foo. If multiple URIs -# are provided, the eclass will consider them as fallback URIs to try -# if the first URI does not work. For supported URI syntaxes, read up -# the manpage for git-clone(1). +# URIs to the repository, e.g. git://foo, https://foo. If multiple URIs = are +# provided, the eclass will consider them as fallback URIs to try if the= first +# URI does not work. For supported URI syntaxes, read up the manpage for= +# git-clone(1). EGIT_REPO_URI can also be a whitespace-separated list or= an +# array. # -# It can be overriden via env using ${PN}_LIVE_REPO variable. -# -# Can be a whitespace-separated list or an array. +# It can be overriden via env using the ${PN}_LIVE_REPO variable. Hyphen= s and +# pluses in ${PN} must be substituted for underscores to form a valid va= riable +# name. + +# Additionally, a .bashrc or hook function can use the EGIT_LIVE_REPO[${= PN}] +# associative array (bash 4 only). Its value can be a whitespace-spearat= ed +# list. EGIT_LIVE_REPO takes precedence over ${PN}_LIVE_REPO. # # Example: # @CODE @@ -148,7 +153,8 @@ fi # The branch name to check out. If unset, the upstream default (HEAD) # will be used. # -# It can be overridden via env using ${PN}_LIVE_BRANCH variable. +# It can be overridden via env using ${PN}_LIVE_BRANCH variable or via +# EGIT_LIVE_BRANCH[${PN}] associative array. =20 # @ECLASS-VARIABLE: EGIT_COMMIT # @DEFAULT_UNSET @@ -157,7 +163,8 @@ fi # commit from the branch will be used. If set, EGIT_BRANCH will # be ignored. # -# It can be overridden via env using ${PN}_LIVE_COMMIT variable. +# It can be overridden via env using ${PN}_LIVE_COMMIT variable or via +# EGIT_LIVE_COMMIT[${PN}] associative array. =20 # @ECLASS-VARIABLE: EGIT_COMMIT_DATE # @DEFAULT_UNSET @@ -172,7 +179,8 @@ fi # will be considered alike a single commit with date corresponding # to the merge commit date. # -# It can be overridden via env using ${PN}_LIVE_COMMIT_DATE variable. +# It can be overridden via env using ${PN}_LIVE_COMMIT_DATE variable or = via +# EGIT_LIVE_COMMIT_DATE[${PN}] associative array. =20 # @ECLASS-VARIABLE: EGIT_CHECKOUT_DIR # @DESCRIPTION: @@ -251,28 +259,30 @@ _git-r3_env_setup() { die 'EGIT_SUBMODULES must be an array.' fi =20 - local esc_pn livevar - esc_pn=3D${PN//[-+]/_} - - livevar=3D${esc_pn}_LIVE_REPO - EGIT_REPO_URI=3D${!livevar-${EGIT_REPO_URI}} - [[ ${!livevar} ]] \ - && ewarn "Using ${livevar}, no support will be provided" + # Pairs of variable names associating eclass variables with the + # user-configurable variables for overriding them. + local -a livevars=3D( + EGIT_REPO_URI LIVE_REPO + {EGIT,LIVE}_BRANCH + {EGIT,LIVE}_COMMIT + {EGIT,LIVE}_COMMIT_DATE + ) =20 - livevar=3D${esc_pn}_LIVE_BRANCH - EGIT_BRANCH=3D${!livevar-${EGIT_BRANCH}} - [[ ${!livevar} ]] \ - && ewarn "Using ${livevar}, no support will be provided" + local idx ref esc_pn=3D${PN//[-+]/_} + for ((idx =3D 0; idx <=3D ${#livevars[@]}; idx +=3D 2)); do + [[ + ( BASH_VERSINFO[0] -ge 4 || EAPI -ge 6 ) && + $(declare -p "EGIT_${livevars[idx+1]}" 2>/dev/null) =3D=3D 'declare -= A'* + ]] && ref=3DEGIT_${livevars[idx+1]}[\$PN] =20 - livevar=3D${esc_pn}_LIVE_COMMIT - EGIT_COMMIT=3D${!livevar-${EGIT_COMMIT}} - [[ ${!livevar} ]] \ - && ewarn "Using ${livevar}, no support will be provided" + [[ ${!ref} ]] || ref=3D${esc_pn}_${livevars[idx+1]} =20 - livevar=3D${esc_pn}_LIVE_COMMIT_DATE - EGIT_COMMIT_DATE=3D${!livevar-${EGIT_COMMIT_DATE}} - [[ ${!livevar} ]] \ - && ewarn "Using ${livevar}, no support will be provided" + if [[ ${!ref} ]]; then + ewarn "Using ${livevars[idx]} =3D ${!ref}. This build is unsupported.= " + printf -v "${livevars[idx]}" -- %s "${!ref}" + fi + unset -v ref + done =20 if [[ ${EGIT_COMMIT} && ${EGIT_COMMIT_DATE} ]]; then die "EGIT_COMMIT and EGIT_COMMIT_DATE can not be specified simultaneou= sly" --=20 2.9.0 --QGxiVawCU3i1BOXHSkOUumDGSWo568U6r-- --Gk79VFmr665RmJEA9mOFEdjr7CMqLc5cF Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAldrHb8ACgkQMmyDamdg+MwRNQCgg5SVYsfTvS9btNzuUoezIxzH nt8AoIfPbfgMBwjiwk6TvmrXLL9KDBWA =Htb4 -----END PGP SIGNATURE----- --Gk79VFmr665RmJEA9mOFEdjr7CMqLc5cF--