public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCHES] python-r1, add integrity checks for redefined control vars
@ 2017-03-01 16:02 Michał Górny
  2017-03-01 16:02 ` [gentoo-dev] [PATCH 01/10] python-utils-r1.eclass: _python_set_impls, use local vars Michał Górny
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Michał Górny @ 2017-03-01 16:02 UTC (permalink / raw
  To: gentoo-dev

Hi,

Here's a patch serie inspired by the recent spidermonkey issue [1]. Long
story short, both mozcoreconf-*.eclass and spidermonkey were setting
different values of PYTHON_REQ_USE and inherit python-any-r1. Thanks to
double include guards, the dependencies were set using the first value
on the first iteration. However, python_setup() used the final value,
being more strict as a result.

This patch series aims to reduce the likeliness of such mistakes,
by comparing the values of output variables between successive eclass
inherits. This both catches some mistakes of overwriting the value,
and any potential integrity issues in eclass itself.

The remaining commits are purely cleanup/refactor.

However, the following technical limitations need to be noted:

1. We can only detect changes of control variables between successive
inherits of eclass, which makes every solution highly dependent
on the inherit order. If you 'inherit mozcoreconf-v4 python-any-r1',
the control variables are overwritten before python-any-r1 can see them.

2. There was a suggestion to make the eclass output variables updated
for the last values of control. However, the output variables are
currently marked readonly, to avoid accidental rewrites. If we were
to update them, we would have to disable that.

3. The same bugs (and also the case of defining after inherit) could
be caught if control variables were made readonly after setting globals.
However, this would cause spurious errors if the ebuild was sourced
more than once by the PM.

Please review.

[1]:https://bugs.gentoo.org/611176

--
Best regards,
Michał Górny



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gentoo-dev] [PATCH 01/10] python-utils-r1.eclass: _python_set_impls, use local vars
  2017-03-01 16:02 [gentoo-dev] [PATCHES] python-r1, add integrity checks for redefined control vars Michał Górny
@ 2017-03-01 16:02 ` Michał Górny
  2017-03-01 16:02 ` [gentoo-dev] [PATCH 02/10] python-utils-r1.eclass: _python_set_impls, add integrity check Michał Górny
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Michał Górny @ 2017-03-01 16:02 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Refactor _python_set_impls to use local variables throughout
the function and assign global values at the end. This prepares it for
double-inherit integrity checks. NFC.
---
 eclass/python-utils-r1.eclass | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 3937d066a095..fd219d95a760 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -114,21 +114,22 @@ _python_set_impls() {
 		_python_impl_supported "${i}"
 	done
 
-	_PYTHON_SUPPORTED_IMPLS=()
-	_PYTHON_UNSUPPORTED_IMPLS=()
+	local supp=() unsupp=()
 
 	for i in "${_PYTHON_ALL_IMPLS[@]}"; do
 		if has "${i}" "${PYTHON_COMPAT[@]}"; then
-			_PYTHON_SUPPORTED_IMPLS+=( "${i}" )
+			supp+=( "${i}" )
 		else
-			_PYTHON_UNSUPPORTED_IMPLS+=( "${i}" )
+			unsupp+=( "${i}" )
 		fi
 	done
 
-	if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 0 ]]; then
+	if [[ ! ${supp[@]} ]]; then
 		die "No supported implementation in PYTHON_COMPAT."
 	fi
 
+	_PYTHON_SUPPORTED_IMPLS=( "${supp[@]}" )
+	_PYTHON_UNSUPPORTED_IMPLS=( "${unsupp[@]}" )
 	readonly _PYTHON_SUPPORTED_IMPLS _PYTHON_UNSUPPORTED_IMPLS
 }
 
-- 
2.12.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-dev] [PATCH 02/10] python-utils-r1.eclass: _python_set_impls, add integrity check
  2017-03-01 16:02 [gentoo-dev] [PATCHES] python-r1, add integrity checks for redefined control vars Michał Górny
  2017-03-01 16:02 ` [gentoo-dev] [PATCH 01/10] python-utils-r1.eclass: _python_set_impls, use local vars Michał Górny
