Merge lp:~cjwatson/launchpad/publish-distro-careful-release into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 17954
Proposed branch: lp:~cjwatson/launchpad/publish-distro-careful-release
Merge into: lp:launchpad
Diff against target: 185 lines (+86/-7)
3 files modified
lib/lp/archivepublisher/publishing.py (+14/-0)
lib/lp/archivepublisher/scripts/publishdistro.py (+18/-3)
lib/lp/archivepublisher/tests/test_publishdistro.py (+54/-4)
To merge this branch: bzr merge lp:~cjwatson/launchpad/publish-distro-careful-release
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+289401@code.launchpad.net

Commit message

Add publish-distro options allowing us to just rewrite Release files in all PPAs.

Description of the change

Add publish-distro options allowing us to just rewrite Release files in all PPAs. This will let us deal with situations like bug 1558331 where we need to upgrade signatures on everything, without having to incur the cost of a full republication.

I don't have figures on how long a careful-Release run over all PPAs will take, but step D is usually quick compared to the rest of it.

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=== modified file 'lib/lp/archivepublisher/publishing.py'
2--- lib/lp/archivepublisher/publishing.py 2016-03-11 11:45:56 +0000
3+++ lib/lp/archivepublisher/publishing.py 2016-03-17 17:14:24 +0000
4@@ -574,6 +574,20 @@
5 (distroseries.name, pocket.name))
6 continue
7 self.checkDirtySuiteBeforePublishing(distroseries, pocket)
8+ else:
9+ if not self.isAllowed(distroseries, pocket):
10+ continue
11+ # If we were asked for careful Release file generation
12+ # but not careful indexing, then we may not have the raw
13+ # material needed to generate Release files for all
14+ # suites. Only force those suites that already have
15+ # Release files.
16+ release_path = os.path.join(
17+ self._config.distsroot, distroseries.getSuite(pocket),
18+ "Release")
19+ if file_exists(release_path):
20+ self.release_files_needed.add(
21+ (distroseries.name, pocket))
22 self._writeSuite(distroseries, pocket)
23
24 def _allIndexFiles(self, distroseries):
25
26=== modified file 'lib/lp/archivepublisher/scripts/publishdistro.py'
27--- lib/lp/archivepublisher/scripts/publishdistro.py 2015-09-23 13:19:25 +0000
28+++ lib/lp/archivepublisher/scripts/publishdistro.py 2016-03-17 17:14:24 +0000
29@@ -1,4 +1,4 @@
30-# Copyright 2009-2015 Canonical Ltd. This software is licensed under the
31+# Copyright 2009-2016 Canonical Ltd. This software is licensed under the
32 # GNU Affero General Public License version 3 (see the file LICENSE).
33
34 """Publisher script class."""
35@@ -67,6 +67,18 @@
36 help="Make index generation (e.g. apt-ftparchive) careful.")
37
38 self.parser.add_option(
39+ "--careful-release", action="store_true", dest="careful_release",
40+ default=False,
41+ help="Make the Release file generation process careful.")
42+
43+ self.parser.add_option(
44+ "--include-non-pending", action="store_true",
45+ dest="include_non_pending", default=False,
46+ help=(
47+ "When publishing PPAs, also include those that do not have "
48+ "pending publications."))
49+
50+ self.parser.add_option(
51 '-s', '--suite', metavar='SUITE', dest='suite', action='append',
52 type='string', default=[], help='The suite to publish')
53
54@@ -153,6 +165,7 @@
55 ('Publishing', self.options.careful_publishing),
56 ('Domination', self.options.careful_domination),
57 (indexing_engine, self.options.careful_apt),
58+ ('Release', self.options.careful_release),
59 ]
60 for name, option in log_items:
61 self.logOption(name, self.describeCare(option))
62@@ -207,7 +220,8 @@
63
64 def getPPAs(self, distribution):
65 """Find private package archives for the selected distribution."""
66- if self.isCareful(self.options.careful_publishing):
67+ if (self.isCareful(self.options.careful_publishing) or
68+ self.options.include_non_pending):
69 return distribution.getAllPPAs()
70 else:
71 return distribution.getPendingPublicationPPAs()
72@@ -274,7 +288,8 @@
73 publisher.C_writeIndexes(careful_indexing)
74 self.txn.commit()
75
76- publisher.D_writeReleaseFiles(careful_indexing)
77+ publisher.D_writeReleaseFiles(self.isCareful(
78+ self.options.careful_apt or self.options.careful_release))
79 # The caller will commit this last step.
80
81 publisher.createSeriesAliases()
82
83=== modified file 'lib/lp/archivepublisher/tests/test_publishdistro.py'
84--- lib/lp/archivepublisher/tests/test_publishdistro.py 2016-03-14 19:40:14 +0000
85+++ lib/lp/archivepublisher/tests/test_publishdistro.py 2016-03-17 17:14:24 +0000
86@@ -11,6 +11,10 @@
87 import subprocess
88 import sys
89
90+from testtools.matchers import (
91+ Not,
92+ PathExists,
93+ )
94 from zope.component import getUtility
95 from zope.security.proxy import removeSecurityProxy
96
97@@ -394,6 +398,44 @@
98 self.config.distsroot)
99 self.assertNotExists(index_path)
100
101+ def testCarefulRelease(self):
102+ """publish-distro can be asked to just rewrite Release files."""
103+ archive = self.factory.makeArchive(distribution=self.ubuntutest)
104+ pub_source = self.getPubSource(filecontent='foo', archive=archive)
105+
106+ self.setUpRequireSigningKeys()
107+ tac = KeyServerTac()
108+ tac.setUp()
109+ self.addCleanup(tac.tearDown)
110+ key_path = os.path.join(gpgkeysdir, 'ppa-sample@canonical.com.sec')
111+ IArchiveSigningKey(archive).setSigningKey(key_path)
112+
113+ self.layer.txn.commit()
114+
115+ self.runPublishDistro(['--ppa'])
116+
117+ pub_source.sync()
118+ self.assertEqual(PackagePublishingStatus.PUBLISHED, pub_source.status)
119+
120+ dists_path = getPubConfig(archive).distsroot
121+ hoary_inrelease_path = os.path.join(
122+ dists_path, 'hoary-test', 'InRelease')
123+ breezy_inrelease_path = os.path.join(
124+ dists_path, 'breezy-autotest', 'InRelease')
125+ self.assertThat(hoary_inrelease_path, Not(PathExists()))
126+ os.unlink(breezy_inrelease_path)
127+
128+ self.runPublishDistro(['--ppa', '--careful-release'])
129+ self.assertThat(hoary_inrelease_path, Not(PathExists()))
130+ self.assertThat(breezy_inrelease_path, Not(PathExists()))
131+
132+ self.runPublishDistro(
133+ ['--ppa', '--careful-release', '--include-non-pending'])
134+ # hoary-test never had indexes created, so is untouched.
135+ self.assertThat(hoary_inrelease_path, Not(PathExists()))
136+ # breezy-autotest has its Release files rewritten.
137+ self.assertThat(breezy_inrelease_path, PathExists())
138+
139
140 class TestPublishDistroWithGPGService(TestPublishDistro):
141 """A copy of the TestPublishDistro tests, but with the gpgservice feature
142@@ -703,7 +745,7 @@
143
144 def test_getPPAs_gets_pending_distro_PPAs_if_careful(self):
145 # In careful mode, getPPAs includes PPAs for the distribution
146- # that are pending pulication.
147+ # that are pending publication.
148 distro = self.makeDistro()
149 script = self.makeScript(distro, ['--careful'])
150 ppa = self.factory.makeArchive(distro, purpose=ArchivePurpose.PPA)
151@@ -712,15 +754,23 @@
152
153 def test_getPPAs_gets_nonpending_distro_PPAs_if_careful(self):
154 # In careful mode, getPPAs includes PPAs for the distribution
155- # that are not pending pulication.
156+ # that are not pending publication.
157 distro = self.makeDistro()
158 script = self.makeScript(distro, ['--careful'])
159 ppa = self.factory.makeArchive(distro, purpose=ArchivePurpose.PPA)
160 self.assertContentEqual([ppa], script.getPPAs(distro))
161
162+ def test_getPPAs_gets_nonpending_distro_PPAs_if_requested(self):
163+ # In --include-non-pending mode, getPPAs includes PPAs for the
164+ # distribution that are not pending publication.
165+ distro = self.makeDistro()
166+ script = self.makeScript(distro, ['--include-non-pending'])
167+ ppa = self.factory.makeArchive(distro, purpose=ArchivePurpose.PPA)
168+ self.assertContentEqual([ppa], script.getPPAs(distro))
169+
170 def test_getPPAs_gets_pending_distro_PPAs_if_not_careful(self):
171 # In non-careful mode, getPPAs includes PPAs that are pending
172- # pulication.
173+ # publication.
174 distro = self.makeDistro()
175 script = self.makeScript(distro)
176 ppa = self.factory.makeArchive(distro, purpose=ArchivePurpose.PPA)
177@@ -729,7 +779,7 @@
178
179 def test_getPPAs_ignores_nonpending_distro_PPAs_if_not_careful(self):
180 # In non-careful mode, getPPAs does not include PPAs that are
181- # not pending pulication.
182+ # not pending publication.
183 distro = self.makeDistro()
184 script = self.makeScript(distro)
185 self.factory.makeArchive(distro, purpose=ArchivePurpose.PPA)