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
=== modified file 'lib/lp/archivepublisher/publishing.py'
--- lib/lp/archivepublisher/publishing.py 2016-03-11 11:45:56 +0000
+++ lib/lp/archivepublisher/publishing.py 2016-03-17 17:14:24 +0000
@@ -574,6 +574,20 @@
574 (distroseries.name, pocket.name))574 (distroseries.name, pocket.name))
575 continue575 continue
576 self.checkDirtySuiteBeforePublishing(distroseries, pocket)576 self.checkDirtySuiteBeforePublishing(distroseries, pocket)
577 else:
578 if not self.isAllowed(distroseries, pocket):
579 continue
580 # If we were asked for careful Release file generation
581 # but not careful indexing, then we may not have the raw
582 # material needed to generate Release files for all
583 # suites. Only force those suites that already have
584 # Release files.
585 release_path = os.path.join(
586 self._config.distsroot, distroseries.getSuite(pocket),
587 "Release")
588 if file_exists(release_path):
589 self.release_files_needed.add(
590 (distroseries.name, pocket))
577 self._writeSuite(distroseries, pocket)591 self._writeSuite(distroseries, pocket)
578592
579 def _allIndexFiles(self, distroseries):593 def _allIndexFiles(self, distroseries):
580594
=== modified file 'lib/lp/archivepublisher/scripts/publishdistro.py'
--- lib/lp/archivepublisher/scripts/publishdistro.py 2015-09-23 13:19:25 +0000
+++ lib/lp/archivepublisher/scripts/publishdistro.py 2016-03-17 17:14:24 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009-2015 Canonical Ltd. This software is licensed under the1# Copyright 2009-2016 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Publisher script class."""4"""Publisher script class."""
@@ -67,6 +67,18 @@
67 help="Make index generation (e.g. apt-ftparchive) careful.")67 help="Make index generation (e.g. apt-ftparchive) careful.")
6868
69 self.parser.add_option(69 self.parser.add_option(
70 "--careful-release", action="store_true", dest="careful_release",
71 default=False,
72 help="Make the Release file generation process careful.")
73
74 self.parser.add_option(
75 "--include-non-pending", action="store_true",
76 dest="include_non_pending", default=False,
77 help=(
78 "When publishing PPAs, also include those that do not have "
79 "pending publications."))
80
81 self.parser.add_option(
70 '-s', '--suite', metavar='SUITE', dest='suite', action='append',82 '-s', '--suite', metavar='SUITE', dest='suite', action='append',
71 type='string', default=[], help='The suite to publish')83 type='string', default=[], help='The suite to publish')
7284
@@ -153,6 +165,7 @@
153 ('Publishing', self.options.careful_publishing),165 ('Publishing', self.options.careful_publishing),
154 ('Domination', self.options.careful_domination),166 ('Domination', self.options.careful_domination),
155 (indexing_engine, self.options.careful_apt),167 (indexing_engine, self.options.careful_apt),
168 ('Release', self.options.careful_release),
156 ]169 ]
157 for name, option in log_items:170 for name, option in log_items:
158 self.logOption(name, self.describeCare(option))171 self.logOption(name, self.describeCare(option))
@@ -207,7 +220,8 @@
207220
208 def getPPAs(self, distribution):221 def getPPAs(self, distribution):
209 """Find private package archives for the selected distribution."""222 """Find private package archives for the selected distribution."""
210 if self.isCareful(self.options.careful_publishing):223 if (self.isCareful(self.options.careful_publishing) or
224 self.options.include_non_pending):
211 return distribution.getAllPPAs()225 return distribution.getAllPPAs()
212 else:226 else:
213 return distribution.getPendingPublicationPPAs()227 return distribution.getPendingPublicationPPAs()
@@ -274,7 +288,8 @@
274 publisher.C_writeIndexes(careful_indexing)288 publisher.C_writeIndexes(careful_indexing)
275 self.txn.commit()289 self.txn.commit()
276290
277 publisher.D_writeReleaseFiles(careful_indexing)291 publisher.D_writeReleaseFiles(self.isCareful(
292 self.options.careful_apt or self.options.careful_release))
278 # The caller will commit this last step.293 # The caller will commit this last step.
279294
280 publisher.createSeriesAliases()295 publisher.createSeriesAliases()
281296
=== modified file 'lib/lp/archivepublisher/tests/test_publishdistro.py'
--- lib/lp/archivepublisher/tests/test_publishdistro.py 2016-03-14 19:40:14 +0000
+++ lib/lp/archivepublisher/tests/test_publishdistro.py 2016-03-17 17:14:24 +0000
@@ -11,6 +11,10 @@
11import subprocess11import subprocess
12import sys12import sys
1313
14from testtools.matchers import (
15 Not,
16 PathExists,
17 )
14from zope.component import getUtility18from zope.component import getUtility
15from zope.security.proxy import removeSecurityProxy19from zope.security.proxy import removeSecurityProxy
1620
@@ -394,6 +398,44 @@
394 self.config.distsroot)398 self.config.distsroot)
395 self.assertNotExists(index_path)399 self.assertNotExists(index_path)
396400
401 def testCarefulRelease(self):
402 """publish-distro can be asked to just rewrite Release files."""
403 archive = self.factory.makeArchive(distribution=self.ubuntutest)
404 pub_source = self.getPubSource(filecontent='foo', archive=archive)
405
406 self.setUpRequireSigningKeys()
407 tac = KeyServerTac()
408 tac.setUp()
409 self.addCleanup(tac.tearDown)
410 key_path = os.path.join(gpgkeysdir, 'ppa-sample@canonical.com.sec')
411 IArchiveSigningKey(archive).setSigningKey(key_path)
412
413 self.layer.txn.commit()
414
415 self.runPublishDistro(['--ppa'])
416
417 pub_source.sync()
418 self.assertEqual(PackagePublishingStatus.PUBLISHED, pub_source.status)
419
420 dists_path = getPubConfig(archive).distsroot
421 hoary_inrelease_path = os.path.join(
422 dists_path, 'hoary-test', 'InRelease')
423 breezy_inrelease_path = os.path.join(
424 dists_path, 'breezy-autotest', 'InRelease')
425 self.assertThat(hoary_inrelease_path, Not(PathExists()))
426 os.unlink(breezy_inrelease_path)
427
428 self.runPublishDistro(['--ppa', '--careful-release'])
429 self.assertThat(hoary_inrelease_path, Not(PathExists()))
430 self.assertThat(breezy_inrelease_path, Not(PathExists()))
431
432 self.runPublishDistro(
433 ['--ppa', '--careful-release', '--include-non-pending'])
434 # hoary-test never had indexes created, so is untouched.
435 self.assertThat(hoary_inrelease_path, Not(PathExists()))
436 # breezy-autotest has its Release files rewritten.
437 self.assertThat(breezy_inrelease_path, PathExists())
438
397439
398class TestPublishDistroWithGPGService(TestPublishDistro):440class TestPublishDistroWithGPGService(TestPublishDistro):
399 """A copy of the TestPublishDistro tests, but with the gpgservice feature441 """A copy of the TestPublishDistro tests, but with the gpgservice feature
@@ -703,7 +745,7 @@
703745
704 def test_getPPAs_gets_pending_distro_PPAs_if_careful(self):746 def test_getPPAs_gets_pending_distro_PPAs_if_careful(self):
705 # In careful mode, getPPAs includes PPAs for the distribution747 # In careful mode, getPPAs includes PPAs for the distribution
706 # that are pending pulication.748 # that are pending publication.
707 distro = self.makeDistro()749 distro = self.makeDistro()
708 script = self.makeScript(distro, ['--careful'])750 script = self.makeScript(distro, ['--careful'])
709 ppa = self.factory.makeArchive(distro, purpose=ArchivePurpose.PPA)751 ppa = self.factory.makeArchive(distro, purpose=ArchivePurpose.PPA)
@@ -712,15 +754,23 @@
712754
713 def test_getPPAs_gets_nonpending_distro_PPAs_if_careful(self):755 def test_getPPAs_gets_nonpending_distro_PPAs_if_careful(self):
714 # In careful mode, getPPAs includes PPAs for the distribution756 # In careful mode, getPPAs includes PPAs for the distribution
715 # that are not pending pulication.757 # that are not pending publication.
716 distro = self.makeDistro()758 distro = self.makeDistro()
717 script = self.makeScript(distro, ['--careful'])759 script = self.makeScript(distro, ['--careful'])
718 ppa = self.factory.makeArchive(distro, purpose=ArchivePurpose.PPA)760 ppa = self.factory.makeArchive(distro, purpose=ArchivePurpose.PPA)
719 self.assertContentEqual([ppa], script.getPPAs(distro))761 self.assertContentEqual([ppa], script.getPPAs(distro))
720762
763 def test_getPPAs_gets_nonpending_distro_PPAs_if_requested(self):
764 # In --include-non-pending mode, getPPAs includes PPAs for the
765 # distribution that are not pending publication.
766 distro = self.makeDistro()
767 script = self.makeScript(distro, ['--include-non-pending'])
768 ppa = self.factory.makeArchive(distro, purpose=ArchivePurpose.PPA)
769 self.assertContentEqual([ppa], script.getPPAs(distro))
770
721 def test_getPPAs_gets_pending_distro_PPAs_if_not_careful(self):771 def test_getPPAs_gets_pending_distro_PPAs_if_not_careful(self):
722 # In non-careful mode, getPPAs includes PPAs that are pending772 # In non-careful mode, getPPAs includes PPAs that are pending
723 # pulication.773 # publication.
724 distro = self.makeDistro()774 distro = self.makeDistro()
725 script = self.makeScript(distro)775 script = self.makeScript(distro)
726 ppa = self.factory.makeArchive(distro, purpose=ArchivePurpose.PPA)776 ppa = self.factory.makeArchive(distro, purpose=ArchivePurpose.PPA)
@@ -729,7 +779,7 @@
729779
730 def test_getPPAs_ignores_nonpending_distro_PPAs_if_not_careful(self):780 def test_getPPAs_ignores_nonpending_distro_PPAs_if_not_careful(self):
731 # In non-careful mode, getPPAs does not include PPAs that are781 # In non-careful mode, getPPAs does not include PPAs that are
732 # not pending pulication.782 # not pending publication.
733 distro = self.makeDistro()783 distro = self.makeDistro()
734 script = self.makeScript(distro)784 script = self.makeScript(distro)
735 self.factory.makeArchive(distro, purpose=ArchivePurpose.PPA)785 self.factory.makeArchive(distro, purpose=ArchivePurpose.PPA)