Merge lp:~jelmer/launchpad/600153-main-archive-builds-on-restricted into lp:launchpad

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: no longer in the source branch.
Merged at revision: 11084
Proposed branch: lp:~jelmer/launchpad/600153-main-archive-builds-on-restricted
Merge into: lp:launchpad
Diff against target: 157 lines (+52/-16)
3 files modified
lib/lp/soyuz/interfaces/archive.py (+5/-0)
lib/lp/soyuz/model/archive.py (+22/-7)
lib/lp/soyuz/tests/test_archive.py (+25/-9)
To merge this branch: bzr merge lp:~jelmer/launchpad/600153-main-archive-builds-on-restricted
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) Approve
Review via email: mp+28867@code.launchpad.net

Commit message

Always allow main archives to build on restricted architectures.

Description of the change

This updates Archive.enabled_restricted_architectures to always include all restricted architectures for main archives, as we only want to restrict PPA's and copy architectures in this way for the moment.

Brief pre-imp call with Julian.

Tests:

./bin/test lp.soyuz.tests.test_archive

To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Reviewed per IRC. Notes:

 * Run "make lint" before you submit the MP!

 * No seriously, run "make lint"!

 * Pass exception message to exception constructor. Putting it in _fmt seems unsafe.

 * There's no need for proper docstrings on test methods.

 * capitalize and punctuate error strings

Otherwise, you're good to go.

Jeroen

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/soyuz/interfaces/archive.py'
--- lib/lp/soyuz/interfaces/archive.py 2010-06-29 15:00:35 +0000
+++ lib/lp/soyuz/interfaces/archive.py 2010-06-30 16:48:32 +0000
@@ -18,6 +18,7 @@
18 'CannotCopy',18 'CannotCopy',
19 'CannotSwitchPrivacy',19 'CannotSwitchPrivacy',
20 'ComponentNotFound',20 'ComponentNotFound',
21 'CannotRestrictArchitectures',
21 'CannotUploadToPPA',22 'CannotUploadToPPA',
22 'CannotUploadToPocket',23 'CannotUploadToPocket',
23 'DistroSeriesNotFound',24 'DistroSeriesNotFound',
@@ -142,6 +143,10 @@
142 webservice_error(400) # Bad request.143 webservice_error(400) # Bad request.
143144
144145
146class CannotRestrictArchitectures(Exception):
147 """The architectures for this archive can not be restricted."""
148
149
145class CannotUploadToArchive(Exception):150class CannotUploadToArchive(Exception):
146 """A reason for not being able to upload to an archive."""151 """A reason for not being able to upload to an archive."""
147 webservice_error(403) # Forbidden.152 webservice_error(403) # Forbidden.
148153
=== modified file 'lib/lp/soyuz/model/archive.py'
--- lib/lp/soyuz/model/archive.py 2010-06-29 13:49:39 +0000
+++ lib/lp/soyuz/model/archive.py 2010-06-30 16:48:32 +0000
@@ -63,9 +63,9 @@
63from lp.soyuz.interfaces.archive import (63from lp.soyuz.interfaces.archive import (
64 AlreadySubscribed, ArchiveDependencyError, ArchiveDisabled,64 AlreadySubscribed, ArchiveDependencyError, ArchiveDisabled,
65 ArchiveNotPrivate, ArchivePurpose, ArchiveStatus, CannotCopy,65 ArchiveNotPrivate, ArchivePurpose, ArchiveStatus, CannotCopy,
66 CannotSwitchPrivacy, CannotUploadToPPA, CannotUploadToPocket,66 CannotRestrictArchitectures, CannotSwitchPrivacy, CannotUploadToPPA,
67 DistroSeriesNotFound, IArchive, IArchiveSet, IDistributionArchive,67 CannotUploadToPocket, DistroSeriesNotFound, IArchive, IArchiveSet,
68 InsufficientUploadRights, InvalidPocketForPPA,68 IDistributionArchive, InsufficientUploadRights, InvalidPocketForPPA,
69 InvalidPocketForPartnerArchive, InvalidComponent, IPPA,69 InvalidPocketForPartnerArchive, InvalidComponent, IPPA,
70 MAIN_ARCHIVE_PURPOSES, NoRightsForArchive, NoRightsForComponent,70 MAIN_ARCHIVE_PURPOSES, NoRightsForArchive, NoRightsForComponent,
71 NoSuchPPA, NoTokensForTeams, PocketNotFound, VersionRequiresName,71 NoSuchPPA, NoTokensForTeams, PocketNotFound, VersionRequiresName,
@@ -1554,13 +1554,28 @@
1554 LibraryFileContent.id == LibraryFileAlias.contentID).config(1554 LibraryFileContent.id == LibraryFileAlias.contentID).config(
1555 distinct=True))1555 distinct=True))
15561556
1557 def _get_enabled_restricted_families(self):1557 def _getEnabledRestrictedFamilies(self):
1558 """Retrieve the restricted architecture families this archive can
1559 build on."""
1560 # Main archives are always allowed to build on restricted
1561 # architectures.
1562 if self.is_main:
1563 return getUtility(IProcessorFamilySet).getRestricted()
1558 archive_arch_set = getUtility(IArchiveArchSet)1564 archive_arch_set = getUtility(IArchiveArchSet)
1559 restricted_families = archive_arch_set.getRestrictedfamilies(self)1565 restricted_families = archive_arch_set.getRestrictedfamilies(self)
1560 return [family for (family, archive_arch) in restricted_families 1566 return [family for (family, archive_arch) in restricted_families
1561 if archive_arch is not None]1567 if archive_arch is not None]
15621568
1563 def _set_enabled_restricted_families(self, value):1569 def _setEnabledRestrictedFamilies(self, value):
1570 """Set the restricted architecture families this archive can
1571 build on."""
1572 # Main archives are always allowed to build on restricted
1573 # architectures.
1574 if self.is_main:
1575 proc_family_set = getUtility(IProcessorFamilySet)
1576 if set(value) != set(proc_family_set.getRestricted()):
1577 raise CannotRestrictArchitectures("Main archives can not "
1578 "be restricted to certain architectures")
1564 archive_arch_set = getUtility(IArchiveArchSet)1579 archive_arch_set = getUtility(IArchiveArchSet)
1565 restricted_families = archive_arch_set.getRestrictedfamilies(self)1580 restricted_families = archive_arch_set.getRestrictedfamilies(self)
1566 for (family, archive_arch) in restricted_families:1581 for (family, archive_arch) in restricted_families:
@@ -1569,8 +1584,8 @@
1569 if family not in value and archive_arch is not None:1584 if family not in value and archive_arch is not None:
1570 Store.of(self).remove(archive_arch)1585 Store.of(self).remove(archive_arch)
15711586
1572 enabled_restricted_families = property(_get_enabled_restricted_families,1587 enabled_restricted_families = property(_getEnabledRestrictedFamilies,
1573 _set_enabled_restricted_families)1588 _setEnabledRestrictedFamilies)
15741589
15751590
1576class ArchiveSet:1591class ArchiveSet:
15771592
=== modified file 'lib/lp/soyuz/tests/test_archive.py'
--- lib/lp/soyuz/tests/test_archive.py 2010-06-29 13:20:28 +0000
+++ lib/lp/soyuz/tests/test_archive.py 2010-06-30 16:48:32 +0000
@@ -21,8 +21,8 @@
21from lp.registry.interfaces.pocket import PackagePublishingPocket21from lp.registry.interfaces.pocket import PackagePublishingPocket
22from lp.services.job.interfaces.job import JobStatus22from lp.services.job.interfaces.job import JobStatus
23from lp.soyuz.interfaces.archive import (IArchiveSet, ArchivePurpose,23from lp.soyuz.interfaces.archive import (IArchiveSet, ArchivePurpose,
24 ArchiveStatus, CannotSwitchPrivacy, InvalidPocketForPartnerArchive,24 ArchiveStatus, CannotRestrictArchitectures, CannotSwitchPrivacy,
25 InvalidPocketForPPA)25 InvalidPocketForPartnerArchive, InvalidPocketForPPA)
26from lp.services.worlddata.interfaces.country import ICountrySet26from lp.services.worlddata.interfaces.country import ICountrySet
27from lp.soyuz.interfaces.archivearch import IArchiveArchSet27from lp.soyuz.interfaces.archivearch import IArchiveArchSet
28from lp.soyuz.interfaces.binarypackagename import IBinaryPackageNameSet28from lp.soyuz.interfaces.binarypackagename import IBinaryPackageNameSet
@@ -753,29 +753,45 @@
753 self.archive_arch_set = getUtility(IArchiveArchSet)753 self.archive_arch_set = getUtility(IArchiveArchSet)
754 self.arm = getUtility(IProcessorFamilySet).getByName('arm')754 self.arm = getUtility(IProcessorFamilySet).getByName('arm')
755755
756 def test_main_archive_can_use_restricted(self):
757 # Main archives for distributions can always use restricted
758 # architectures.
759 distro = self.factory.makeDistribution()
760 self.assertContentEqual([self.arm],
761 distro.main_archive.enabled_restricted_families)
762
763 def test_main_archive_can_not_be_restricted(self):
764 # A main archive can not be restricted to certain architectures.
765 distro = self.factory.makeDistribution()
766 # Restricting to all restricted architectures is fine
767 distro.main_archive.enabled_restricted_families = [self.arm]
768 def restrict():
769 distro.main_archive.enabled_restricted_families = []
770 self.assertRaises(CannotRestrictArchitectures, restrict)
771
756 def test_default(self):772 def test_default(self):
757 """By default, ARM builds are not allowed as ARM is restricted."""773 """By default, ARM builds are not allowed as ARM is restricted."""
758 self.assertEquals(0,774 self.assertEquals(0,
759 self.archive_arch_set.getByArchive(775 self.archive_arch_set.getByArchive(
760 self.archive, self.arm).count())776 self.archive, self.arm).count())
761 self.assertEquals([], list(self.archive.enabled_restricted_families))777 self.assertContentEqual([], self.archive.enabled_restricted_families)
762778
763 def test_get_uses_archivearch(self):779 def test_get_uses_archivearch(self):
764 """Adding an entry to ArchiveArch for ARM and an archive will780 """Adding an entry to ArchiveArch for ARM and an archive will
765 enable enabled_restricted_families for arm for that archive."""781 enable enabled_restricted_families for arm for that archive."""
766 self.assertEquals([], list(self.archive.enabled_restricted_families))782 self.assertContentEqual([], self.archive.enabled_restricted_families)
767 self.archive_arch_set.new(self.archive, self.arm)783 self.archive_arch_set.new(self.archive, self.arm)
768 self.assertEquals([self.arm], 784 self.assertContentEqual([self.arm],
769 list(self.archive.enabled_restricted_families))785 self.archive.enabled_restricted_families)
770786
771 def test_get_returns_restricted_only(self):787 def test_get_returns_restricted_only(self):
772 """Adding an entry to ArchiveArch for something that is not 788 """Adding an entry to ArchiveArch for something that is not
773 restricted does not make it show up in enabled_restricted_families.789 restricted does not make it show up in enabled_restricted_families.
774 """790 """
775 self.assertEquals([], list(self.archive.enabled_restricted_families))791 self.assertContentEqual([], self.archive.enabled_restricted_families)
776 self.archive_arch_set.new(self.archive,792 self.archive_arch_set.new(self.archive,
777 getUtility(IProcessorFamilySet).getByName('amd64'))793 getUtility(IProcessorFamilySet).getByName('amd64'))
778 self.assertEquals([], list(self.archive.enabled_restricted_families))794 self.assertContentEqual([], self.archive.enabled_restricted_families)
779795
780 def test_set(self):796 def test_set(self):
781 """The property remembers its value correctly and sets ArchiveArch."""797 """The property remembers its value correctly and sets ArchiveArch."""
@@ -790,7 +806,7 @@
790 self.assertEquals(0,806 self.assertEquals(0,
791 self.archive_arch_set.getByArchive(807 self.archive_arch_set.getByArchive(
792 self.archive, self.arm).count())808 self.archive, self.arm).count())
793 self.assertEquals([], list(self.archive.enabled_restricted_families))809 self.assertContentEqual([], self.archive.enabled_restricted_families)
794810
795811
796class TestArchiveTokens(TestCaseWithFactory):812class TestArchiveTokens(TestCaseWithFactory):