Merge lp:~wgrant/launchpad/get-out-of-here-p-a-s into lp:launchpad

Proposed by William Grant
Status: Merged
Approved by: Henning Eggers
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~wgrant/launchpad/get-out-of-here-p-a-s
Merge into: lp:launchpad
Diff against target: 304 lines (+104/-100)
6 files modified
lib/lp/buildmaster/master.py (+1/-95)
lib/lp/soyuz/doc/package-arch-specific.txt (+2/-3)
lib/lp/soyuz/model/publishing.py (+1/-1)
lib/lp/soyuz/model/queue.py (+1/-1)
lib/lp/soyuz/pas.py (+94/-0)
lib/lp/soyuz/tests/test_doc.py (+5/-0)
To merge this branch: bzr merge lp:~wgrant/launchpad/get-out-of-here-p-a-s
Reviewer Review Type Date Requested Status
Julian Edwards (community) Approve
Henning Eggers (community) code Approve
Review via email: mp+21312@code.launchpad.net

Commit message

Move P-a-s from lp.buildmaster to lp.soyuz. Landed by henninge.

Description of the change

This branch just moves the Packages-architecture-specific code from lp.buildmaster to lp.soyuz. It's only used to select the Soyuz binary builds that need to be created, so it belongs in lp.soyuz.

To post a comment you must log in.
Revision history for this message
Henning Eggers (henninge) wrote :

Thanks. ;-)

review: Approve (code)
Revision history for this message
Julian Edwards (julian-edwards) wrote :

Looks ok, but I think pas.py should come out of model/ and into soyuz/

Cheers