@ 2017-03-01 16:02 ` Michał Górny
  2017-03-01 16:02 ` [gentoo-dev] [PATCH 03/10] python-any-r1.eclass: Global setter, refactor for more local vars Michał Górny
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Michał Górny @ 2017-03-01 16:02 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Add integrity check for multi-inherits, i.e. ensure that PYTHON_COMPAT
has not changed between successive calls to _python_set_impls. If it did
(e.g. because of eclass+ebuild setting different values), then we abort
not to give surprising results to the user.
---
 eclass/python-utils-r1.eclass | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index fd219d95a760..60129173fc06 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -128,9 +128,25 @@ _python_set_impls() {
 		die "No supported implementation in PYTHON_COMPAT."
 	fi
 
-	_PYTHON_SUPPORTED_IMPLS=( "${supp[@]}" )
-	_PYTHON_UNSUPPORTED_IMPLS=( "${unsupp[@]}" )
-	readonly _PYTHON_SUPPORTED_IMPLS _PYTHON_UNSUPPORTED_IMPLS
+	if [[ ${_PYTHON_SUPPORTED_IMPLS[@]} ]]; then
+		# set once already, verify integrity
+		if [[ ${_PYTHON_SUPPORTED_IMPLS[@]} != ${supp[@]} ]]; then
+			eerror "Supported impls (PYTHON_COMPAT) changed between inherits!"
+			eerror "Before: ${_PYTHON_SUPPORTED_IMPLS[*]}"
+			eerror "Now   : ${supp[*]}"
+			die "_PYTHON_SUPPORTED_IMPLS integrity check failed"
+		fi
+		if [[ ${_PYTHON_UNSUPPORTED_IMPLS[@]} != ${unsupp[@]} ]]; then
+			eerror "Unsupported impls changed between inherits!"
+			eerror "Before: ${_PYTHON_UNSUPPORTED_IMPLS[*]}"
+			eerror "Now   : ${unsupp[*]}"
+			die "_PYTHON_UNSUPPORTED_IMPLS integrity check failed"
+		fi
+	else
+		_PYTHON_SUPPORTED_IMPLS=( "${supp[@]}" )
+		_PYTHON_UNSUPPORTED_IMPLS=( "${unsupp[@]}" )
+		readonly _PYTHON_SUPPORTED_IMPLS _PYTHON_UNSUPPORTED_IMPLS
+	fi
 }
 
 # @ECLASS-VARIABLE: PYTHON
-- 
2.12.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-dev] [PATCH 03/10] python-any-r1.eclass: Global setter, refactor for more local vars
  2017-03-01 16:02 [gentoo-dev] [PATCHES] python-r1, add integrity checks for redefined control vars Michał Górny
  2017-03-01 16:02 ` [gentoo-dev] [PATCH 01/10] python-utils-r1.eclass: _python_set_impls, use local vars Michał Górny
  2017-03-01 16:02 ` [gentoo-dev] [PATCH 02/10] python-utils-r1.eclass: _python_set_impls, add integrity check Michał Górny
@ 2017-03-01 16:02 ` Michał Górny
  2017-03-01 16:02 ` [gentoo-dev] [PATCH 04/10] python-any-r1.eclass: Add integrity check for globals Michał Górny
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Michał Górny @ 2017-03-01 16:02 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Refactor _python_any_set_globals() to use local variables while
generating all output, and copy it to final vars at the end. This is
in preparation for integrity checks. NFC.
---
 eclass/python-any-r1.eclass | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass
index a1dd4282c1ef..d41cf6a5808d 100644
--- a/eclass/python-any-r1.eclass
+++ b/eclass/python-any-r1.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2015 Gentoo Foundation
+# Copyright 1999-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: python-any-r1.eclass
@@ -148,19 +148,20 @@ if [[ ! ${_PYTHON_ANY_R1} ]]; then
 # @CODE
 
 _python_any_set_globals() {
-	local usestr i PYTHON_PKG_DEP
+	local usestr deps i PYTHON_PKG_DEP
 	[[ ${PYTHON_REQ_USE} ]] && usestr="[${PYTHON_REQ_USE}]"
 
 	_python_set_impls
 
-	PYTHON_DEPS=
 	for i in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
 		python_export "${i}" PYTHON_PKG_DEP
 
 		# note: need to strip '=' slot operator for || deps
-		PYTHON_DEPS="${PYTHON_PKG_DEP%=} ${PYTHON_DEPS}"
+		deps="${PYTHON_PKG_DEP%=} ${deps}"
 	done
-	PYTHON_DEPS="|| ( ${PYTHON_DEPS})"
+	deps="|| ( ${deps})"
+
+	PYTHON_DEPS=${deps}
 	readonly PYTHON_DEPS
 }
 _python_any_set_globals
