public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Sergei Trofimovich <slyfox@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Cc: Zac Medico <zmedico@gentoo.org>, Sergei Trofimovich <slyfox@gentoo.org>
Subject: [gentoo-portage-dev] [PATCH] bin/eapi.sh: default to EAPI=0 when EAPI is unset
Date: Sat, 17 Jan 2015 12:07:27 +0000	[thread overview]
Message-ID: <1421496447-20561-1-git-send-email-slyfox@gentoo.org> (raw)

Observed as a breakage on binutils ebuilds:

> ERROR: sys-devel/binutils-2.24-r3::gentoo failed (depend phase):
>  use() calls are not allowed in global scope
>    Call stack:
>    ebuild.sh, line 584:  Called source 'binutils-2.24-r3.ebuild,
>    ebuild.sh, line   7:  Called inherit 'toolchain-binutils'
>    ebuild.sh, line 280:  Called __qa_source '/gentoo-32k/gentoo-x86/eclass/toolchain-binutils.e
>    ebuild.sh, line  80:  Called source '/gentoo-32k/gentoo-x86/eclass/toolchain-binutils.eclass
>  toolchain-binutils.eclass, line 106:  Called use 'multislot'
>                  ebuild.sh, line  47:  Called die
> The specific snippet of code:
>       # These functions die because calls to them during the "depend" phase

Zac confirms it's a safe thing to use ${EAPI-0} here:
> ebuild.sh unsets the EAPI just before it sources the ebuild,
> and then it does this after it sources the ebuild:
>
>   [ "${EAPI+set}" = set ] || EAPI=0
>
> So, for any code that is called while the ebuild is being sourced, using
> ${EAPI-0} would be correct.

For consistency and defense against future copy/paste errors
converted all uses of ${EAPI} for ${EAPI-0} in 'bin/eapi.sh'.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
---
 bin/eapi.sh | 90 ++++++++++++++++++++++++++++++-------------------------------
 1 file changed, 45 insertions(+), 45 deletions(-)

