Merge lp:~julian-edwards/launchpad/no-disabled-arch-publications-bug-648715 into lp:launchpad/db-devel

Proposed by Julian Edwards
Status: Merged
Approved by: Graham Binns
Approved revision: no longer in the source branch.
Merged at revision: 9844
Proposed branch: lp:~julian-edwards/launchpad/no-disabled-arch-publications-bug-648715
Merge into: lp:launchpad/db-devel
Diff against target: 198 lines (+101/-26)
5 files modified
lib/lp/soyuz/model/distroarchseries.py (+0/-5)
lib/lp/soyuz/model/publishing.py (+7/-1)
lib/lp/soyuz/model/queue.py (+18/-8)
lib/lp/soyuz/scripts/tests/test_copypackage.py (+38/-0)
lib/lp/soyuz/tests/test_publishing_top_level_api.py (+38/-12)
To merge this branch: bzr merge lp:~julian-edwards/launchpad/no-disabled-arch-publications-bug-648715
Reviewer Review Type Date Requested Status
William Grant code Approve
Graham Binns (community) code Approve
Robert Collins release-critical Pending
Review via email: mp+36838@code.launchpad.net

Commit message

Prevent arch-all packages from being published in disabled architectures.

Description of the change

= Summary =
Prevent arch-all packages from being published in disabled architectures

= Description =
A fix was done a while ago that stopped disabled distroarchseries from
publishing. This was the wrong approach - what needs to happen is to prevent
new publications in the first place.

This only happens for arch-all (architecture independent packages) because
directly targeted builds for disabled architectures are already prevented.

= Implementation =
A few stages:
 * Remove the old code that prevented publication. We want to do this now so
that old publications can be removed from the repo.
 * Modify the test so that it checks that arch-all binaries don't get
published in disabled distroarchseries.
 * Change the publication creating code to ignore disabled architectures when
calculating the list of distroarchseries for arch-all packages.

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

PublishingSet.copyBinariesTo needs to be fixed as well. Ideally this would be abstracted.

review: Needs Fixing (code)
Revision history for this message
Graham Binns (gmb) :
review: Approve (code)
Revision history for this message
Julian Edwards (julian-edwards) wrote :

I've added a new revision that also does the same check when copying packages
betweeb distroseries. Would you mind blessing that too please? Thanks.
(partial diff attached)