-- 
2.12.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-dev] [PATCH 04/10] python-any-r1.eclass: Add integrity check for globals
  2017-03-01 16:02 [gentoo-dev] [PATCHES] python-r1, add integrity checks for redefined control vars Michał Górny
                   ` (2 preceding siblings ...)
  2017-03-01 16:02 ` [gentoo-dev] [PATCH 03/10] python-any-r1.eclass: Global setter, refactor for more local vars Michał Górny
@ 2017-03-01 16:02 ` Michał Górny
  2017-03-01 16:02 ` [gentoo-dev] [PATCH 05/10] python-r1.eclass: Remove stale EAPI=4 branch in globals Michał Górny
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Michał Górny @ 2017-03-01 16:02 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

---
 eclass/python-any-r1.eclass | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass
index d41cf6a5808d..69f7bb736d22 100644
--- a/eclass/python-any-r1.eclass
+++ b/eclass/python-any-r1.eclass
@@ -57,8 +57,6 @@ fi
 
 EXPORT_FUNCTIONS pkg_setup
 
-if [[ ! ${_PYTHON_ANY_R1} ]]; then
-
 # @ECLASS-VARIABLE: PYTHON_COMPAT
 # @REQUIRED
 # @DESCRIPTION:
@@ -161,12 +159,23 @@ _python_any_set_globals() {
 	done
 	deps="|| ( ${deps})"
 
-	PYTHON_DEPS=${deps}
-	readonly PYTHON_DEPS
+	if [[ ${PYTHON_DEPS+1} ]]; then
+		if [[ ${PYTHON_DEPS} != "${deps}" ]]; then
+			eerror "PYTHON_DEPS have changed between inherits (PYTHON_REQ_USE?)!"
+			eerror "Before: ${PYTHON_DEPS}"
+			eerror "Now   : ${deps}"
+			die "PYTHON_DEPS integrity check failed"
+		fi
+	else
+		PYTHON_DEPS=${deps}
+		readonly PYTHON_DEPS
+	fi
 }
 _python_any_set_globals
 unset -f _python_any_set_globals
 
+if [[ ! ${_PYTHON_ANY_R1} ]]; then
+
 # @FUNCTION: python_gen_any_dep
 # @USAGE: <dependency-block>
 # @DESCRIPTION:
-- 
2.12.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-dev] [PATCH 05/10] python-r1.eclass: Remove stale EAPI=4 branch in globals
  2017-03-01 16:02 [gentoo-dev] [PATCHES] python-r1, add integrity checks for redefined control vars Michał Górny
                   ` (3 preceding siblings ...)
  2017-03-01 16:02 ` [gentoo-dev] [PATCH 04/10] python-any-r1.eclass: Add integrity check for globals Michał Górny
@ 2017-03-01 16:02 ` Michał Górny
  2017-03-01 16:02 ` [gentoo-dev] [PATCH 06/10] python-r1.eclass: Refactor globals to use local vars, NFC Michał Górny
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Michał Górny @ 2017-03-01 16:02 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

---
 eclass/python-r1.eclass | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index 929ec8fa8f89..549474630353 100644
--- a/eclass/python-r1.eclass
+++ b/eclass/python-r1.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2015 Gentoo Foundation
+# Copyright 1999-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: python-r1.eclass
@@ -195,14 +195,10 @@ _python_set_globals() {
 	# but no point in making this overcomplex, BDEP doesn't hurt anyone
 	# 2) python-exec should be built with all targets forced anyway
 	# but if new targets were added, we may need to force a rebuild
-	# 3) use whichever python-exec slot installed in EAPI 5. For EAPI 4,
-	# just fix :2 since := deps are not supported.
 	if [[ ${_PYTHON_WANT_PYTHON_EXEC2} == 0 ]]; then
 		die "python-exec:0 is no longer supported, please fix your ebuild to work with python-exec:2"
-	elif [[ ${EAPI} != 4 ]]; then
-		PYTHON_DEPS+=">=dev-lang/python-exec-2:=[${PYTHON_USEDEP}]"
 	else
-		PYTHON_DEPS+="dev-lang/python-exec:2[${PYTHON_USEDEP}]"
+		PYTHON_DEPS+=">=dev-lang/python-exec-2:=[${PYTHON_USEDEP}]"
 	fi
 	readonly PYTHON_DEPS PYTHON_REQUIRED_USE PYTHON_USEDEP
 }