diff --git a/bin/eapi.sh b/bin/eapi.sh
index 7e7b54b..f1c677e 100644
--- a/bin/eapi.sh
+++ b/bin/eapi.sh
@@ -5,189 +5,189 @@
 # PHASES
 
 ___eapi_has_pkg_pretend() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3)$ ]]
 }
 
 ___eapi_has_src_prepare() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1)$ ]]
 }
 
 ___eapi_has_src_configure() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1)$ ]]
 }
 
 ___eapi_default_src_test_disables_parallel_jobs() {
-	[[ ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ ]]
+	[[ ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ ]]
 }
 
 ___eapi_has_S_WORKDIR_fallback() {
-	[[ ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
+	[[ ${1-${EAPI-0}} =~ ^(0|1|2|3)$ ]]
 }
 
 # VARIABLES
 
 ___eapi_has_prefix_variables() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2)$ || " ${FEATURES} " == *" force-prefix "* ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2)$ || " ${FEATURES} " == *" force-prefix "* ]]
 }
 
 ___eapi_has_HDEPEND() {
-	[[ ${1-${EAPI}} =~ ^(5-hdepend)$ ]]
+	[[ ${1-${EAPI-0}} =~ ^(5-hdepend)$ ]]
 }
 
 ___eapi_has_RDEPEND_DEPEND_fallback() {
-	[[ ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
+	[[ ${1-${EAPI-0}} =~ ^(0|1|2|3)$ ]]
 }
 
 # HELPERS PRESENCE
 
 ___eapi_has_dohard() {
-	[[ ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
+	[[ ${1-${EAPI-0}} =~ ^(0|1|2|3)$ ]]
 }
 
 ___eapi_has_dosed() {
-	[[ ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
+	[[ ${1-${EAPI-0}} =~ ^(0|1|2|3)$ ]]
 }
 
 ___eapi_has_einstall() {
-	[[ ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
+	[[ ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
 }
 
 ___eapi_has_dohtml_deprecated() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
 }
 
 ___eapi_has_docompress() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3)$ ]]
 }
 
 ___eapi_has_nonfatal() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3)$ ]]
 }
 
 ___eapi_has_doheader() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ ]]
 }
 
 ___eapi_has_usex() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ ]]
 }
 
 ___eapi_has_get_libdir() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
 }
 
 ___eapi_has_einstalldocs() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
 }
 
 ___eapi_has_eapply() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
 }
 
 ___eapi_has_eapply_user() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
 }
 
 ___eapi_has_in_iuse() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
 }
 
 ___eapi_has_master_repositories() {
-	[[ ${1-${EAPI}} =~ ^(5-progress)$ ]]
+	[[ ${1-${EAPI-0}} =~ ^(5-progress)$ ]]
 }
 
 ___eapi_has_repository_path() {
-	[[ ${1-${EAPI}} =~ ^(5-progress)$ ]]
+	[[ ${1-${EAPI-0}} =~ ^(5-progress)$ ]]
 }
 
 ___eapi_has_available_eclasses() {
-	[[ ${1-${EAPI}} =~ ^(5-progress)$ ]]
+	[[ ${1-${EAPI-0}} =~ ^(5-progress)$ ]]
 }
 
 ___eapi_has_eclass_path() {
-	[[ ${1-${EAPI}} =~ ^(5-progress)$ ]]
+	[[ ${1-${EAPI-0}} =~ ^(5-progress)$ ]]
 }
 
 ___eapi_has_license_path() {
-	[[ ${1-${EAPI}} =~ ^(5-progress)$ ]]
+	[[ ${1-${EAPI-0}} =~ ^(5-progress)$ ]]
 }
 
 ___eapi_has_package_manager_build_user() {
-	[[ ${1-${EAPI}} =~ ^(5-progress)$ ]]
+	[[ ${1-${EAPI-0}} =~ ^(5-progress)$ ]]
 }
 
 ___eapi_has_package_manager_build_group() {
-	[[ ${1-${EAPI}} =~ ^(5-progress)$ ]]
+	[[ ${1-${EAPI-0}} =~ ^(5-progress)$ ]]
 }
 
 # HELPERS BEHAVIOR
 
 ___eapi_best_version_and_has_version_support_--host-root() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ ]]
 }
 
 ___eapi_unpack_supports_xz() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2)$ ]]
 }
 
 ___eapi_unpack_supports_txz() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
 }
 
 ___eapi_econf_passes_--disable-dependency-tracking() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3)$ ]]
 }
 
 ___eapi_econf_passes_--disable-silent-rules() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ ]]
 }
 
 ___eapi_econf_passes_--docdir_and_--htmldir() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
 }
 
 ___eapi_use_enable_and_use_with_support_empty_third_argument() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3)$ ]]
 }
 
 ___eapi_dodoc_supports_-r() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3)$ ]]
 }
 
 ___eapi_doins_and_newins_preserve_symlinks() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3)$ ]]
 }
 
 ___eapi_newins_supports_reading_from_standard_input() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ ]]
 }
 
 ___eapi_helpers_can_die() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3)$ ]]
 }
 
 ___eapi_disallows_helpers_in_global_scope() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-slot-abi|5|5-hdepend)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-slot-abi|5|5-hdepend)$ ]]
 }
 
 ___eapi_unpack_is_case_sensitive() {
-	[[ ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend)$ ]]
+	[[ ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend)$ ]]
 }
 
 ___eapi_unpack_supports_absolute_paths() {
-	[[ ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend)$ ]]
+	[[ ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend)$ ]]
 }
 
 ___eapi_die_can_respect_nonfatal() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
 }
 
 # OTHERS
 
 ___eapi_enables_failglob_in_global_scope() {
-	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
 }
 
 ___eapi_enables_globstar() {
-	[[ ${1-${EAPI}} =~ ^(4-python|5-progress)$ ]]
+	[[ ${1-${EAPI-0}} =~ ^(4-python|5-progress)$ ]]
 }
-- 
2.2.1



             reply	other threads:[~2015-01-17 12:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-17 12:07 Sergei Trofimovich [this message]
2015-01-17 20:20 ` [gentoo-portage-dev] Re: [PATCH] bin/eapi.sh: default to EAPI=0 when EAPI is unset Zac Medico
2015-01-18  5:14   ` Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1421496447-20561-1-git-send-email-slyfox@gentoo.org \
    --to=slyfox@gentoo.org \
    --cc=gentoo-portage-dev@lists.gentoo.org \
    --cc=zmedico@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox