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/portage/tests/resolver/binpkg_multi_instance/
Date: Wed, 04 Mar 2015 21:37:56
Message-Id: 1425504727.6d4eb498e59ff6477b4290047bee78c77bd28676.zmedico@gentoo
1 commit: 6d4eb498e59ff6477b4290047bee78c77bd28676
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Tue Feb 17 22:56:47 2015 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Wed Mar 4 21:32:07 2015 +0000
6 URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=6d4eb498
7
8 binpkg-multi-instance 4 of 7
9
10 Add a test case to verify that emerge --rebuilt-binaries works with
11 binpkg-multi-instance. This relies on the fact that binary packages of
12 the same version are ordered by BUILD_TIME, so that the latest builds
13 are preferred when appropriate.
14
15 pym/portage/tests/resolver/ResolverPlayground.py | 25 ++++-
16 .../resolver/binpkg_multi_instance/__init__.py | 2 +
17 .../resolver/binpkg_multi_instance/__test__.py | 2 +
18 .../binpkg_multi_instance/test_rebuilt_binaries.py | 101 +++++++++++++++++++++
19 4 files changed, 126 insertions(+), 4 deletions(-)
20
21 diff --git a/pym/portage/tests/resolver/ResolverPlayground.py b/pym/portage/tests/resolver/ResolverPlayground.py
22 index 84ad17c..6bdf2c7 100644
23 --- a/pym/portage/tests/resolver/ResolverPlayground.py
24 +++ b/pym/portage/tests/resolver/ResolverPlayground.py
25 @@ -39,6 +39,7 @@ class ResolverPlayground(object):
26
27 config_files = frozenset(("eapi", "layout.conf", "make.conf", "package.accept_keywords",
28 "package.keywords", "package.license", "package.mask", "package.properties",
29 + "package.provided", "packages",
30 "package.unmask", "package.use", "package.use.aliases", "package.use.stable.mask",
31 "soname.provided",
32 "unpack_dependencies", "use.aliases", "use.force", "use.mask", "layout.conf"))
33 @@ -208,12 +209,18 @@ class ResolverPlayground(object):
34 raise AssertionError('digest creation failed for %s' % ebuild_path)
35
36 def _create_binpkgs(self, binpkgs):
37 - for cpv, metadata in binpkgs.items():
38 + # When using BUILD_ID, there can be mutiple instances for the
39 + # same cpv. Therefore, binpkgs may be an iterable instead of
40 + # a dict.
41 + items = getattr(binpkgs, 'items', None)
42 + items = items() if items is not None else binpkgs
43 + for cpv, metadata in items:
44 a = Atom("=" + cpv, allow_repo=True)
45 repo = a.repo
46 if repo is None:
47 repo = "test_repo"
48
49 + pn = catsplit(a.cp)[1]
50 cat, pf = catsplit(a.cpv)
51 metadata = metadata.copy()
52 metadata.setdefault("SLOT", "0")
53 @@ -225,8 +232,13 @@ class ResolverPlayground(object):
54
55 repo_dir = self.pkgdir
56 category_dir = os.path.join(repo_dir, cat)
57 - binpkg_path = os.path.join(category_dir, pf + ".tbz2")
58 - ensure_dirs(category_dir)
59 + if "BUILD_ID" in metadata:
60 + binpkg_path = os.path.join(category_dir, pn,
61 + "%s-%s.xpak"% (pf, metadata["BUILD_ID"]))
62 + else:
63 + binpkg_path = os.path.join(category_dir, pf + ".tbz2")
64 +
65 + ensure_dirs(os.path.dirname(binpkg_path))
66 t = portage.xpak.tbz2(binpkg_path)
67 t.recompose_mem(portage.xpak.xpak_mem(metadata))
68
69 @@ -252,6 +264,7 @@ class ResolverPlayground(object):
70 unknown_keys = set(metadata).difference(
71 portage.dbapi.dbapi._known_keys)
72 unknown_keys.discard("BUILD_TIME")
73 + unknown_keys.discard("BUILD_ID")
74 unknown_keys.discard("COUNTER")
75 unknown_keys.discard("repository")
76 unknown_keys.discard("USE")
77 @@ -749,7 +762,11 @@ class ResolverPlaygroundResult(object):
78 repo_str = ""
79 if x.repo != "test_repo":
80 repo_str = _repo_separator + x.repo
81 - mergelist_str = x.cpv + repo_str
82 + build_id_str = ""
83 + if (x.type_name == "binary" and
84 + x.cpv.build_id is not None):
85 + build_id_str = "-%s" % x.cpv.build_id
86 + mergelist_str = x.cpv + build_id_str + repo_str
87 if x.built:
88 if x.operation == "merge":
89 desc = x.type_name
90
91 diff --git a/pym/portage/tests/resolver/binpkg_multi_instance/__init__.py b/pym/portage/tests/resolver/binpkg_multi_instance/__init__.py
92 new file mode 100644
93 index 0000000..4725d33
94 --- /dev/null
95 +++ b/pym/portage/tests/resolver/binpkg_multi_instance/__init__.py
96 @@ -0,0 +1,2 @@
97 +# Copyright 2015 Gentoo Foundation
98 +# Distributed under the terms of the GNU General Public License v2
99
100 diff --git a/pym/portage/tests/resolver/binpkg_multi_instance/__test__.py b/pym/portage/tests/resolver/binpkg_multi_instance/__test__.py
101 new file mode 100644
102 index 0000000..4725d33
103 --- /dev/null
104 +++ b/pym/portage/tests/resolver/binpkg_multi_instance/__test__.py
105 @@ -0,0 +1,2 @@
106 +# Copyright 2015 Gentoo Foundation
107 +# Distributed under the terms of the GNU General Public License v2
108
109 diff --git a/pym/portage/tests/resolver/binpkg_multi_instance/test_rebuilt_binaries.py b/pym/portage/tests/resolver/binpkg_multi_instance/test_rebuilt_binaries.py
110 new file mode 100644
111 index 0000000..5729df4
112 --- /dev/null
113 +++ b/pym/portage/tests/resolver/binpkg_multi_instance/test_rebuilt_binaries.py
114 @@ -0,0 +1,101 @@
115 +# Copyright 2015 Gentoo Foundation
116 +# Distributed under the terms of the GNU General Public License v2
117 +
118 +from portage.tests import TestCase
119 +from portage.tests.resolver.ResolverPlayground import (ResolverPlayground,
120 + ResolverPlaygroundTestCase)
121 +
122 +class RebuiltBinariesCase(TestCase):
123 +
124 + def testRebuiltBinaries(self):
125 +
126 + user_config = {
127 + "make.conf":
128 + (
129 + "FEATURES=\"binpkg-multi-instance\"",
130 + ),
131 + }
132 +
133 + binpkgs = (
134 + ("app-misc/A-1", {
135 + "EAPI": "5",
136 + "BUILD_ID": "1",
137 + "BUILD_TIME": "1",
138 + }),
139 + ("app-misc/A-1", {
140 + "EAPI": "5",
141 + "BUILD_ID": "2",
142 + "BUILD_TIME": "2",
143 + }),
144 + ("app-misc/A-1", {
145 + "EAPI": "5",
146 + "BUILD_ID": "3",
147 + "BUILD_TIME": "3",
148 + }),
149 + ("dev-libs/B-1", {
150 + "EAPI": "5",
151 + "BUILD_ID": "1",
152 + "BUILD_TIME": "1",
153 + }),
154 + ("dev-libs/B-1", {
155 + "EAPI": "5",
156 + "BUILD_ID": "2",
157 + "BUILD_TIME": "2",
158 + }),
159 + ("dev-libs/B-1", {
160 + "EAPI": "5",
161 + "BUILD_ID": "3",
162 + "BUILD_TIME": "3",
163 + }),
164 + )
165 +
166 + installed = {
167 + "app-misc/A-1" : {
168 + "EAPI": "5",
169 + "BUILD_ID": "1",
170 + "BUILD_TIME": "1",
171 + },
172 + "dev-libs/B-1" : {
173 + "EAPI": "5",
174 + "BUILD_ID": "2",
175 + "BUILD_TIME": "2",
176 + },
177 + }
178 +
179 + world = (
180 + "app-misc/A",
181 + "dev-libs/B",
182 + )
183 +
184 + test_cases = (
185 +
186 + ResolverPlaygroundTestCase(
187 + ["@world"],
188 + options = {
189 + "--deep": True,
190 + "--rebuilt-binaries": True,
191 + "--update": True,
192 + "--usepkgonly": True,
193 + },
194 + success = True,
195 + ignore_mergelist_order=True,
196 + mergelist = [
197 + "[binary]dev-libs/B-1-3",
198 + "[binary]app-misc/A-1-3"
199 + ]
200 + ),
201 +
202 + )
203 +
204 + playground = ResolverPlayground(debug=False,
205 + binpkgs=binpkgs, installed=installed,
206 + user_config=user_config, world=world)
207 + try:
208 + for test_case in test_cases:
209 + playground.run_TestCase(test_case)
210 + self.assertEqual(test_case.test_success, True,
211 + test_case.fail_msg)
212 + finally:
213 + # Disable debug so that cleanup works.
214 + #playground.debug = False
215 + playground.cleanup()