Merge lp:~cjwatson/launchpad/remove-unembargo-package into lp:launchpad

Proposed by Colin Watson
Status: Merged
Approved by: Steve Kowalik
Approved revision: no longer in the source branch.
Merged at revision: 15506
Proposed branch: lp:~cjwatson/launchpad/remove-unembargo-package
Merge into: lp:launchpad
Diff against target: 341 lines (+48/-208)
3 files modified
lib/lp/soyuz/scripts/packagecopier.py (+0/-72)
lib/lp/soyuz/scripts/tests/test_copypackage.py (+48/-117)
scripts/ftpmaster-tools/unembargo-package.py (+0/-19)
To merge this branch: bzr merge lp:~cjwatson/launchpad/remove-unembargo-package
Reviewer Review Type Date Requested Status
Steve Kowalik (community) code Approve
Review via email: mp+112044@code.launchpad.net

Commit message

Remove unembargo-package.py, superseded by Archive.copyPackage(unembargo=True).

Description of the change

Following https://code.launchpad.net/~cjwatson/launchpad/pcj-reupload/+merge/111124 (and a few subsequent fixes), the Ubuntu security team should be able to use Archive.copyPackage(unembargo=True) rather than the old unembargo-package.py script, so we can remove the latter.

I've QAed the new method on dogfood, but I still need to do a smoke-test on production with the security team, currently planned for Wednesday. I won't land this at least until that's done.

