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
=== modified file 'lib/lp/soyuz/doc/publishing.txt'
--- lib/lp/soyuz/doc/publishing.txt 2009-08-28 06:41:25 +0000
+++ lib/lp/soyuz/doc/publishing.txt 2009-09-11 10:47:43 +0000
@@ -1,4 +1,6 @@
1== SourcePackagePublishingHistory ==1==============================
2SourcePackagePublishingHistory
3==============================
24
3This class provides public access to publishing records via a SQL view.5This class provides public access to publishing records via a SQL view.
46
@@ -268,7 +270,8 @@
268 base270 base
269271
270272
271== Stanza generation ==273Stanza generation
274=================
272275
273 >>> from canonical.launchpad.interfaces import (276 >>> from canonical.launchpad.interfaces import (
274 ... IArchiveSafePublisher,277 ... IArchiveSafePublisher,
@@ -328,7 +331,8 @@
328 u'http://ftpmaster.internal/ubuntu/pool/main/a/alsa-utils/alsa-utils_1.0.8-1ubuntu1.dsc')]331 u'http://ftpmaster.internal/ubuntu/pool/main/a/alsa-utils/alsa-utils_1.0.8-1ubuntu1.dsc')]
329332
330333
331== Deletion and obsolescence ==334Deletion and obsolescence
335=========================
332336
333ArchivePublisherBase, which is common to SourcePackagePublishingHistory337ArchivePublisherBase, which is common to SourcePackagePublishingHistory
334and BinaryPackagePublishingHistory, contains the methods requestDeletion338and BinaryPackagePublishingHistory, contains the methods requestDeletion
@@ -374,7 +378,8 @@
374 True378 True
375379
376380
377== Copying and published binarypackages lookup ==381Copying and published binarypackages lookup
382===========================================
378383
379ISourcePackagePublishingHistory provides the getPublishedBinaries384ISourcePackagePublishingHistory provides the getPublishedBinaries
380which returns all published binaries build from a source in the pocket385which returns all published binaries build from a source in the pocket
@@ -609,7 +614,8 @@
609 >>> syncUpdate(deleted)614 >>> syncUpdate(deleted)
610615
611616
612== Copying and inspecting architecture independent binaries ==617Copying and inspecting architecture independent binaries
618========================================================
613619
614copyTo() behaves differently for architecture independent and620copyTo() behaves differently for architecture independent and
615architecture specific binaries. We will create a621architecture specific binaries. We will create a
@@ -690,7 +696,8 @@
690 pirulito 666 in breezy-autotest i386696 pirulito 666 in breezy-autotest i386
691697
692698
693== Copying to PPAs ==699Copying to PPAs
700===============
694701
695Another common copy use-case is rebuild the same source in another702Another common copy use-case is rebuild the same source in another
696suite. To simulate this we will create a publication in Celso's PPA.703suite. To simulate this we will create a publication in Celso's PPA.
@@ -819,7 +826,8 @@
819 []826 []
820827
821828
822== getSourceAndBinaryLibraryFiles ==829getSourceAndBinaryLibraryFiles
830==============================
823831
824This method retrieves LibraryFileAlias records for all source and binary832This method retrieves LibraryFileAlias records for all source and binary
825files associated with this publication.833files associated with this publication.
@@ -847,7 +855,8 @@
847 foo_666.dsc855 foo_666.dsc
848856
849857
850== Publishing records age ==858Publishing records age
859======================
851860
852Both ISourcePackagePublishingHistory and IBinaryPackagePublishingHistory861Both ISourcePackagePublishingHistory and IBinaryPackagePublishingHistory
853implement the 'age' property which return a timedelta representing862implement the 'age' property which return a timedelta representing
@@ -860,7 +869,8 @@
860 datetime.timedelta(...)869 datetime.timedelta(...)
861870
862871
863== Secure Source Publishing ==872Secure Source Publishing
873========================
864874
865'secure_record' returns a ISecureSourcePackagePublishing instance875'secure_record' returns a ISecureSourcePackagePublishing instance
866corresponding to this publication. This instance also implements876corresponding to this publication. This instance also implements
@@ -875,7 +885,8 @@
875 False885 False
876886
877887
878== Binary and Binary File Publishing ===888Binary and Binary File Publishing
889=================================
879890
880Symmetric behaviour is offered for BinaryPackagePublishing,891Symmetric behaviour is offered for BinaryPackagePublishing,
881BinaryPackageFile and ISecureBinaryPackagePublishingHistory892BinaryPackageFile and ISecureBinaryPackagePublishingHistory
@@ -935,17 +946,23 @@
935 [u'http://ftpmaster.internal/debian/pool/universe/m/mozilla-firefox/mozilla-firefox_0.9_i386.deb']946 [u'http://ftpmaster.internal/debian/pool/universe/m/mozilla-firefox/mozilla-firefox_0.9_i386.deb']
936947
937948
938== IPublishingSet ==949IPublishingSet
950==============
939951
940This utility implements the following methods:952This utility implements the following methods:
941953
954 * newBinaryPublication();
955 * newSourcePublication();
956
957which create new publishing records, and:
958
942 * getBuildsForSources();959 * getBuildsForSources();
943 * getUnpublishedBuildsForSources();960 * getUnpublishedBuildsForSources();
944 * getFilesForSources();961 * getFilesForSources();
945 * getBinaryPublicationsForSources();962 * getBinaryPublicationsForSources();
946 * getPackageDiffsForSources();963 * getPackageDiffsForSources();
947964
948They receive a list of `SourcePackagePublishingHistory` objects and965which receive a list of `SourcePackagePublishingHistory` objects and
949fetch the corresponding information for all of them.966fetch the corresponding information for all of them.
950967
951Their returned `ResultSet` (they all use storm natively) follows a968Their returned `ResultSet` (they all use storm natively) follows a
@@ -963,27 +980,69 @@
963 * getSourceAndBinaryLibraryFiles -> IPublishingSet.getFilesForSources;980 * getSourceAndBinaryLibraryFiles -> IPublishingSet.getFilesForSources;
964 * getPublishedBinaries -> IPublishingSet.getBinaryPublicationsForSources;981 * getPublishedBinaries -> IPublishingSet.getBinaryPublicationsForSources;
965982
966So, they were already tested implicitly before in this file, the983So, they were already tested implicitly before in this file, they
967simply use the IPublishing methods passing only a single source984simply use the IPublishing methods passing only a single source
968publication. Now we will document how they work for multiple source985publication. Now we will document how they work for multiple source
969publications.986publications.
970987
988 >>> from lp.soyuz.interfaces.publishing import (
989 ... IPublishingSet)
990
991 >>> publishing_set = getUtility(IPublishingSet)
992
993 >>> verifyObject(IPublishingSet, publishing_set)
994 True
995
996
997Creating new publication records
998--------------------------------
999
1000newSourcePublication() and newBinaryPublication() will create source and
1001binary publication records respectively. They are already implicitly tested
1002above via the copyTo methods which use them to create new records. However,
1003they have one extra feature which is important for PPAs - they will ensure
1004that the published component is always 'main'.
1005
1006When copying publications from non-main components in the primary archive,
1007the PPA publication will always be main:
1008
1009 >>> test_source_pub = test_publisher.getPubSource(
1010 ... sourcename='overrideme', component='universe')
1011 >>> ppa_pub = publishing_set.newSourcePublication(
1012 ... archive=mark.archive,
1013 ... sourcepackagerelease=test_source_pub.sourcepackagerelease,
1014 ... distroseries=test_source_pub.distroseries,
1015 ... component=test_source_pub.component,
1016 ... section=test_source_pub.section,
1017 ... status=test_source_pub.status,
1018 ... pocket=test_source_pub.pocket)
1019 >>> print ppa_pub.component.name
1020 main
1021
1022 >>> test_bin_pubs = test_publisher.getPubBinaries(
1023 ... pub_source=test_source_pub)
1024 >>> test_bin_pub = test_bin_pubs[0]
1025 >>> ppa_pub = publishing_set.newBinaryPublication(
1026 ... archive=mark.archive,
1027 ... binarypackagerelease=test_bin_pub.binarypackagerelease,
1028 ... distroarchseries=test_bin_pub.distroarchseries,
1029 ... component=test_bin_pub.component,
1030 ... section=test_bin_pub.section,
1031 ... priority=test_bin_pub.priority,
1032 ... status=test_bin_pub.status,
1033 ... pocket=test_bin_pub.pocket)
1034 >>> print ppa_pub.binarypackagerelease.component.name
1035 universe
1036 >>> print ppa_pub.component.name
1037 main
1038
971IPublishingSet is an essential component for1039IPublishingSet is an essential component for
972`ArchiveSourcePublications` feature, see more information below in1040`ArchiveSourcePublications` feature, see more information below in
973its corresponding test section.1041its corresponding test section.
9741042
975 >>> from lp.soyuz.interfaces.publishing import (
976 ... IPublishingSet)
977
978 >>> publishing_set = getUtility(IPublishingSet)
979
980 >>> verifyObject(IPublishingSet, publishing_set)
981 True
982
983We will assembly a list of source publications based on what was1043We will assembly a list of source publications based on what was
984ever published in Celso's PPA.1044ever published in Celso's PPA.
9851045
986 >>> cprov = getUtility(IPersonSet).getByName('cprov')
987 >>> cprov_sources = list(cprov.archive.getPublishedSources())1046 >>> cprov_sources = list(cprov.archive.getPublishedSources())
988 >>> len(cprov_sources)1047 >>> len(cprov_sources)
989 81048 8
@@ -1301,7 +1360,8 @@
1301 AssertionError: The 'sources' parameter must be a list.1360 AssertionError: The 'sources' parameter must be a list.
13021361
13031362
1304== ArchiveSourcePublications ==1363ArchiveSourcePublications
1364=========================
13051365
1306`ArchiveSourcePublications` wraps `IPublishingSet` methods to build a1366`ArchiveSourcePublications` wraps `IPublishingSet` methods to build a
1307set of objects which decorate `ISourcePackagePublishingHistory` with1367set of objects which decorate `ISourcePackagePublishingHistory` with
@@ -1516,7 +1576,8 @@
1516 i386 build of foo 999 in ubuntutest breezy-autotest RELEASE1576 i386 build of foo 999 in ubuntutest breezy-autotest RELEASE
15171577
15181578
1519== IPublishingSet.getBuildStatusSummariesForSourceIdsAndArchive() ==1579IPublishingSet.getBuildStatusSummariesForSourceIdsAndArchive()
1580==============================================================
15201581
1521This extra method on IPublishingSet allows a summary of the build status1582This extra method on IPublishingSet allows a summary of the build status
1522for a set of sources to be presented. The corresponding archive is a1583for a set of sources to be presented. The corresponding archive is a
@@ -1586,7 +1647,8 @@
1586 >>> print_build_summaries(build_summaries)1647 >>> print_build_summaries(build_summaries)
15871648
15881649
1589== IPublishing ancestry lookup and override ==1650IPublishing ancestry lookup and override
1651========================================
15901652
1591`IPublishing` is implemented by both kinds of package publications we1653`IPublishing` is implemented by both kinds of package publications we
1592have `SourcePackagePublishingHistory` and1654have `SourcePackagePublishingHistory` and
@@ -1671,7 +1733,8 @@
16711733
1672`overrideFromAncestry` operates directly on top of the default1734`overrideFromAncestry` operates directly on top of the default
1673behavior of `getAncestry`. It looks up the most recent ancestry for a1735behavior of `getAncestry`. It looks up the most recent ancestry for a
1674publication and override it in place.1736publication and override it in place. If there is no previous publication
1737then the package's component is used.
16751738
1676 >>> print test_source.component.name1739 >>> print test_source.component.name
1677 universe1740 universe
@@ -1680,17 +1743,19 @@
1680 >>> print test_source.component.name1743 >>> print test_source.component.name
1681 multiverse1744 multiverse
16821745
1683It works in the same way for binaries and follows the new publishing1746It works in the same way for binaries.
1684context.1747
1748 >>> multiverse = getUtility(IComponentSet)['multiverse']
1749 >>> test_binary.binarypackagerelease.component = multiverse
16851750
1686 >>> print test_binary.component.name1751 >>> print test_binary.component.name
1687 universe1752 universe
16881753
1689 >>> copied_binary = test_binary.copyTo(1754 >>> copied_binary = test_binary.copyTo(
1690 ... test_source.distroseries, test_source.pocket, cprov.archive)[0]1755 ... hoary_test, test_source.pocket, archive=test_binary.archive)[0]
1691 >>> print copied_binary.component.name1756 >>> print copied_binary.component.name
1692 universe1757 universe
16931758
1694 >>> copied_binary.overrideFromAncestry()1759 >>> copied_binary.overrideFromAncestry()
1695 >>> print copied_binary.component.name1760 >>> print copied_binary.component.name
1696 main1761 multiverse
16971762
=== modified file 'lib/lp/soyuz/interfaces/publishing.py'
--- lib/lp/soyuz/interfaces/publishing.py 2009-08-28 07:39:05 +0000
+++ lib/lp/soyuz/interfaces/publishing.py 2009-09-10 15:25:45 +0000
@@ -846,6 +846,20 @@
846class IPublishingSet(Interface):846class IPublishingSet(Interface):
847 """Auxiliary methods for dealing with sets of publications."""847 """Auxiliary methods for dealing with sets of publications."""
848848
849 def newBinaryPublication(archive, binarypackagerelease, distroarchseries,
850 component, section, priority, status, pocket):
851 """Create a new `BinaryPackagePublishingHistory`.
852
853 datecreated will be UTC_NOW.
854 """
855
856 def newSourcePublication(archive, sourcepackagerelease, distroseries,
857 component, section, status, pocket):
858 """Create a new `SourcePackagePublishingHistory`.
859
860 datecreated will be UTC_NOW.
861 """
862
849 def getByIdAndArchive(id, archive, source=True):863 def getByIdAndArchive(id, archive, source=True):
850 """Return the publication matching id AND archive.864 """Return the publication matching id AND archive.
851865
852866
=== modified file 'lib/lp/soyuz/model/publishing.py'
--- lib/lp/soyuz/model/publishing.py 2009-08-28 07:34:44 +0000
+++ lib/lp/soyuz/model/publishing.py 2009-09-11 10:47:43 +0000
@@ -45,6 +45,7 @@
45 LibraryFileAlias, LibraryFileContent)45 LibraryFileAlias, LibraryFileContent)
46from lp.soyuz.model.packagediff import PackageDiff46from lp.soyuz.model.packagediff import PackageDiff
47from lp.soyuz.interfaces.archive import ArchivePurpose47from lp.soyuz.interfaces.archive import ArchivePurpose
48from lp.soyuz.interfaces.component import IComponentSet
48from lp.soyuz.interfaces.queue import PackageUploadStatus49from lp.soyuz.interfaces.queue import PackageUploadStatus
49from lp.soyuz.interfaces.publishing import (50from lp.soyuz.interfaces.publishing import (
50 active_publishing_status, IArchiveSafePublisher,51 active_publishing_status, IArchiveSafePublisher,
@@ -779,17 +780,15 @@
779 def copyTo(self, distroseries, pocket, archive):780 def copyTo(self, distroseries, pocket, archive):
780 """See `ISourcePackagePublishingHistory`."""781 """See `ISourcePackagePublishingHistory`."""
781 current = self.secure_record782 current = self.secure_record
782 secure_copy = SecureSourcePackagePublishingHistory(783 return getUtility(IPublishingSet).newSourcePublication(
783 distroseries=distroseries,784 archive,
784 pocket=pocket,785 current.sourcepackagerelease,
785 archive=archive,786 distroseries,
786 sourcepackagerelease=current.sourcepackagerelease,787 current.component,
787 component=current.component,788 current.section,
788 section=current.section,789 PackagePublishingStatus.PENDING,
789 status=PackagePublishingStatus.PENDING,790 pocket
790 datecreated=UTC_NOW,791 )
791 embargo=False)
792 return SourcePackagePublishingHistory.get(secure_copy.id)
793792
794 def getStatusSummaryForBuilds(self):793 def getStatusSummaryForBuilds(self):
795 """See `ISourcePackagePublishingHistory`."""794 """See `ISourcePackagePublishingHistory`."""
@@ -1045,21 +1044,19 @@
10451044
1046 copies = []1045 copies = []
1047 for architecture in destination_architectures:1046 for architecture in destination_architectures:
1048 copy = SecureBinaryPackagePublishingHistory(1047 copy = getUtility(IPublishingSet).newBinaryPublication(
1049 archive=archive,1048 archive,
1050 binarypackagerelease=self.binarypackagerelease,1049 self.binarypackagerelease,
1051 distroarchseries=architecture,1050 architecture,
1052 component=current.component,1051 current.component,
1053 section=current.section,1052 current.section,
1054 priority=current.priority,1053 current.priority,
1055 status=PackagePublishingStatus.PENDING,1054 PackagePublishingStatus.PENDING,
1056 datecreated=UTC_NOW,1055 pocket
1057 pocket=pocket,1056 )
1058 embargo=False)
1059 copies.append(copy)1057 copies.append(copy)
10601058
1061 return [1059 return copies
1062 BinaryPackagePublishingHistory.get(copy.id) for copy in copies]
10631060
1064 def getAncestry(self, archive=None, distroseries=None, pocket=None,1061 def getAncestry(self, archive=None, distroseries=None, pocket=None,
1065 status=None):1062 status=None):
@@ -1105,6 +1102,53 @@
11051102
1106 implements(IPublishingSet)1103 implements(IPublishingSet)
11071104
1105 def newBinaryPublication(self, archive, binarypackagerelease,
1106 distroarchseries, component, section, priority,
1107 status, pocket):
1108 """See `IPublishingSet`."""
1109 if archive.is_ppa:
1110 # PPA component must always be 'main', so we override it
1111 # here.
1112 component = getUtility(IComponentSet)['main']
1113 pub = SecureBinaryPackagePublishingHistory(
1114 archive=archive,
1115 binarypackagerelease=binarypackagerelease,
1116 distroarchseries=distroarchseries,
1117 component=component,
1118 section=section,
1119 priority=priority,
1120 status=PackagePublishingStatus.PENDING,
1121 datecreated=UTC_NOW,
1122 pocket=pocket,
1123 embargo=False)
1124
1125 # One day, this will not be necessary when we have time to kill
1126 # the Secure* records.
1127 return BinaryPackagePublishingHistory.get(pub.id)
1128
1129 def newSourcePublication(self, archive, sourcepackagerelease,
1130 distroseries, component, section, status,
1131 pocket):
1132 """See `IPublishingSet`."""
1133 if archive.is_ppa:
1134 # PPA component must always be 'main', so we override it
1135 # here.
1136 component = getUtility(IComponentSet)['main']
1137 pub = SecureSourcePackagePublishingHistory(
1138 distroseries=distroseries,
1139 pocket=pocket,
1140 archive=archive,
1141 sourcepackagerelease=sourcepackagerelease,
1142 component=component,
1143 section=section,
1144 status=PackagePublishingStatus.PENDING,
1145 datecreated=UTC_NOW,
1146 embargo=False)
1147
1148 # One day, this will not be necessary when we have time to kill
1149 # the Secure* records.
1150 return SourcePackagePublishingHistory.get(pub.id)
1151
1108 def getBuildsForSourceIds(1152 def getBuildsForSourceIds(
1109 self, source_publication_ids, archive=None, build_states=None):1153 self, source_publication_ids, archive=None, build_states=None):
1110 """See `IPublishingSet`."""1154 """See `IPublishingSet`."""
11111155
=== modified file 'lib/lp/soyuz/model/queue.py'
--- lib/lp/soyuz/model/queue.py 2009-08-16 12:38:12 +0000
+++ lib/lp/soyuz/model/queue.py 2009-09-14 15:19:37 +0000
@@ -43,15 +43,11 @@
43from canonical.database.enumcol import EnumCol43from canonical.database.enumcol import EnumCol
44from canonical.database.sqlbase import SQLBase, sqlvalues44from canonical.database.sqlbase import SQLBase, sqlvalues
45from canonical.encoding import guess as guess_encoding, ascii_smash45from canonical.encoding import guess as guess_encoding, ascii_smash
46from lp.soyuz.model.publishing import (
47 BinaryPackagePublishingHistory, SecureBinaryPackagePublishingHistory,
48 SecureSourcePackagePublishingHistory, SourcePackagePublishingHistory)
49from canonical.launchpad.helpers import get_email_template46from canonical.launchpad.helpers import get_email_template
50from lp.soyuz.interfaces.archive import (47from lp.soyuz.interfaces.archive import (
51 ArchivePurpose, IArchiveSet)48 ArchivePurpose, IArchiveSet)
52from lp.soyuz.interfaces.binarypackagerelease import (49from lp.soyuz.interfaces.binarypackagerelease import (
53 BinaryPackageFormat)50 BinaryPackageFormat)
54from lp.soyuz.interfaces.component import IComponentSet
55from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities51from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities
56from lp.soyuz.interfaces.queue import (52from lp.soyuz.interfaces.queue import (
57 PackageUploadStatus, PackageUploadCustomFormat)53 PackageUploadStatus, PackageUploadCustomFormat)
@@ -59,7 +55,7 @@
59from lp.registry.interfaces.pocket import (55from lp.registry.interfaces.pocket import (
60 PackagePublishingPocket, pocketsuffix)56 PackagePublishingPocket, pocketsuffix)
61from lp.soyuz.interfaces.publishing import (57from lp.soyuz.interfaces.publishing import (
62 ISourcePackagePublishingHistory, PackagePublishingStatus)58 IPublishingSet, ISourcePackagePublishingHistory, PackagePublishingStatus)
63from lp.soyuz.interfaces.queue import (59from lp.soyuz.interfaces.queue import (
64 IPackageUpload, IPackageUploadBuild, IPackageUploadCustom,60 IPackageUpload, IPackageUploadBuild, IPackageUploadCustom,
65 IPackageUploadQueue, IPackageUploadSource, IPackageUploadSet,61 IPackageUploadQueue, IPackageUploadSource, IPackageUploadSet,
@@ -1305,7 +1301,6 @@
1305 other_dars = other_dars - set([target_dar])1301 other_dars = other_dars - set([target_dar])
1306 # First up, publish everything in this build into that dar.1302 # First up, publish everything in this build into that dar.
1307 published_binaries = []1303 published_binaries = []
1308 main_component = getUtility(IComponentSet)['main']
1309 for binary in self.build.binarypackages:1304 for binary in self.build.binarypackages:
1310 target_dars = set([target_dar])1305 target_dars = set([target_dar])
1311 if not binary.architecturespecific:1306 if not binary.architecturespecific:
@@ -1332,28 +1327,17 @@
1332 "Could not find the corresponding DEBUG archive "1327 "Could not find the corresponding DEBUG archive "
1333 "for %s" % (distribution.title))1328 "for %s" % (distribution.title))
13341329
1335 # We override PPA to always publish in the main component.
1336 if self.packageupload.archive.is_ppa:
1337 component = main_component
1338 else:
1339 component = binary.component
1340
1341 for each_target_dar in target_dars:1330 for each_target_dar in target_dars:
1342 # XXX: dsilvers 2005-10-20 bug=3408:1331 bpph = getUtility(IPublishingSet).newBinaryPublication(
1343 # What do we do about embargoed binaries here?1332 archive=archive,
1344 sbpph = SecureBinaryPackagePublishingHistory(
1345 binarypackagerelease=binary,1333 binarypackagerelease=binary,
1346 distroarchseries=each_target_dar,1334 distroarchseries=each_target_dar,
1335 component=binary.component,
1347 section=binary.section,1336 section=binary.section,
1348 priority=binary.priority,1337 priority=binary.priority,
1349 status=PackagePublishingStatus.PENDING,1338 status=PackagePublishingStatus.PENDING,
1350 datecreated=UTC_NOW,1339 pocket=self.packageupload.pocket
1351 pocket=self.packageupload.pocket,
1352 embargo=False,
1353 component=component,
1354 archive=archive,
1355 )1340 )
1356 bpph = BinaryPackagePublishingHistory.get(sbpph.id)
1357 published_binaries.append(bpph)1341 published_binaries.append(bpph)
1358 return published_binaries1342 return published_binaries
13591343
@@ -1470,31 +1454,21 @@
1470 def publish(self, logger=None):1454 def publish(self, logger=None):
1471 """See `IPackageUploadSource`."""1455 """See `IPackageUploadSource`."""
1472 # Publish myself in the distroseries pointed at by my queue item.1456 # Publish myself in the distroseries pointed at by my queue item.
1473 # XXX: dsilvers: 2005-10-20 bug=3408:
1474 # What do we do here to support embargoed sources?
1475 debug(logger, "Publishing source %s/%s to %s/%s" % (1457 debug(logger, "Publishing source %s/%s to %s/%s" % (
1476 self.sourcepackagerelease.name,1458 self.sourcepackagerelease.name,
1477 self.sourcepackagerelease.version,1459 self.sourcepackagerelease.version,
1478 self.packageupload.distroseries.distribution.name,1460 self.packageupload.distroseries.distribution.name,
1479 self.packageupload.distroseries.name))1461 self.packageupload.distroseries.name))
14801462
1481 if self.packageupload.archive.is_ppa:1463 return getUtility(IPublishingSet).newSourcePublication(
1482 # We override PPA to always publish in the main component.1464 archive=self.packageupload.archive,
1483 component = getUtility(IComponentSet)['main']1465 sourcepackagerelease=self.sourcepackagerelease,
1484 else:
1485 component = self.sourcepackagerelease.component
1486
1487 sspph = SecureSourcePackagePublishingHistory(
1488 distroseries=self.packageupload.distroseries,1466 distroseries=self.packageupload.distroseries,
1489 sourcepackagerelease=self.sourcepackagerelease,1467 component=self.sourcepackagerelease.component,
1490 component=component,
1491 section=self.sourcepackagerelease.section,1468 section=self.sourcepackagerelease.section,
1492 status=PackagePublishingStatus.PENDING,1469 status=PackagePublishingStatus.PENDING,
1493 datecreated=UTC_NOW,1470 pocket=self.packageupload.pocket
1494 pocket=self.packageupload.pocket,1471 )
1495 embargo=False,
1496 archive=self.packageupload.archive)
1497 return SourcePackagePublishingHistory.get(sspph.id)
14981472
14991473
1500class PackageUploadCustom(SQLBase):1474class PackageUploadCustom(SQLBase):
15011475
=== modified file 'lib/lp/soyuz/stories/soyuz/xx-queue-pages-delayed-copies.txt'
--- lib/lp/soyuz/stories/soyuz/xx-queue-pages-delayed-copies.txt 2009-08-28 06:39:38 +0000
+++ lib/lp/soyuz/stories/soyuz/xx-queue-pages-delayed-copies.txt 2009-09-14 15:15:54 +0000
@@ -23,6 +23,7 @@
23 >>> [bin_hppa, bin_i386] = stp.getPubBinaries(archive=cprov.archive)23 >>> [bin_hppa, bin_i386] = stp.getPubBinaries(archive=cprov.archive)
24 >>> build = bin_hppa.binarypackagerelease.build24 >>> build = bin_hppa.binarypackagerelease.build
25 >>> breezy_autotest = ubuntu.getSeries('breezy-autotest')25 >>> breezy_autotest = ubuntu.getSeries('breezy-autotest')
26 >>> stp.addFakeChroots(breezy_autotest)
26 >>> delayed_copy = getUtility(IPackageUploadSet).createDelayedCopy(27 >>> delayed_copy = getUtility(IPackageUploadSet).createDelayedCopy(
27 ... archive=ubuntu.main_archive, distroseries=breezy_autotest,28 ... archive=ubuntu.main_archive, distroseries=breezy_autotest,
28 ... pocket=PackagePublishingPocket.RELEASE, signing_key=None)29 ... pocket=PackagePublishingPocket.RELEASE, signing_key=None)
@@ -100,14 +101,22 @@
100 http://launchpad.dev/~cprov/+archive/ppa101 http://launchpad.dev/~cprov/+archive/ppa
101102
102When the delayed-copy is processed (moved to DONE queue) its contents103When the delayed-copy is processed (moved to DONE queue) its contents
103becomes available to everyone.104become available to everyone.
104105
105 # Process the delayed-copy.106 # Process the delayed-copy using an external script call. Since some
106 >>> login('foo.bar@canonical.com')107 # DB objects that have no security adapter are modified during the
107 >>> stp.addFakeChroots(breezy_autotest)108 # delayed copy, the modification must be done in Zopeless mode.
108 >>> unused = delayed_copy.realiseUpload()109 >>> import os.path
109 >>> transaction.commit()110 >>> import subprocess
110 >>> logout()111 >>> import sys
112 >>> from canonical.config import config
113 >>> script = os.path.join(config.root, "scripts/process-accepted.py")
114 >>> process = subprocess.Popen(
115 ... [sys.executable, script, "ubuntu"],
116 ... stdout=subprocess.PIPE, stderr=subprocess.PIPE)
117 >>> stdout, stderr = process.communicate()
118 >>> if process.returncode != 0:
119 ... print stderr
111120
112Any user can access the DONE queue and access the delayed-copy121Any user can access the DONE queue and access the delayed-copy
113'changesfile' and view its files in the expandable area.122'changesfile' and view its files in the expandable area.