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
1=== modified file 'lib/lp/soyuz/scripts/publishdistro.py'
2--- lib/lp/soyuz/scripts/publishdistro.py 2009-06-25 04:06:00 +0000
3+++ lib/lp/soyuz/scripts/publishdistro.py 2010-02-24 11:55:28 +0000
4@@ -69,6 +69,11 @@
5 dest="partner", metavar="PARTNER", default=False,
6 help="Run only over the partner archive.")
7
8+ parser.add_option("--copy-archive", action="store_true",
9+ dest="copy_archive", metavar="COPYARCHIVE",
10+ default=False,
11+ help="Run only over the copy archives.")
12+
13 parser.add_option(
14 "--primary-debug", action="store_true", default=False,
15 dest="primary_debug", metavar="PRIMARYDEBUG",
16@@ -103,12 +108,13 @@
17
18 exclusive_options = (
19 options.partner, options.ppa, options.private_ppa,
20- options.primary_debug)
21+ options.primary_debug, options.copy_archive)
22+
23 num_exclusive = [flag for flag in exclusive_options if flag]
24 if len(num_exclusive) > 1:
25 raise LaunchpadScriptFailure(
26- "Can only specify one of partner, ppa, private-ppa and "
27- "primary-debug.")
28+ "Can only specify one of partner, ppa, private-ppa, copy-archive"
29+ " and primary-debug.")
30
31 log.debug(" Distribution: %s" % options.distribution)
32 log.debug(" Publishing: %s" % careful_msg(options.careful_publishing))
33@@ -161,6 +167,14 @@
34 raise LaunchpadScriptFailure(
35 "Could not find DEBUG archive for %s" % distribution.name)
36 archives = [debug_archive]
37+ elif options.copy_archive:
38+ archives = getUtility(IArchiveSet).getArchivesForDistribution(
39+ distribution, purposes=[ArchivePurpose.COPY])
40+ # XXX 2010-02-24 Julian bug=246200
41+ # Fix this to use bool when Storm fixes __nonzero__ on sqlobj
42+ # result sets.
43+ if archives.count() == 0:
44+ raise LaunchpadScriptFailure("Could not find any COPY archives")
45 else:
46 archives = [distribution.main_archive]
47
48@@ -185,9 +199,9 @@
49 try_and_commit("dominating", publisher.B_dominate,
50 options.careful or options.careful_domination)
51
52- # The primary archive uses apt-ftparchive to generate the indexes,
53- # everything else uses the newer internal LP code.
54- if archive.purpose == ArchivePurpose.PRIMARY:
55+ # The primary and copy archives use apt-ftparchive to generate the
56+ # indexes, everything else uses the newer internal LP code.
57+ if archive.purpose in (ArchivePurpose.PRIMARY, ArchivePurpose.COPY):
58 try_and_commit("doing apt-ftparchive", publisher.C_doFTPArchive,
59 options.careful or options.careful_apt)
60 else:
61
62=== modified file 'lib/lp/soyuz/scripts/tests/test_publishdistro.py'
63--- lib/lp/soyuz/scripts/tests/test_publishdistro.py 2009-06-25 04:06:00 +0000
64+++ lib/lp/soyuz/scripts/tests/test_publishdistro.py 2010-02-24 11:55:28 +0000
65@@ -308,6 +308,47 @@
66 self.assertEqual(
67 open(debug_index_path).readlines()[0], 'Package: foo-bin\n')
68
69+ def testPublishCopyArchive(self):
70+ """Run publish-distro in copy archive mode.
71+
72+ It should only publish copy archives.
73+ """
74+ ubuntutest = getUtility(IDistributionSet)['ubuntutest']
75+ cprov = getUtility(IPersonSet).getByName('cprov')
76+ copy_archive_name = 'test-copy-publish'
77+
78+ # The COPY repository path is not created yet.
79+ repo_path = os.path.join(
80+ config.archivepublisher.root,
81+ ubuntutest.name + '-' + copy_archive_name)
82+ self.assertNotExists(repo_path)
83+
84+ copy_archive = getUtility(IArchiveSet).new(
85+ distribution=ubuntutest, owner=cprov, name=copy_archive_name,
86+ purpose=ArchivePurpose.COPY, enabled=True)
87+ # Save some test CPU cycles by avoiding logging in as the user
88+ # necessary to alter the publish flag.
89+ removeSecurityProxy(copy_archive).publish = True
90+
91+ # Publish something.
92+ pub_source = self.getPubSource(
93+ sourcename='baz', filecontent='baz', archive=copy_archive)
94+
95+ # Try a plain PPA run, to ensure the copy archive is not published.
96+ self.runPublishDistro(['--ppa'])
97+
98+ self.assertEqual(pub_source.status, PackagePublishingStatus.PENDING)
99+
100+ # Now publish the copy archives and make sure they are really
101+ # published.
102+ self.runPublishDistro(['--copy-archive'])
103+
104+ self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED)
105+
106+ # Make sure that the files were published in the right place.
107+ pool_path = os.path.join(repo_path, 'pool/main/b/baz/baz_666.dsc')
108+ self.assertExists(pool_path)
109+
110 def testRunWithEmptySuites(self):
111 """Try a publish-distro run on empty suites in careful_apt mode
112
113@@ -347,7 +388,8 @@
114 """Test that some command line options are mutually exclusive."""
115 self.assertRaises(
116 LaunchpadScriptFailure,
117- self.runPublishDistro, ['--ppa', '--partner', '--primary-debug'])
118+ self.runPublishDistro,
119+ ['--ppa', '--partner', '--primary-debug', '--copy-archive'])
120 self.assertRaises(
121 LaunchpadScriptFailure,
122 self.runPublishDistro, ['--ppa', '--partner'])
123@@ -359,10 +401,19 @@
124 self.runPublishDistro, ['--ppa', '--primary-debug'])
125 self.assertRaises(
126 LaunchpadScriptFailure,
127+ self.runPublishDistro, ['--ppa', '--copy-archive'])
128+ self.assertRaises(
129+ LaunchpadScriptFailure,
130 self.runPublishDistro, ['--partner', '--private-ppa'])
131 self.assertRaises(
132 LaunchpadScriptFailure,
133 self.runPublishDistro, ['--partner', '--primary-debug'])
134+ self.assertRaises(
135+ LaunchpadScriptFailure,
136+ self.runPublishDistro, ['--partner', '--copy-archive'])
137+ self.assertRaises(
138+ LaunchpadScriptFailure,
139+ self.runPublishDistro, ['--primary-debug', '--copy-archive'])
140
141
142 def test_suite():