Merge lp:~stevenk/launchpad/destroy-pas-yay into lp:launchpad

Proposed by Steve Kowalik
Status: Merged
Approved by: William Grant
Approved revision: no longer in the source branch.
Merged at revision: 16661
Proposed branch: lp:~stevenk/launchpad/destroy-pas-yay
Merge into: lp:launchpad
Diff against target: 676 lines (+53/-389)
7 files modified
lib/lp/soyuz/adapters/buildarch.py (+29/-160)
lib/lp/soyuz/adapters/tests/test_buildarch.py (+10/-159)
lib/lp/soyuz/interfaces/publishing.py (+1/-4)
lib/lp/soyuz/model/publishing.py (+5/-8)
lib/lp/soyuz/model/queue.py (+1/-6)
lib/lp/soyuz/scripts/add_missing_builds.py (+6/-13)
lib/lp/soyuz/scripts/tests/test_add_missing_builds.py (+1/-39)
To merge this branch: bzr merge lp:~stevenk/launchpad/destroy-pas-yay
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+166639@code.launchpad.net

Commit message

Destroy the P-a-s parser, and all callsites that were still using it.

Description of the change

Destroy the P-a-s parser, and all callsites that were still using it. Rationale better than I could type is in the bug.

lp.soyuz.pas is dead, now lp.soyuz.adapters.buildarch. I've removed all tests that depended on P-a-s functionality, but buildbot should tell me if I missed any.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== renamed file 'lib/lp/soyuz/pas.py' => 'lib/lp/soyuz/adapters/buildarch.py'
2--- lib/lp/soyuz/pas.py 2012-05-30 12:34:56 +0000
3+++ lib/lp/soyuz/adapters/buildarch.py 2013-05-31 04:30:36 +0000
4@@ -1,114 +1,17 @@
5-# Copyright 2009-2012 Canonical Ltd. This software is licensed under the
6+# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
7 # GNU Affero General Public License version 3 (see the file LICENSE).
8
9-import operator
10+__metaclass__ = type
11+
12+__all__ = [
13+ 'determine_architectures_to_build',
14+ ]
15+
16+
17+from operator import attrgetter
18 import os
19 import subprocess
20
21-from sqlobject import SQLObjectNotFound
22-
23-
24-class BuildDaemonPackagesArchSpecific:
25- """Parse and implement "PackagesArchSpecific"."""
26-
27- def __init__(self, pas_dir, distroseries):
28- self.pas_file = os.path.join(pas_dir, "Packages-arch-specific")
29- self.distroseries = distroseries
30- self.permit = {}
31- self._parsePAS()
32-
33- def _parsePAS(self):
34- """Parse self.pas_file and construct the permissible arch lists.
35-
36- A PAS source line looks like this:
37-
38- %openoffice.org2: i386 sparc powerpc amd64
39-
40- A PAS binary line looks like this:
41-
42- cmucl: i386 sparc amd64
43- """
44- try:
45- fd = open(self.pas_file, "r")
46- except IOError:
47- return
48-
49- all_arch_tags = set([a.architecturetag for a in
50- self.distroseries.architectures])
51- for line in fd:
52- line = line.split("#")[0]
53- line = line.strip()
54- if not line:
55- continue
56-
57- is_source = False
58- if line.startswith("%"):
59- is_source = True
60- line = line[1:]
61-
62- pkgname, arch_tags = line.split(":", 1)
63- is_exclude = False
64- if "!" in arch_tags:
65- is_exclude = True
66- arch_tags = arch_tags.replace("!", "")
67-
68- line_arch_tags = arch_tags.strip().split()
69- arch_tags = set(line_arch_tags).intersection(all_arch_tags)
70- if is_exclude:
71- arch_tags = all_arch_tags - arch_tags
72-
73- if not is_source:
74- ret = self._handleBinaryPAS(pkgname, arch_tags)
75- if ret is None:
76- continue
77- pkgname, arch_tags = ret
78-
79- self.permit[pkgname] = arch_tags
80-
81- fd.close()
82-
83- def _handleBinaryPAS(self, binary_name, arch_tags):
84- # We need to find a sourcepackagename, so search for it against
85- # the nominated distroarchseries (it could be any one, but
86- # using this one simplifies testing). If the sourcepackagename
87- # changes across arches then we'll have problems. We hope
88- # this'll never happen!
89- default_architecture = self.distroseries.nominatedarchindep
90- try:
91- binary_publications = default_architecture.getReleasedPackages(
92- binary_name)
93- except SQLObjectNotFound:
94- # Can't find it at all...
95- return None
96-
97- if len(binary_publications) == 0:
98- # Can't find it, so give up
99- return None
100-
101- # Use the first binary, they will all point to the same build and
102- # consequently to the same source.
103- test_binary = binary_publications[0]
104- build = test_binary.binarypackagerelease.build
105-
106- # If the source produces more than one binary it can't be restricted,
107- # The binary PAS line is completely ignored.
108- if build.binarypackages.count() > 1:
109- return None
110-
111- # The source produces a single binary, so it can be restricted.
112- source_name = build.source_package_release.name
113-
114- # The arch-independent builder /must/ be included in the
115- # arch_tags, regardless of whether the binary PAS line allows
116- # for it. If it is omitted and the package includes an arch-all
117- # binary, that binary will not be built! See thread on Launchpad
118- # list during Aug/2006 for more details on discussion. -- kiko
119- default_architecture_tag = default_architecture.architecturetag
120- if default_architecture_tag not in arch_tags:
121- arch_tags.add(default_architecture_tag)
122-
123- return source_name, arch_tags
124-
125
126 class DpkgArchitectureCache:
127 """Cache the results of asking questions of dpkg-architecture."""
128@@ -133,51 +36,29 @@
129 dpkg_architecture = DpkgArchitectureCache()
130
131
132-def determineArchitecturesToBuild(pubrec, legal_archseries,
133- distroseries, pas_verify=None):
134+def determine_architectures_to_build(hintlist, archive, distroseries,
135+ legal_archseries):
136 """Return a list of architectures for which this publication should build.
137
138- This function answers the question: given a publication, what
139- architectures should we build it for? It takes a set of legal
140- distroarchseries and the distribution series for which we are
141- building, and optionally a BuildDaemonPackagesArchSpecific
142- (informally known as 'P-a-s') instance.
143-
144- The P-a-s component contains a list of forbidden architectures for
145- each source package, which should be respected regardless of which
146- architectures have been requested in the source package metadata,
147- for instance:
148-
149- * 'aboot' should only build on powerpc
150- * 'mozilla-firefox' should not build on sparc
151-
152- This black/white list is an optimization to suppress temporarily
153- known-failures build attempts and thus saving build-farm time.
154+ This function answers the question: given a list of architectures and
155+ an archive, what architectures should we build it for? It takes a set of
156+ legal distroarchseries and the distribution series for which we are
157+ building.
158
159 For PPA publications we only consider architectures supported by PPA
160- subsystem (`DistroArchSeries`.supports_virtualized flag) and P-a-s is
161- turned off to give the users the chance to test their fixes for upstream
162- problems.
163+ subsystem (`DistroArchSeries`.supports_virtualized flag).
164
165- :param: pubrec: `ISourcePackagePublishingHistory` representing the
166- source publication.
167+ :param: hintlist: A string of the architectures this source package
168+ specifies it builds for.
169+ :param: archive: The `IArchive` we are building into.
170+ :param: distroseries: the context `DistroSeries`.
171 :param: legal_archseries: a list of all initialized `DistroArchSeries`
172 to be considered.
173- :param: distroseries: the context `DistroSeries`.
174- :param: pas_verify: optional P-a-s verifier object/component.
175 :return: a list of `DistroArchSeries` for which the source publication in
176 question should be built.
177 """
178- hint_string = pubrec.sourcepackagerelease.architecturehintlist
179-
180- assert hint_string, 'Missing arch_hint_list'
181-
182- # Ignore P-a-s for PPA publications.
183- if pubrec.archive.is_ppa:
184- pas_verify = None
185-
186 # The 'PPA supported' flag only applies to virtualized archives
187- if pubrec.archive.require_virtualized:
188+ if archive.require_virtualized:
189 legal_archseries = [
190 arch for arch in legal_archseries if arch.supports_virtualized]
191 # Cope with no virtualization support at all. It usually happens when
192@@ -191,32 +72,20 @@
193 legal_arch_tags = set(
194 arch.architecturetag for arch in legal_archseries if arch.enabled)
195
196- hint_archs = set(hint_string.split())
197- package_tags = set(dpkg_architecture.findAllMatches(
198+ hint_archs = set(hintlist.split())
199+ build_tags = set(dpkg_architecture.findAllMatches(
200 legal_arch_tags, hint_archs))
201
202 # 'all' is only used as a last resort, to create an arch-indep build
203 # where no builds would otherwise exist.
204- if len(package_tags) == 0 and 'all' in hint_archs:
205+ if len(build_tags) == 0 and 'all' in hint_archs:
206 nominated_arch = distroseries.nominatedarchindep
207 if nominated_arch in legal_archseries:
208- package_tags = set([nominated_arch.architecturetag])
209+ build_tags = set([nominated_arch.architecturetag])
210 else:
211- package_tags = set()
212-
213- if pas_verify:
214- build_tags = set()
215- for tag in package_tags:
216- sourcepackage_name = pubrec.sourcepackagerelease.name
217- if sourcepackage_name in pas_verify.permit:
218- permitted = pas_verify.permit[sourcepackage_name]
219- if tag not in permitted:
220- continue
221- build_tags.add(tag)
222- else:
223- build_tags = package_tags
224-
225- sorted_archseries = sorted(legal_archseries,
226- key=operator.attrgetter('architecturetag'))
227+ build_tags = set()
228+
229+ sorted_archseries = sorted(
230+ legal_archseries, key=attrgetter('architecturetag'))
231 return [arch for arch in sorted_archseries
232 if arch.architecturetag in build_tags]
233
234=== renamed file 'lib/lp/soyuz/tests/test_pas.py' => 'lib/lp/soyuz/adapters/tests/test_buildarch.py'
235--- lib/lp/soyuz/tests/test_pas.py 2012-05-30 12:34:41 +0000
236+++ lib/lp/soyuz/adapters/tests/test_buildarch.py 2013-05-31 04:30:36 +0000
237@@ -1,24 +1,16 @@
238-# Copyright 2009-2012 Canonical Ltd. This software is licensed under the
239+# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
240 # GNU Affero General Public License version 3 (see the file LICENSE).
241
242-import os
243-
244-from lp.soyuz.enums import (
245- ArchivePurpose,
246- PackagePublishingStatus,
247- )
248+from lp.soyuz.adapters.buildarch import determine_architectures_to_build
249 from lp.soyuz.model.processor import ProcessorFamily
250-from lp.soyuz.pas import (
251- BuildDaemonPackagesArchSpecific,
252- determineArchitecturesToBuild,
253- )
254 from lp.soyuz.tests.test_publishing import SoyuzTestPublisher
255 from lp.testing import TestCaseWithFactory
256 from lp.testing.layers import LaunchpadZopelessLayer
257
258
259 class TestDetermineArchitecturesToBuild(TestCaseWithFactory):
260- """Test that determineArchitecturesToBuild correctly interprets hints."""
261+ """Test that determine_architectures_to_build correctly interprets hints.
262+ """
263
264 layer = LaunchpadZopelessLayer
265
266@@ -33,43 +25,27 @@
267 'armel', armel_family, False, self.publisher.person)
268 self.publisher.addFakeChroots()
269
270- def getPASVerifier(self, pas_string):
271- """Build and return a PAS verifier based on the string provided."""
272- temp_dir = self.makeTemporaryDirectory()
273- pas_filename = os.path.join(temp_dir, "Packages-arch-specific")
274- with open(pas_filename, "w") as pas_file:
275- pas_file.write(pas_string)
276- pas_verify = BuildDaemonPackagesArchSpecific(
277- temp_dir, self.publisher.breezy_autotest)
278- return pas_verify
279-
280 def assertArchitecturesToBuild(self, expected_arch_tags, pub,
281- allowed_arch_tags=None, pas_string=None):
282+ allowed_arch_tags=None):
283 if allowed_arch_tags is None:
284 allowed_archs = self.publisher.breezy_autotest.architectures
285 else:
286 allowed_archs = [
287 arch for arch in self.publisher.breezy_autotest.architectures
288 if arch.architecturetag in allowed_arch_tags]
289- if pas_string is None:
290- pas_verify = None
291- else:
292- pas_verify = self.getPASVerifier(pas_string)
293- architectures = determineArchitecturesToBuild(
294- pub, allowed_archs, self.publisher.breezy_autotest,
295- pas_verify=pas_verify)
296+ architectures = determine_architectures_to_build(
297+ pub.sourcepackagerelease.architecturehintlist, pub.archive,
298+ self.publisher.breezy_autotest, allowed_archs)
299 self.assertContentEqual(
300 expected_arch_tags, [a.architecturetag for a in architectures])
301
302 def assertArchsForHint(self, hint_string, expected_arch_tags,
303- allowed_arch_tags=None, sourcename=None,
304- pas_string=None):
305+ allowed_arch_tags=None, sourcename=None):
306 """Assert that the given hint resolves to the expected archtags."""
307 pub = self.publisher.getPubSource(
308 sourcename=sourcename, architecturehintlist=hint_string)
309 self.assertArchitecturesToBuild(
310- expected_arch_tags, pub, allowed_arch_tags=allowed_arch_tags,
311- pas_string=pas_string)
312+ expected_arch_tags, pub, allowed_arch_tags=allowed_arch_tags)
313
314 def test_single_architecture(self):
315 # A hint string with a single arch resolves to just that arch.
316@@ -154,128 +130,3 @@
317 # i386) is omitted, no builds will be created for arch-indep
318 # sources.
319 self.assertArchsForHint('all', [], allowed_arch_tags=['hppa'])
320-
321- def test_source_pas_defaults_to_all_available_architectures(self):
322- # Normally, a source package will be built on all available
323- # architectures in the series.
324- self.assertArchsForHint(
325- "i386 hppa amd64", ["hppa", "i386"], pas_string="")
326-
327- def test_source_pas_can_restrict_to_one_architecture(self):
328- # A source package can be restricted to a single architecture via PAS.
329- self.assertArchsForHint(
330- "i386 hppa amd64", ["i386"], sourcename="test",
331- pas_string="%test: i386")
332-
333- def test_source_pas_can_restrict_to_no_architectures(self):
334- # A source package can be restricted to not built on any architecture.
335- self.assertArchsForHint(
336- "i386 hppa amd64", [], sourcename="test",
337- pas_string="%test: sparc")
338-
339- def test_source_pas_can_exclude_specific_architecture(self):
340- # A source PAS entry can exclude a specific architecture.
341- self.assertArchsForHint(
342- "i386 hppa amd64", ["hppa"], sourcename="test",
343- pas_string="%test: !i386")
344-
345- def setUpPPAAndSource(self):
346- # Create a PPA and return a new source publication in it.
347- archive = self.factory.makeArchive(
348- distribution=self.publisher.ubuntutest, purpose=ArchivePurpose.PPA)
349- return self.publisher.getPubSource(
350- sourcename="test-ppa", architecturehintlist="i386 hppa",
351- archive=archive)
352-
353- def test_source_pas_does_not_affect_ppa(self):
354- # PPA builds are not affected by source PAS restrictions; that is,
355- # they will build for all requested architectures currently
356- # supported in the PPA subsystem.
357- pub_ppa = self.setUpPPAAndSource()
358- self.assertArchitecturesToBuild(
359- ["i386"], pub_ppa, pas_string="%test-ppa: hppa")
360- self.assertArchitecturesToBuild(
361- ["i386"], pub_ppa, pas_string="%test-ppa: !i386")
362-
363- def setUpSourceAndBinary(self):
364- # To check binary PAS listings we'll use a source publication which
365- # produces a single binary.
366- pub_single = self.publisher.getPubSource(
367- sourcename="single", architecturehintlist="any")
368- binaries = self.publisher.getPubBinaries(
369- binaryname="single-bin", pub_source=pub_single,
370- status=PackagePublishingStatus.PUBLISHED)
371- binary_names = set(
372- pub.binarypackagerelease.name
373- for pub in pub_single.getPublishedBinaries())
374- self.assertEqual(1, len(binary_names))
375- return pub_single, binaries
376-
377- def test_binary_pas_unrelated_binary_lines_have_no_effect(self):
378- # Source packages are unaffected by an unrelated binary PAS line.
379- pub_single, binaries = self.setUpSourceAndBinary()
380- self.assertArchitecturesToBuild(
381- ["armel", "hppa", "i386"], pub_single, pas_string="boing: i386")
382-
383- def test_binary_pas_can_restrict_architectures(self):
384- # A PAS entry can restrict the build architectures by tagging the
385- # produced binary with a list of allowed architectures.
386- pub_single, binaries = self.setUpSourceAndBinary()
387- self.assertArchitecturesToBuild(
388- ["i386"], pub_single, pas_string="single-bin: i386 sparc")
389-
390- def test_binary_pas_can_exclude_specific_architecture(self):
391- # A binary PAS entry can exclude a specific architecture.
392- pub_single, binaries = self.setUpSourceAndBinary()
393- self.assertArchitecturesToBuild(
394- ["armel", "i386"], pub_single, pas_string="single-bin: !hppa")
395-
396- def test_binary_pas_cannot_exclude_nominatedarchindep(self):
397- # A binary PAS entry cannot exclude the 'nominatedarchindep'
398- # architecture. Architecture-independent binaries are only built on
399- # nominatedarchindep; if that architecture is blacklisted, those
400- # binaries will never be built.
401- pub_single, binaries = self.setUpSourceAndBinary()
402- self.assertArchitecturesToBuild(
403- ["i386"], pub_single, pas_string="single-bin: !i386 !hppa !armel")
404-
405- def test_binary_pas_does_not_affect_ppa(self):
406- # PPA builds are not affected by binary PAS restrictions.
407- pub_ppa = self.setUpPPAAndSource()
408- pub_ppa.archive.require_virtualized = False
409- self.publisher.getPubBinaries(
410- binaryname="ppa-bin", pub_source=pub_ppa,
411- status=PackagePublishingStatus.PUBLISHED)
412- self.assertArchitecturesToBuild(
413- ["hppa", "i386"], pub_ppa, pas_string="")
414- self.assertArchitecturesToBuild(
415- ["hppa", "i386"], pub_ppa, pas_string="ppa-bin: !hppa")
416-
417- def test_binary_pas_does_not_affect_multi_binary_sources(self):
418- # Binary PAS entries referring to binary packages whose source
419- # produces other binaries are completely ignored. Other tools use
420- # that information, but we can't restrict builds in this
421- # circumstance.
422- pub_multiple = self.publisher.getPubSource(
423- sourcename="multiple", architecturehintlist="any")
424- for build in pub_multiple.createMissingBuilds():
425- bin_one = self.publisher.uploadBinaryForBuild(build, "bin-one")
426- self.publisher.publishBinaryInArchive(
427- bin_one, pub_multiple.archive,
428- status=PackagePublishingStatus.PUBLISHED)
429- bin_two = self.publisher.uploadBinaryForBuild(build, "bin-two")
430- self.publisher.publishBinaryInArchive(
431- bin_two, pub_multiple.archive,
432- status=PackagePublishingStatus.PUBLISHED)
433- binary_names = set(
434- pub.binarypackagerelease.name
435- for pub in pub_multiple.getPublishedBinaries())
436- self.assertEqual(2, len(binary_names))
437- self.assertArchitecturesToBuild(
438- ["armel", "hppa", "i386"], pub_multiple, pas_string="")
439- self.assertArchitecturesToBuild(
440- ["armel", "hppa", "i386"], pub_multiple,
441- pas_string="bin-one: i386 sparc")
442- self.assertArchitecturesToBuild(
443- ["armel", "hppa", "i386"], pub_multiple,
444- pas_string="bin-two: !hppa")
445
446=== modified file 'lib/lp/soyuz/interfaces/publishing.py'
447--- lib/lp/soyuz/interfaces/publishing.py 2013-05-30 00:53:13 +0000
448+++ lib/lp/soyuz/interfaces/publishing.py 2013-05-31 04:30:36 +0000
449@@ -577,8 +577,7 @@
450 :return: a result set of `IBuilds`.
451 """
452
453- def createMissingBuilds(architectures_available=None, pas_verify=None,
454- logger=None):
455+ def createMissingBuilds(architectures_available=None, logger=None):
456 """Create missing Build records for a published source.
457
458 P-a-s should be used when accepting sources to the PRIMARY archive
459@@ -589,8 +588,6 @@
460 that should be considered for build creation; if not given
461 it will be calculated in place, all architectures for the
462 context distroseries with available chroot.
463- :param pas_verify: optional Package-architecture-specific (P-a-s)
464- object, to be used, when convinient, for creating builds;
465 :param logger: optional context Logger object (used on DEBUG level).
466
467 :return: a list of `Builds` created for this source publication.
468
469=== modified file 'lib/lp/soyuz/model/publishing.py'
470--- lib/lp/soyuz/model/publishing.py 2013-05-30 01:07:50 +0000
471+++ lib/lp/soyuz/model/publishing.py 2013-05-31 04:30:36 +0000
472@@ -85,6 +85,7 @@
473 ScriptRequest,
474 )
475 from lp.services.worlddata.model.country import Country
476+from lp.soyuz.adapters.buildarch import determine_architectures_to_build
477 from lp.soyuz.enums import (
478 ArchivePurpose,
479 BinaryPackageFormat,
480@@ -127,7 +128,6 @@
481 )
482 from lp.soyuz.model.packagediff import PackageDiff
483 from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
484-from lp.soyuz.pas import determineArchitecturesToBuild
485
486
487 def makePoolPath(source_name, component_name):
488@@ -606,12 +606,8 @@
489 distroarch.processorfamily in
490 self.archive.enabled_restricted_families]
491
492- def createMissingBuilds(self, architectures_available=None,
493- pas_verify=None, logger=None):
494+ def createMissingBuilds(self, architectures_available=None, logger=None):
495 """See `ISourcePackagePublishingHistory`."""
496- if self.archive.is_ppa:
497- pas_verify = None
498-
499 if architectures_available is None:
500 architectures_available = list(
501 self.distroseries.buildable_architectures)
502@@ -619,8 +615,9 @@
503 architectures_available = self._getAllowedArchitectures(
504 architectures_available)
505
506- build_architectures = determineArchitecturesToBuild(
507- self, architectures_available, self.distroseries, pas_verify)
508+ build_architectures = determine_architectures_to_build(
509+ self.sourcepackagerelease.architecturehintlist, self.archive,
510+ self.distroseries, architectures_available)
511
512 builds = []
513 for arch in build_architectures:
514
515=== modified file 'lib/lp/soyuz/model/queue.py'
516--- lib/lp/soyuz/model/queue.py 2013-05-28 01:24:33 +0000
517+++ lib/lp/soyuz/model/queue.py 2013-05-31 04:30:36 +0000
518@@ -51,7 +51,6 @@
519 from lp.registry.interfaces.pocket import PackagePublishingPocket
520 from lp.registry.model.sourcepackagename import SourcePackageName
521 from lp.services.auditor.client import AuditorClient
522-from lp.services.config import config
523 from lp.services.database.bulk import (
524 load_referencing,
525 load_related,
526@@ -124,7 +123,6 @@
527 from lp.soyuz.model.component import Component
528 from lp.soyuz.model.distroarchseries import DistroArchSeries
529 from lp.soyuz.model.section import Section
530-from lp.soyuz.pas import BuildDaemonPackagesArchSpecific
531
532 # There are imports below in PackageUploadCustom for various bits
533 # of the archivepublisher which cause circular import errors if they
534@@ -523,10 +521,7 @@
535
536 debug(logger, "Creating PENDING publishing record.")
537 [pub_source] = self.realiseUpload()
538- pas_verify = BuildDaemonPackagesArchSpecific(
539- config.builddmaster.root, self.distroseries)
540- builds = pub_source.createMissingBuilds(
541- pas_verify=pas_verify, logger=logger)
542+ builds = pub_source.createMissingBuilds(logger=logger)
543 self._validateBuildsForSource(pub_source.sourcepackagerelease, builds)
544 self._closeBugs(changesfile_path, logger)
545 self._giveKarma()
546
547=== modified file 'lib/lp/soyuz/scripts/add_missing_builds.py'
548--- lib/lp/soyuz/scripts/add_missing_builds.py 2012-06-29 08:40:05 +0000
549+++ lib/lp/soyuz/scripts/add_missing_builds.py 2013-05-31 04:30:36 +0000
550@@ -1,14 +1,11 @@
551-#
552-# Copyright 2009 Canonical Ltd. This software is licensed under the
553+# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
554 # GNU Affero General Public License version 3 (see the file LICENSE).
555
556 import sys
557
558 from lp.app.errors import NotFoundError
559-from lp.services.config import config
560 from lp.services.scripts.base import LaunchpadScriptFailure
561 from lp.soyuz.enums import PackagePublishingStatus
562-from lp.soyuz.pas import BuildDaemonPackagesArchSpecific
563 from lp.soyuz.scripts.ftpmasterbase import (
564 SoyuzScript,
565 SoyuzScriptError,
566@@ -18,8 +15,8 @@
567 class AddMissingBuilds(SoyuzScript):
568 """Helper class to create builds in PPAs for requested architectures."""
569
570- def add_missing_builds(self, archive, required_arches, pas_verify,
571- distroseries, pocket):
572+ def add_missing_builds(self, archive, required_arches, distroseries,
573+ pocket):
574 """Create builds in an archive as necessary.
575
576 :param archive: The `Archive`.
577@@ -71,8 +68,7 @@
578 for pubrec in sources:
579 self.logger.info("Considering %s" % pubrec.displayname)
580 builds = pubrec.createMissingBuilds(
581- architectures_available=doable_arch_set,
582- pas_verify=pas_verify, logger=self.logger)
583+ architectures_available=doable_arch_set, logger=self.logger)
584 if len(builds) > 0:
585 self.logger.info("Created %s build(s)" % len(builds))
586
587@@ -103,14 +99,11 @@
588 "%s not a valid architecture for %s" % (
589 arch_tag, self.location.distroseries.name))
590
591- pas_verify = BuildDaemonPackagesArchSpecific(
592- config.builddmaster.root, self.location.distroseries)
593-
594 # I'm tired of parsing options. Let's do it.
595 try:
596 self.add_missing_builds(
597- self.location.archive, arches, pas_verify,
598- self.location.distroseries, self.location.pocket)
599+ self.location.archive, arches, self.location.distroseries,
600+ self.location.pocket)
601 self.txn.commit()
602 self.logger.info("Finished adding builds.")
603 except Exception as err:
604
605=== modified file 'lib/lp/soyuz/scripts/tests/test_add_missing_builds.py'
606--- lib/lp/soyuz/scripts/tests/test_add_missing_builds.py 2011-12-30 06:14:56 +0000
607+++ lib/lp/soyuz/scripts/tests/test_add_missing_builds.py 2013-05-31 04:30:36 +0000
608@@ -1,13 +1,11 @@
609-# Copyright 2010 Canonical Ltd. This software is licensed under the
610+# Copyright 2010-2013 Canonical Ltd. This software is licensed under the
611 # GNU Affero General Public License version 3 (see the file LICENSE).
612
613 """Test the add-missing-builds.py script. """
614
615 import os
616-import shutil
617 import subprocess
618 import sys
619-import tempfile
620
621 from lp.registry.interfaces.pocket import PackagePublishingPocket
622 from lp.services.config import config
623@@ -20,7 +18,6 @@
624 ArchivePurpose,
625 PackagePublishingStatus,
626 )
627-from lp.soyuz.pas import BuildDaemonPackagesArchSpecific
628 from lp.soyuz.scripts.add_missing_builds import AddMissingBuilds
629 from lp.soyuz.tests.test_publishing import SoyuzTestPublisher
630 from lp.testing import TestCaseWithFactory
631@@ -79,17 +76,6 @@
632 script.logger = BufferLogger()
633 return script
634
635- def makePasVerifier(self, content, series):
636- """Create a BuildDaemonPackagesArchSpecific."""
637- temp_dir = tempfile.mkdtemp()
638- filename = os.path.join(temp_dir, "Packages-arch-specific")
639- file = open(filename, "w")
640- file.write(content)
641- file.close()
642- verifier = BuildDaemonPackagesArchSpecific(temp_dir, series)
643- shutil.rmtree(temp_dir)
644- return verifier
645-
646 def getBuilds(self):
647 """Helper to return build records."""
648 any_build_i386 = self.any.sourcepackagerelease.getBuildByArch(
649@@ -173,27 +159,3 @@
650 self.ppa, self.required_arches, None, self.stp.breezy_autotest,
651 PackagePublishingPocket.RELEASE)
652 self.assertNoBuilds()
653-
654- def testPrimaryArchiveWithPas(self):
655- """Test that the script functions correctly on a primary archive.
656-
657- Also verifies that it respects Packages-arch-specific in this case.
658- """
659- archive = self.stp.ubuntutest.main_archive
660- any = self.stp.getPubSource(
661- sourcename="any", architecturehintlist="any",
662- status=PackagePublishingStatus.PUBLISHED)
663- pas_any = self.stp.getPubSource(
664- sourcename="pas-any", architecturehintlist="any",
665- status=PackagePublishingStatus.PUBLISHED)
666-
667- verifier = self.makePasVerifier(
668- "%pas-any: hppa", self.stp.breezy_autotest)
669- script = self.getScript()
670- script.add_missing_builds(
671- archive, self.required_arches, verifier,
672- self.stp.breezy_autotest, PackagePublishingPocket.RELEASE)
673-
674- # any gets i386 and hppa builds, but pas-any is restricted to hppa.
675- self.assertEquals(len(any.getBuilds()), 2)
676- self.assertEquals(len(pas_any.getBuilds()), 1)