Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/tests/resolver/, pym/_emerge/
Date: Sun, 26 Feb 2012 10:01:10
Message-Id: 1330250340.b684a8d3a73da02423d090c58c0f1536c25b093b.zmedico@gentoo
1 commit: b684a8d3a73da02423d090c58c0f1536c25b093b
2 Author: Sebastian Luther <SebastianLuther <AT> gmx <DOT> de>
3 AuthorDate: Sun Feb 26 09:34:31 2012 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Sun Feb 26 09:59:00 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b684a8d3
7
8 autounmask: Avoid unmasking live versions if possible
9
10 Before this patch the allowed changes were:
11
12 1. USE
13 2. USE + ~arch + license
14 3. USE + ~arch + license + missing keywords + masks
15
16 With this patch:
17
18 1. USE
19 2. USE + ~arch + license
20 3. USE + ~arch + license + missing keywords
21 4. USE + ~arch + license + masks
22 5. USE + ~arch + license + missing keywords + masks
23
24 This avoids unmasking live versions, which are typically masked
25 and have missing keywords to be avoided if there is a regular
26 masked version available.
27
28 ---
29 pym/_emerge/depgraph.py | 33 +++++++++++++----
30 pym/portage/tests/resolver/test_autounmask.py | 47 ++++++++++++++++++++++++-
31 2 files changed, 71 insertions(+), 9 deletions(-)
32
33 diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
34 index a05c17e..e4310b4 100644
35 --- a/pym/_emerge/depgraph.py
36 +++ b/pym/_emerge/depgraph.py
37 @@ -3505,15 +3505,31 @@ class depgraph(object):
38 return True
39
40 class _AutounmaskLevel(object):
41 - __slots__ = ("allow_use_changes", "allow_unstable_keywords", "allow_license_changes", "allow_unmasks")
42 + __slots__ = ("allow_use_changes", "allow_unstable_keywords", "allow_license_changes", \
43 + "allow_missing_keywords", "allow_unmasks")
44
45 def __init__(self):
46 self.allow_use_changes = False
47 - self.allow_unstable_keywords = False
48 self.allow_license_changes = False
49 + self.allow_unstable_keywords = False
50 + self.allow_missing_keywords = False
51 self.allow_unmasks = False
52
53 def _autounmask_levels(self):
54 + """
55 + Iterate over the different allowed things to unmask.
56 +
57 + 1. USE
58 + 2. USE + ~arch + license
59 + 3. USE + ~arch + license + missing keywords
60 + 4. USE + ~arch + license + masks
61 + 5. USE + ~arch + license + missing keywords + masks
62 +
63 + Some thoughts:
64 + * Do least invasive changes first.
65 + * Try unmasking alone before unmasking + missing keywords
66 + to avoid -9999 versions if possible
67 + """
68
69 if self._dynamic_config._autounmask is not True:
70 return
71 @@ -3528,11 +3544,13 @@ class depgraph(object):
72 autounmask_level.allow_unstable_keywords = (not only_use_changes)
73 autounmask_level.allow_license_changes = (not only_use_changes)
74
75 - for allow_unmasks in (False, True):
76 - if allow_unmasks and (only_use_changes or autounmask_keep_masks):
77 - continue
78 + for missing_keyword, unmask in ((False,False), (True, False), (False, True), (True, True)):
79 +
80 + if (only_use_changes or autounmask_keep_masks) and (missing_keyword or unmask):
81 + break
82
83 - autounmask_level.allow_unmasks = allow_unmasks
84 + autounmask_level.allow_missing_keywords = missing_keyword
85 + autounmask_level.allow_unmasks = unmask
86
87 yield autounmask_level
88
89 @@ -3634,9 +3652,8 @@ class depgraph(object):
90 #Package has already been unmasked.
91 return True
92
93 - #We treat missing keywords in the same way as masks.
94 if (masked_by_unstable_keywords and not autounmask_level.allow_unstable_keywords) or \
95 - (masked_by_missing_keywords and not autounmask_level.allow_unmasks) or \
96 + (masked_by_missing_keywords and not autounmask_level.allow_missing_keywords) or \
97 (masked_by_p_mask and not autounmask_level.allow_unmasks) or \
98 (missing_licenses and not autounmask_level.allow_license_changes):
99 #We are not allowed to do the needed changes.
100
101 diff --git a/pym/portage/tests/resolver/test_autounmask.py b/pym/portage/tests/resolver/test_autounmask.py
102 index 3da1c25..46dbab1 100644
103 --- a/pym/portage/tests/resolver/test_autounmask.py
104 +++ b/pym/portage/tests/resolver/test_autounmask.py
105 @@ -391,7 +391,11 @@ class AutounmaskTestCase(TestCase):
106
107
108 def testAutounmaskKeepMasks(self):
109 -
110 + """
111 + Ensure that we try to use a masked version with keywords before trying
112 + masked version with missing keywords (prefer masked regular version
113 + over -9999 version).
114 + """
115 ebuilds = {
116 "app-text/A-1": {},
117 }
118 @@ -427,3 +431,44 @@ class AutounmaskTestCase(TestCase):
119 self.assertEqual(test_case.test_success, True, test_case.fail_msg)
120 finally:
121 playground.cleanup()
122 +
123 +
124 + def testAutounmask9999(self):
125 +
126 + ebuilds = {
127 + "dev-libs/A-1": { },
128 + "dev-libs/A-2": { },
129 + "dev-libs/A-9999": { "KEYWORDS": "" },
130 + "dev-libs/B-1": { "DEPEND": ">=dev-libs/A-2" },
131 + "dev-libs/C-1": { "DEPEND": ">=dev-libs/A-3" },
132 + }
133 +
134 + profile = {
135 + "package.mask":
136 + (
137 + ">=dev-libs/A-2",
138 + ),
139 + }
140 +
141 + test_cases = (
142 + ResolverPlaygroundTestCase(
143 + ["dev-libs/B"],
144 + success = False,
145 + mergelist = ["dev-libs/A-2", "dev-libs/B-1"],
146 + needed_p_mask_changes = set(["dev-libs/A-2"])),
147 +
148 + ResolverPlaygroundTestCase(
149 + ["dev-libs/C"],
150 + success = False,
151 + mergelist = ["dev-libs/A-9999", "dev-libs/C-1"],
152 + unstable_keywords = set(["dev-libs/A-9999"]),
153 + needed_p_mask_changes = set(["dev-libs/A-9999"])),
154 + )
155 +
156 + playground = ResolverPlayground(ebuilds=ebuilds, profile=profile)
157 + try:
158 + for test_case in test_cases:
159 + playground.run_TestCase(test_case)
160 + self.assertEqual(test_case.test_success, True, test_case.fail_msg)
161 + finally:
162 + playground.cleanup()