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 07/10] python-r1.eclass: Add integrity checks for globals
Date: Wed, 01 Mar 2017 16:09:02
Message-Id: 20170301160249.11287-8-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCHES] python-r1, add integrity checks for redefined control vars by "Michał Górny"
1 ---
2 eclass/python-r1.eclass | 42 +++++++++++++++++++++++++++++++++++++-----
3 1 file changed, 37 insertions(+), 5 deletions(-)
4
5 diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
6 index 1cf65056f637..bacf869ef237 100644
7 --- a/eclass/python-r1.eclass
8 +++ b/eclass/python-r1.eclass
9 @@ -51,6 +51,8 @@ fi
10 [[ ${EAPI} == [45] ]] && inherit eutils
11 inherit multibuild python-utils-r1
12
13 +fi
14 +
15 # @ECLASS-VARIABLE: PYTHON_COMPAT
16 # @REQUIRED
17 # @DESCRIPTION:
18 @@ -198,15 +200,45 @@ _python_set_globals() {
19 deps+=">=dev-lang/python-exec-2:=[${usedep}]"
20 fi
21
22 - PYTHON_DEPS=${deps}
23 - IUSE=${flags[*]}
24 - PYTHON_REQUIRED_USE=${requse}
25 - PYTHON_USEDEP=${usedep}
26 - readonly PYTHON_DEPS PYTHON_REQUIRED_USE PYTHON_USEDEP
27 + if [[ ${PYTHON_DEPS+1} ]]; then
28 + # IUSE is magical, so we can't really check it
29 + # (but we verify PYTHON_COMPAT already)
30 +
31 + if [[ ${PYTHON_DEPS} != "${deps}" ]]; then
32 + eerror "PYTHON_DEPS have changed between inherits (PYTHON_REQ_USE?)!"
33 + eerror "Before: ${PYTHON_DEPS}"
34 + eerror "Now : ${deps}"
35 + die "PYTHON_DEPS integrity check failed"
36 + fi
37 +
38 + # these two are formality -- they depend on PYTHON_COMPAT only
39 + if [[ ${PYTHON_REQUIRED_USE} != ${requse} ]]; then
40 + eerror "PYTHON_REQUIRED_USE have changed between inherits!"
41 + eerror "Before: ${PYTHON_REQUIRED_USE}"
42 + eerror "Now : ${requse}"
43 + die "PYTHON_REQUIRED_USE integrity check failed"
44 + fi
45 +
46 + if [[ ${PYTHON_USEDEP} != "${usedep}" ]]; then
47 + eerror "PYTHON_USEDEP have changed between inherits!"
48 + eerror "Before: ${PYTHON_USEDEP}"
49 + eerror "Now : ${usedep}"
50 + die "PYTHON_USEDEP integrity check failed"
51 + fi
52 + else
53 + IUSE=${flags[*]}
54 +
55 + PYTHON_DEPS=${deps}
56 + PYTHON_REQUIRED_USE=${requse}
57 + PYTHON_USEDEP=${usedep}
58 + readonly PYTHON_DEPS PYTHON_REQUIRED_USE PYTHON_USEDEP
59 + fi
60 }
61 _python_set_globals
62 unset -f _python_set_globals
63
64 +if [[ ! ${_PYTHON_R1} ]]; then
65 +
66 # @FUNCTION: _python_validate_useflags
67 # @INTERNAL
68 # @DESCRIPTION:
69 --
70 2.12.0