Merge lp:~julian-edwards/launchpad/publish-copy-archives-bug-520520-publish-distro into lp:launchpad

Proposed by Julian Edwards
Status: Merged
Merged at revision: not available
Proposed branch: lp:~julian-edwards/launchpad/publish-copy-archives-bug-520520-publish-distro
Merge into: lp:launchpad
Diff against target: 142 lines (+72/-7)
2 files modified
lib/lp/soyuz/scripts/publishdistro.py (+20/-6)
lib/lp/soyuz/scripts/tests/test_publishdistro.py (+52/-1)
To merge this branch: bzr merge lp:~julian-edwards/launchpad/publish-copy-archives-bug-520520-publish-distro
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) code Approve
Review via email: mp+20049@code.launchpad.net

Commit message

Add support for publishing of copy archives to the publish-distro script.

To post a comment you must log in.
Revision history for this message
Julian Edwards (julian-edwards) wrote :

This is a simple branch that adds support for publishing of copy archives to
the publish-distro script.

It adds the option --copy-archive which will cause all archives with
ArchivePurpose.COPY to be published, provided their "publish" flag is set.

There's also a simple test case added.

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

It's a shame the is_empty equivalent on the result set does not work. The only change I'm requesting is an XXX for that. Otherwise, all good.

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/scripts/publishdistro.py'
--- lib/lp/soyuz/scripts/publishdistro.py 2009-06-25 04:06:00 +0000
+++ lib/lp/soyuz/scripts/publishdistro.py 2010-02-24 11:55:28 +0000
@@ -69,6 +69,11 @@
69 dest="partner", metavar="PARTNER", default=False,69 dest="partner", metavar="PARTNER", default=False,
70 help="Run only over the partner archive.")70 help="Run only over the partner archive.")
7171
72 parser.add_option("--copy-archive", action="store_true",
73 dest="copy_archive", metavar="COPYARCHIVE",
74 default=False,
75 help="Run only over the copy archives.")
76
72 parser.add_option(77 parser.add_option(
73 "--primary-debug", action="store_true", default=False,78 "--primary-debug", action="store_true", default=False,
74 dest="primary_debug", metavar="PRIMARYDEBUG",79 dest="primary_debug", metavar="PRIMARYDEBUG",
@@ -103,12 +108,13 @@
103108
104 exclusive_options = (109 exclusive_options = (
105 options.partner, options.ppa, options.private_ppa,110 options.partner, options.ppa, options.private_ppa,
106 options.primary_debug)111 options.primary_debug, options.copy_archive)
112
107 num_exclusive = [flag for flag in exclusive_options if flag]113 num_exclusive = [flag for flag in exclusive_options if flag]
108 if len(num_exclusive) > 1:114 if len(num_exclusive) > 1:
109 raise LaunchpadScriptFailure(115 raise LaunchpadScriptFailure(
110 "Can only specify one of partner, ppa, private-ppa and "116 "Can only specify one of partner, ppa, private-ppa, copy-archive"
111 "primary-debug.")117 " and primary-debug.")
112118
113 log.debug(" Distribution: %s" % options.distribution)119 log.debug(" Distribution: %s" % options.distribution)
114 log.debug(" Publishing: %s" % careful_msg(options.careful_publishing))120 log.debug(" Publishing: %s" % careful_msg(options.careful_publishing))
@@ -161,6 +167,14 @@
161 raise LaunchpadScriptFailure(167 raise LaunchpadScriptFailure(
162 "Could not find DEBUG archive for %s" % distribution.name)168 "Could not find DEBUG archive for %s" % distribution.name)
163 archives = [debug_archive]169 archives = [debug_archive]
170 elif options.copy_archive:
171 archives = getUtility(IArchiveSet).getArchivesForDistribution(
172 distribution, purposes=[ArchivePurpose.COPY])
173 # XXX 2010-02-24 Julian bug=246200
174 # Fix this to use bool when Storm fixes __nonzero__ on sqlobj
175 # result sets.
176 if archives.count() == 0:
177 raise LaunchpadScriptFailure("Could not find any COPY archives")
164 else:178 else:
165 archives = [distribution.main_archive]179 archives = [distribution.main_archive]
166180
@@ -185,9 +199,9 @@
185 try_and_commit("dominating", publisher.B_dominate,199 try_and_commit("dominating", publisher.B_dominate,
186 options.careful or options.careful_domination)200 options.careful or options.careful_domination)
187201
188 # The primary archive uses apt-ftparchive to generate the indexes,202 # The primary and copy archives use apt-ftparchive to generate the
189 # everything else uses the newer internal LP code.203 # indexes, everything else uses the newer internal LP code.
190 if archive.purpose == ArchivePurpose.PRIMARY:204 if archive.purpose in (ArchivePurpose.PRIMARY, ArchivePurpose.COPY):
191 try_and_commit("doing apt-ftparchive", publisher.C_doFTPArchive,205 try_and_commit("doing apt-ftparchive", publisher.C_doFTPArchive,
192 options.careful or options.careful_apt)206 options.careful or options.careful_apt)
193 else:207 else:
194208
=== modified file 'lib/lp/soyuz/scripts/tests/test_publishdistro.py'
--- lib/lp/soyuz/scripts/tests/test_publishdistro.py 2009-06-25 04:06:00 +0000
+++ lib/lp/soyuz/scripts/tests/test_publishdistro.py 2010-02-24 11:55:28 +0000
@@ -308,6 +308,47 @@
308 self.assertEqual(308 self.assertEqual(
309 open(debug_index_path).readlines()[0], 'Package: foo-bin\n')309 open(debug_index_path).readlines()[0], 'Package: foo-bin\n')
310310
311 def testPublishCopyArchive(self):
312 """Run publish-distro in copy archive mode.
313
314 It should only publish copy archives.
315 """
316 ubuntutest = getUtility(IDistributionSet)['ubuntutest']
317 cprov = getUtility(IPersonSet).getByName('cprov')
318 copy_archive_name = 'test-copy-publish'
319
320 # The COPY repository path is not created yet.
321 repo_path = os.path.join(
322 config.archivepublisher.root,
323 ubuntutest.name + '-' + copy_archive_name)
324 self.assertNotExists(repo_path)
325
326 copy_archive = getUtility(IArchiveSet).new(
327 distribution=ubuntutest, owner=cprov, name=copy_archive_name,
328 purpose=ArchivePurpose.COPY, enabled=True)
329 # Save some test CPU cycles by avoiding logging in as the user
330 # necessary to alter the publish flag.
331 removeSecurityProxy(copy_archive).publish = True
332
333 # Publish something.
334 pub_source = self.getPubSource(
335 sourcename='baz', filecontent='baz', archive=copy_archive)
336
337 # Try a plain PPA run, to ensure the copy archive is not published.
338 self.runPublishDistro(['--ppa'])
339
340 self.assertEqual(pub_source.status, PackagePublishingStatus.PENDING)
341
342 # Now publish the copy archives and make sure they are really
343 # published.
344 self.runPublishDistro(['--copy-archive'])
345
346 self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED)
347
348 # Make sure that the files were published in the right place.
349 pool_path = os.path.join(repo_path, 'pool/main/b/baz/baz_666.dsc')
350 self.assertExists(pool_path)
351
311 def testRunWithEmptySuites(self):352 def testRunWithEmptySuites(self):
312 """Try a publish-distro run on empty suites in careful_apt mode353 """Try a publish-distro run on empty suites in careful_apt mode
313354
@@ -347,7 +388,8 @@
347 """Test that some command line options are mutually exclusive."""388 """Test that some command line options are mutually exclusive."""
348 self.assertRaises(389 self.assertRaises(
349 LaunchpadScriptFailure,390 LaunchpadScriptFailure,
350 self.runPublishDistro, ['--ppa', '--partner', '--primary-debug'])391 self.runPublishDistro,
392 ['--ppa', '--partner', '--primary-debug', '--copy-archive'])
351 self.assertRaises(393 self.assertRaises(
352 LaunchpadScriptFailure,394 LaunchpadScriptFailure,
353 self.runPublishDistro, ['--ppa', '--partner'])395 self.runPublishDistro, ['--ppa', '--partner'])
@@ -359,10 +401,19 @@
359 self.runPublishDistro, ['--ppa', '--primary-debug'])401 self.runPublishDistro, ['--ppa', '--primary-debug'])
360 self.assertRaises(402 self.assertRaises(
361 LaunchpadScriptFailure,403 LaunchpadScriptFailure,
404 self.runPublishDistro, ['--ppa', '--copy-archive'])
405 self.assertRaises(
406 LaunchpadScriptFailure,
362 self.runPublishDistro, ['--partner', '--private-ppa'])407 self.runPublishDistro, ['--partner', '--private-ppa'])
363 self.assertRaises(408 self.assertRaises(
364 LaunchpadScriptFailure,409 LaunchpadScriptFailure,
365 self.runPublishDistro, ['--partner', '--primary-debug'])410 self.runPublishDistro, ['--partner', '--primary-debug'])
411 self.assertRaises(
412 LaunchpadScriptFailure,
413 self.runPublishDistro, ['--partner', '--copy-archive'])
414 self.assertRaises(
415 LaunchpadScriptFailure,
416 self.runPublishDistro, ['--primary-debug', '--copy-archive'])
366417
367418
368def test_suite():419def test_suite():