To post a comment you must log in.
Revision history for this message
Steve Kowalik (stevenk) :
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/packagecopier.py'
2--- lib/lp/soyuz/scripts/packagecopier.py 2012-06-26 00:46:41 +0000
3+++ lib/lp/soyuz/scripts/packagecopier.py 2012-06-26 09:53:26 +0000
4@@ -7,7 +7,6 @@
5
6 __all__ = [
7 'PackageCopier',
8- 'UnembargoSecurityPackage',
9 'CopyChecker',
10 'check_copy_permissions',
11 'do_copy',
12@@ -1080,74 +1079,3 @@
13 raise SoyuzScriptError(
14 "Can not sync between the same locations: '%s' to '%s'" % (
15 self.location, self.destination))
16-
17-
18-class UnembargoSecurityPackage(PackageCopier):
19- """`SoyuzScript` that unembargoes security packages and their builds.
20-
21- Security builds are done in the ubuntu-security private PPA.
22- When they are ready to be unembargoed, this script will copy
23- them from the PPA to the Ubuntu archive and re-upload any files
24- from the restricted librarian into the non-restricted one.
25-
26- This script simply wraps up PackageCopier with some nicer options.
27-
28- An assumption is made, to reduce the number of command line options,
29- that packages are always copied between the same distroseries. The user
30- can, however, select which target pocket to unembargo into. This is
31- useful to the security team when there are major version upgrades
32- and they want to stage it through -proposed first for testing.
33- """
34-
35- usage = ("%prog [-d <distribution>] [-s <suite>] [--ppa <private ppa>] "
36- "<package(s)>")
37- description = ("Unembargo packages in a private PPA by copying to the "
38- "specified location and re-uploading any files to the "
39- "unrestricted librarian.")
40-
41- def add_my_options(self):
42- """Add -d, -s, dry-run and confirmation options."""
43- SoyuzScript.add_distro_options(self)
44- SoyuzScript.add_transaction_options(self)
45-
46- self.parser.add_option(
47- "-p", "--ppa", dest="archive_owner_name",
48- default="ubuntu-security", action="store",
49- help="Private PPA owner's name.")
50-
51- self.parser.add_option(
52- "--ppa-name", dest="archive_name",
53- default="ppa", action="store",
54- help="Private PPA name.")
55-
56- def setUpCopierOptions(self):
57- """Set up options needed by PackageCopier."""
58- # Set up the options for PackageCopier that are needed in addition
59- # to the ones that this class sets up.
60- self.options.to_partner = False
61- self.options.to_ppa = False
62- self.options.partner_archive = None
63- self.options.include_binaries = True
64- self.options.unembargo = True
65- self.options.to_distribution = self.options.distribution_name
66- # The PackageCopier parent class uses options.suite as the source
67- # suite, so we need to override it to remove the pocket since PPAs
68- # are pocket-less.
69- self.options.to_suite = self.options.suite
70- self.options.suite = self.options.suite.split("-")[0]
71- self.options.version = None
72- self.options.component = None
73-
74- def mainTask(self):
75- """Invoke PackageCopier to copy the package(s) and re-upload files."""
76- self.setUpCopierOptions()
77-
78- # Generate the location for PackageCopier after overriding the
79- # options.
80- self.setupLocation()
81-
82- # Invoke the package copy operation.
83- copies = PackageCopier.mainTask(self)
84-
85- # Return this for the benefit of the test suite.
86- return copies
87
88=== modified file 'lib/lp/soyuz/scripts/tests/test_copypackage.py'
89--- lib/lp/soyuz/scripts/tests/test_copypackage.py 2012-06-25 08:35:33 +0000
90+++ lib/lp/soyuz/scripts/tests/test_copypackage.py 2012-06-26 09:53:26 +0000
91@@ -74,7 +74,6 @@
92 do_copy,
93 PackageCopier,
94 re_upload_file,
95- UnembargoSecurityPackage,
96 update_files_privacy,
97 )
98 from lp.soyuz.tests.test_publishing import SoyuzTestPublisher
99@@ -2915,95 +2914,32 @@
100 distribution=ubuntu)
101
102 # Create a source and binary private publication.
103- hoary = ubuntu.getSeries('hoary')
104- hoary.status = SeriesStatus.CURRENT
105- test_publisher = self.getTestPublisher(hoary)
106- ppa_source = test_publisher.getPubSource(
107- archive=joe_private_ppa, version='1.0', distroseries=hoary)
108- test_publisher.getPubBinaries(
109- pub_source=ppa_source, distroseries=hoary)
110- self.layer.txn.commit()
111-
112- # Run the copy package script storing the logged information.
113- copy_helper = self.getCopier(
114- sourcename='foo', from_ppa='joe',
115- include_binaries=True, from_suite='hoary',
116- to_suite='hoary-security', unembargo=True)
117- copied = copy_helper.mainTask()
118-
119- # The private files are copied via a direct-copy request.
120- self.assertEqual(len(copied), 3)
121- self.assertEqual(
122- ['INFO FROM: joe: hoary-RELEASE',
123- 'INFO TO: Primary Archive for Ubuntu Linux: hoary-SECURITY',
124- 'INFO Copy candidates:',
125- 'INFO \tfoo 1.0 in hoary',
126- 'INFO \tfoo-bin 1.0 in hoary hppa',
127- 'INFO \tfoo-bin 1.0 in hoary i386',
128- 'INFO Re-uploaded foo_1.0.dsc to librarian',
129- 'INFO Re-uploaded foo_1.0_source.changes to librarian',
130- 'INFO Re-uploaded foo-bin_1.0_all.deb to librarian',
131- 'INFO Re-uploaded foo-bin_1.0_i386.changes to librarian',
132- 'INFO Re-uploaded '
133- 'buildlog_ubuntu-hoary-i386.foo_1.0_FULLYBUILT.txt.gz to '
134- 'librarian',
135- 'INFO Copied:',
136- 'INFO \tfoo 1.0 in hoary',
137- 'INFO \tfoo-bin 1.0 in hoary hppa',
138- 'INFO \tfoo-bin 1.0 in hoary i386',
139- 'INFO 3 packages successfully copied.',
140- ],
141- copy_helper.logger.getLogBuffer().splitlines())
142-
143- def testUnembargoing(self):
144- """Test UnembargoSecurityPackage, which wraps PackagerCopier."""
145- # Set up a private PPA.
146- joe = self.factory.makePerson(name="joe")
147- ubuntu = getUtility(IDistributionSet).getByName('ubuntu')
148- joe_private_ppa = self.factory.makeArchive(
149- owner=joe, name='ppa', private=True,
150- distribution=ubuntu)
151-
152- # Setup a SoyuzTestPublisher object, so we can create publication
153- # to be unembargoed.
154 warty = ubuntu.getSeries('warty')
155 test_publisher = self.getTestPublisher(warty)
156-
157- # Create a source and binary pair to be unembargoed from the PPA.
158 ppa_source = test_publisher.getPubSource(
159- archive=joe_private_ppa, version='1.1',
160- distroseries=warty,
161+ archive=joe_private_ppa, version='1.1', distroseries=warty,
162 status=PackagePublishingStatus.PUBLISHED)
163 other_source = test_publisher.getPubSource(
164 archive=joe_private_ppa, version='1.1',
165 sourcename="sourcefordiff", distroseries=warty,
166 status=PackagePublishingStatus.PUBLISHED)
167- test_publisher.addFakeChroots(warty)
168 ppa_binaries = test_publisher.getPubBinaries(
169 pub_source=ppa_source, distroseries=warty,
170 status=PackagePublishingStatus.PUBLISHED)
171+ self.layer.txn.commit()
172
173 # Give the new source a private package diff.
174- sourcepackagerelease = other_source.sourcepackagerelease
175+ spr = other_source.sourcepackagerelease
176 diff_file = test_publisher.addMockFile("diff_file", restricted=True)
177- package_diff = sourcepackagerelease.requestDiffTo(
178- joe, ppa_source.sourcepackagerelease)
179+ package_diff = spr.requestDiffTo(joe, ppa_source.sourcepackagerelease)
180 package_diff.diff_content = diff_file
181
182- # Prepare a *restricted* buildlog file for the Build instances.
183- fake_buildlog = test_publisher.addMockFile(
184- 'foo_source.buildlog', restricted=True)
185-
186- for build in ppa_source.getBuilds():
187- build.log = fake_buildlog
188-
189 # Add a restricted changelog file.
190- fake_changelog = test_publisher.addMockFile(
191- 'changelog', restricted=True)
192- ppa_source.sourcepackagerelease.changelog = fake_changelog
193+ changelog = test_publisher.addMockFile("changelog", restricted=True)
194+ ppa_source.sourcepackagerelease.changelog = changelog
195
196- # Create ancestry environment in the primary archive, so we can
197- # test unembargoed overrides.
198+ # Create ancestry environment in the primary archive, so we can test
199+ # unembargoed overrides.
200 ancestry_source = test_publisher.getPubSource(
201 version='1.0', distroseries=warty,
202 status=PackagePublishingStatus.PUBLISHED)
203@@ -3011,7 +2947,7 @@
204 pub_source=ancestry_source, distroseries=warty,
205 status=PackagePublishingStatus.SUPERSEDED)
206
207- # Override the published ancestry source to 'universe'
208+ # Override the published ancestry source to 'universe'.
209 universe = getUtility(IComponentSet)['universe']
210 ancestry_source.component = universe
211
212@@ -3021,22 +2957,38 @@
213
214 self.layer.txn.commit()
215
216- # Now we can invoke the unembargo script and check its results.
217- test_args = [
218- "--ppa", "joe",
219- "--ppa-name", "ppa",
220- "-s", "%s" % ppa_source.distroseries.name + "-security",
221- "foo",
222- ]
223-
224- script = UnembargoSecurityPackage(
225- name='unembargo', test_args=test_args)
226- script.logger = BufferLogger()
227-
228- copied = script.mainTask()
229-
230- # Check the results.
231- self.checkCopies(copied, script.destination.archive, 3)
232+ # Run the copy package script storing the logged information.
233+ copy_helper = self.getCopier(
234+ sourcename='foo', from_ppa='joe',
235+ include_binaries=True, from_suite='warty',
236+ to_suite='warty-security', unembargo=True)
237+ copied = copy_helper.mainTask()
238+
239+ # The private files are copied via a direct-copy request.
240+ self.checkCopies(copied, copy_helper.destination.archive, 3)
241+ self.assertEqual(
242+ ['INFO FROM: joe: warty-RELEASE',
243+ 'INFO TO: Primary Archive for Ubuntu Linux: warty-SECURITY',
244+ 'INFO Copy candidates:',
245+ 'INFO \tfoo 1.1 in warty',
246+ 'INFO \tfoo-bin 1.1 in warty hppa',
247+ 'INFO \tfoo-bin 1.1 in warty i386',
248+ 'INFO Re-uploaded foo_1.1.dsc to librarian',
249+ 'INFO Re-uploaded diff_file to librarian',
250+ 'INFO Re-uploaded foo_1.1_source.changes to librarian',
251+ 'INFO Re-uploaded changelog to librarian',
252+ 'INFO Re-uploaded foo-bin_1.1_all.deb to librarian',
253+ 'INFO Re-uploaded foo-bin_1.1_i386.changes to librarian',
254+ 'INFO Re-uploaded '
255+ 'buildlog_ubuntu-warty-i386.foo_1.1_FULLYBUILT.txt.gz to '
256+ 'librarian',
257+ 'INFO Copied:',
258+ 'INFO \tfoo 1.1 in warty',
259+ 'INFO \tfoo-bin 1.1 in warty hppa',
260+ 'INFO \tfoo-bin 1.1 in warty i386',
261+ 'INFO 3 packages successfully copied.',
262+ ],
263+ copy_helper.logger.getLogBuffer().splitlines())
264
265 # Check that the librarian files are all unrestricted now.
266 # We must commit the txn for SQL object to see the change.
267@@ -3071,43 +3023,22 @@
268 published.pocket.title, "Security",
269 "Expected Security pocket, got %s" % published.pocket.title)
270
271- def testUnembargoSuite(self):
272- """Test that passing different suites works as expected."""
273+ def testUnembargoStableReleasePocketForbidden(self):
274+ """Unembargoing into release pocket of stable series is forbidden."""
275 # Set up a private PPA.
276 joe = self.factory.makePerson(name="joe")
277 ubuntu = getUtility(IDistributionSet).getByName('ubuntu')
278 self.factory.makeArchive(
279 owner=joe, name='ppa', private=True, distribution=ubuntu)
280
281- test_args = [
282- "--ppa", "joe",
283- "-s", "warty-backports",
284- "foo",
285- ]
286-
287- script = UnembargoSecurityPackage(
288- name='unembargo', test_args=test_args)
289- script.setUpCopierOptions()
290- script.setupLocation()
291- script.setupDestination()
292- script.destination.distroseries.status = SeriesStatus.CURRENT
293- script.checkPrivacyOptions()
294- self.assertEqual("warty-backports", script.options.to_suite)
295-
296- # Change the suite to one with the release pocket. It should copy
297- # nothing as you're not allowed to unembargo into the release
298- # pocket of a stable series.
299- test_args[3] = "warty"
300- script = UnembargoSecurityPackage(
301- name='unembargo', test_args=test_args)
302- script.logger = BufferLogger()
303- script.setUpCopierOptions()
304- script.setupLocation()
305- script.setupDestination()
306+ copy_helper = self.getCopier(
307+ sourcename='foo', from_ppa='joe',
308+ include_binaries=True, from_suite='warty',
309+ to_suite='warty', unembargo=True)
310 self.assertRaisesWithContent(
311 SoyuzScriptError,
312 "Can't unembargo into suite 'warty' of a distribution.",
313- script.checkPrivacyOptions)
314+ copy_helper.mainTask)
315
316 def testCopyClosesBugs(self):
317 """Copying packages closes bugs.
318
319=== removed file 'scripts/ftpmaster-tools/unembargo-package.py'
320--- scripts/ftpmaster-tools/unembargo-package.py 2011-12-29 05:29:36 +0000
321+++ scripts/ftpmaster-tools/unembargo-package.py 1970-01-01 00:00:00 +0000
322@@ -1,19 +0,0 @@
323-#!/usr/bin/python -S
324-#
325-# Copyright 2009 Canonical Ltd. This software is licensed under the
326-# GNU Affero General Public License version 3 (see the file LICENSE).
327-
328-# pylint: disable-msg=W0403
329-"""Unembargo a package from the security private PPA."""
330-
331-import _pythonpath
332-
333-from lp.services.config import config
334-from lp.soyuz.scripts.packagecopier import UnembargoSecurityPackage
335-
336-
337-if __name__ == '__main__':
338- script = UnembargoSecurityPackage(
339- 'unembargo-package', dbuser=config.archivepublisher.dbuser)
340- script.lock_and_run()
341-