1=== modified file 'lib/lp/soyuz/model/publishing.py'
2--- lib/lp/soyuz/model/publishing.py 2010-08-30 15:00:23 +0000
3+++ lib/lp/soyuz/model/publishing.py 2010-09-28 14:26:27 +0000
4@@ -1234,6 +1234,10 @@
5 binarypackagerelease = binary.binarypackagerelease
6 target_component = override_component or binary.component
7
8+ # XXX 2010-09-28 Julian bug=649859
9+ # This piece of code duplicates the logic in
10+ # PackageUploadBuild.publish(), it needs to be refactored.
11+
12 if binarypackagerelease.architecturespecific:
13 # If the binary is architecture specific and the target
14 # distroseries does not include the architecture then we
15@@ -1250,7 +1254,9 @@
16 continue
17 destination_architectures = [target_architecture]
18 else:
19- destination_architectures = distroseries.architectures
20+ destination_architectures = [
21+ arch for arch in distroseries.architectures
22+ if arch.enabled]
23
24 for distroarchseries in destination_architectures:
25
26
27=== modified file 'lib/lp/soyuz/model/queue.py'
28--- lib/lp/soyuz/model/queue.py 2010-09-28 09:53:27 +0000
29+++ lib/lp/soyuz/model/queue.py 2010-09-28 14:26:14 +0000
30@@ -1447,9 +1447,15 @@
31 target_das.distroseries.distribution.name,
32 target_das.distroseries.name,
33 build_archtag))
34+
35 # Get the other enabled distroarchseries for this
36 # distroseries. If the binary is architecture independent then
37 # we need to publish it in all of those too.
38+
39+ # XXX Julian 2010-09-28 bug=649859
40+ # This logic is duplicated in
41+ # PackagePublishingSet.copyBinariesTo() and should be
42+ # refactored.
43 other_das = set(
44 arch for arch in self.packageupload.distroseries.architectures
45 if arch.enabled)
46
47=== modified file 'lib/lp/soyuz/scripts/tests/test_copypackage.py'
48--- lib/lp/soyuz/scripts/tests/test_copypackage.py 2010-08-27 11:19:54 +0000
49+++ lib/lp/soyuz/scripts/tests/test_copypackage.py 2010-09-28 14:21:42 +0000
50@@ -977,6 +977,44 @@
51 ],
52 [copy.displayname for copy in copies])
53
54+ def test_copying_arch_indep_binaries_with_disabled_arches(self):
55+ # When copying an arch-indep binary to a new series, we must not
56+ # copy it into architectures that are disabled.
57+
58+ # Make a new arch-all source and binary in breezy-autotest:
59+ archive = self.factory.makeArchive(
60+ distribution=self.test_publisher.ubuntutest, virtualized=False)
61+ source = self.test_publisher.getPubSource(
62+ archive=archive, architecturehintlist='all')
63+ [bin_i386, bin_hppa] = self.test_publisher.getPubBinaries(
64+ pub_source=source)
65+
66+ # Now make a new distroseries with two architectures, one of
67+ # which is disabled.
68+ nobby = self.factory.makeDistroSeries(
69+ distribution=self.test_publisher.ubuntutest, name='nobby')
70+ i386_pf = self.factory.makeProcessorFamily(name='my_i386')
71+ nobby_i386 = self.factory.makeDistroArchSeries(
72+ distroseries=nobby, architecturetag='i386',
73+ processorfamily=i386_pf)
74+ hppa_pf = self.factory.makeProcessorFamily(name='my_hppa')
75+ nobby_hppa = self.factory.makeDistroArchSeries(
76+ distroseries=nobby, architecturetag='hppa',
77+ processorfamily=hppa_pf)
78+ nobby_hppa.enabled = False
79+ nobby.nominatedarchindep = nobby_i386
80+ self.test_publisher.addFakeChroots(nobby)
81+
82+ # Now we can copy the package with binaries.
83+ copies = _do_direct_copy(
84+ source, source.archive, nobby, source.pocket, True)
85+
86+ # The binary should not be published for hppa.
87+ self.assertEquals(
88+ [u'foo 666 in nobby',
89+ u'foo-bin 666 in nobby i386',],
90+ [copy.displayname for copy in copies])
91+
92
93 class DoDelayedCopyTestCase(TestCaseWithFactory):
94
Revision history for this message
Graham Binns (gmb) wrote :

> I've added a new revision that also does the same check when copying packages
> betweeb distroseries. Would you mind blessing that too please? Thanks.
> (partial diff attached)

r=me on those changes.