Revision history for this message
Julian Edwards (julian-edwards) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/buildmaster/master.py'
2--- lib/lp/buildmaster/master.py 2010-03-08 12:53:59 +0000
3+++ lib/lp/buildmaster/master.py 2010-03-15 10:39:26 +0000
4@@ -14,7 +14,6 @@
5
6
7 import logging
8-import operator
9
10 from zope.component import getUtility
11
12@@ -24,102 +23,9 @@
13 from lp.archivepublisher.utils import process_in_batches
14 from lp.buildmaster.interfaces.buildbase import BuildStatus
15 from lp.buildmaster.interfaces.buildqueue import IBuildQueueSet
16-from lp.buildmaster.pas import BuildDaemonPackagesArchSpecific
17 from lp.buildmaster.buildergroup import BuilderGroup
18-from lp.soyuz.interfaces.archive import ArchivePurpose
19 from lp.soyuz.interfaces.build import IBuildSet
20-
21-
22-def determineArchitecturesToBuild(pubrec, legal_archseries,
23- distroseries, pas_verify=None):
24- """Return a list of architectures for which this publication should build.
25-
26- This function answers the question: given a publication, what
27- architectures should we build it for? It takes a set of legal
28- distroarchseries and the distribution series for which we are
29- building, and optionally a BuildDaemonPackagesArchSpecific
30- (informally known as 'P-a-s') instance.
31-
32- The P-a-s component contains a list of forbidden architectures for
33- each source package, which should be respected regardless of which
34- architectures have been requested in the source package metadata,
35- for instance:
36-
37- * 'aboot' should only build on powerpc
38- * 'mozilla-firefox' should not build on sparc
39-
40- This black/white list is an optimization to suppress temporarily
41- known-failures build attempts and thus saving build-farm time.
42-
43- For PPA publications we only consider architectures supported by PPA
44- subsystem (`DistroArchSeries`.supports_virtualized flag) and P-a-s is turned
45- off to give the users the chance to test their fixes for upstream
46- problems.
47-
48- :param: pubrec: `ISourcePackagePublishingHistory` representing the
49- source publication.
50- :param: legal_archseries: a list of all initialized `DistroArchSeries`
51- to be considered.
52- :param: distroseries: the context `DistroSeries`.
53- :param: pas_verify: optional P-a-s verifier object/component.
54- :return: a list of `DistroArchSeries` for which the source publication in
55- question should be built.
56- """
57- hint_string = pubrec.sourcepackagerelease.architecturehintlist
58-
59- assert hint_string, 'Missing arch_hint_list'
60-
61- # Ignore P-a-s for PPA publications.
62- if pubrec.archive.purpose == ArchivePurpose.PPA:
63- pas_verify = None
64-
65- # The 'PPA supported' flag only applies to virtualized archives
66- if pubrec.archive.require_virtualized:
67- legal_archseries = [
68- arch for arch in legal_archseries if arch.supports_virtualized]
69- # Cope with no virtualization support at all. It usually happens when
70- # a distroseries is created and initialized, by default no
71- # architecture supports its. Distro-team might take some time to
72- # decide which architecture will be allowed for PPAs and queue-builder
73- # will continue to work meanwhile.
74- if not legal_archseries:
75- return []
76-
77- legal_arch_tags = set(arch.architecturetag for arch in legal_archseries)
78-
79- if hint_string == 'any':
80- package_tags = legal_arch_tags
81- elif hint_string == 'all':
82- nominated_arch = distroseries.nominatedarchindep
83- legal_archseries_ids = [arch.id for arch in legal_archseries]
84- assert nominated_arch.id in legal_archseries_ids, (
85- 'nominatedarchindep is not present in legal_archseries: %s' %
86- ' '.join(legal_arch_tags))
87- package_tags = set([nominated_arch.architecturetag])
88- else:
89- my_archs = hint_string.split()
90- # Allow any-foo or linux-foo to mean foo. See bug 73761.
91- my_archs = [arch.replace("any-", "") for arch in my_archs]
92- my_archs = [arch.replace("linux-", "") for arch in my_archs]
93- my_archs = set(my_archs)
94- package_tags = my_archs.intersection(legal_arch_tags)
95-
96- if pas_verify:
97- build_tags = set()
98- for tag in package_tags:
99- sourcepackage_name = pubrec.sourcepackagerelease.name
100- if sourcepackage_name in pas_verify.permit:
101- permitted = pas_verify.permit[sourcepackage_name]
102- if tag not in permitted:
103- continue
104- build_tags.add(tag)
105- else:
106- build_tags = package_tags
107-
108- sorted_archseries = sorted(legal_archseries,
109- key=operator.attrgetter('architecturetag'))
110- return [arch for arch in sorted_archseries
111- if arch.architecturetag in build_tags]
112+from lp.soyuz.pas import BuildDaemonPackagesArchSpecific
113
114
115 class BuilddMaster:
116
117=== renamed file 'lib/lp/buildmaster/tests/package-arch-specific.txt' => 'lib/lp/soyuz/doc/package-arch-specific.txt'
118--- lib/lp/buildmaster/tests/package-arch-specific.txt 2009-05-14 09:28:47 +0000
119+++ lib/lp/soyuz/doc/package-arch-specific.txt 2010-03-15 10:39:26 +0000
120@@ -95,8 +95,8 @@
121 See if the code which determines archs to build does the right thing for
122 each of these options:
123
124- >>> from lp.buildmaster.master import (
125- ... determineArchitecturesToBuild)
126+ >>> from lp.soyuz.pas import (
127+ ... BuildDaemonPackagesArchSpecific, determineArchitecturesToBuild)
128
129 >>> def print_build_architectures(pub, pas_verify=None):
130 ... allowed_architectures = determineArchitecturesToBuild(
131@@ -182,7 +182,6 @@
132 >>> import os
133 >>> import tempfile
134 >>> import shutil
135- >>> from lp.buildmaster.pas import BuildDaemonPackagesArchSpecific
136
137 >>> def getPASVerifier(pas_string):
138 ... """Build and return a PAS verifier based on the string provided."""
139
140=== modified file 'lib/lp/soyuz/model/publishing.py'
141--- lib/lp/soyuz/model/publishing.py 2010-03-06 04:57:40 +0000
142+++ lib/lp/soyuz/model/publishing.py 2010-03-15 10:39:26 +0000
143@@ -41,7 +41,6 @@
144 IStoreSelector, MAIN_STORE, DEFAULT_FLAVOR)
145 from canonical.launchpad.webapp.interfaces import NotFoundError
146 from lp.buildmaster.interfaces.buildbase import BuildStatus
147-from lp.buildmaster.master import determineArchitecturesToBuild
148 from lp.registry.interfaces.person import validate_public_person
149 from lp.registry.interfaces.pocket import PackagePublishingPocket
150 from lp.soyuz.model.binarypackagename import BinaryPackageName
151@@ -62,6 +61,7 @@
152 PackagePublishingPriority, PackagePublishingStatus,
153 PoolFileOverwriteError)
154 from lp.soyuz.interfaces.queue import PackageUploadStatus
155+from lp.soyuz.pas import determineArchitecturesToBuild
156 from lp.soyuz.scripts.changeoverride import ArchiveOverriderError
157
158
159
160=== modified file 'lib/lp/soyuz/model/queue.py'
161--- lib/lp/soyuz/model/queue.py 2010-03-12 16:52:21 +0000
162+++ lib/lp/soyuz/model/queue.py 2010-03-15 10:39:26 +0000
163@@ -35,7 +35,6 @@
164 from lp.archiveuploader.changesfile import ChangesFile
165 from lp.archiveuploader.tagfiles import parse_tagfile_lines
166 from lp.archiveuploader.utils import safe_fix_maintainer
167-from lp.buildmaster.pas import BuildDaemonPackagesArchSpecific
168 from canonical.cachedproperty import cachedproperty
169 from canonical.config import config
170 from canonical.database.constants import UTC_NOW
171@@ -60,6 +59,7 @@
172 NonBuildableSourceUploadError, QueueBuildAcceptError,
173 QueueInconsistentStateError, QueueSourceAcceptError,
174 QueueStateWriteProtectedError)
175+from lp.soyuz.pas import BuildDaemonPackagesArchSpecific
176 from canonical.launchpad.mail import (
177 format_address, signed_message_from_string, sendmail)
178 from lp.soyuz.scripts.processaccepted import (
179
180=== renamed file 'lib/lp/buildmaster/pas.py' => 'lib/lp/soyuz/pas.py'
181--- lib/lp/buildmaster/pas.py 2009-06-25 00:46:29 +0000
182+++ lib/lp/soyuz/pas.py 2010-03-15 10:39:26 +0000
183@@ -2,9 +2,12 @@
184 # GNU Affero General Public License version 3 (see the file LICENSE).
185
186 import os
187+import operator
188
189 from sqlobject import SQLObjectNotFound
190
191+from lp.soyuz.interfaces.archive import ArchivePurpose
192+
193 class BuildDaemonPackagesArchSpecific:
194 """Parse and implement "PackagesArchSpecific"."""
195
196@@ -106,3 +109,94 @@
197
198 return source_name, arch_tags
199
200+
201+def determineArchitecturesToBuild(pubrec, legal_archseries,
202+ distroseries, pas_verify=None):
203+ """Return a list of architectures for which this publication should build.
204+
205+ This function answers the question: given a publication, what
206+ architectures should we build it for? It takes a set of legal
207+ distroarchseries and the distribution series for which we are
208+ building, and optionally a BuildDaemonPackagesArchSpecific
209+ (informally known as 'P-a-s') instance.
210+
211+ The P-a-s component contains a list of forbidden architectures for
212+ each source package, which should be respected regardless of which
213+ architectures have been requested in the source package metadata,
214+ for instance:
215+
216+ * 'aboot' should only build on powerpc
217+ * 'mozilla-firefox' should not build on sparc
218+
219+ This black/white list is an optimization to suppress temporarily
220+ known-failures build attempts and thus saving build-farm time.
221+
222+ For PPA publications we only consider architectures supported by PPA
223+ subsystem (`DistroArchSeries`.supports_virtualized flag) and P-a-s is turned
224+ off to give the users the chance to test their fixes for upstream
225+ problems.
226+
227+ :param: pubrec: `ISourcePackagePublishingHistory` representing the
228+ source publication.
229+ :param: legal_archseries: a list of all initialized `DistroArchSeries`
230+ to be considered.
231+ :param: distroseries: the context `DistroSeries`.
232+ :param: pas_verify: optional P-a-s verifier object/component.
233+ :return: a list of `DistroArchSeries` for which the source publication in
234+ question should be built.
235+ """
236+ hint_string = pubrec.sourcepackagerelease.architecturehintlist
237+
238+ assert hint_string, 'Missing arch_hint_list'
239+
240+ # Ignore P-a-s for PPA publications.
241+ if pubrec.archive.purpose == ArchivePurpose.PPA:
242+ pas_verify = None
243+
244+ # The 'PPA supported' flag only applies to virtualized archives
245+ if pubrec.archive.require_virtualized:
246+ legal_archseries = [
247+ arch for arch in legal_archseries if arch.supports_virtualized]
248+ # Cope with no virtualization support at all. It usually happens when
249+ # a distroseries is created and initialized, by default no
250+ # architecture supports its. Distro-team might take some time to
251+ # decide which architecture will be allowed for PPAs and queue-builder
252+ # will continue to work meanwhile.
253+ if not legal_archseries:
254+ return []
255+
256+ legal_arch_tags = set(arch.architecturetag for arch in legal_archseries)
257+
258+ if hint_string == 'any':
259+ package_tags = legal_arch_tags
260+ elif hint_string == 'all':
261+ nominated_arch = distroseries.nominatedarchindep
262+ legal_archseries_ids = [arch.id for arch in legal_archseries]
263+ assert nominated_arch.id in legal_archseries_ids, (
264+ 'nominatedarchindep is not present in legal_archseries: %s' %
265+ ' '.join(legal_arch_tags))
266+ package_tags = set([nominated_arch.architecturetag])
267+ else:
268+ my_archs = hint_string.split()
269+ # Allow any-foo or linux-foo to mean foo. See bug 73761.
270+ my_archs = [arch.replace("any-", "") for arch in my_archs]
271+ my_archs = [arch.replace("linux-", "") for arch in my_archs]
272+ my_archs = set(my_archs)
273+ package_tags = my_archs.intersection(legal_arch_tags)
274+
275+ if pas_verify:
276+ build_tags = set()
277+ for tag in package_tags:
278+ sourcepackage_name = pubrec.sourcepackagerelease.name
279+ if sourcepackage_name in pas_verify.permit:
280+ permitted = pas_verify.permit[sourcepackage_name]
281+ if tag not in permitted:
282+ continue
283+ build_tags.add(tag)
284+ else:
285+ build_tags = package_tags
286+
287+ sorted_archseries = sorted(legal_archseries,
288+ key=operator.attrgetter('architecturetag'))
289+ return [arch for arch in sorted_archseries
290+ if arch.architecturetag in build_tags]
291
292=== modified file 'lib/lp/soyuz/tests/test_doc.py'
293--- lib/lp/soyuz/tests/test_doc.py 2009-06-30 16:56:07 +0000
294+++ lib/lp/soyuz/tests/test_doc.py 2010-03-15 10:39:26 +0000
295@@ -200,6 +200,11 @@
296 setUp=builddmasterSetUp,
297 layer=LaunchpadZopelessLayer,
298 ),
299+ 'package-arch-specific.txt': LayeredDocFileSuite(
300+ '../doc/package-arch-specific.txt',
301+ setUp=builddmasterSetUp,
302+ layer=LaunchpadZopelessLayer,
303+ ),
304 }
305
306