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)

=== modified file 'lib/lp/soyuz/model/publishing.py'
--- lib/lp/soyuz/model/publishing.py 2010-08-30 15:00:23 +0000
+++ lib/lp/soyuz/model/publishing.py 2010-09-28 14:26:27 +0000
@@ -1234,6 +1234,10 @@
1234 binarypackagerelease = binary.binarypackagerelease1234 binarypackagerelease = binary.binarypackagerelease
1235 target_component = override_component or binary.component1235 target_component = override_component or binary.component
12361236
1237 # XXX 2010-09-28 Julian bug=649859
1238 # This piece of code duplicates the logic in
1239 # PackageUploadBuild.publish(), it needs to be refactored.
1240
1237 if binarypackagerelease.architecturespecific:1241 if binarypackagerelease.architecturespecific:
1238 # If the binary is architecture specific and the target1242 # If the binary is architecture specific and the target
1239 # distroseries does not include the architecture then we1243 # distroseries does not include the architecture then we
@@ -1250,7 +1254,9 @@
1250 continue1254 continue
1251 destination_architectures = [target_architecture]1255 destination_architectures = [target_architecture]
1252 else:1256 else:
1253 destination_architectures = distroseries.architectures1257 destination_architectures = [
1258 arch for arch in distroseries.architectures
1259 if arch.enabled]
12541260
1255 for distroarchseries in destination_architectures:1261 for distroarchseries in destination_architectures:
12561262
12571263
=== modified file 'lib/lp/soyuz/model/queue.py'
--- lib/lp/soyuz/model/queue.py 2010-09-28 09:53:27 +0000
+++ lib/lp/soyuz/model/queue.py 2010-09-28 14:26:14 +0000
@@ -1447,9 +1447,15 @@
1447 target_das.distroseries.distribution.name,1447 target_das.distroseries.distribution.name,
1448 target_das.distroseries.name,1448 target_das.distroseries.name,
1449 build_archtag))1449 build_archtag))
1450
1450 # Get the other enabled distroarchseries for this1451 # Get the other enabled distroarchseries for this
1451 # distroseries. If the binary is architecture independent then1452 # distroseries. If the binary is architecture independent then
1452 # we need to publish it in all of those too.1453 # we need to publish it in all of those too.
1454
1455 # XXX Julian 2010-09-28 bug=649859
1456 # This logic is duplicated in
1457 # PackagePublishingSet.copyBinariesTo() and should be
1458 # refactored.
1453 other_das = set(1459 other_das = set(
1454 arch for arch in self.packageupload.distroseries.architectures1460 arch for arch in self.packageupload.distroseries.architectures
1455 if arch.enabled)1461 if arch.enabled)
14561462
=== modified file 'lib/lp/soyuz/scripts/tests/test_copypackage.py'
--- lib/lp/soyuz/scripts/tests/test_copypackage.py 2010-08-27 11:19:54 +0000
+++ lib/lp/soyuz/scripts/tests/test_copypackage.py 2010-09-28 14:21:42 +0000
@@ -977,6 +977,44 @@
977 ],977 ],
978 [copy.displayname for copy in copies])978 [copy.displayname for copy in copies])
979979
980 def test_copying_arch_indep_binaries_with_disabled_arches(self):
981 # When copying an arch-indep binary to a new series, we must not
982 # copy it into architectures that are disabled.
983
984 # Make a new arch-all source and binary in breezy-autotest:
985 archive = self.factory.makeArchive(
986 distribution=self.test_publisher.ubuntutest, virtualized=False)
987 source = self.test_publisher.getPubSource(
988 archive=archive, architecturehintlist='all')
989 [bin_i386, bin_hppa] = self.test_publisher.getPubBinaries(
990 pub_source=source)
991
992 # Now make a new distroseries with two architectures, one of
993 # which is disabled.
994 nobby = self.factory.makeDistroSeries(
995 distribution=self.test_publisher.ubuntutest, name='nobby')
996 i386_pf = self.factory.makeProcessorFamily(name='my_i386')
997 nobby_i386 = self.factory.makeDistroArchSeries(
998 distroseries=nobby, architecturetag='i386',
999 processorfamily=i386_pf)
1000 hppa_pf = self.factory.makeProcessorFamily(name='my_hppa')
1001 nobby_hppa = self.factory.makeDistroArchSeries(
1002 distroseries=nobby, architecturetag='hppa',
1003 processorfamily=hppa_pf)
1004 nobby_hppa.enabled = False
1005 nobby.nominatedarchindep = nobby_i386
1006 self.test_publisher.addFakeChroots(nobby)
1007
1008 # Now we can copy the package with binaries.
1009 copies = _do_direct_copy(
1010 source, source.archive, nobby, source.pocket, True)
1011
1012 # The binary should not be published for hppa.
1013 self.assertEquals(
1014 [u'foo 666 in nobby',
1015 u'foo-bin 666 in nobby i386',],
1016 [copy.displayname for copy in copies])
1017
9801018
981class DoDelayedCopyTestCase(TestCaseWithFactory):1019class DoDelayedCopyTestCase(TestCaseWithFactory):
9821020
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
=== modified file 'lib/lp/soyuz/model/distroarchseries.py'
--- lib/lp/soyuz/model/distroarchseries.py 2010-09-10 15:28:42 +0000
+++ lib/lp/soyuz/model/distroarchseries.py 2010-09-28 16:07:50 +0000
@@ -338,11 +338,6 @@
338338
339 def publish(self, diskpool, log, archive, pocket, is_careful=False):339 def publish(self, diskpool, log, archive, pocket, is_careful=False):
340 """See `ICanPublishPackages`."""340 """See `ICanPublishPackages`."""
341 if not self.enabled:
342 log.debug(
343 "Skipping disabled architecture %s" % self.architecturetag)
344 return set()
345
346 log.debug("Attempting to publish pending binaries for %s"341 log.debug("Attempting to publish pending binaries for %s"
347 % self.architecturetag)342 % self.architecturetag)
348343
349344
=== modified file 'lib/lp/soyuz/model/publishing.py'
--- lib/lp/soyuz/model/publishing.py 2010-08-30 15:00:23 +0000
+++ lib/lp/soyuz/model/publishing.py 2010-09-28 16:07:50 +0000
@@ -1234,6 +1234,10 @@
1234 binarypackagerelease = binary.binarypackagerelease1234 binarypackagerelease = binary.binarypackagerelease
1235 target_component = override_component or binary.component1235 target_component = override_component or binary.component
12361236
1237 # XXX 2010-09-28 Julian bug=649859
1238 # This piece of code duplicates the logic in
1239 # PackageUploadBuild.publish(), it needs to be refactored.
1240
1237 if binarypackagerelease.architecturespecific:1241 if binarypackagerelease.architecturespecific:
1238 # If the binary is architecture specific and the target1242 # If the binary is architecture specific and the target
1239 # distroseries does not include the architecture then we1243 # distroseries does not include the architecture then we
@@ -1250,7 +1254,9 @@
1250 continue1254 continue
1251 destination_architectures = [target_architecture]1255 destination_architectures = [target_architecture]
1252 else:1256 else:
1253 destination_architectures = distroseries.architectures1257 destination_architectures = [
1258 arch for arch in distroseries.architectures
1259 if arch.enabled]
12541260
1255 for distroarchseries in destination_architectures:1261 for distroarchseries in destination_architectures:
12561262
12571263
=== modified file 'lib/lp/soyuz/model/queue.py'
--- lib/lp/soyuz/model/queue.py 2010-09-03 15:02:39 +0000
+++ lib/lp/soyuz/model/queue.py 2010-09-28 16:07:50 +0000
@@ -1442,20 +1442,30 @@
1442 build_archtag = self.build.distro_arch_series.architecturetag1442 build_archtag = self.build.distro_arch_series.architecturetag
1443 # Determine the target arch series.1443 # Determine the target arch series.
1444 # This will raise NotFoundError if anything odd happens.1444 # This will raise NotFoundError if anything odd happens.
1445 target_dar = self.packageupload.distroseries[build_archtag]1445 target_das = self.packageupload.distroseries[build_archtag]
1446 debug(logger, "Publishing build to %s/%s/%s" % (1446 debug(logger, "Publishing build to %s/%s/%s" % (
1447 target_dar.distroseries.distribution.name,1447 target_das.distroseries.distribution.name,
1448 target_dar.distroseries.name,1448 target_das.distroseries.name,
1449 build_archtag))1449 build_archtag))
1450 # And get the other distroarchseriess1450
1451 other_dars = set(self.packageupload.distroseries.architectures)1451 # Get the other enabled distroarchseries for this
1452 other_dars = other_dars - set([target_dar])1452 # distroseries. If the binary is architecture independent then
1453 # we need to publish it in all of those too.
1454
1455 # XXX Julian 2010-09-28 bug=649859
1456 # This logic is duplicated in
1457 # PackagePublishingSet.copyBinariesTo() and should be
1458 # refactored.
1459 other_das = set(
1460 arch for arch in self.packageupload.distroseries.architectures
1461 if arch.enabled)
1462 other_das = other_das - set([target_das])
1453 # First up, publish everything in this build into that dar.1463 # First up, publish everything in this build into that dar.
1454 published_binaries = []1464 published_binaries = []
1455 for binary in self.build.binarypackages:1465 for binary in self.build.binarypackages:
1456 target_dars = set([target_dar])1466 target_dars = set([target_das])
1457 if not binary.architecturespecific:1467 if not binary.architecturespecific:
1458 target_dars = target_dars.union(other_dars)1468 target_dars = target_dars.union(other_das)
1459 debug(logger, "... %s/%s (Arch Independent)" % (1469 debug(logger, "... %s/%s (Arch Independent)" % (
1460 binary.binarypackagename.name,1470 binary.binarypackagename.name,
1461 binary.version))1471 binary.version))
14621472
=== modified file 'lib/lp/soyuz/scripts/tests/test_copypackage.py'
--- lib/lp/soyuz/scripts/tests/test_copypackage.py 2010-08-27 11:19:54 +0000
+++ lib/lp/soyuz/scripts/tests/test_copypackage.py 2010-09-28 16:07:50 +0000
@@ -977,6 +977,44 @@
977 ],977 ],
978 [copy.displayname for copy in copies])978 [copy.displayname for copy in copies])
979979
980 def test_copying_arch_indep_binaries_with_disabled_arches(self):
981 # When copying an arch-indep binary to a new series, we must not
982 # copy it into architectures that are disabled.
983
984 # Make a new arch-all source and binary in breezy-autotest:
985 archive = self.factory.makeArchive(
986 distribution=self.test_publisher.ubuntutest, virtualized=False)
987 source = self.test_publisher.getPubSource(
988 archive=archive, architecturehintlist='all')
989 [bin_i386, bin_hppa] = self.test_publisher.getPubBinaries(
990 pub_source=source)
991
992 # Now make a new distroseries with two architectures, one of
993 # which is disabled.
994 nobby = self.factory.makeDistroSeries(
995 distribution=self.test_publisher.ubuntutest, name='nobby')
996 i386_pf = self.factory.makeProcessorFamily(name='my_i386')
997 nobby_i386 = self.factory.makeDistroArchSeries(
998 distroseries=nobby, architecturetag='i386',
999 processorfamily=i386_pf)
1000 hppa_pf = self.factory.makeProcessorFamily(name='my_hppa')
1001 nobby_hppa = self.factory.makeDistroArchSeries(
1002 distroseries=nobby, architecturetag='hppa',
1003 processorfamily=hppa_pf)
1004 nobby_hppa.enabled = False
1005 nobby.nominatedarchindep = nobby_i386
1006 self.test_publisher.addFakeChroots(nobby)
1007
1008 # Now we can copy the package with binaries.
1009 copies = _do_direct_copy(
1010 source, source.archive, nobby, source.pocket, True)
1011
1012 # The binary should not be published for hppa.
1013 self.assertEquals(
1014 [u'foo 666 in nobby',
1015 u'foo-bin 666 in nobby i386',],
1016 [copy.displayname for copy in copies])
1017
9801018
981class DoDelayedCopyTestCase(TestCaseWithFactory):1019class DoDelayedCopyTestCase(TestCaseWithFactory):
9821020
9831021
=== modified file 'lib/lp/soyuz/tests/test_publishing_top_level_api.py'
--- lib/lp/soyuz/tests/test_publishing_top_level_api.py 2010-09-10 15:24:47 +0000
+++ lib/lp/soyuz/tests/test_publishing_top_level_api.py 2010-09-28 16:07:50 +0000
@@ -5,7 +5,10 @@
55
6from lp.registry.interfaces.pocket import PackagePublishingPocket6from lp.registry.interfaces.pocket import PackagePublishingPocket
7from lp.registry.interfaces.series import SeriesStatus7from lp.registry.interfaces.series import SeriesStatus
8from lp.soyuz.enums import PackagePublishingStatus8from lp.soyuz.enums import (
9 PackagePublishingStatus,
10 PackageUploadStatus,
11 )
9from lp.soyuz.tests.test_publishing import TestNativePublishingBase12from lp.soyuz.tests.test_publishing import TestNativePublishingBase
1013
1114
@@ -421,14 +424,37 @@
421 expected_result=[pub_published_release, pub_pending_release])424 expected_result=[pub_published_release, pub_pending_release])
422425
423 def test_publishing_disabled_distroarchseries(self):426 def test_publishing_disabled_distroarchseries(self):
424 # Disabled DASes will be skipped even if there are pending427 # Disabled DASes will not receive new publications at all.
425 # publications for them.428
426 binaries = self.getPubBinaries(architecturespecific=True)429 # Make an arch-all source and some builds for it.
427 # Just use the first binary.430 archive = self.factory.makeArchive(
428 binary = binaries[0]431 distribution=self.ubuntutest, virtualized=False)
429 self.assertEqual(PackagePublishingStatus.PENDING, binary.status)432 source = self.getPubSource(
430433 archive=archive, architecturehintlist='all')
431 binary.distroarchseries.enabled = False434 [build_i386] = source.createMissingBuilds()
432 self._publish(pocket=binary.pocket)435 bin_i386 = self.uploadBinaryForBuild(build_i386, 'bin-i386')
433436
434 self.assertEqual(PackagePublishingStatus.PENDING, binary.status)437 # Now make sure they have a packageupload (but no publishing
438 # records).
439 changes_file_name = '%s_%s_%s.changes' % (
440 bin_i386.name, bin_i386.version, build_i386.arch_tag)
441 pu_i386 = self.addPackageUpload(
442 build_i386.archive, build_i386.distro_arch_series.distroseries,
443 build_i386.pocket, changes_file_content='anything',
444 changes_file_name=changes_file_name,
445 upload_status=PackageUploadStatus.ACCEPTED)
446 pu_i386.addBuild(build_i386)
447
448 # Now we make hppa a disabled architecture, and then call the
449 # publish method on the packageupload. The arch-all binary
450 # should be published only in the i386 arch, not the hppa one.
451 hppa = pu_i386.distroseries.getDistroArchSeries('hppa')
452 hppa.enabled = False
453 for pu_build in pu_i386.builds:
454 pu_build.publish()
455
456 publications = archive.getAllPublishedBinaries(name="bin-i386")
457
458 self.assertEqual(1, publications.count())
459 self.assertEqual(
460 'i386', publications[0].distroarchseries.architecturetag)

Subscribers

People subscribed via source and target branches

to status/vote changes: