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
1=== modified file 'lib/lp/soyuz/interfaces/archive.py'
2--- lib/lp/soyuz/interfaces/archive.py 2010-06-29 15:00:35 +0000
3+++ lib/lp/soyuz/interfaces/archive.py 2010-06-30 16:48:32 +0000
4@@ -18,6 +18,7 @@
5 'CannotCopy',
6 'CannotSwitchPrivacy',
7 'ComponentNotFound',
8+ 'CannotRestrictArchitectures',
9 'CannotUploadToPPA',
10 'CannotUploadToPocket',
11 'DistroSeriesNotFound',
12@@ -142,6 +143,10 @@
13 webservice_error(400) # Bad request.
14
15
16+class CannotRestrictArchitectures(Exception):
17+ """The architectures for this archive can not be restricted."""
18+
19+
20 class CannotUploadToArchive(Exception):
21 """A reason for not being able to upload to an archive."""
22 webservice_error(403) # Forbidden.
23
24=== modified file 'lib/lp/soyuz/model/archive.py'
25--- lib/lp/soyuz/model/archive.py 2010-06-29 13:49:39 +0000
26+++ lib/lp/soyuz/model/archive.py 2010-06-30 16:48:32 +0000
27@@ -63,9 +63,9 @@
28 from lp.soyuz.interfaces.archive import (
29 AlreadySubscribed, ArchiveDependencyError, ArchiveDisabled,
30 ArchiveNotPrivate, ArchivePurpose, ArchiveStatus, CannotCopy,
31- CannotSwitchPrivacy, CannotUploadToPPA, CannotUploadToPocket,
32- DistroSeriesNotFound, IArchive, IArchiveSet, IDistributionArchive,
33- InsufficientUploadRights, InvalidPocketForPPA,
34+ CannotRestrictArchitectures, CannotSwitchPrivacy, CannotUploadToPPA,
35+ CannotUploadToPocket, DistroSeriesNotFound, IArchive, IArchiveSet,
36+ IDistributionArchive, InsufficientUploadRights, InvalidPocketForPPA,
37 InvalidPocketForPartnerArchive, InvalidComponent, IPPA,
38 MAIN_ARCHIVE_PURPOSES, NoRightsForArchive, NoRightsForComponent,
39 NoSuchPPA, NoTokensForTeams, PocketNotFound, VersionRequiresName,
40@@ -1554,13 +1554,28 @@
41 LibraryFileContent.id == LibraryFileAlias.contentID).config(
42 distinct=True))
43
44- def _get_enabled_restricted_families(self):
45+ def _getEnabledRestrictedFamilies(self):
46+ """Retrieve the restricted architecture families this archive can
47+ build on."""
48+ # Main archives are always allowed to build on restricted
49+ # architectures.
50+ if self.is_main:
51+ return getUtility(IProcessorFamilySet).getRestricted()
52 archive_arch_set = getUtility(IArchiveArchSet)
53 restricted_families = archive_arch_set.getRestrictedfamilies(self)
54 return [family for (family, archive_arch) in restricted_families
55 if archive_arch is not None]
56
57- def _set_enabled_restricted_families(self, value):
58+ def _setEnabledRestrictedFamilies(self, value):
59+ """Set the restricted architecture families this archive can
60+ build on."""
61+ # Main archives are always allowed to build on restricted
62+ # architectures.
63+ if self.is_main:
64+ proc_family_set = getUtility(IProcessorFamilySet)
65+ if set(value) != set(proc_family_set.getRestricted()):
66+ raise CannotRestrictArchitectures("Main archives can not "
67+ "be restricted to certain architectures")
68 archive_arch_set = getUtility(IArchiveArchSet)
69 restricted_families = archive_arch_set.getRestrictedfamilies(self)
70 for (family, archive_arch) in restricted_families:
71@@ -1569,8 +1584,8 @@
72 if family not in value and archive_arch is not None:
73 Store.of(self).remove(archive_arch)
74
75- enabled_restricted_families = property(_get_enabled_restricted_families,
76- _set_enabled_restricted_families)
77+ enabled_restricted_families = property(_getEnabledRestrictedFamilies,
78+ _setEnabledRestrictedFamilies)
79
80
81 class ArchiveSet:
82
83=== modified file 'lib/lp/soyuz/tests/test_archive.py'
84--- lib/lp/soyuz/tests/test_archive.py 2010-06-29 13:20:28 +0000
85+++ lib/lp/soyuz/tests/test_archive.py 2010-06-30 16:48:32 +0000
86@@ -21,8 +21,8 @@
87 from lp.registry.interfaces.pocket import PackagePublishingPocket
88 from lp.services.job.interfaces.job import JobStatus
89 from lp.soyuz.interfaces.archive import (IArchiveSet, ArchivePurpose,
90- ArchiveStatus, CannotSwitchPrivacy, InvalidPocketForPartnerArchive,
91- InvalidPocketForPPA)
92+ ArchiveStatus, CannotRestrictArchitectures, CannotSwitchPrivacy,
93+ InvalidPocketForPartnerArchive, InvalidPocketForPPA)
94 from lp.services.worlddata.interfaces.country import ICountrySet
95 from lp.soyuz.interfaces.archivearch import IArchiveArchSet
96 from lp.soyuz.interfaces.binarypackagename import IBinaryPackageNameSet
97@@ -753,29 +753,45 @@
98 self.archive_arch_set = getUtility(IArchiveArchSet)
99 self.arm = getUtility(IProcessorFamilySet).getByName('arm')
100
101+ def test_main_archive_can_use_restricted(self):
102+ # Main archives for distributions can always use restricted
103+ # architectures.
104+ distro = self.factory.makeDistribution()
105+ self.assertContentEqual([self.arm],
106+ distro.main_archive.enabled_restricted_families)
107+
108+ def test_main_archive_can_not_be_restricted(self):
109+ # A main archive can not be restricted to certain architectures.
110+ distro = self.factory.makeDistribution()
111+ # Restricting to all restricted architectures is fine
112+ distro.main_archive.enabled_restricted_families = [self.arm]
113+ def restrict():
114+ distro.main_archive.enabled_restricted_families = []
115+ self.assertRaises(CannotRestrictArchitectures, restrict)
116+
117 def test_default(self):
118 """By default, ARM builds are not allowed as ARM is restricted."""
119 self.assertEquals(0,
120 self.archive_arch_set.getByArchive(
121 self.archive, self.arm).count())
122- self.assertEquals([], list(self.archive.enabled_restricted_families))
123+ self.assertContentEqual([], self.archive.enabled_restricted_families)
124
125 def test_get_uses_archivearch(self):
126 """Adding an entry to ArchiveArch for ARM and an archive will
127 enable enabled_restricted_families for arm for that archive."""
128- self.assertEquals([], list(self.archive.enabled_restricted_families))
129+ self.assertContentEqual([], self.archive.enabled_restricted_families)
130 self.archive_arch_set.new(self.archive, self.arm)
131- self.assertEquals([self.arm],
132- list(self.archive.enabled_restricted_families))
133+ self.assertContentEqual([self.arm],
134+ self.archive.enabled_restricted_families)
135
136 def test_get_returns_restricted_only(self):
137 """Adding an entry to ArchiveArch for something that is not
138 restricted does not make it show up in enabled_restricted_families.
139 """
140- self.assertEquals([], list(self.archive.enabled_restricted_families))
141+ self.assertContentEqual([], self.archive.enabled_restricted_families)
142 self.archive_arch_set.new(self.archive,
143 getUtility(IProcessorFamilySet).getByName('amd64'))
144- self.assertEquals([], list(self.archive.enabled_restricted_families))
145+ self.assertContentEqual([], self.archive.enabled_restricted_families)
146
147 def test_set(self):
148 """The property remembers its value correctly and sets ArchiveArch."""
149@@ -790,7 +806,7 @@
150 self.assertEquals(0,
151 self.archive_arch_set.getByArchive(
152 self.archive, self.arm).count())
153- self.assertEquals([], list(self.archive.enabled_restricted_families))
154+ self.assertContentEqual([], self.archive.enabled_restricted_families)
155
156
157 class TestArchiveTokens(TestCaseWithFactory):