Merge lp:~julian-edwards/launchpad/ppa-copy-to-main-bug-426163 into lp:launchpad

Proposed by Julian Edwards
Status: Merged
Approved by: Aaron Bentley
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~julian-edwards/launchpad/ppa-copy-to-main-bug-426163
Merge into: lp:launchpad
Diff against target: None lines
To merge this branch: bzr merge lp:~julian-edwards/launchpad/ppa-copy-to-main-bug-426163
Reviewer Review Type Date Requested Status
Aaron Bentley (community) code Approve
Review via email: mp+11705@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Julian Edwards (julian-edwards) wrote :

= Summary =
Ensure that packages copied from the primary archive into a PPA don't get a
non-main component

== Proposed fix ==
Right now, when packages are copied from Ubuntu into a PPA, if the source was
in a non-main component then that component is retained in the PPA. This is
bad because PPAs are not supposed to have non-main components!

== Pre-implementation notes ==
I chatted with Celso about this. The actual fix for this is quite trivial;
that is to override the component when the publishing record in the PPA is
created. However, we identified more than one place where publications are
created and this overriding happens. Therefore, this branch contains some
refactoring.

== Implementation details ==
The various methods that created publishing records are now refactored into
the IPublishingSet utility. There's two new methods, one for source and one
for binary. They both override the component to main if the context archive
is a PPA.

File-by-file changes:

* lib/lp/soyuz/doc/publishing.txt:
  I did a moin -> reST conversion. Also updated tests for the new methods on
IPublishingSet. Had to fixe the last test in the file which was copying stuff
into a PPA and expecting a non-main component!

* lib/lp/soyuz/model/publishing.py
  Fixed some code that creates publications so that they use the utility.
  Also added the new utility methods here.

* lib/lp/soyuz/model/queue.py
  Calling the new utility methods instead of creating publishing records
directly.

* lib/lp/soyuz/stories/soyuz/xx-queue-pages-delayed-copies.txt
  This test got broken by the changes because it was relying on the fact that
the publishing records had no security wrapper. Now that they created in a
utility, they will get a wrapper, and this has the knock on effect of also
putting things like SourcePackageReleaseFile in a wrapper which means the
pagetest interaction can't process the upload. I made it call out to a script
instead which runs zopeless. (the objects are *only* ever created in zopeless
scripts in production)

== Tests ==
bin/test -cvvt publishing.txt -t xx-queue-pages-delayed-copies.txt

== Demo and Q/A ==
Can test this on dogfood by using the +copy-packages page to copy some
packages into a PPA. If the packages appear in main, then it's all good!

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/soyuz/model/queue.py
  lib/lp/soyuz/stories/soyuz/xx-queue-pages-delayed-copies.txt
  lib/lp/soyuz/model/publishing.py
  lib/lp/soyuz/doc/publishing.txt
  lib/lp/soyuz/interfaces/publishing.py

== Pylint notices ==

lib/lp/soyuz/interfaces/publishing.py
    32: [F0401] Unable to import 'lazr.enum' (No module named enum)
    39: [F0401] Unable to import 'lazr.restful.fields' (No module named
restful)
    40: [F0401] Unable to import 'lazr.restful.declarations' (No module named
restful)

Revision history for this message
Aaron Bentley (abentley) wrote :

This looks basically good, but there are a few things I'd like changed.

1. Please document the parameters of newBinaryPublication and newSourcePublication
2. Both methods take a status parameter which they ignore. Either they should not accept the parameter, or they should not ignore it. Celso suggests they should not accept the parameter
3. xx-queue-pages-delayed-copies.txt appears to reimplement canonical.launchpad.scripts.tests.run_script. If possible, please use run_script.

Revision history for this message
Julian Edwards (julian-edwards) wrote :
Download full text (9.9 KiB)

Thanks for the review Aaron.

On Monday 14 September 2009 18:15:48 Aaron Bentley wrote:
> This looks basically good, but there are a few things I'd like changed.
>
> 1. Please document the parameters of newBinaryPublication and
> newSourcePublication

Done.

> 2. Both methods take a status parameter which they
> ignore. Either they should not accept the parameter, or they should not
> ignore it. Celso suggests they should not accept the parameter