-- 
2.12.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-dev] [PATCH 06/10] python-r1.eclass: Refactor globals to use local vars, NFC
  2017-03-01 16:02 [gentoo-dev] [PATCHES] python-r1, add integrity checks for redefined control vars Michał Górny
                   ` (4 preceding siblings ...)
  2017-03-01 16:02 ` [gentoo-dev] [PATCH 05/10] python-r1.eclass: Remove stale EAPI=4 branch in globals Michał Górny
@ 2017-03-01 16:02 ` Michał Górny
  2017-03-01 16:02 ` [gentoo-dev] [PATCH 07/10] python-r1.eclass: Add integrity checks for globals Michał Górny
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Michał Górny @ 2017-03-01 16:02 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

---
 eclass/python-r1.eclass | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index 549474630353..1cf65056f637 100644
--- a/eclass/python-r1.eclass
+++ b/eclass/python-r1.eclass
@@ -165,14 +165,13 @@ inherit multibuild python-utils-r1
 # @CODE
 
 _python_set_globals() {
-	PYTHON_DEPS=
-	local i PYTHON_PKG_DEP
+	local deps i PYTHON_PKG_DEP
 
 	_python_set_impls
 
 	for i in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
 		python_export "${i}" PYTHON_PKG_DEP
-		PYTHON_DEPS+="python_targets_${i}? ( ${PYTHON_PKG_DEP} ) "
+		deps+="python_targets_${i}? ( ${PYTHON_PKG_DEP} ) "
 	done
 
 	local flags=( "${_PYTHON_SUPPORTED_IMPLS[@]/#/python_targets_}" )
@@ -186,10 +185,8 @@ _python_set_globals() {
 
 	local flags_st=( "${_PYTHON_SUPPORTED_IMPLS[@]/#/-python_single_target_}" )
 	optflags+=,${flags_st[@]/%/(-)}
-
-	IUSE=${flags[*]}
-	PYTHON_REQUIRED_USE="|| ( ${flags[*]} )"
-	PYTHON_USEDEP=${optflags// /,}
+	local requse="|| ( ${flags[*]} )"
+	local usedep=${optflags// /,}
 
 	# 1) well, python-exec would suffice as an RDEP
 	# but no point in making this overcomplex, BDEP doesn't hurt anyone
@@ -198,8 +195,13 @@ _python_set_globals() {
 	if [[ ${_PYTHON_WANT_PYTHON_EXEC2} == 0 ]]; then
 		die "python-exec:0 is no longer supported, please fix your ebuild to work with python-exec:2"
 	else
-		PYTHON_DEPS+=">=dev-lang/python-exec-2:=[${PYTHON_USEDEP}]"
+		deps+=">=dev-lang/python-exec-2:=[${usedep}]"
 	fi
+
+	PYTHON_DEPS=${deps}
+	IUSE=${flags[*]}
+	PYTHON_REQUIRED_USE=${requse}
+	PYTHON_USEDEP=${usedep}
 	readonly PYTHON_DEPS PYTHON_REQUIRED_USE PYTHON_USEDEP
 }
 _python_set_globals
-- 
2.12.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-dev] [PATCH 07/10] python-r1.eclass: Add integrity checks for globals
  2017-03-01 16:02 [gentoo-dev] [PATCHES] python-r1, add integrity checks for redefined control vars Michał Górny
                   ` (5 preceding siblings ...)
  2017-03-01 16:02 ` [gentoo-dev] [PATCH 06/10] python-r1.eclass: Refactor globals to use local vars, NFC Michał Górny
@ 2017-03-01 16:02 ` Michał Górny
  2017-03-01 16:02 ` [gentoo-dev] [PATCH 08/10] python-single-r1.eclass: Remove stale EAPI=4 branch in globals Michał Górny
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Michał Górny @ 2017-03-01 16:02 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

---
 eclass/python-r1.eclass | 42 +++++++++++++++++++++++++++++++++++++-----
 1 file changed, 37 insertions(+), 5 deletions(-)

diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index 1cf65056f637..bacf869ef237 100644
--- a/eclass/python-r1.eclass
+++ b/eclass/python-r1.eclass
@@ -51,6 +51,8 @@ fi
 [[ ${EAPI} == [45] ]] && inherit eutils
 inherit multibuild python-utils-r1
 
+fi
+
 # @ECLASS-VARIABLE: PYTHON_COMPAT
 # @REQUIRED
 # @DESCRIPTION:
@@ -198,15 +200,45 @@ _python_set_globals() {
 		deps+=">=dev-lang/python-exec-2:=[${usedep}]"
 	fi
 
-	PYTHON_DEPS=${deps}
-	IUSE=${flags[*]}
-	PYTHON_REQUIRED_USE=${requse}
-	PYTHON_USEDEP=${usedep}
-	readonly PYTHON_DEPS PYTHON_REQUIRED_USE PYTHON_USEDEP
+	if [[ ${PYTHON_DEPS+1} ]]; then
+		# IUSE is magical, so we can't really check it
+		# (but we verify PYTHON_COMPAT already)
+
+		if [[ ${PYTHON_DEPS} != "${deps}" ]]; then
+			eerror "PYTHON_DEPS have changed between inherits (PYTHON_REQ_USE?)!"
+			eerror "Before: ${PYTHON_DEPS}"
+			eerror "Now   : ${deps}"
+			die "PYTHON_DEPS integrity check failed"
+		fi
+
+		# these two are formality -- they depend on PYTHON_COMPAT only
+		if [[ ${PYTHON_REQUIRED_USE} != ${requse} ]]; then
+			eerror "PYTHON_REQUIRED_USE have changed between inherits!"
+			eerror "Before: ${PYTHON_REQUIRED_USE}"
+			eerror "Now   : ${requse}"
+			die "PYTHON_REQUIRED_USE integrity check failed"
+		fi
+
+		if [[ ${PYTHON_USEDEP} != "${usedep}" ]]; then
+			eerror "PYTHON_USEDEP have changed between inherits!"
+			eerror "Before: ${PYTHON_USEDEP}"
+			eerror "Now   : ${usedep}"
+			die "PYTHON_USEDEP integrity check failed"
+		fi
+	else
+		IUSE=${flags[*]}
+
+		PYTHON_DEPS=${deps}
+		PYTHON_REQUIRED_USE=${requse}
+		PYTHON_USEDEP=${usedep}
+		readonly PYTHON_DEPS PYTHON_REQUIRED_USE PYTHON_USEDEP
+	fi
 }
 _python_set_globals
 unset -f _python_set_globals
 
+if [[ ! ${_PYTHON_R1} ]]; then
+
 # @FUNCTION: _python_validate_useflags
 # @INTERNAL
 # @DESCRIPTION:
-- 
2.12.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-dev] [PATCH 08/10] python-single-r1.eclass: Remove stale EAPI=4 branch in globals
  2017-03-01 16:02 [gentoo-dev] [PATCHES] python-r1, add integrity checks for redefined control vars Michał Górny
                   ` (6 preceding siblings ...)
  2017-03-01 16:02 ` [gentoo-dev] [PATCH 07/10] python-r1.eclass: Add integrity checks for globals Michał Górny
@ 2017-03-01 16:02 ` Michał Górny
  2017-03-01 16:02 ` [gentoo-dev] [PATCH 09/10] python-single-r1.eclass: Refactor global setter to use locals, NFC Michał Górny
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Michał Górny @ 2017-03-01 16:02 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

---
 eclass/python-single-r1.eclass | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass
index 3b89ef57cfef..84d1f067be14 100644
--- a/eclass/python-single-r1.eclass
+++ b/eclass/python-single-r1.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2015 Gentoo Foundation
+# Copyright 1999-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: python-single-r1.eclass
@@ -226,14 +226,10 @@ _python_single_set_globals() {
 	# but no point in making this overcomplex, BDEP doesn't hurt anyone
 	# 2) python-exec should be built with all targets forced anyway
 	# but if new targets were added, we may need to force a rebuild
-	# 3) use whichever python-exec slot installed in EAPI 5. For EAPI 4,
-	# just fix :2 since := deps are not supported.
 	if [[ ${_PYTHON_WANT_PYTHON_EXEC2} == 0 ]]; then
 		die "python-exec:0 is no longer supported, please fix your ebuild to work with python-exec:2"
-	elif [[ ${EAPI} != 4 ]]; then
-		PYTHON_DEPS+=">=dev-lang/python-exec-2:=[${PYTHON_USEDEP}]"
 	else
-		PYTHON_DEPS+="dev-lang/python-exec:2[${PYTHON_USEDEP}]"
+		PYTHON_DEPS+=">=dev-lang/python-exec-2:=[${PYTHON_USEDEP}]"
 	fi
 	readonly PYTHON_DEPS PYTHON_REQUIRED_USE PYTHON_USEDEP
 }
-- 
2.12.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-dev] [PATCH 09/10] python-single-r1.eclass: Refactor global setter to use locals, NFC
  2017-03-01 16:02 [gentoo-dev] [PATCHES] python-r1, add integrity checks for redefined control vars Michał Górny
                   ` (7 preceding siblings ...)
  2017-03-01 16:02 ` [gentoo-dev] [PATCH 08/10] python-single-r1.eclass: Remove stale EAPI=4 branch in globals Michał Górny
@ 2017-03-01 16:02 ` Michał Górny
  2017-03-01 16:02 ` [gentoo-dev] [PATCH 10/10] python-single-r1.eclass: Add integrity checks for globals Michał Górny
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Michał Górny @ 2017-03-01 16:02 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

---
 eclass/python-single-r1.eclass | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass
index 84d1f067be14..85350924b657 100644
--- a/eclass/python-single-r1.eclass
+++ b/eclass/python-single-r1.eclass
@@ -180,7 +180,6 @@ if [[ ! ${_PYTHON_SINGLE_R1} ]]; then
 _python_single_set_globals() {
 	_python_set_impls
 
-	PYTHON_DEPS=
 	local i PYTHON_PKG_DEP
 
 	local flags_mt=( "${_PYTHON_SUPPORTED_IMPLS[@]/#/python_targets_}" )
@@ -191,12 +190,13 @@ _python_single_set_globals() {
 
 	IUSE="${flags_mt[*]}"
 
+	local deps requse usedep
 	if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
 		# There is only one supported implementation; set IUSE and other
 		# variables without PYTHON_SINGLE_TARGET.
-		PYTHON_REQUIRED_USE="${flags_mt[*]}"
+		requse=${flags_mt[*]}
 		python_export "${_PYTHON_SUPPORTED_IMPLS[0]}" PYTHON_PKG_DEP
-		PYTHON_DEPS="${flags_mt[*]}? ( ${PYTHON_PKG_DEP} ) "
+		deps="${flags_mt[*]}? ( ${PYTHON_PKG_DEP} ) "
 		# Force on the python_single_target_* flag for this impl, so
 		# that any dependencies that inherit python-single-r1 and
 		# happen to have multiple implementations will still need
@@ -205,7 +205,7 @@ _python_single_set_globals() {
 	else
 		# Multiple supported implementations; honor PYTHON_SINGLE_TARGET.
 		IUSE+=" ${flags[*]}"
-		PYTHON_REQUIRED_USE="^^ ( ${flags[*]} )"
+		requse="^^ ( ${flags[*]} )"
 		# Ensure deps honor the same python_single_target_* flag as is set
 		# on this package.
 		optflags+=,${flags[@]/%/(+)?}
@@ -214,13 +214,13 @@ _python_single_set_globals() {
 			# The chosen targets need to be in PYTHON_TARGETS as well.
 			# This is in order to enforce correct dependencies on packages
 			# supporting multiple implementations.
-			PYTHON_REQUIRED_USE+=" python_single_target_${i}? ( python_targets_${i} )"
+			requse+=" python_single_target_${i}? ( python_targets_${i} )"
 
 			python_export "${i}" PYTHON_PKG_DEP
-			PYTHON_DEPS+="python_single_target_${i}? ( ${PYTHON_PKG_DEP} ) "
+			deps+="python_single_target_${i}? ( ${PYTHON_PKG_DEP} ) "
 		done
 	fi
-	PYTHON_USEDEP=${optflags// /,}
+	usedep=${optflags// /,}
 
 	# 1) well, python-exec would suffice as an RDEP
 	# but no point in making this overcomplex, BDEP doesn't hurt anyone
@@ -229,8 +229,12 @@ _python_single_set_globals() {
 	if [[ ${_PYTHON_WANT_PYTHON_EXEC2} == 0 ]]; then
 		die "python-exec:0 is no longer supported, please fix your ebuild to work with python-exec:2"
 	else
-		PYTHON_DEPS+=">=dev-lang/python-exec-2:=[${PYTHON_USEDEP}]"
+		deps+=">=dev-lang/python-exec-2:=[${usedep}]"
 	fi
+
+	PYTHON_DEPS=${deps}
+	PYTHON_REQUIRED_USE=${requse}
+	PYTHON_USEDEP=${usedep}
 	readonly PYTHON_DEPS PYTHON_REQUIRED_USE PYTHON_USEDEP
 }
 _python_single_set_globals
-- 
2.12.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-dev] [PATCH 10/10] python-single-r1.eclass: Add integrity checks for globals
  2017-03-01 16:02 [gentoo-dev] [PATCHES] python-r1, add integrity checks for redefined control vars Michał Górny
                   ` (8 preceding siblings ...)
  2017-03-01 16:02 ` [gentoo-dev] [PATCH 09/10] python-single-r1.eclass: Refactor global setter to use locals, NFC Michał Górny
@ 2017-03-01 16:02 ` Michał Górny
  2017-03-03 20:54 ` [gentoo-dev] [PATCHES] python-r1, add integrity checks for redefined control vars Tim Harder
  2017-03-08  7:41 ` Michał Górny
  11 siblings, 0 replies; 13+ messages in thread
From: Michał Górny @ 2017-03-01 16:02 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

---
 eclass/python-single-r1.eclass | 36 ++++++++++++++++++++++++++++++------
 1 file changed, 30 insertions(+), 6 deletions(-)

diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass
index 85350924b657..fc51c4ec2377 100644
--- a/eclass/python-single-r1.eclass
+++ b/eclass/python-single-r1.eclass
@@ -56,8 +56,6 @@ fi
 
 EXPORT_FUNCTIONS pkg_setup
 
-if [[ ! ${_PYTHON_SINGLE_R1} ]]; then
-
 # @ECLASS-VARIABLE: PYTHON_COMPAT
 # @REQUIRED
 # @DESCRIPTION:
@@ -232,14 +230,40 @@ _python_single_set_globals() {
 		deps+=">=dev-lang/python-exec-2:=[${usedep}]"
 	fi
 
-	PYTHON_DEPS=${deps}
-	PYTHON_REQUIRED_USE=${requse}
-	PYTHON_USEDEP=${usedep}
-	readonly PYTHON_DEPS PYTHON_REQUIRED_USE PYTHON_USEDEP
+	if [[ ${PYTHON_DEPS+1} ]]; then
+		if [[ ${PYTHON_DEPS} != "${deps}" ]]; then
+			eerror "PYTHON_DEPS have changed between inherits (PYTHON_REQ_USE?)!"
+			eerror "Before: ${PYTHON_DEPS}"
+			eerror "Now   : ${deps}"
+			die "PYTHON_DEPS integrity check failed"
+		fi
+
+		# these two are formality -- they depend on PYTHON_COMPAT only
+		if [[ ${PYTHON_REQUIRED_USE} != ${requse} ]]; then
+			eerror "PYTHON_REQUIRED_USE have changed between inherits!"
+			eerror "Before: ${PYTHON_REQUIRED_USE}"
+			eerror "Now   : ${requse}"
+			die "PYTHON_REQUIRED_USE integrity check failed"
+		fi
+
+		if [[ ${PYTHON_USEDEP} != "${usedep}" ]]; then
+			eerror "PYTHON_USEDEP have changed between inherits!"
+			eerror "Before: ${PYTHON_USEDEP}"
+			eerror "Now   : ${usedep}"
+			die "PYTHON_USEDEP integrity check failed"
+		fi
+	else
+		PYTHON_DEPS=${deps}
+		PYTHON_REQUIRED_USE=${requse}
+		PYTHON_USEDEP=${usedep}
+		readonly PYTHON_DEPS PYTHON_REQUIRED_USE PYTHON_USEDEP
+	fi
 }
 _python_single_set_globals
 unset -f _python_single_set_globals
 
+if [[ ! ${_PYTHON_SINGLE_R1} ]]; then
+
 # @FUNCTION: python_gen_usedep
 # @USAGE: <pattern> [...]
 # @DESCRIPTION:
-- 
2.12.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [gentoo-dev] [PATCHES] python-r1, add integrity checks for redefined control vars
  2017-03-01 16:02 [gentoo-dev] [PATCHES] python-r1, add integrity checks for redefined control vars Michał Górny
                   ` (9 preceding siblings ...)
  2017-03-01 16:02 ` [gentoo-dev] [PATCH 10/10] python-single-r1.eclass: Add integrity checks for globals Michał Górny
@ 2017-03-03 20:54 ` Tim Harder
  2017-03-08  7:41 ` Michał Górny
  11 siblings, 0 replies; 13+ messages in thread
From: Tim Harder @ 2017-03-03 20:54 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 201 bytes --]

I've attached another simple patch that I don't think was fixed in your
changeset to stop the 'impl' var from _python_obtain_impls() in
python-r1.eclass from leaking into the environment.

Thanks,
Tim

[-- Attachment #2: 0001-python-r1.eclass-localize-variable-to-avoid-leaking-.patch --]
[-- Type: text/x-diff, Size: 723 bytes --]

From 0a6174036e5d31028e47fb5f477033fdb7b76aba Mon Sep 17 00:00:00 2001
From: Tim Harder <radhermit@gentoo.org>
Date: Fri, 3 Mar 2017 15:49:16 -0500
Subject: [PATCH] python-r1.eclass: localize variable to avoid leaking into the
 env

---
 eclass/python-r1.eclass | 1 +
 1 file changed, 1 insertion(+)

diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index 929ec8fa8f..4d27881cd5 100644
--- a/eclass/python-r1.eclass
+++ b/eclass/python-r1.eclass
@@ -476,6 +476,7 @@ _python_obtain_impls() {
 
 	MULTIBUILD_VARIANTS=()
 
+	local impl
 	for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
 		has "${impl}" "${PYTHON_COMPAT[@]}" && \
 		use "python_targets_${impl}" && MULTIBUILD_VARIANTS+=( "${impl}" )
-- 
2.12.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [gentoo-dev] [PATCHES] python-r1, add integrity checks for redefined control vars
  2017-03-01 16:02 [gentoo-dev] [PATCHES] python-r1, add integrity checks for redefined control vars Michał Górny
                   ` (10 preceding siblings ...)
  2017-03-03 20:54 ` [gentoo-dev] [PATCHES] python-r1, add integrity checks for redefined control vars Tim Harder
@ 2017-03-08  7:41 ` Michał Górny
  11 siblings, 0 replies; 13+ messages in thread
From: Michał Górny @ 2017-03-08  7:41 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 77 bytes --]

Merged, along with radhermit's patch.

-- 
Best regards,
Michał Górny

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 963 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-03-08  7:42 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-01 16:02 [gentoo-dev] [PATCHES] python-r1, add integrity checks for redefined control vars Michał Górny
2017-03-01 16:02 ` [gentoo-dev] [PATCH 01/10] python-utils-r1.eclass: _python_set_impls, use local vars Michał Górny
2017-03-01 16:02 ` [gentoo-dev] [PATCH 02/10] python-utils-r1.eclass: _python_set_impls, add integrity check Michał Górny
2017-03-01 16:02 ` [gentoo-dev] [PATCH 03/10] python-any-r1.eclass: Global setter, refactor for more local vars Michał Górny
2017-03-01 16:02 ` [gentoo-dev] [PATCH 04/10] python-any-r1.eclass: Add integrity check for globals Michał Górny
2017-03-01 16:02 ` [gentoo-dev] [PATCH 05/10] python-r1.eclass: Remove stale EAPI=4 branch in globals Michał Górny
2017-03-01 16:02 ` [gentoo-dev] [PATCH 06/10] python-r1.eclass: Refactor globals to use local vars, NFC Michał Górny
2017-03-01 16:02 ` [gentoo-dev] [PATCH 07/10] python-r1.eclass: Add integrity checks for globals Michał Górny
2017-03-01 16:02 ` [gentoo-dev] [PATCH 08/10] python-single-r1.eclass: Remove stale EAPI=4 branch in globals Michał Górny
2017-03-01 16:02 ` [gentoo-dev] [PATCH 09/10] python-single-r1.eclass: Refactor global setter to use locals, NFC Michał Górny
2017-03-01 16:02 ` [gentoo-dev] [PATCH 10/10] python-single-r1.eclass: Add integrity checks for globals Michał Górny
2017-03-03 20:54 ` [gentoo-dev] [PATCHES] python-r1, add integrity checks for redefined control vars Tim Harder
2017-03-08  7:41 ` Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox