Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 02/10] python-utils-r1.eclass: _python_set_impls, add integrity check
Date: Wed, 01 Mar 2017 16:04:16
Message-Id: 20170301160249.11287-3-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCHES] python-r1, add integrity checks for redefined control vars by "Michał Górny"
1 Add integrity check for multi-inherits, i.e. ensure that PYTHON_COMPAT
2 has not changed between successive calls to _python_set_impls. If it did
3 (e.g. because of eclass+ebuild setting different values), then we abort
4 not to give surprising results to the user.
5 ---
6 eclass/python-utils-r1.eclass | 22 +++++++++++++++++++---
7 1 file changed, 19 insertions(+), 3 deletions(-)
8
9 diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
10 index fd219d95a760..60129173fc06 100644
11 --- a/eclass/python-utils-r1.eclass
12 +++ b/eclass/python-utils-r1.eclass
13 @@ -128,9 +128,25 @@ _python_set_impls() {
14 die "No supported implementation in PYTHON_COMPAT."
15 fi
16
17 - _PYTHON_SUPPORTED_IMPLS=( "${supp[@]}" )
18 - _PYTHON_UNSUPPORTED_IMPLS=( "${unsupp[@]}" )
19 - readonly _PYTHON_SUPPORTED_IMPLS _PYTHON_UNSUPPORTED_IMPLS
20 + if [[ ${_PYTHON_SUPPORTED_IMPLS[@]} ]]; then
21 + # set once already, verify integrity
22 + if [[ ${_PYTHON_SUPPORTED_IMPLS[@]} != ${supp[@]} ]]; then
23 + eerror "Supported impls (PYTHON_COMPAT) changed between inherits!"
24 + eerror "Before: ${_PYTHON_SUPPORTED_IMPLS[*]}"
25 + eerror "Now : ${supp[*]}"
26 + die "_PYTHON_SUPPORTED_IMPLS integrity check failed"
27 + fi
28 + if [[ ${_PYTHON_UNSUPPORTED_IMPLS[@]} != ${unsupp[@]} ]]; then
29 + eerror "Unsupported impls changed between inherits!"
30 + eerror "Before: ${_PYTHON_UNSUPPORTED_IMPLS[*]}"
31 + eerror "Now : ${unsupp[*]}"
32 + die "_PYTHON_UNSUPPORTED_IMPLS integrity check failed"
33 + fi
34 + else
35 + _PYTHON_SUPPORTED_IMPLS=( "${supp[@]}" )
36 + _PYTHON_UNSUPPORTED_IMPLS=( "${unsupp[@]}" )
37 + readonly _PYTHON_SUPPORTED_IMPLS _PYTHON_UNSUPPORTED_IMPLS
38 + fi
39 }
40
41 # @ECLASS-VARIABLE: PYTHON
42 --
43 2.12.0