Right, I had intended to take that out and completely forgot, as you can see
from the half-assed attempt! Thanks for spotting it, both methods now create
new publications with a default status of PENDING.

> 3.
> xx-queue-pages-delayed-copies.txt appears to reimplement
> canonical.launchpad.scripts.tests.run_script. If possible, please use
> run_script.
>

I've changed that.

Partial diff below.

Cheers
Julian

=== modified file 'lib/lp/soyuz/doc/publishing.txt'
--- lib/lp/soyuz/doc/publishing.txt 2009-09-11 10:47:43 +0000
+++ lib/lp/soyuz/doc/publishing.txt 2009-09-15 07:55:17 +0000
@@ -1014,7 +1014,6 @@
     ... distroseries=test_source_pub.distroseries,
     ... component=test_source_pub.component,
     ... section=test_source_pub.section,
- ... status=test_source_pub.status,
     ... pocket=test_source_pub.pocket)
     >>> print ppa_pub.component.name
     main
@@ -1029,7 +1028,6 @@
     ... component=test_bin_pub.component,
     ... section=test_bin_pub.section,
     ... priority=test_bin_pub.priority,
- ... status=test_bin_pub.status,
     ... pocket=test_bin_pub.pocket)
     >>> print ppa_pub.binarypackagerelease.component.name
     universe