review: Approve (code)
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=== modified file 'lib/lp/soyuz/model/distroarchseries.py'
2--- lib/lp/soyuz/model/distroarchseries.py 2010-09-10 15:28:42 +0000
3+++ lib/lp/soyuz/model/distroarchseries.py 2010-09-28 16:07:50 +0000
4@@ -338,11 +338,6 @@
5
6 def publish(self, diskpool, log, archive, pocket, is_careful=False):
7 """See `ICanPublishPackages`."""
8- if not self.enabled:
9- log.debug(
10- "Skipping disabled architecture %s" % self.architecturetag)
11- return set()
12-
13 log.debug("Attempting to publish pending binaries for %s"
14 % self.architecturetag)
15
16
17=== modified file 'lib/lp/soyuz/model/publishing.py'
18--- lib/lp/soyuz/model/publishing.py 2010-08-30 15:00:23 +0000
19+++ lib/lp/soyuz/model/publishing.py 2010-09-28 16:07:50 +0000
20@@ -1234,6 +1234,10 @@
21 binarypackagerelease = binary.binarypackagerelease
22 target_component = override_component or binary.component
23
24+ # XXX 2010-09-28 Julian bug=649859
25+ # This piece of code duplicates the logic in
26+ # PackageUploadBuild.publish(), it needs to be refactored.
27+
28 if binarypackagerelease.architecturespecific:
29 # If the binary is architecture specific and the target
30 # distroseries does not include the architecture then we
31@@ -1250,7 +1254,9 @@
32 continue
33 destination_architectures = [target_architecture]
34 else:
35- destination_architectures = distroseries.architectures
36+ destination_architectures = [
37+ arch for arch in distroseries.architectures
38+ if arch.enabled]
39
40 for distroarchseries in destination_architectures:
41
42
43=== modified file 'lib/lp/soyuz/model/queue.py'
44--- lib/lp/soyuz/model/queue.py 2010-09-03 15:02:39 +0000
45+++ lib/lp/soyuz/model/queue.py 2010-09-28 16:07:50 +0000
46@@ -1442,20 +1442,30 @@
47 build_archtag = self.build.distro_arch_series.architecturetag
48 # Determine the target arch series.
49 # This will raise NotFoundError if anything odd happens.
50- target_dar = self.packageupload.distroseries[build_archtag]
51+ target_das = self.packageupload.distroseries[build_archtag]
52 debug(logger, "Publishing build to %s/%s/%s" % (
53- target_dar.distroseries.distribution.name,
54- target_dar.distroseries.name,
55+ target_das.distroseries.distribution.name,
56+ target_das.distroseries.name,
57 build_archtag))
58- # And get the other distroarchseriess
59- other_dars = set(self.packageupload.distroseries.architectures)
60- other_dars = other_dars - set([target_dar])
61+
62+ # Get the other enabled distroarchseries for this
63+ # distroseries. If the binary is architecture independent then
64+ # we need to publish it in all of those too.
65+
66+ # XXX Julian 2010-09-28 bug=649859
67+ # This logic is duplicated in
68+ # PackagePublishingSet.copyBinariesTo() and should be
69+ # refactored.
70+ other_das = set(
71+ arch for arch in self.packageupload.distroseries.architectures
72+ if arch.enabled)
73+ other_das = other_das - set([target_das])
74 # First up, publish everything in this build into that dar.
75 published_binaries = []
76 for binary in self.build.binarypackages:
77- target_dars = set([target_dar])
78+ target_dars = set([target_das])
79 if not binary.architecturespecific:
80- target_dars = target_dars.union(other_dars)
81+ target_dars = target_dars.union(other_das)
82 debug(logger, "... %s/%s (Arch Independent)" % (
83 binary.binarypackagename.name,
84 binary.version))
85
86=== modified file 'lib/lp/soyuz/scripts/tests/test_copypackage.py'
87--- lib/lp/soyuz/scripts/tests/test_copypackage.py 2010-08-27 11:19:54 +0000
88+++ lib/lp/soyuz/scripts/tests/test_copypackage.py 2010-09-28 16:07:50 +0000
89@@ -977,6 +977,44 @@
90 ],
91 [copy.displayname for copy in copies])
92
93+ def test_copying_arch_indep_binaries_with_disabled_arches(self):
94+ # When copying an arch-indep binary to a new series, we must not
95+ # copy it into architectures that are disabled.
96+
97+ # Make a new arch-all source and binary in breezy-autotest:
98+ archive = self.factory.makeArchive(
99+ distribution=self.test_publisher.ubuntutest, virtualized=False)
100+ source = self.test_publisher.getPubSource(
101+ archive=archive, architecturehintlist='all')
102+ [bin_i386, bin_hppa] = self.test_publisher.getPubBinaries(
103+ pub_source=source)
104+
105+ # Now make a new distroseries with two architectures, one of
106+ # which is disabled.
107+ nobby = self.factory.makeDistroSeries(
108+ distribution=self.test_publisher.ubuntutest, name='nobby')
109+ i386_pf = self.factory.makeProcessorFamily(name='my_i386')
110+ nobby_i386 = self.factory.makeDistroArchSeries(
111+ distroseries=nobby, architecturetag='i386',
112+ processorfamily=i386_pf)
113+ hppa_pf = self.factory.makeProcessorFamily(name='my_hppa')
114+ nobby_hppa = self.factory.makeDistroArchSeries(
115+ distroseries=nobby, architecturetag='hppa',
116+ processorfamily=hppa_pf)
117+ nobby_hppa.enabled = False
118+ nobby.nominatedarchindep = nobby_i386
119+ self.test_publisher.addFakeChroots(nobby)
120+
121+ # Now we can copy the package with binaries.
122+ copies = _do_direct_copy(
123+ source, source.archive, nobby, source.pocket, True)
124+
125+ # The binary should not be published for hppa.
126+ self.assertEquals(
127+ [u'foo 666 in nobby',
128+ u'foo-bin 666 in nobby i386',],
129+ [copy.displayname for copy in copies])
130+
131
132 class DoDelayedCopyTestCase(TestCaseWithFactory):
133
134
135=== modified file 'lib/lp/soyuz/tests/test_publishing_top_level_api.py'
136--- lib/lp/soyuz/tests/test_publishing_top_level_api.py 2010-09-10 15:24:47 +0000
137+++ lib/lp/soyuz/tests/test_publishing_top_level_api.py 2010-09-28 16:07:50 +0000
138@@ -5,7 +5,10 @@
139
140 from lp.registry.interfaces.pocket import PackagePublishingPocket
141 from lp.registry.interfaces.series import SeriesStatus
142-from lp.soyuz.enums import PackagePublishingStatus
143+from lp.soyuz.enums import (
144+ PackagePublishingStatus,
145+ PackageUploadStatus,
146+ )
147 from lp.soyuz.tests.test_publishing import TestNativePublishingBase
148
149
150@@ -421,14 +424,37 @@
151 expected_result=[pub_published_release, pub_pending_release])
152
153 def test_publishing_disabled_distroarchseries(self):
154- # Disabled DASes will be skipped even if there are pending
155- # publications for them.
156- binaries = self.getPubBinaries(architecturespecific=True)
157- # Just use the first binary.
158- binary = binaries[0]
159- self.assertEqual(PackagePublishingStatus.PENDING, binary.status)
160-
161- binary.distroarchseries.enabled = False
162- self._publish(pocket=binary.pocket)
163-
164- self.assertEqual(PackagePublishingStatus.PENDING, binary.status)
165+ # Disabled DASes will not receive new publications at all.
166+
167+ # Make an arch-all source and some builds for it.
168+ archive = self.factory.makeArchive(
169+ distribution=self.ubuntutest, virtualized=False)
170+ source = self.getPubSource(
171+ archive=archive, architecturehintlist='all')
172+ [build_i386] = source.createMissingBuilds()
173+ bin_i386 = self.uploadBinaryForBuild(build_i386, 'bin-i386')
174+
175+ # Now make sure they have a packageupload (but no publishing
176+ # records).
177+ changes_file_name = '%s_%s_%s.changes' % (
178+ bin_i386.name, bin_i386.version, build_i386.arch_tag)
179+ pu_i386 = self.addPackageUpload(
180+ build_i386.archive, build_i386.distro_arch_series.distroseries,
181+ build_i386.pocket, changes_file_content='anything',
182+ changes_file_name=changes_file_name,
183+ upload_status=PackageUploadStatus.ACCEPTED)
184+ pu_i386.addBuild(build_i386)
185+
186+ # Now we make hppa a disabled architecture, and then call the
187+ # publish method on the packageupload. The arch-all binary
188+ # should be published only in the i386 arch, not the hppa one.
189+ hppa = pu_i386.distroseries.getDistroArchSeries('hppa')
190+ hppa.enabled = False
191+ for pu_build in pu_i386.builds:
192+ pu_build.publish()
193+
194+ publications = archive.getAllPublishedBinaries(name="bin-i386")
195+
196+ self.assertEqual(1, publications.count())
197+ self.assertEqual(
198+ 'i386', publications[0].distroarchseries.architecturetag)

Subscribers

People subscribed via source and target branches

to status/vote changes: