Merge lp:~julian-edwards/launchpad/ppa-copy-to-main-bug-426163 into lp:launchpad
- ppa-copy-to-main-bug-426163
- Merge into devel
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Aaron Bentley (community) | code | Approve | |
Review via email:
|
Commit message
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Julian Edwards (julian-edwards) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Aaron Bentley (abentley) wrote : | # |
This looks basically good, but there are a few things I'd like changed.
1. Please document the parameters of newBinaryPublic
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-
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Julian Edwards (julian-edwards) wrote : | # |
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 newBinaryPublic
> newSourcePublic
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-
> canonical.
> run_script.
>
I've changed that.
Partial diff below.
Cheers
Julian
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -1014,7 +1014,6 @@
... distroseries=
... component=
... section=
- ... status=
... pocket=
>>> print ppa_pub.
main
@@ -1029,7 +1028,6 @@
... component=
... section=
... priority=
- ... status=
... pocket=
>>> print ppa_pub.
universe
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -847,17 +847,34 @@
"""Auxiliary methods for dealing with sets of publications."""
def newBinaryPublic
- component, section, priority, status, pocket):
+ component, section, priority, pocket):
"""Create a new `BinaryPackageP
+ :param archive: An...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Aaron Bentley (abentley) wrote : | # |
Thanks for your changes. This looks good.
Preview Diff
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 @@ | |||
6 | 1 | == SourcePackagePublishingHistory == | 1 | ============================== |
7 | 2 | SourcePackagePublishingHistory | ||
8 | 3 | ============================== | ||
9 | 2 | 4 | ||
10 | 3 | This class provides public access to publishing records via a SQL view. | 5 | This class provides public access to publishing records via a SQL view. |
11 | 4 | 6 | ||
12 | @@ -268,7 +270,8 @@ | |||
13 | 268 | base | 270 | base |
14 | 269 | 271 | ||
15 | 270 | 272 | ||
17 | 271 | == Stanza generation == | 273 | Stanza generation |
18 | 274 | ================= | ||
19 | 272 | 275 | ||
20 | 273 | >>> from canonical.launchpad.interfaces import ( | 276 | >>> from canonical.launchpad.interfaces import ( |
21 | 274 | ... IArchiveSafePublisher, | 277 | ... IArchiveSafePublisher, |
22 | @@ -328,7 +331,8 @@ | |||
23 | 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')] |
24 | 329 | 332 | ||
25 | 330 | 333 | ||
27 | 331 | == Deletion and obsolescence == | 334 | Deletion and obsolescence |
28 | 335 | ========================= | ||
29 | 332 | 336 | ||
30 | 333 | ArchivePublisherBase, which is common to SourcePackagePublishingHistory | 337 | ArchivePublisherBase, which is common to SourcePackagePublishingHistory |
31 | 334 | and BinaryPackagePublishingHistory, contains the methods requestDeletion | 338 | and BinaryPackagePublishingHistory, contains the methods requestDeletion |
32 | @@ -374,7 +378,8 @@ | |||
33 | 374 | True | 378 | True |
34 | 375 | 379 | ||
35 | 376 | 380 | ||
37 | 377 | == Copying and published binarypackages lookup == | 381 | Copying and published binarypackages lookup |
38 | 382 | =========================================== | ||
39 | 378 | 383 | ||
40 | 379 | ISourcePackagePublishingHistory provides the getPublishedBinaries | 384 | ISourcePackagePublishingHistory provides the getPublishedBinaries |
41 | 380 | which returns all published binaries build from a source in the pocket | 385 | which returns all published binaries build from a source in the pocket |
42 | @@ -609,7 +614,8 @@ | |||
43 | 609 | >>> syncUpdate(deleted) | 614 | >>> syncUpdate(deleted) |
44 | 610 | 615 | ||
45 | 611 | 616 | ||
47 | 612 | == Copying and inspecting architecture independent binaries == | 617 | Copying and inspecting architecture independent binaries |
48 | 618 | ======================================================== | ||
49 | 613 | 619 | ||
50 | 614 | copyTo() behaves differently for architecture independent and | 620 | copyTo() behaves differently for architecture independent and |
51 | 615 | architecture specific binaries. We will create a | 621 | architecture specific binaries. We will create a |
52 | @@ -690,7 +696,8 @@ | |||
53 | 690 | pirulito 666 in breezy-autotest i386 | 696 | pirulito 666 in breezy-autotest i386 |
54 | 691 | 697 | ||
55 | 692 | 698 | ||
57 | 693 | == Copying to PPAs == | 699 | Copying to PPAs |
58 | 700 | =============== | ||
59 | 694 | 701 | ||
60 | 695 | Another common copy use-case is rebuild the same source in another | 702 | Another common copy use-case is rebuild the same source in another |
61 | 696 | suite. To simulate this we will create a publication in Celso's PPA. | 703 | suite. To simulate this we will create a publication in Celso's PPA. |
62 | @@ -819,7 +826,8 @@ | |||
63 | 819 | [] | 826 | [] |
64 | 820 | 827 | ||
65 | 821 | 828 | ||
67 | 822 | == getSourceAndBinaryLibraryFiles == | 829 | getSourceAndBinaryLibraryFiles |
68 | 830 | ============================== | ||
69 | 823 | 831 | ||
70 | 824 | This method retrieves LibraryFileAlias records for all source and binary | 832 | This method retrieves LibraryFileAlias records for all source and binary |
71 | 825 | files associated with this publication. | 833 | files associated with this publication. |
72 | @@ -847,7 +855,8 @@ | |||
73 | 847 | foo_666.dsc | 855 | foo_666.dsc |
74 | 848 | 856 | ||
75 | 849 | 857 | ||
77 | 850 | == Publishing records age == | 858 | Publishing records age |
78 | 859 | ====================== | ||
79 | 851 | 860 | ||
80 | 852 | Both ISourcePackagePublishingHistory and IBinaryPackagePublishingHistory | 861 | Both ISourcePackagePublishingHistory and IBinaryPackagePublishingHistory |
81 | 853 | implement the 'age' property which return a timedelta representing | 862 | implement the 'age' property which return a timedelta representing |
82 | @@ -860,7 +869,8 @@ | |||
83 | 860 | datetime.timedelta(...) | 869 | datetime.timedelta(...) |
84 | 861 | 870 | ||
85 | 862 | 871 | ||
87 | 863 | == Secure Source Publishing == | 872 | Secure Source Publishing |
88 | 873 | ======================== | ||
89 | 864 | 874 | ||
90 | 865 | 'secure_record' returns a ISecureSourcePackagePublishing instance | 875 | 'secure_record' returns a ISecureSourcePackagePublishing instance |
91 | 866 | corresponding to this publication. This instance also implements | 876 | corresponding to this publication. This instance also implements |
92 | @@ -875,7 +885,8 @@ | |||
93 | 875 | False | 885 | False |
94 | 876 | 886 | ||
95 | 877 | 887 | ||
97 | 878 | == Binary and Binary File Publishing === | 888 | Binary and Binary File Publishing |
98 | 889 | ================================= | ||
99 | 879 | 890 | ||
100 | 880 | Symmetric behaviour is offered for BinaryPackagePublishing, | 891 | Symmetric behaviour is offered for BinaryPackagePublishing, |
101 | 881 | BinaryPackageFile and ISecureBinaryPackagePublishingHistory | 892 | BinaryPackageFile and ISecureBinaryPackagePublishingHistory |
102 | @@ -935,17 +946,23 @@ | |||
103 | 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'] |
104 | 936 | 947 | ||
105 | 937 | 948 | ||
107 | 938 | == IPublishingSet == | 949 | IPublishingSet |
108 | 950 | ============== | ||
109 | 939 | 951 | ||
110 | 940 | This utility implements the following methods: | 952 | This utility implements the following methods: |
111 | 941 | 953 | ||
112 | 954 | * newBinaryPublication(); | ||
113 | 955 | * newSourcePublication(); | ||
114 | 956 | |||
115 | 957 | which create new publishing records, and: | ||
116 | 958 | |||
117 | 942 | * getBuildsForSources(); | 959 | * getBuildsForSources(); |
118 | 943 | * getUnpublishedBuildsForSources(); | 960 | * getUnpublishedBuildsForSources(); |
119 | 944 | * getFilesForSources(); | 961 | * getFilesForSources(); |
120 | 945 | * getBinaryPublicationsForSources(); | 962 | * getBinaryPublicationsForSources(); |
121 | 946 | * getPackageDiffsForSources(); | 963 | * getPackageDiffsForSources(); |
122 | 947 | 964 | ||
124 | 948 | They receive a list of `SourcePackagePublishingHistory` objects and | 965 | which receive a list of `SourcePackagePublishingHistory` objects and |
125 | 949 | fetch the corresponding information for all of them. | 966 | fetch the corresponding information for all of them. |
126 | 950 | 967 | ||
127 | 951 | Their returned `ResultSet` (they all use storm natively) follows a | 968 | Their returned `ResultSet` (they all use storm natively) follows a |
128 | @@ -963,27 +980,69 @@ | |||
129 | 963 | * getSourceAndBinaryLibraryFiles -> IPublishingSet.getFilesForSources; | 980 | * getSourceAndBinaryLibraryFiles -> IPublishingSet.getFilesForSources; |
130 | 964 | * getPublishedBinaries -> IPublishingSet.getBinaryPublicationsForSources; | 981 | * getPublishedBinaries -> IPublishingSet.getBinaryPublicationsForSources; |
131 | 965 | 982 | ||
133 | 966 | So, they were already tested implicitly before in this file, the | 983 | So, they were already tested implicitly before in this file, they |
134 | 967 | simply use the IPublishing methods passing only a single source | 984 | simply use the IPublishing methods passing only a single source |
135 | 968 | publication. Now we will document how they work for multiple source | 985 | publication. Now we will document how they work for multiple source |
136 | 969 | publications. | 986 | publications. |
137 | 970 | 987 | ||
138 | 988 | >>> from lp.soyuz.interfaces.publishing import ( | ||
139 | 989 | ... IPublishingSet) | ||
140 | 990 | |||
141 | 991 | >>> publishing_set = getUtility(IPublishingSet) | ||
142 | 992 | |||
143 | 993 | >>> verifyObject(IPublishingSet, publishing_set) | ||
144 | 994 | True | ||
145 | 995 | |||
146 | 996 | |||
147 | 997 | Creating new publication records | ||
148 | 998 | -------------------------------- | ||
149 | 999 | |||
150 | 1000 | newSourcePublication() and newBinaryPublication() will create source and | ||
151 | 1001 | binary publication records respectively. They are already implicitly tested | ||
152 | 1002 | above via the copyTo methods which use them to create new records. However, | ||
153 | 1003 | they have one extra feature which is important for PPAs - they will ensure | ||
154 | 1004 | that the published component is always 'main'. | ||
155 | 1005 | |||
156 | 1006 | When copying publications from non-main components in the primary archive, | ||
157 | 1007 | the PPA publication will always be main: | ||
158 | 1008 | |||
159 | 1009 | >>> test_source_pub = test_publisher.getPubSource( | ||
160 | 1010 | ... sourcename='overrideme', component='universe') | ||
161 | 1011 | >>> ppa_pub = publishing_set.newSourcePublication( | ||
162 | 1012 | ... archive=mark.archive, | ||
163 | 1013 | ... sourcepackagerelease=test_source_pub.sourcepackagerelease, | ||
164 | 1014 | ... distroseries=test_source_pub.distroseries, | ||
165 | 1015 | ... component=test_source_pub.component, | ||
166 | 1016 | ... section=test_source_pub.section, | ||
167 | 1017 | ... status=test_source_pub.status, | ||
168 | 1018 | ... pocket=test_source_pub.pocket) | ||
169 | 1019 | >>> print ppa_pub.component.name | ||
170 | 1020 | main | ||
171 | 1021 | |||
172 | 1022 | >>> test_bin_pubs = test_publisher.getPubBinaries( | ||
173 | 1023 | ... pub_source=test_source_pub) | ||
174 | 1024 | >>> test_bin_pub = test_bin_pubs[0] | ||
175 | 1025 | >>> ppa_pub = publishing_set.newBinaryPublication( | ||
176 | 1026 | ... archive=mark.archive, | ||
177 | 1027 | ... binarypackagerelease=test_bin_pub.binarypackagerelease, | ||
178 | 1028 | ... distroarchseries=test_bin_pub.distroarchseries, | ||
179 | 1029 | ... component=test_bin_pub.component, | ||
180 | 1030 | ... section=test_bin_pub.section, | ||
181 | 1031 | ... priority=test_bin_pub.priority, | ||
182 | 1032 | ... status=test_bin_pub.status, | ||
183 | 1033 | ... pocket=test_bin_pub.pocket) | ||
184 | 1034 | >>> print ppa_pub.binarypackagerelease.component.name | ||
185 | 1035 | universe | ||
186 | 1036 | >>> print ppa_pub.component.name | ||
187 | 1037 | main | ||
188 | 1038 | |||
189 | 971 | IPublishingSet is an essential component for | 1039 | IPublishingSet is an essential component for |
190 | 972 | `ArchiveSourcePublications` feature, see more information below in | 1040 | `ArchiveSourcePublications` feature, see more information below in |
191 | 973 | its corresponding test section. | 1041 | its corresponding test section. |
192 | 974 | 1042 | ||
193 | 975 | >>> from lp.soyuz.interfaces.publishing import ( | ||
194 | 976 | ... IPublishingSet) | ||
195 | 977 | |||
196 | 978 | >>> publishing_set = getUtility(IPublishingSet) | ||
197 | 979 | |||
198 | 980 | >>> verifyObject(IPublishingSet, publishing_set) | ||
199 | 981 | True | ||
200 | 982 | |||
201 | 983 | We will assembly a list of source publications based on what was | 1043 | We will assembly a list of source publications based on what was |
202 | 984 | ever published in Celso's PPA. | 1044 | ever published in Celso's PPA. |
203 | 985 | 1045 | ||
204 | 986 | >>> cprov = getUtility(IPersonSet).getByName('cprov') | ||
205 | 987 | >>> cprov_sources = list(cprov.archive.getPublishedSources()) | 1046 | >>> cprov_sources = list(cprov.archive.getPublishedSources()) |
206 | 988 | >>> len(cprov_sources) | 1047 | >>> len(cprov_sources) |
207 | 989 | 8 | 1048 | 8 |
208 | @@ -1301,7 +1360,8 @@ | |||
209 | 1301 | AssertionError: The 'sources' parameter must be a list. | 1360 | AssertionError: The 'sources' parameter must be a list. |
210 | 1302 | 1361 | ||
211 | 1303 | 1362 | ||
213 | 1304 | == ArchiveSourcePublications == | 1363 | ArchiveSourcePublications |
214 | 1364 | ========================= | ||
215 | 1305 | 1365 | ||
216 | 1306 | `ArchiveSourcePublications` wraps `IPublishingSet` methods to build a | 1366 | `ArchiveSourcePublications` wraps `IPublishingSet` methods to build a |
217 | 1307 | set of objects which decorate `ISourcePackagePublishingHistory` with | 1367 | set of objects which decorate `ISourcePackagePublishingHistory` with |
218 | @@ -1516,7 +1576,8 @@ | |||
219 | 1516 | i386 build of foo 999 in ubuntutest breezy-autotest RELEASE | 1576 | i386 build of foo 999 in ubuntutest breezy-autotest RELEASE |
220 | 1517 | 1577 | ||
221 | 1518 | 1578 | ||
223 | 1519 | == IPublishingSet.getBuildStatusSummariesForSourceIdsAndArchive() == | 1579 | IPublishingSet.getBuildStatusSummariesForSourceIdsAndArchive() |
224 | 1580 | ============================================================== | ||
225 | 1520 | 1581 | ||
226 | 1521 | This extra method on IPublishingSet allows a summary of the build status | 1582 | This extra method on IPublishingSet allows a summary of the build status |
227 | 1522 | for a set of sources to be presented. The corresponding archive is a | 1583 | for a set of sources to be presented. The corresponding archive is a |
228 | @@ -1586,7 +1647,8 @@ | |||
229 | 1586 | >>> print_build_summaries(build_summaries) | 1647 | >>> print_build_summaries(build_summaries) |
230 | 1587 | 1648 | ||
231 | 1588 | 1649 | ||
233 | 1589 | == IPublishing ancestry lookup and override == | 1650 | IPublishing ancestry lookup and override |
234 | 1651 | ======================================== | ||
235 | 1590 | 1652 | ||
236 | 1591 | `IPublishing` is implemented by both kinds of package publications we | 1653 | `IPublishing` is implemented by both kinds of package publications we |
237 | 1592 | have `SourcePackagePublishingHistory` and | 1654 | have `SourcePackagePublishingHistory` and |
238 | @@ -1671,7 +1733,8 @@ | |||
239 | 1671 | 1733 | ||
240 | 1672 | `overrideFromAncestry` operates directly on top of the default | 1734 | `overrideFromAncestry` operates directly on top of the default |
241 | 1673 | behavior of `getAncestry`. It looks up the most recent ancestry for a | 1735 | behavior of `getAncestry`. It looks up the most recent ancestry for a |
243 | 1674 | publication and override it in place. | 1736 | publication and override it in place. If there is no previous publication |
244 | 1737 | then the package's component is used. | ||
245 | 1675 | 1738 | ||
246 | 1676 | >>> print test_source.component.name | 1739 | >>> print test_source.component.name |
247 | 1677 | universe | 1740 | universe |
248 | @@ -1680,17 +1743,19 @@ | |||
249 | 1680 | >>> print test_source.component.name | 1743 | >>> print test_source.component.name |
250 | 1681 | multiverse | 1744 | multiverse |
251 | 1682 | 1745 | ||
254 | 1683 | It works in the same way for binaries and follows the new publishing | 1746 | It works in the same way for binaries. |
255 | 1684 | context. | 1747 | |
256 | 1748 | >>> multiverse = getUtility(IComponentSet)['multiverse'] | ||
257 | 1749 | >>> test_binary.binarypackagerelease.component = multiverse | ||
258 | 1685 | 1750 | ||
259 | 1686 | >>> print test_binary.component.name | 1751 | >>> print test_binary.component.name |
260 | 1687 | universe | 1752 | universe |
261 | 1688 | 1753 | ||
262 | 1689 | >>> copied_binary = test_binary.copyTo( | 1754 | >>> copied_binary = test_binary.copyTo( |
264 | 1690 | ... test_source.distroseries, test_source.pocket, cprov.archive)[0] | 1755 | ... hoary_test, test_source.pocket, archive=test_binary.archive)[0] |
265 | 1691 | >>> print copied_binary.component.name | 1756 | >>> print copied_binary.component.name |
266 | 1692 | universe | 1757 | universe |
267 | 1693 | 1758 | ||
268 | 1694 | >>> copied_binary.overrideFromAncestry() | 1759 | >>> copied_binary.overrideFromAncestry() |
269 | 1695 | >>> print copied_binary.component.name | 1760 | >>> print copied_binary.component.name |
271 | 1696 | main | 1761 | multiverse |
272 | 1697 | 1762 | ||
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 | 846 | class IPublishingSet(Interface): | 846 | class IPublishingSet(Interface): |
278 | 847 | """Auxiliary methods for dealing with sets of publications.""" | 847 | """Auxiliary methods for dealing with sets of publications.""" |
279 | 848 | 848 | ||
280 | 849 | def newBinaryPublication(archive, binarypackagerelease, distroarchseries, | ||
281 | 850 | component, section, priority, status, pocket): | ||
282 | 851 | """Create a new `BinaryPackagePublishingHistory`. | ||
283 | 852 | |||
284 | 853 | datecreated will be UTC_NOW. | ||
285 | 854 | """ | ||
286 | 855 | |||
287 | 856 | def newSourcePublication(archive, sourcepackagerelease, distroseries, | ||
288 | 857 | component, section, status, pocket): | ||
289 | 858 | """Create a new `SourcePackagePublishingHistory`. | ||
290 | 859 | |||
291 | 860 | datecreated will be UTC_NOW. | ||
292 | 861 | """ | ||
293 | 862 | |||
294 | 849 | def getByIdAndArchive(id, archive, source=True): | 863 | def getByIdAndArchive(id, archive, source=True): |
295 | 850 | """Return the publication matching id AND archive. | 864 | """Return the publication matching id AND archive. |
296 | 851 | 865 | ||
297 | 852 | 866 | ||
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 | 45 | LibraryFileAlias, LibraryFileContent) | 45 | LibraryFileAlias, LibraryFileContent) |
303 | 46 | from lp.soyuz.model.packagediff import PackageDiff | 46 | from lp.soyuz.model.packagediff import PackageDiff |
304 | 47 | from lp.soyuz.interfaces.archive import ArchivePurpose | 47 | from lp.soyuz.interfaces.archive import ArchivePurpose |
305 | 48 | from lp.soyuz.interfaces.component import IComponentSet | ||
306 | 48 | from lp.soyuz.interfaces.queue import PackageUploadStatus | 49 | from lp.soyuz.interfaces.queue import PackageUploadStatus |
307 | 49 | from lp.soyuz.interfaces.publishing import ( | 50 | from lp.soyuz.interfaces.publishing import ( |
308 | 50 | active_publishing_status, IArchiveSafePublisher, | 51 | active_publishing_status, IArchiveSafePublisher, |
309 | @@ -779,17 +780,15 @@ | |||
310 | 779 | def copyTo(self, distroseries, pocket, archive): | 780 | def copyTo(self, distroseries, pocket, archive): |
311 | 780 | """See `ISourcePackagePublishingHistory`.""" | 781 | """See `ISourcePackagePublishingHistory`.""" |
312 | 781 | current = self.secure_record | 782 | current = self.secure_record |
324 | 782 | secure_copy = SecureSourcePackagePublishingHistory( | 783 | return getUtility(IPublishingSet).newSourcePublication( |
325 | 783 | distroseries=distroseries, | 784 | archive, |
326 | 784 | pocket=pocket, | 785 | current.sourcepackagerelease, |
327 | 785 | archive=archive, | 786 | distroseries, |
328 | 786 | sourcepackagerelease=current.sourcepackagerelease, | 787 | current.component, |
329 | 787 | component=current.component, | 788 | current.section, |
330 | 788 | section=current.section, | 789 | PackagePublishingStatus.PENDING, |
331 | 789 | status=PackagePublishingStatus.PENDING, | 790 | |
332 | 790 | datecreated=UTC_NOW, | 791 | ) |
322 | 791 | embargo=False) | ||
323 | 792 | return SourcePackagePublishingHistory.get(secure_copy.id) | ||
333 | 793 | 792 | ||
334 | 794 | def getStatusSummaryForBuilds(self): | 793 | def getStatusSummaryForBuilds(self): |
335 | 795 | """See `ISourcePackagePublishingHistory`.""" | 794 | """See `ISourcePackagePublishingHistory`.""" |
336 | @@ -1045,21 +1044,19 @@ | |||
337 | 1045 | 1044 | ||
338 | 1046 | copies = [] | 1045 | copies = [] |
339 | 1047 | for architecture in destination_architectures: | 1046 | for architecture in destination_architectures: |
351 | 1048 | copy = SecureBinaryPackagePublishingHistory( | 1047 | copy = getUtility(IPublishingSet).newBinaryPublication( |
352 | 1049 | archive=archive, | 1048 | archive, |
353 | 1050 | binarypackagerelease=self.binarypackagerelease, | 1049 | self.binarypackagerelease, |
354 | 1051 | distroarchseries=architecture, | 1050 | architecture, |
355 | 1052 | component=current.component, | 1051 | current.component, |
356 | 1053 | section=current.section, | 1052 | current.section, |
357 | 1054 | priority=current.priority, | 1053 | current.priority, |
358 | 1055 | status=PackagePublishingStatus.PENDING, | 1054 | PackagePublishingStatus.PENDING, |
359 | 1056 | datecreated=UTC_NOW, | 1055 | |
360 | 1057 | pocket=pocket, | 1056 | ) |
350 | 1058 | embargo=False) | ||
361 | 1059 | copies.append(copy) | 1057 | copies.append(copy) |
362 | 1060 | 1058 | ||
365 | 1061 | return [ | 1059 | return copies |
364 | 1062 | BinaryPackagePublishingHistory.get(copy.id) for copy in copies] | ||
366 | 1063 | 1060 | ||
367 | 1064 | def getAncestry(self, archive=None, distroseries=None, pocket=None, | 1061 | def getAncestry(self, archive=None, distroseries=None, pocket=None, |
368 | 1065 | status=None): | 1062 | status=None): |
369 | @@ -1105,6 +1102,53 @@ | |||
370 | 1105 | 1102 | ||
371 | 1106 | implements(IPublishingSet) | 1103 | implements(IPublishingSet) |
372 | 1107 | 1104 | ||
373 | 1105 | def newBinaryPublication(self, archive, binarypackagerelease, | ||
374 | 1106 | distroarchseries, component, section, priority, | ||
375 | 1107 | status, pocket): | ||
376 | 1108 | """See `IPublishingSet`.""" | ||
377 | 1109 | if archive.is_ppa: | ||
378 | 1110 | # PPA component must always be 'main', so we override it | ||
379 | 1111 | # here. | ||
380 | 1112 | component = getUtility(IComponentSet)['main'] | ||
381 | 1113 | pub = SecureBinaryPackagePublishingHistory( | ||
382 | 1114 | archive=archive, | ||
383 | 1115 | binarypackagerelease=binarypackagerelease, | ||
384 | 1116 | distroarchseries=distroarchseries, | ||
385 | 1117 | component=component, | ||
386 | 1118 | section=section, | ||
387 | 1119 | priority=priority, | ||
388 | 1120 | status=PackagePublishingStatus.PENDING, | ||
389 | 1121 | datecreated=UTC_NOW, | ||
390 | 1122 | pocket=pocket, | ||
391 | 1123 | embargo=False) | ||
392 | 1124 | |||
393 | 1125 | # One day, this will not be necessary when we have time to kill | ||
394 | 1126 | # the Secure* records. | ||
395 | 1127 | return BinaryPackagePublishingHistory.get(pub.id) | ||
396 | 1128 | |||
397 | 1129 | def newSourcePublication(self, archive, sourcepackagerelease, | ||
398 | 1130 | distroseries, component, section, status, | ||
399 | 1131 | pocket): | ||
400 | 1132 | """See `IPublishingSet`.""" | ||
401 | 1133 | if archive.is_ppa: | ||
402 | 1134 | # PPA component must always be 'main', so we override it | ||
403 | 1135 | # here. | ||
404 | 1136 | component = getUtility(IComponentSet)['main'] | ||
405 | 1137 | pub = SecureSourcePackagePublishingHistory( | ||
406 | 1138 | distroseries=distroseries, | ||
407 | 1139 | pocket=pocket, | ||
408 | 1140 | archive=archive, | ||
409 | 1141 | sourcepackagerelease=sourcepackagerelease, | ||
410 | 1142 | component=component, | ||
411 | 1143 | section=section, | ||
412 | 1144 | status=PackagePublishingStatus.PENDING, | ||
413 | 1145 | datecreated=UTC_NOW, | ||
414 | 1146 | embargo=False) | ||
415 | 1147 | |||
416 | 1148 | # One day, this will not be necessary when we have time to kill | ||
417 | 1149 | # the Secure* records. | ||
418 | 1150 | return SourcePackagePublishingHistory.get(pub.id) | ||
419 | 1151 | |||
420 | 1108 | def getBuildsForSourceIds( | 1152 | def getBuildsForSourceIds( |
421 | 1109 | self, source_publication_ids, archive=None, build_states=None): | 1153 | self, source_publication_ids, archive=None, build_states=None): |
422 | 1110 | """See `IPublishingSet`.""" | 1154 | """See `IPublishingSet`.""" |
423 | 1111 | 1155 | ||
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 | 43 | from canonical.database.enumcol import EnumCol | 43 | from canonical.database.enumcol import EnumCol |
429 | 44 | from canonical.database.sqlbase import SQLBase, sqlvalues | 44 | from canonical.database.sqlbase import SQLBase, sqlvalues |
430 | 45 | from canonical.encoding import guess as guess_encoding, ascii_smash | 45 | from canonical.encoding import guess as guess_encoding, ascii_smash |
431 | 46 | from lp.soyuz.model.publishing import ( | ||
432 | 47 | BinaryPackagePublishingHistory, SecureBinaryPackagePublishingHistory, | ||
433 | 48 | SecureSourcePackagePublishingHistory, SourcePackagePublishingHistory) | ||
434 | 49 | from canonical.launchpad.helpers import get_email_template | 46 | from canonical.launchpad.helpers import get_email_template |
435 | 50 | from lp.soyuz.interfaces.archive import ( | 47 | from lp.soyuz.interfaces.archive import ( |
436 | 51 | ArchivePurpose, IArchiveSet) | 48 | ArchivePurpose, IArchiveSet) |
437 | 52 | from lp.soyuz.interfaces.binarypackagerelease import ( | 49 | from lp.soyuz.interfaces.binarypackagerelease import ( |
438 | 53 | BinaryPackageFormat) | 50 | BinaryPackageFormat) |
439 | 54 | from lp.soyuz.interfaces.component import IComponentSet | ||
440 | 55 | from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities | 51 | from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities |
441 | 56 | from lp.soyuz.interfaces.queue import ( | 52 | from lp.soyuz.interfaces.queue import ( |
442 | 57 | PackageUploadStatus, PackageUploadCustomFormat) | 53 | PackageUploadStatus, PackageUploadCustomFormat) |
443 | @@ -59,7 +55,7 @@ | |||
444 | 59 | from lp.registry.interfaces.pocket import ( | 55 | from lp.registry.interfaces.pocket import ( |
445 | 60 | PackagePublishingPocket, pocketsuffix) | 56 | PackagePublishingPocket, pocketsuffix) |
446 | 61 | from lp.soyuz.interfaces.publishing import ( | 57 | from lp.soyuz.interfaces.publishing import ( |
448 | 62 | ISourcePackagePublishingHistory, PackagePublishingStatus) | 58 | IPublishingSet, ISourcePackagePublishingHistory, PackagePublishingStatus) |
449 | 63 | from lp.soyuz.interfaces.queue import ( | 59 | from lp.soyuz.interfaces.queue import ( |
450 | 64 | IPackageUpload, IPackageUploadBuild, IPackageUploadCustom, | 60 | IPackageUpload, IPackageUploadBuild, IPackageUploadCustom, |
451 | 65 | IPackageUploadQueue, IPackageUploadSource, IPackageUploadSet, | 61 | IPackageUploadQueue, IPackageUploadSource, IPackageUploadSet, |
452 | @@ -1305,7 +1301,6 @@ | |||
453 | 1305 | other_dars = other_dars - set([target_dar]) | 1301 | other_dars = other_dars - set([target_dar]) |
454 | 1306 | # First up, publish everything in this build into that dar. | 1302 | # First up, publish everything in this build into that dar. |
455 | 1307 | published_binaries = [] | 1303 | published_binaries = [] |
456 | 1308 | main_component = getUtility(IComponentSet)['main'] | ||
457 | 1309 | for binary in self.build.binarypackages: | 1304 | for binary in self.build.binarypackages: |
458 | 1310 | target_dars = set([target_dar]) | 1305 | target_dars = set([target_dar]) |
459 | 1311 | if not binary.architecturespecific: | 1306 | if not binary.architecturespecific: |
460 | @@ -1332,28 +1327,17 @@ | |||
461 | 1332 | "Could not find the corresponding DEBUG archive " | 1327 | "Could not find the corresponding DEBUG archive " |
462 | 1333 | "for %s" % (distribution.title)) | 1328 | "for %s" % (distribution.title)) |
463 | 1334 | 1329 | ||
464 | 1335 | # We override PPA to always publish in the main component. | ||
465 | 1336 | if self.packageupload.archive.is_ppa: | ||
466 | 1337 | component = main_component | ||
467 | 1338 | else: | ||
468 | 1339 | component = binary.component | ||
469 | 1340 | |||
470 | 1341 | for each_target_dar in target_dars: | 1330 | for each_target_dar in target_dars: |
474 | 1342 | # XXX: dsilvers 2005-10-20 bug=3408: | 1331 | bpph = getUtility(IPublishingSet).newBinaryPublication( |
475 | 1343 | # What do we do about embargoed binaries here? | 1332 | archive=archive, |
473 | 1344 | sbpph = SecureBinaryPackagePublishingHistory( | ||
476 | 1345 | binarypackagerelease=binary, | 1333 | binarypackagerelease=binary, |
477 | 1346 | distroarchseries=each_target_dar, | 1334 | distroarchseries=each_target_dar, |
478 | 1335 | component=binary.component, | ||
479 | 1347 | section=binary.section, | 1336 | section=binary.section, |
480 | 1348 | priority=binary.priority, | 1337 | priority=binary.priority, |
481 | 1349 | status=PackagePublishingStatus.PENDING, | 1338 | status=PackagePublishingStatus.PENDING, |
487 | 1350 | datecreated=UTC_NOW, | 1339 | pocket=self.packageupload.pocket |
483 | 1351 | pocket=self.packageupload.pocket, | ||
484 | 1352 | embargo=False, | ||
485 | 1353 | component=component, | ||
486 | 1354 | archive=archive, | ||
488 | 1355 | ) | 1340 | ) |
489 | 1356 | bpph = BinaryPackagePublishingHistory.get(sbpph.id) | ||
490 | 1357 | published_binaries.append(bpph) | 1341 | published_binaries.append(bpph) |
491 | 1358 | return published_binaries | 1342 | return published_binaries |
492 | 1359 | 1343 | ||
493 | @@ -1470,31 +1454,21 @@ | |||
494 | 1470 | def publish(self, logger=None): | 1454 | def publish(self, logger=None): |
495 | 1471 | """See `IPackageUploadSource`.""" | 1455 | """See `IPackageUploadSource`.""" |
496 | 1472 | # Publish myself in the distroseries pointed at by my queue item. | 1456 | # Publish myself in the distroseries pointed at by my queue item. |
497 | 1473 | # XXX: dsilvers: 2005-10-20 bug=3408: | ||
498 | 1474 | # What do we do here to support embargoed sources? | ||
499 | 1475 | debug(logger, "Publishing source %s/%s to %s/%s" % ( | 1457 | debug(logger, "Publishing source %s/%s to %s/%s" % ( |
500 | 1476 | self.sourcepackagerelease.name, | 1458 | self.sourcepackagerelease.name, |
501 | 1477 | self.sourcepackagerelease.version, | 1459 | self.sourcepackagerelease.version, |
502 | 1478 | self.packageupload.distroseries.distribution.name, | 1460 | self.packageupload.distroseries.distribution.name, |
503 | 1479 | self.packageupload.distroseries.name)) | 1461 | self.packageupload.distroseries.name)) |
504 | 1480 | 1462 | ||
512 | 1481 | if self.packageupload.archive.is_ppa: | 1463 | return getUtility(IPublishingSet).newSourcePublication( |
513 | 1482 | # We override PPA to always publish in the main component. | 1464 | archive=self.packageupload.archive, |
514 | 1483 | component = getUtility(IComponentSet)['main'] | 1465 | sourcepackagerelease=self.sourcepackagerelease, |
508 | 1484 | else: | ||
509 | 1485 | component = self.sourcepackagerelease.component | ||
510 | 1486 | |||
511 | 1487 | sspph = SecureSourcePackagePublishingHistory( | ||
515 | 1488 | distroseries=self.packageupload.distroseries, | 1466 | distroseries=self.packageupload.distroseries, |
518 | 1489 | sourcepackagerelease=self.sourcepackagerelease, | 1467 | component=self.sourcepackagerelease.component, |
517 | 1490 | component=component, | ||
519 | 1491 | section=self.sourcepackagerelease.section, | 1468 | section=self.sourcepackagerelease.section, |
520 | 1492 | status=PackagePublishingStatus.PENDING, | 1469 | status=PackagePublishingStatus.PENDING, |
526 | 1493 | datecreated=UTC_NOW, | 1470 | pocket=self.packageupload.pocket |
527 | 1494 | pocket=self.packageupload.pocket, | 1471 | ) |
523 | 1495 | embargo=False, | ||
524 | 1496 | archive=self.packageupload.archive) | ||
525 | 1497 | return SourcePackagePublishingHistory.get(sspph.id) | ||
528 | 1498 | 1472 | ||
529 | 1499 | 1473 | ||
530 | 1500 | class PackageUploadCustom(SQLBase): | 1474 | class PackageUploadCustom(SQLBase): |
531 | 1501 | 1475 | ||
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 | 23 | >>> [bin_hppa, bin_i386] = stp.getPubBinaries(archive=cprov.archive) | 23 | >>> [bin_hppa, bin_i386] = stp.getPubBinaries(archive=cprov.archive) |
537 | 24 | >>> build = bin_hppa.binarypackagerelease.build | 24 | >>> build = bin_hppa.binarypackagerelease.build |
538 | 25 | >>> breezy_autotest = ubuntu.getSeries('breezy-autotest') | 25 | >>> breezy_autotest = ubuntu.getSeries('breezy-autotest') |
539 | 26 | >>> stp.addFakeChroots(breezy_autotest) | ||
540 | 26 | >>> delayed_copy = getUtility(IPackageUploadSet).createDelayedCopy( | 27 | >>> delayed_copy = getUtility(IPackageUploadSet).createDelayedCopy( |
541 | 27 | ... archive=ubuntu.main_archive, distroseries=breezy_autotest, | 28 | ... archive=ubuntu.main_archive, distroseries=breezy_autotest, |
542 | 28 | ... pocket=PackagePublishingPocket.RELEASE, signing_key=None) | 29 | ... pocket=PackagePublishingPocket.RELEASE, signing_key=None) |
543 | @@ -100,14 +101,22 @@ | |||
544 | 100 | http://launchpad.dev/~cprov/+archive/ppa | 101 | http://launchpad.dev/~cprov/+archive/ppa |
545 | 101 | 102 | ||
546 | 102 | When the delayed-copy is processed (moved to DONE queue) its contents | 103 | When the delayed-copy is processed (moved to DONE queue) its contents |
548 | 103 | becomes available to everyone. | 104 | become available to everyone. |
549 | 104 | 105 | ||
556 | 105 | # Process the delayed-copy. | 106 | # Process the delayed-copy using an external script call. Since some |
557 | 106 | >>> login('foo.bar@canonical.com') | 107 | # DB objects that have no security adapter are modified during the |
558 | 107 | >>> stp.addFakeChroots(breezy_autotest) | 108 | # delayed copy, the modification must be done in Zopeless mode. |
559 | 108 | >>> unused = delayed_copy.realiseUpload() | 109 | >>> import os.path |
560 | 109 | >>> transaction.commit() | 110 | >>> import subprocess |
561 | 110 | >>> logout() | 111 | >>> import sys |
562 | 112 | >>> from canonical.config import config | ||
563 | 113 | >>> script = os.path.join(config.root, "scripts/process-accepted.py") | ||
564 | 114 | >>> process = subprocess.Popen( | ||
565 | 115 | ... [sys.executable, script, "ubuntu"], | ||
566 | 116 | ... stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
567 | 117 | >>> stdout, stderr = process.communicate() | ||
568 | 118 | >>> if process.returncode != 0: | ||
569 | 119 | ... print stderr | ||
570 | 111 | 120 | ||
571 | 112 | Any user can access the DONE queue and access the delayed-copy | 121 | Any user can access the DONE queue and access the delayed-copy |
572 | 113 | 'changesfile' and view its files in the expandable area. | 122 | 'changesfile' and view its files in the expandable area. |
= 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 leaseFile in a wrapper which means the
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 SourcePackageRe
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 == pages-delayed- copies. txt
bin/test -cvvt publishing.txt -t xx-queue-
== 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: soyuz/model/ queue.py soyuz/stories/ soyuz/xx- queue-pages- delayed- copies. txt soyuz/model/ publishing. py soyuz/doc/ publishing. txt soyuz/interface s/publishing. py
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
== Pylint notices ==
lib/lp/ soyuz/interface s/publishing. py fields' (No module named declarations' (No module named
32: [F0401] Unable to import 'lazr.enum' (No module named enum)
39: [F0401] Unable to import 'lazr.restful.
restful)
40: [F0401] Unable to import 'lazr.restful.
restful)