=== modified file 'lib/lp/soyuz/interfaces/publishing.py'
--- lib/lp/soyuz/interfaces/publishing.py 2009-09-10 15:25:45 +0000
+++ lib/lp/soyuz/interfaces/publishing.py 2009-09-15 09:10:22 +0000
@@ -847,17 +847,34 @@
     """Auxiliary methods for dealing with sets of publications."""

     def newBinaryPublication(archive, binarypackagerelease, distroarchseries,
- component, section, priority, status, pocket):
+ component, section, priority, pocket):
         """Create a new `BinaryPackagePublishingHistory`.

+ :param archive: An...

Revision history for this message
Aaron Bentley (abentley) wrote :

Thanks for your changes. This looks 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/doc/publishing.txt'
2--- lib/lp/soyuz/doc/publishing.txt 2009-08-28 06:41:25 +0000
3+++ lib/lp/soyuz/doc/publishing.txt 2009-09-11 10:47:43 +0000
4@@ -1,4 +1,6 @@
5-== SourcePackagePublishingHistory ==
6+==============================
7+SourcePackagePublishingHistory
8+==============================
9
10 This class provides public access to publishing records via a SQL view.
11
12@@ -268,7 +270,8 @@
13 base
14
15
16-== Stanza generation ==
17+Stanza generation
18+=================
19
20 >>> from canonical.launchpad.interfaces import (
21 ... IArchiveSafePublisher,
22@@ -328,7 +331,8 @@
23 u'http://ftpmaster.internal/ubuntu/pool/main/a/alsa-utils/alsa-utils_1.0.8-1ubuntu1.dsc')]
24
25
26-== Deletion and obsolescence ==
27+Deletion and obsolescence
28+=========================
29
30 ArchivePublisherBase, which is common to SourcePackagePublishingHistory
31 and BinaryPackagePublishingHistory, contains the methods requestDeletion
32@@ -374,7 +378,8 @@
33 True
34
35
36-== Copying and published binarypackages lookup ==
37+Copying and published binarypackages lookup
38+===========================================
39
40 ISourcePackagePublishingHistory provides the getPublishedBinaries
41 which returns all published binaries build from a source in the pocket
42@@ -609,7 +614,8 @@
43 >>> syncUpdate(deleted)
44
45
46-== Copying and inspecting architecture independent binaries ==
47+Copying and inspecting architecture independent binaries
48+========================================================
49
50 copyTo() behaves differently for architecture independent and
51 architecture specific binaries. We will create a
52@@ -690,7 +696,8 @@
53 pirulito 666 in breezy-autotest i386
54
55
56-== Copying to PPAs ==
57+Copying to PPAs
58+===============
59
60 Another common copy use-case is rebuild the same source in another
61 suite. To simulate this we will create a publication in Celso's PPA.
62@@ -819,7 +826,8 @@
63 []
64
65
66-== getSourceAndBinaryLibraryFiles ==
67+getSourceAndBinaryLibraryFiles
68+==============================
69
70 This method retrieves LibraryFileAlias records for all source and binary
71 files associated with this publication.
72@@ -847,7 +855,8 @@
73 foo_666.dsc
74
75
76-== Publishing records age ==
77+Publishing records age
78+======================
79
80 Both ISourcePackagePublishingHistory and IBinaryPackagePublishingHistory
81 implement the 'age' property which return a timedelta representing
82@@ -860,7 +869,8 @@
83 datetime.timedelta(...)
84
85
86-== Secure Source Publishing ==
87+Secure Source Publishing
88+========================
89
90 'secure_record' returns a ISecureSourcePackagePublishing instance
91 corresponding to this publication. This instance also implements
92@@ -875,7 +885,8 @@
93 False
94
95
96-== Binary and Binary File Publishing ===
97+Binary and Binary File Publishing
98+=================================
99
100 Symmetric behaviour is offered for BinaryPackagePublishing,
101 BinaryPackageFile and ISecureBinaryPackagePublishingHistory
102@@ -935,17 +946,23 @@
103 [u'http://ftpmaster.internal/debian/pool/universe/m/mozilla-firefox/mozilla-firefox_0.9_i386.deb']
104
105
106-== IPublishingSet ==
107+IPublishingSet
108+==============
109
110 This utility implements the following methods:
111
112+ * newBinaryPublication();
113+ * newSourcePublication();
114+
115+which create new publishing records, and:
116+
117 * getBuildsForSources();
118 * getUnpublishedBuildsForSources();
119 * getFilesForSources();
120 * getBinaryPublicationsForSources();
121 * getPackageDiffsForSources();
122
123-They receive a list of `SourcePackagePublishingHistory` objects and
124+which receive a list of `SourcePackagePublishingHistory` objects and
125 fetch the corresponding information for all of them.
126
127 Their returned `ResultSet` (they all use storm natively) follows a
128@@ -963,27 +980,69 @@
129 * getSourceAndBinaryLibraryFiles -> IPublishingSet.getFilesForSources;
130 * getPublishedBinaries -> IPublishingSet.getBinaryPublicationsForSources;
131
132-So, they were already tested implicitly before in this file, the
133+So, they were already tested implicitly before in this file, they
134 simply use the IPublishing methods passing only a single source
135 publication. Now we will document how they work for multiple source
136 publications.
137
138+ >>> from lp.soyuz.interfaces.publishing import (
139+ ... IPublishingSet)
140+
141+ >>> publishing_set = getUtility(IPublishingSet)
142+
143+ >>> verifyObject(IPublishingSet, publishing_set)
144+ True
145+
146+
147+Creating new publication records
148+--------------------------------
149+
150+newSourcePublication() and newBinaryPublication() will create source and
151+binary publication records respectively. They are already implicitly tested
152+above via the copyTo methods which use them to create new records. However,
153+they have one extra feature which is important for PPAs - they will ensure
154+that the published component is always 'main'.
155+
156+When copying publications from non-main components in the primary archive,
157+the PPA publication will always be main:
158+
159+ >>> test_source_pub = test_publisher.getPubSource(
160+ ... sourcename='overrideme', component='universe')
161+ >>> ppa_pub = publishing_set.newSourcePublication(
162+ ... archive=mark.archive,
163+ ... sourcepackagerelease=test_source_pub.sourcepackagerelease,
164+ ... distroseries=test_source_pub.distroseries,
165+ ... component=test_source_pub.component,
166+ ... section=test_source_pub.section,
167+ ... status=test_source_pub.status,
168+ ... pocket=test_source_pub.pocket)
169+ >>> print ppa_pub.component.name
170+ main
171+
172+ >>> test_bin_pubs = test_publisher.getPubBinaries(
173+ ... pub_source=test_source_pub)
174+ >>> test_bin_pub = test_bin_pubs[0]
175+ >>> ppa_pub = publishing_set.newBinaryPublication(
176+ ... archive=mark.archive,
177+ ... binarypackagerelease=test_bin_pub.binarypackagerelease,
178+ ... distroarchseries=test_bin_pub.distroarchseries,
179+ ... component=test_bin_pub.component,
180+ ... section=test_bin_pub.section,
181+ ... priority=test_bin_pub.priority,
182+ ... status=test_bin_pub.status,
183+ ... pocket=test_bin_pub.pocket)
184+ >>> print ppa_pub.binarypackagerelease.component.name
185+ universe
186+ >>> print ppa_pub.component.name
187+ main
188+
189 IPublishingSet is an essential component for
190 `ArchiveSourcePublications` feature, see more information below in
191 its corresponding test section.
192
193- >>> from lp.soyuz.interfaces.publishing import (
194- ... IPublishingSet)
195-
196- >>> publishing_set = getUtility(IPublishingSet)
197-
198- >>> verifyObject(IPublishingSet, publishing_set)
199- True
200-
201 We will assembly a list of source publications based on what was
202 ever published in Celso's PPA.
203
204- >>> cprov = getUtility(IPersonSet).getByName('cprov')
205 >>> cprov_sources = list(cprov.archive.getPublishedSources())
206 >>> len(cprov_sources)
207 8
208@@ -1301,7 +1360,8 @@
209 AssertionError: The 'sources' parameter must be a list.
210
211
212-== ArchiveSourcePublications ==
213+ArchiveSourcePublications
214+=========================
215
216 `ArchiveSourcePublications` wraps `IPublishingSet` methods to build a
217 set of objects which decorate `ISourcePackagePublishingHistory` with
218@@ -1516,7 +1576,8 @@
219 i386 build of foo 999 in ubuntutest breezy-autotest RELEASE
220
221
222-== IPublishingSet.getBuildStatusSummariesForSourceIdsAndArchive() ==
223+IPublishingSet.getBuildStatusSummariesForSourceIdsAndArchive()
224+==============================================================
225
226 This extra method on IPublishingSet allows a summary of the build status
227 for a set of sources to be presented. The corresponding archive is a
228@@ -1586,7 +1647,8 @@
229 >>> print_build_summaries(build_summaries)
230
231
232-== IPublishing ancestry lookup and override ==
233+IPublishing ancestry lookup and override
234+========================================
235
236 `IPublishing` is implemented by both kinds of package publications we
237 have `SourcePackagePublishingHistory` and
238@@ -1671,7 +1733,8 @@
239
240 `overrideFromAncestry` operates directly on top of the default
241 behavior of `getAncestry`. It looks up the most recent ancestry for a
242-publication and override it in place.
243+publication and override it in place. If there is no previous publication
244+then the package's component is used.
245
246 >>> print test_source.component.name
247 universe
248@@ -1680,17 +1743,19 @@
249 >>> print test_source.component.name
250 multiverse
251
252-It works in the same way for binaries and follows the new publishing
253-context.
254+It works in the same way for binaries.
255+
256+ >>> multiverse = getUtility(IComponentSet)['multiverse']
257+ >>> test_binary.binarypackagerelease.component = multiverse
258
259 >>> print test_binary.component.name
260 universe
261
262 >>> copied_binary = test_binary.copyTo(
263- ... test_source.distroseries, test_source.pocket, cprov.archive)[0]
264+ ... hoary_test, test_source.pocket, archive=test_binary.archive)[0]
265 >>> print copied_binary.component.name
266 universe
267
268 >>> copied_binary.overrideFromAncestry()
269 >>> print copied_binary.component.name
270- main
271+ multiverse
272
273=== modified file 'lib/lp/soyuz/interfaces/publishing.py'
274--- lib/lp/soyuz/interfaces/publishing.py 2009-08-28 07:39:05 +0000
275+++ lib/lp/soyuz/interfaces/publishing.py 2009-09-10 15:25:45 +0000
276@@ -846,6 +846,20 @@
277 class IPublishingSet(Interface):
278 """Auxiliary methods for dealing with sets of publications."""
279
280+ def newBinaryPublication(archive, binarypackagerelease, distroarchseries,
281+ component, section, priority, status, pocket):
282+ """Create a new `BinaryPackagePublishingHistory`.
283+
284+ datecreated will be UTC_NOW.
285+ """
286+
287+ def newSourcePublication(archive, sourcepackagerelease, distroseries,
288+ component, section, status, pocket):
289+ """Create a new `SourcePackagePublishingHistory`.
290+
291+ datecreated will be UTC_NOW.
292+ """
293+
294 def getByIdAndArchive(id, archive, source=True):
295 """Return the publication matching id AND archive.
296
297
298=== modified file 'lib/lp/soyuz/model/publishing.py'
299--- lib/lp/soyuz/model/publishing.py 2009-08-28 07:34:44 +0000
300+++ lib/lp/soyuz/model/publishing.py 2009-09-11 10:47:43 +0000
301@@ -45,6 +45,7 @@
302 LibraryFileAlias, LibraryFileContent)
303 from lp.soyuz.model.packagediff import PackageDiff
304 from lp.soyuz.interfaces.archive import ArchivePurpose
305+from lp.soyuz.interfaces.component import IComponentSet
306 from lp.soyuz.interfaces.queue import PackageUploadStatus
307 from lp.soyuz.interfaces.publishing import (
308 active_publishing_status, IArchiveSafePublisher,
309@@ -779,17 +780,15 @@
310 def copyTo(self, distroseries, pocket, archive):
311 """See `ISourcePackagePublishingHistory`."""
312 current = self.secure_record
313- secure_copy = SecureSourcePackagePublishingHistory(
314- distroseries=distroseries,
315- pocket=pocket,
316- archive=archive,
317- sourcepackagerelease=current.sourcepackagerelease,
318- component=current.component,
319- section=current.section,
320- status=PackagePublishingStatus.PENDING,
321- datecreated=UTC_NOW,
322- embargo=False)
323- return SourcePackagePublishingHistory.get(secure_copy.id)
324+ return getUtility(IPublishingSet).newSourcePublication(
325+ archive,
326+ current.sourcepackagerelease,
327+ distroseries,
328+ current.component,
329+ current.section,
330+ PackagePublishingStatus.PENDING,
331+ pocket
332+ )
333
334 def getStatusSummaryForBuilds(self):
335 """See `ISourcePackagePublishingHistory`."""
336@@ -1045,21 +1044,19 @@
337
338 copies = []
339 for architecture in destination_architectures:
340- copy = SecureBinaryPackagePublishingHistory(
341- archive=archive,
342- binarypackagerelease=self.binarypackagerelease,
343- distroarchseries=architecture,
344- component=current.component,
345- section=current.section,
346- priority=current.priority,
347- status=PackagePublishingStatus.PENDING,
348- datecreated=UTC_NOW,
349- pocket=pocket,
350- embargo=False)
351+ copy = getUtility(IPublishingSet).newBinaryPublication(
352+ archive,
353+ self.binarypackagerelease,
354+ architecture,
355+ current.component,
356+ current.section,
357+ current.priority,
358+ PackagePublishingStatus.PENDING,
359+ pocket
360+ )
361 copies.append(copy)
362
363- return [
364- BinaryPackagePublishingHistory.get(copy.id) for copy in copies]
365+ return copies
366
367 def getAncestry(self, archive=None, distroseries=None, pocket=None,
368 status=None):
369@@ -1105,6 +1102,53 @@
370
371 implements(IPublishingSet)
372
373+ def newBinaryPublication(self, archive, binarypackagerelease,
374+ distroarchseries, component, section, priority,
375+ status, pocket):
376+ """See `IPublishingSet`."""
377+ if archive.is_ppa:
378+ # PPA component must always be 'main', so we override it
379+ # here.
380+ component = getUtility(IComponentSet)['main']
381+ pub = SecureBinaryPackagePublishingHistory(
382+ archive=archive,
383+ binarypackagerelease=binarypackagerelease,
384+ distroarchseries=distroarchseries,
385+ component=component,
386+ section=section,
387+ priority=priority,
388+ status=PackagePublishingStatus.PENDING,
389+ datecreated=UTC_NOW,
390+ pocket=pocket,
391+ embargo=False)
392+
393+ # One day, this will not be necessary when we have time to kill
394+ # the Secure* records.
395+ return BinaryPackagePublishingHistory.get(pub.id)
396+
397+ def newSourcePublication(self, archive, sourcepackagerelease,
398+ distroseries, component, section, status,
399+ pocket):
400+ """See `IPublishingSet`."""
401+ if archive.is_ppa:
402+ # PPA component must always be 'main', so we override it
403+ # here.
404+ component = getUtility(IComponentSet)['main']
405+ pub = SecureSourcePackagePublishingHistory(
406+ distroseries=distroseries,
407+ pocket=pocket,
408+ archive=archive,
409+ sourcepackagerelease=sourcepackagerelease,
410+ component=component,
411+ section=section,
412+ status=PackagePublishingStatus.PENDING,
413+ datecreated=UTC_NOW,
414+ embargo=False)
415+
416+ # One day, this will not be necessary when we have time to kill
417+ # the Secure* records.
418+ return SourcePackagePublishingHistory.get(pub.id)
419+
420 def getBuildsForSourceIds(
421 self, source_publication_ids, archive=None, build_states=None):
422 """See `IPublishingSet`."""
423
424=== modified file 'lib/lp/soyuz/model/queue.py'
425--- lib/lp/soyuz/model/queue.py 2009-08-16 12:38:12 +0000
426+++ lib/lp/soyuz/model/queue.py 2009-09-14 15:19:37 +0000
427@@ -43,15 +43,11 @@
428 from canonical.database.enumcol import EnumCol
429 from canonical.database.sqlbase import SQLBase, sqlvalues
430 from canonical.encoding import guess as guess_encoding, ascii_smash
431-from lp.soyuz.model.publishing import (
432- BinaryPackagePublishingHistory, SecureBinaryPackagePublishingHistory,
433- SecureSourcePackagePublishingHistory, SourcePackagePublishingHistory)
434 from canonical.launchpad.helpers import get_email_template
435 from lp.soyuz.interfaces.archive import (
436 ArchivePurpose, IArchiveSet)
437 from lp.soyuz.interfaces.binarypackagerelease import (
438 BinaryPackageFormat)
439-from lp.soyuz.interfaces.component import IComponentSet
440 from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities
441 from lp.soyuz.interfaces.queue import (
442 PackageUploadStatus, PackageUploadCustomFormat)
443@@ -59,7 +55,7 @@
444 from lp.registry.interfaces.pocket import (
445 PackagePublishingPocket, pocketsuffix)
446 from lp.soyuz.interfaces.publishing import (
447- ISourcePackagePublishingHistory, PackagePublishingStatus)
448+ IPublishingSet, ISourcePackagePublishingHistory, PackagePublishingStatus)
449 from lp.soyuz.interfaces.queue import (
450 IPackageUpload, IPackageUploadBuild, IPackageUploadCustom,
451 IPackageUploadQueue, IPackageUploadSource, IPackageUploadSet,
452@@ -1305,7 +1301,6 @@
453 other_dars = other_dars - set([target_dar])
454 # First up, publish everything in this build into that dar.
455 published_binaries = []
456- main_component = getUtility(IComponentSet)['main']
457 for binary in self.build.binarypackages:
458 target_dars = set([target_dar])
459 if not binary.architecturespecific:
460@@ -1332,28 +1327,17 @@
461 "Could not find the corresponding DEBUG archive "
462 "for %s" % (distribution.title))
463
464- # We override PPA to always publish in the main component.
465- if self.packageupload.archive.is_ppa:
466- component = main_component
467- else:
468- component = binary.component
469-
470 for each_target_dar in target_dars:
471- # XXX: dsilvers 2005-10-20 bug=3408:
472- # What do we do about embargoed binaries here?
473- sbpph = SecureBinaryPackagePublishingHistory(
474+ bpph = getUtility(IPublishingSet).newBinaryPublication(
475+ archive=archive,
476 binarypackagerelease=binary,
477 distroarchseries=each_target_dar,
478+ component=binary.component,
479 section=binary.section,
480 priority=binary.priority,
481 status=PackagePublishingStatus.PENDING,
482- datecreated=UTC_NOW,
483- pocket=self.packageupload.pocket,
484- embargo=False,
485- component=component,
486- archive=archive,
487+ pocket=self.packageupload.pocket
488 )
489- bpph = BinaryPackagePublishingHistory.get(sbpph.id)
490 published_binaries.append(bpph)
491 return published_binaries
492
493@@ -1470,31 +1454,21 @@
494 def publish(self, logger=None):
495 """See `IPackageUploadSource`."""
496 # Publish myself in the distroseries pointed at by my queue item.
497- # XXX: dsilvers: 2005-10-20 bug=3408:
498- # What do we do here to support embargoed sources?
499 debug(logger, "Publishing source %s/%s to %s/%s" % (
500 self.sourcepackagerelease.name,
501 self.sourcepackagerelease.version,
502 self.packageupload.distroseries.distribution.name,
503 self.packageupload.distroseries.name))
504
505- if self.packageupload.archive.is_ppa:
506- # We override PPA to always publish in the main component.
507- component = getUtility(IComponentSet)['main']
508- else:
509- component = self.sourcepackagerelease.component
510-
511- sspph = SecureSourcePackagePublishingHistory(
512+ return getUtility(IPublishingSet).newSourcePublication(
513+ archive=self.packageupload.archive,
514+ sourcepackagerelease=self.sourcepackagerelease,
515 distroseries=self.packageupload.distroseries,
516- sourcepackagerelease=self.sourcepackagerelease,
517- component=component,
518+ component=self.sourcepackagerelease.component,
519 section=self.sourcepackagerelease.section,
520 status=PackagePublishingStatus.PENDING,
521- datecreated=UTC_NOW,
522- pocket=self.packageupload.pocket,
523- embargo=False,
524- archive=self.packageupload.archive)
525- return SourcePackagePublishingHistory.get(sspph.id)
526+ pocket=self.packageupload.pocket
527+ )
528
529
530 class PackageUploadCustom(SQLBase):
531
532=== modified file 'lib/lp/soyuz/stories/soyuz/xx-queue-pages-delayed-copies.txt'
533--- lib/lp/soyuz/stories/soyuz/xx-queue-pages-delayed-copies.txt 2009-08-28 06:39:38 +0000
534+++ lib/lp/soyuz/stories/soyuz/xx-queue-pages-delayed-copies.txt 2009-09-14 15:15:54 +0000
535@@ -23,6 +23,7 @@
536 >>> [bin_hppa, bin_i386] = stp.getPubBinaries(archive=cprov.archive)
537 >>> build = bin_hppa.binarypackagerelease.build
538 >>> breezy_autotest = ubuntu.getSeries('breezy-autotest')
539+ >>> stp.addFakeChroots(breezy_autotest)
540 >>> delayed_copy = getUtility(IPackageUploadSet).createDelayedCopy(
541 ... archive=ubuntu.main_archive, distroseries=breezy_autotest,
542 ... pocket=PackagePublishingPocket.RELEASE, signing_key=None)
543@@ -100,14 +101,22 @@
544 http://launchpad.dev/~cprov/+archive/ppa
545
546 When the delayed-copy is processed (moved to DONE queue) its contents
547-becomes available to everyone.
548+become available to everyone.
549
550- # Process the delayed-copy.
551- >>> login('foo.bar@canonical.com')
552- >>> stp.addFakeChroots(breezy_autotest)
553- >>> unused = delayed_copy.realiseUpload()
554- >>> transaction.commit()
555- >>> logout()
556+ # Process the delayed-copy using an external script call. Since some
557+ # DB objects that have no security adapter are modified during the
558+ # delayed copy, the modification must be done in Zopeless mode.
559+ >>> import os.path
560+ >>> import subprocess
561+ >>> import sys
562+ >>> from canonical.config import config
563+ >>> script = os.path.join(config.root, "scripts/process-accepted.py")
564+ >>> process = subprocess.Popen(
565+ ... [sys.executable, script, "ubuntu"],
566+ ... stdout=subprocess.PIPE, stderr=subprocess.PIPE)
567+ >>> stdout, stderr = process.communicate()
568+ >>> if process.returncode != 0:
569+ ... print stderr
570
571 Any user can access the DONE queue and access the delayed-copy
572 'changesfile' and view its files in the expandable area.