Merge lp:~wgrant/launchpad/distroseries-source-format-selection into lp:launchpad/db-devel
- distroseries-source-format-selection
- Merge into db-devel
Status: | Merged | ||||
---|---|---|---|---|---|
Merge reported by: | William Grant | ||||
Merged at revision: | not available | ||||
Proposed branch: | lp:~wgrant/launchpad/distroseries-source-format-selection | ||||
Merge into: | lp:launchpad/db-devel | ||||
Diff against target: |
1205 lines (+727/-96) 20 files modified
lib/lp/archiveuploader/dscfile.py (+144/-58) lib/lp/archiveuploader/nascentuploadfile.py (+8/-4) lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_1.0-bzip2/bar_1.0-1.dsc (+10/-0) lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_1.0-bzip2/bar_1.0-1_source.changes (+20/-0) lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1.dsc (+9/-3) lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1_source.changes (+12/-6) lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0-2.dsc (+22/-0) lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0-2_source.changes (+25/-0) lib/lp/archiveuploader/tests/data/suite/bar_1.0_3.0-native/bar_1.0.dsc (+13/-0) lib/lp/archiveuploader/tests/data/suite/bar_1.0_3.0-native/bar_1.0_source.changes (+25/-0) lib/lp/archiveuploader/tests/nascentuploadfile.txt (+172/-0) lib/lp/archiveuploader/tests/test_ppauploadprocessor.py (+47/-0) lib/lp/archiveuploader/tests/test_uploadprocessor.py (+119/-0) lib/lp/archiveuploader/tests/test_utils.py (+46/-12) lib/lp/archiveuploader/uploadpolicy.py (+4/-0) lib/lp/archiveuploader/utils.py (+13/-6) lib/lp/registry/interfaces/sourcepackage.py (+19/-1) lib/lp/soyuz/interfaces/files.py (+6/-1) lib/lp/soyuz/model/files.py (+12/-2) lib/lp/soyuz/model/queue.py (+1/-3) |
||||
To merge this branch: | bzr merge lp:~wgrant/launchpad/distroseries-source-format-selection | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Julian Edwards (community) | code | Approve | |
Review via email: mp+14977@code.launchpad.net |
Commit message
Description of the change
William Grant (wgrant) wrote : | # |
Julian Edwards (julian-edwards) wrote : | # |
Thanks for making this change William. I've commented inline.
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -32,7 +32,8 @@
> from lp.archiveuploa
> prefix_
> re_valid_pkg_name, re_valid_version, re_issource,
> - determine_
> + re_is_component
> + get_source_
Can you put the imports in alphabetical order please.
> from canonical.encoding import guess as guess_encoding
> from lp.registry.
> from lp.registry.
> @@ -347,8 +348,9 @@
> distribution=
> purpose=
> elif (self.policy.
> - determine_
> - SourcePackageFi
> + determine_
> + SourcePackageFi
> + SourcePackageFi
> archives = [self.policy.
> else:
> archives = [self.policy.
> @@ -374,9 +376,13 @@
> """
>
> diff_count = 0
> + debian_tar_count = 0
> orig_tar_count = 0
> + component_
> native_tar_count = 0
>
> + bzip2_count = 0
> +
> files_missing = False
> for sub_dsc_file in self.files:
> filetype = determine_
> @@ -385,12 +391,23 @@
> diff_count += 1
> elif filetype == SourcePackageFi
> orig_tar_count += 1
> + elif filetype == SourcePackageFi
> + component = re_is_component
> + get_source_
> + if component not in component_
> + component_
> + component_
> + elif filetype == SourcePackageFi
> + debian_tar_count += 1
> elif filetype == SourcePackageFi
> native_tar_count += 1
This big list of "elif" statements is looking a bit unwieldy, especially with all the new conditions. Unless you can suggest anything better, how about we do something like:
def orig_tarball_
def ....
...
}
# Or you could use lambda funcs there --^ it's probably tidier.
William Grant (wgrant) wrote : | # |
On Tue, 2009-11-24 at 23:20 +0000, Julian Edwards wrote:
> Review: Needs Fixing code
> Thanks for making this change William. I've commented inline.
Thanks for the review, Julian. I've fixed the main issues -- an
intermediate diff is attached.
> > === modified file 'lib/lp/
> > --- lib/lp/
> > +++ lib/lp/
> > @@ -32,7 +32,8 @@
> > from lp.archiveuploa
> > prefix_
> > re_valid_pkg_name, re_valid_version, re_issource,
> > - determine_
> > + re_is_component
> > + get_source_
>
> Can you put the imports in alphabetical order please.
Done.
> > from canonical.encoding import guess as guess_encoding
> > from lp.registry.
> > from lp.registry.
> > @@ -347,8 +348,9 @@
> > distribution=
> > purpose=
> > elif (self.policy.
> > - determine_
> > - SourcePackageFi
> > + determine_
> > + SourcePackageFi
> > + SourcePackageFi
> > archives = [self.policy.
> > else:
> > archives = [self.policy.
> > @@ -374,9 +376,13 @@
> > """
> >
> > diff_count = 0
> > + debian_tar_count = 0
> > orig_tar_count = 0
> > + component_
> > native_tar_count = 0
> >
> > + bzip2_count = 0
> > +
> > files_missing = False
> > for sub_dsc_file in self.files:
> > filetype = determine_
> > @@ -385,12 +391,23 @@
> > diff_count += 1
> > elif filetype == SourcePackageFi
> > orig_tar_count += 1
> > + elif filetype == SourcePackageFi
> > + component = re_is_component
> > + get_source_
> > + if component not in component_
> > + component_
> > + component_
> > + elif filetype == SourcePackageFi
> > + debian_tar_count += 1
> > elif filetype == SourcePackageFi
> > native_tar_count += 1
>
> This big list of "elif" statements is looking a bit unwieldy, especially with all the new conditions. Unless you can suggest anything better, how about we do something like:
> [snip]
While your suggested solution would...
1 | === modified file 'lib/lp/archiveuploader/dscfile.py' | |||
2 | --- lib/lp/archiveuploader/dscfile.py 2009-11-18 02:58:23 +0000 | |||
3 | +++ lib/lp/archiveuploader/dscfile.py 2009-11-25 09:40:30 +0000 | |||
4 | @@ -30,10 +30,9 @@ | |||
5 | 30 | from lp.archiveuploader.tagfiles import ( | 30 | from lp.archiveuploader.tagfiles import ( |
6 | 31 | parse_tagfile, TagFileParseError) | 31 | parse_tagfile, TagFileParseError) |
7 | 32 | from lp.archiveuploader.utils import ( | 32 | from lp.archiveuploader.utils import ( |
12 | 33 | prefix_multi_line_string, safe_fix_maintainer, ParseMaintError, | 33 | determine_source_file_type, get_source_file_extension, |
13 | 34 | re_valid_pkg_name, re_valid_version, re_issource, | 34 | ParseMaintError, prefix_multi_line_string, re_is_component_orig_tar_ext, |
14 | 35 | re_is_component_orig_tar_ext, determine_source_file_type, | 35 | re_issource, re_valid_pkg_name, re_valid_version, safe_fix_maintainer) |
11 | 36 | get_source_file_extension) | ||
15 | 37 | from canonical.encoding import guess as guess_encoding | 36 | from canonical.encoding import guess as guess_encoding |
16 | 38 | from lp.registry.interfaces.person import IPersonSet, PersonCreationRationale | 37 | from lp.registry.interfaces.person import IPersonSet, PersonCreationRationale |
17 | 39 | from lp.registry.interfaces.sourcepackage import SourcePackageFileType | 38 | from lp.registry.interfaces.sourcepackage import SourcePackageFileType |
18 | @@ -161,6 +160,9 @@ | |||
19 | 161 | 160 | ||
20 | 162 | Can raise UploadError. | 161 | Can raise UploadError. |
21 | 163 | """ | 162 | """ |
22 | 163 | # Avoid circular imports. | ||
23 | 164 | from lp.archiveuploader.nascentupload import EarlyReturnUploadError | ||
24 | 165 | |||
25 | 164 | SourceUploadFile.__init__( | 166 | SourceUploadFile.__init__( |
26 | 165 | self, filepath, digest, size, component_and_section, priority, | 167 | self, filepath, digest, size, component_and_section, priority, |
27 | 166 | package, version, changes, policy, logger) | 168 | package, version, changes, policy, logger) |
28 | @@ -187,6 +189,10 @@ | |||
29 | 187 | if 'format' not in self._dict: | 189 | if 'format' not in self._dict: |
30 | 188 | self._dict['format'] = "1.0" | 190 | self._dict['format'] = "1.0" |
31 | 189 | 191 | ||
32 | 192 | if self.format is None: | ||
33 | 193 | raise EarlyReturnUploadError( | ||
34 | 194 | "Unsupported source format: %s" % self._dict['format']) | ||
35 | 195 | |||
36 | 190 | if self.policy.unsigned_dsc_ok: | 196 | if self.policy.unsigned_dsc_ok: |
37 | 191 | self.logger.debug("DSC file can be unsigned.") | 197 | self.logger.debug("DSC file can be unsigned.") |
38 | 192 | else: | 198 | else: |
39 | @@ -209,7 +215,11 @@ | |||
40 | 209 | @property | 215 | @property |
41 | 210 | def format(self): | 216 | def format(self): |
42 | 211 | """Return the DSC format.""" | 217 | """Return the DSC format.""" |
44 | 212 | return self._dict['format'] | 218 | try: |
45 | 219 | return SourcePackageFormat.getTermByToken( | ||
46 | 220 | self._dict['format']).value | ||
47 | 221 | except LookupError: | ||
48 | 222 | return None | ||
49 | 213 | 223 | ||
50 | 214 | @property | 224 | @property |
51 | 215 | def architecture(self): | 225 | def architecture(self): |
52 | @@ -232,8 +242,6 @@ | |||
53 | 232 | This method is an error generator, i.e, it returns an iterator over all | 242 | This method is an error generator, i.e, it returns an iterator over all |
54 | 233 | exceptions that are generated while processing DSC file checks. | 243 | exceptions that are generated while processing DSC file checks. |
55 | 234 | """ | 244 | """ |
56 | 235 | # Avoid circular imports. | ||
57 | 236 | from lp.archiveuploader.nascentupload import EarlyReturnUploadError | ||
58 | 237 | 245 | ||
59 | 238 | for error in SourceUploadFile.verify(self): | 246 | for error in SourceUploadFile.verify(self): |
60 | 239 | yield error | 247 | yield error |
61 | @@ -272,14 +280,8 @@ | |||
62 | 272 | yield UploadError( | 280 | yield UploadError( |
63 | 273 | "%s: invalid version %s" % (self.filename, self.dsc_version)) | 281 | "%s: invalid version %s" % (self.filename, self.dsc_version)) |
64 | 274 | 282 | ||
65 | 275 | try: | ||
66 | 276 | format_term = SourcePackageFormat.getTermByToken(self.format) | ||
67 | 277 | except LookupError: | ||
68 | 278 | raise EarlyReturnUploadError( | ||
69 | 279 | "Unsupported source format: %s" % self.format) | ||
70 | 280 | |||
71 | 281 | if not self.policy.distroseries.isSourcePackageFormatPermitted( | 283 | if not self.policy.distroseries.isSourcePackageFormatPermitted( |
73 | 282 | format_term.value): | 284 | self.format): |
74 | 283 | yield UploadError( | 285 | yield UploadError( |
75 | 284 | "%s: format '%s' is not permitted in %s." % | 286 | "%s: format '%s' is not permitted in %s." % |
76 | 285 | (self.filename, self.format, self.policy.distroseries.name)) | 287 | (self.filename, self.format, self.policy.distroseries.name)) |
77 | @@ -375,35 +377,32 @@ | |||
78 | 375 | and checksum. | 377 | and checksum. |
79 | 376 | """ | 378 | """ |
80 | 377 | 379 | ||
84 | 378 | diff_count = 0 | 380 | file_type_counts = { |
85 | 379 | debian_tar_count = 0 | 381 | SourcePackageFileType.DIFF: 0, |
86 | 380 | orig_tar_count = 0 | 382 | SourcePackageFileType.ORIG_TARBALL: 0, |
87 | 383 | SourcePackageFileType.DEBIAN_TARBALL: 0, | ||
88 | 384 | SourcePackageFileType.NATIVE_TARBALL: 0, | ||
89 | 385 | } | ||
90 | 381 | component_orig_tar_counts = {} | 386 | component_orig_tar_counts = {} |
91 | 382 | native_tar_count = 0 | ||
92 | 383 | |||
93 | 384 | bzip2_count = 0 | 387 | bzip2_count = 0 |
94 | 385 | |||
95 | 386 | files_missing = False | 388 | files_missing = False |
96 | 389 | |||
97 | 387 | for sub_dsc_file in self.files: | 390 | for sub_dsc_file in self.files: |
105 | 388 | filetype = determine_source_file_type(sub_dsc_file.filename) | 391 | file_type = determine_source_file_type(sub_dsc_file.filename) |
106 | 389 | 392 | ||
107 | 390 | if filetype == SourcePackageFileType.DIFF: | 393 | if file_type is None: |
108 | 391 | diff_count += 1 | 394 | yield UploadError('Unknown file: ' + sub_dsc_file.filename) |
109 | 392 | elif filetype == SourcePackageFileType.ORIG_TARBALL: | 395 | continue |
110 | 393 | orig_tar_count += 1 | 396 | |
111 | 394 | elif filetype == SourcePackageFileType.COMPONENT_ORIG_TARBALL: | 397 | if file_type == SourcePackageFileType.COMPONENT_ORIG_TARBALL: |
112 | 398 | # Split the count by component name. | ||
113 | 395 | component = re_is_component_orig_tar_ext.match( | 399 | component = re_is_component_orig_tar_ext.match( |
114 | 396 | get_source_file_extension(sub_dsc_file.filename)).group(1) | 400 | get_source_file_extension(sub_dsc_file.filename)).group(1) |
115 | 397 | if component not in component_orig_tar_counts: | 401 | if component not in component_orig_tar_counts: |
116 | 398 | component_orig_tar_counts[component] = 0 | 402 | component_orig_tar_counts[component] = 0 |
117 | 399 | component_orig_tar_counts[component] += 1 | 403 | component_orig_tar_counts[component] += 1 |
118 | 400 | elif filetype == SourcePackageFileType.DEBIAN_TARBALL: | ||
119 | 401 | debian_tar_count += 1 | ||
120 | 402 | elif filetype == SourcePackageFileType.NATIVE_TARBALL: | ||
121 | 403 | native_tar_count += 1 | ||
122 | 404 | else: | 404 | else: |
125 | 405 | yield UploadError('Unknown file: ' + sub_dsc_file.filename) | 405 | file_type_counts[file_type] += 1 |
124 | 406 | continue | ||
126 | 407 | 406 | ||
127 | 408 | if sub_dsc_file.filename.endswith('.bz2'): | 407 | if sub_dsc_file.filename.endswith('.bz2'): |
128 | 409 | bzip2_count += 1 | 408 | bzip2_count += 1 |
129 | @@ -452,99 +451,10 @@ | |||
130 | 452 | yield error | 451 | yield error |
131 | 453 | files_missing = True | 452 | files_missing = True |
132 | 454 | 453 | ||
226 | 455 | # Reject if we have more than one file of any type. | 454 | for error in format_to_file_checker_map[self.format]( |
227 | 456 | if orig_tar_count > 1: | 455 | self.filename, file_type_counts, component_orig_tar_counts, |
228 | 457 | yield UploadError( | 456 | bzip2_count): |
229 | 458 | "%s: has more than one orig.tar.*." | 457 | yield error |
137 | 459 | % self.filename) | ||
138 | 460 | if debian_tar_count > 1: | ||
139 | 461 | yield UploadError( | ||
140 | 462 | "%s: has more than one debian.tar.*." | ||
141 | 463 | % self.filename) | ||
142 | 464 | if native_tar_count > 1: | ||
143 | 465 | yield UploadError( | ||
144 | 466 | "%s: has more than one tar.*." | ||
145 | 467 | % self.filename) | ||
146 | 468 | if diff_count > 1: | ||
147 | 469 | yield UploadError( | ||
148 | 470 | "%s: has more than one diff.gz." | ||
149 | 471 | % self.filename) | ||
150 | 472 | |||
151 | 473 | if ((orig_tar_count == 0 and native_tar_count == 0) or | ||
152 | 474 | (orig_tar_count > 0 and native_tar_count > 0)): | ||
153 | 475 | yield UploadError( | ||
154 | 476 | "%s: must have exactly one tar.* or orig.tar.*." | ||
155 | 477 | % self.filename) | ||
156 | 478 | |||
157 | 479 | if native_tar_count > 0 and debian_tar_count > 0: | ||
158 | 480 | yield UploadError( | ||
159 | 481 | "%s: must have no more than one tar.* or debian.tar.*." | ||
160 | 482 | % self.filename) | ||
161 | 483 | |||
162 | 484 | # Format 1.0 must be native (exactly one tar.gz), or | ||
163 | 485 | # have an orig.tar.gz and a diff.gz. It cannot have | ||
164 | 486 | # compression types other than 'gz'. | ||
165 | 487 | if self.format == '1.0': | ||
166 | 488 | if bzip2_count > 0: | ||
167 | 489 | yield UploadError( | ||
168 | 490 | "%s: is format 1.0 but uses bzip2 compression." | ||
169 | 491 | % self.filename) | ||
170 | 492 | |||
171 | 493 | if ((diff_count == 0 and native_tar_count == 0) or | ||
172 | 494 | (diff_count > 0 and native_tar_count > 0)): | ||
173 | 495 | yield UploadError( | ||
174 | 496 | "%s: must have exactly one diff.gz or tar.gz." | ||
175 | 497 | % self.filename) | ||
176 | 498 | |||
177 | 499 | if debian_tar_count > 0: | ||
178 | 500 | yield UploadError( | ||
179 | 501 | "%s: is format 1.0 but has debian.tar.*." | ||
180 | 502 | % self.filename) | ||
181 | 503 | |||
182 | 504 | if len(component_orig_tar_counts) > 0: | ||
183 | 505 | yield UploadError( | ||
184 | 506 | "%s: is format 1.0 but has orig-COMPONENT.tar.*." | ||
185 | 507 | % self.filename) | ||
186 | 508 | # Format 3.0 (native) must have exactly one tar.*. | ||
187 | 509 | # gz and bz2 are valid compression types. | ||
188 | 510 | elif self.format == '3.0 (native)': | ||
189 | 511 | if native_tar_count == 0: | ||
190 | 512 | yield UploadError( | ||
191 | 513 | "%s: must have exactly one tar.*." | ||
192 | 514 | % self.filename) | ||
193 | 515 | |||
194 | 516 | if diff_count > 0: | ||
195 | 517 | yield UploadError( | ||
196 | 518 | "%s: is format 3.0 but has diff.gz." | ||
197 | 519 | % self.filename) | ||
198 | 520 | |||
199 | 521 | if len(component_orig_tar_counts) > 0: | ||
200 | 522 | yield UploadError( | ||
201 | 523 | "%s: is native but has orig-COMPONENT.tar.*." | ||
202 | 524 | % self.filename) | ||
203 | 525 | elif self.format == '3.0 (quilt)': | ||
204 | 526 | if orig_tar_count == 0: | ||
205 | 527 | yield UploadError( | ||
206 | 528 | "%s: must have exactly one orig.tar.*." | ||
207 | 529 | % self.filename) | ||
208 | 530 | |||
209 | 531 | if debian_tar_count == 0: | ||
210 | 532 | yield UploadError( | ||
211 | 533 | "%s: must have exactly one debian.tar.*." | ||
212 | 534 | % self.filename) | ||
213 | 535 | |||
214 | 536 | if diff_count > 0: | ||
215 | 537 | yield UploadError( | ||
216 | 538 | "%s: is format 3.0 but has diff.gz." | ||
217 | 539 | % self.filename) | ||
218 | 540 | |||
219 | 541 | for component in component_orig_tar_counts: | ||
220 | 542 | if component_orig_tar_counts[component] > 1: | ||
221 | 543 | yield UploadError( | ||
222 | 544 | "%s: has more than one orig-%s.tar.*." | ||
223 | 545 | % (self.filename, component)) | ||
224 | 546 | else: | ||
225 | 547 | raise AssertionError("Unknown source format.") | ||
230 | 548 | 458 | ||
231 | 549 | if files_missing: | 459 | if files_missing: |
232 | 550 | yield UploadError( | 460 | yield UploadError( |
233 | @@ -727,3 +637,78 @@ | |||
234 | 727 | yield error | 637 | yield error |
235 | 728 | 638 | ||
236 | 729 | 639 | ||
237 | 640 | def check_format_1_0_files(filename, file_type_counts, component_counts, | ||
238 | 641 | bzip2_count): | ||
239 | 642 | """Check that the given counts of each file type suit format 1.0. | ||
240 | 643 | |||
241 | 644 | A 1.0 source must be native (with only one tar.gz), or have an orig.tar.gz | ||
242 | 645 | and a diff.gz. It cannot use bzip2 compression. | ||
243 | 646 | """ | ||
244 | 647 | if bzip2_count > 0: | ||
245 | 648 | yield UploadError( | ||
246 | 649 | "%s: is format 1.0 but uses bzip2 compression." | ||
247 | 650 | % filename) | ||
248 | 651 | |||
249 | 652 | if file_type_counts not in ({ | ||
250 | 653 | SourcePackageFileType.NATIVE_TARBALL: 1, | ||
251 | 654 | SourcePackageFileType.ORIG_TARBALL: 0, | ||
252 | 655 | SourcePackageFileType.DEBIAN_TARBALL: 0, | ||
253 | 656 | SourcePackageFileType.DIFF: 0, | ||
254 | 657 | }, { | ||
255 | 658 | SourcePackageFileType.ORIG_TARBALL: 1, | ||
256 | 659 | SourcePackageFileType.DIFF: 1, | ||
257 | 660 | SourcePackageFileType.NATIVE_TARBALL: 0, | ||
258 | 661 | SourcePackageFileType.DEBIAN_TARBALL: 0, | ||
259 | 662 | }) or len(component_counts) > 0: | ||
260 | 663 | yield UploadError( | ||
261 | 664 | "%s: must have exactly one tar.gz, or an orig.tar.gz and diff.gz" | ||
262 | 665 | % filename) | ||
263 | 666 | |||
264 | 667 | |||
265 | 668 | def check_format_3_0_native_files(filename, file_type_counts, | ||
266 | 669 | component_counts, bzip2_count): | ||
267 | 670 | """Check that the given counts of each file type suit format 3.0 (native). | ||
268 | 671 | |||
269 | 672 | A 3.0 (native) source must have only one tar.*. Both gzip and bzip2 | ||
270 | 673 | compression are permissible. | ||
271 | 674 | """ | ||
272 | 675 | |||
273 | 676 | if file_type_counts != { | ||
274 | 677 | SourcePackageFileType.NATIVE_TARBALL: 1, | ||
275 | 678 | SourcePackageFileType.ORIG_TARBALL: 0, | ||
276 | 679 | SourcePackageFileType.DEBIAN_TARBALL: 0, | ||
277 | 680 | SourcePackageFileType.DIFF: 0, | ||
278 | 681 | } or len(component_counts) > 0: | ||
279 | 682 | yield UploadError("%s: must have only a tar.*." % filename) | ||
280 | 683 | |||
281 | 684 | |||
282 | 685 | def check_format_3_0_quilt_files(filename, file_type_counts, | ||
283 | 686 | component_counts, bzip2_count): | ||
284 | 687 | """Check that the given counts of each file type suit format 3.0 (native). | ||
285 | 688 | |||
286 | 689 | A 3.0 (quilt) source must have exactly one orig.tar.*, one debian.tar.*, | ||
287 | 690 | and at most one orig-COMPONENT.tar.* for each COMPONENT. Both gzip and | ||
288 | 691 | bzip2 compression are permissible. | ||
289 | 692 | """ | ||
290 | 693 | if file_type_counts != { | ||
291 | 694 | SourcePackageFileType.ORIG_TARBALL: 1, | ||
292 | 695 | SourcePackageFileType.DEBIAN_TARBALL: 1, | ||
293 | 696 | SourcePackageFileType.NATIVE_TARBALL: 0, | ||
294 | 697 | SourcePackageFileType.DIFF: 0, | ||
295 | 698 | }: | ||
296 | 699 | yield UploadError( | ||
297 | 700 | "%s: must have only an orig.tar.*, a debian.tar.*, and " | ||
298 | 701 | "optionally orig-*.tar.*" % filename) | ||
299 | 702 | |||
300 | 703 | for component in component_counts: | ||
301 | 704 | if component_counts[component] > 1: | ||
302 | 705 | yield UploadError( | ||
303 | 706 | "%s: has more than one orig-%s.tar.*." | ||
304 | 707 | % (filename, component)) | ||
305 | 708 | |||
306 | 709 | |||
307 | 710 | format_to_file_checker_map = { | ||
308 | 711 | SourcePackageFormat.FORMAT_1_0: check_format_1_0_files, | ||
309 | 712 | SourcePackageFormat.FORMAT_3_0_NATIVE: check_format_3_0_native_files, | ||
310 | 713 | SourcePackageFormat.FORMAT_3_0_QUILT: check_format_3_0_quilt_files, | ||
311 | 714 | } |
Julian Edwards (julian-edwards) wrote : | # |
> While your suggested solution would not work (at least not without the
> 'nonlocal' keyword), I believe I have found something better. I keep one
> dict mapping SPFTs to counts, and another mapping component names to
> counts. This means there's only one special case (for
> COMPONENT_
> cleaner too.
Ah, this is 100% better than my suggestion, nice one!
> I've split it, and completely changed the verification style. The
> failure messages are much less verbose, but one would have to manually
> edit the .dsc to get any of them anyway. I feel the reduction in code
> makes things much better.
Actually it is not only better, it's easier to test because there are
fewer cases!
> This does make testing much easier.
>
> However, there are now just a few code paths, but a lot of potential
> failure cases. How completely should I test?
We always test 100% code coverage at least and any peculiar corner cases
that are obvious.
I'd be happy here to have 2 tests per format type; one that tests it accepts
correctly and one that tests it fails correctly, since that's pretty much
all the code is doing now.
> > Also, can you please change it to compare against the format enum instead
> > of strings. Then the assertion error below will make more sense.
> >
> > > else:
> > > raise AssertionError(
>
> It will now die with a KeyError when looking up the file checker, which
> seems as reasonable as the old explicit AssertionError.
I don't really like that, it's not as explicit as the old error, particularly
because the error will appear in the rejection email (unlikely as it is).
Can you catch the KeyError and re-raise it as AssertionError with some good
text. This will ensure if/when we add more format types, it will be easier to
track down why the failure occurred.
> The two uses are on different types: this is a SourceUploadFile, while
> the other is a SourcePackageRe
> utility function alongside SPFT, perhaps?
I would make a mix-in class that both can inherit from and put the property
on that.
> @@ -375,35 +377,32 @@
> and checksum.
> """
>
> - diff_count = 0
> - debian_tar_count = 0
> - orig_tar_count = 0
> + file_type_counts = {
> + SourcePackageFi
> + SourcePackageFi
> + SourcePackageFi
> + SourcePackageFi
> + }
> component_
> - native_tar_count = 0
> -
> bzip2_count = 0
> -
*Loads* better!
> files_missing = False
> +
> for sub_dsc_file in self.files:
> - filetype = determine_
> -
> - if filetype == SourcePackageFi
> - diff_count += 1
> - elif filetype == SourcePackageFi
> - orig_tar_count += 1
> - elif filetype == SourcePackageFi
> + file_type = determine_
William Grant (wgrant) wrote : | # |
On Wed, 2009-11-25 at 23:03 +0000, Julian Edwards wrote:
> Review: Needs Fixing code
> > While your suggested solution would not work (at least not without the
> > 'nonlocal' keyword), I believe I have found something better. I keep one
> > dict mapping SPFTs to counts, and another mapping component names to
> > counts. This means there's only one special case (for
> > COMPONENT_
> > cleaner too.
>
> Ah, this is 100% better than my suggestion, nice one!
>
> > I've split it, and completely changed the verification style. The
> > failure messages are much less verbose, but one would have to manually
> > edit the .dsc to get any of them anyway. I feel the reduction in code
> > makes things much better.
>
> Actually it is not only better, it's easier to test because there are
> fewer cases!
>
> > This does make testing much easier.
> >
> > However, there are now just a few code paths, but a lot of potential
> > failure cases. How completely should I test?
>
> We always test 100% code coverage at least and any peculiar corner cases
> that are obvious.
>
> I'd be happy here to have 2 tests per format type; one that tests it accepts
> correctly and one that tests it fails correctly, since that's pretty much
> all the code is doing now.
I've added tests in nascentuploadfi
> > > Also, can you please change it to compare against the format enum instead
> > > of strings. Then the assertion error below will make more sense.
> > >
> > > > else:
> > > > raise AssertionError(
> >
> > It will now die with a KeyError when looking up the file checker, which
> > seems as reasonable as the old explicit AssertionError.
>
> I don't really like that, it's not as explicit as the old error, particularly
> because the error will appear in the rejection email (unlikely as it is).
>
> Can you catch the KeyError and re-raise it as AssertionError with some good
> text. This will ensure if/when we add more format types, it will be easier to
> track down why the failure occurred.
Done.
> > The two uses are on different types: this is a SourceUploadFile, while
> > the other is a SourcePackageRe
> > utility function alongside SPFT, perhaps?
>
> I would make a mix-in class that both can inherit from and put the property
> on that.
As you suggested on IRC, I've put it in
lp.soyuz.
> > @@ -375,35 +377,32 @@
> > and checksum.
> > """
> >
> > - diff_count = 0
> > - debian_tar_count = 0
> > - orig_tar_count = 0
> > + file_type_counts = {
> > + SourcePackageFi
> > + SourcePackageFi
> > + SourcePackageFi
> > + SourcePackageFi
> > + }
> > component_
> > - native_tar_count = 0
> > -
> > bzip2_count = 0
> > -
>
> *Loads* better!
>
> > files_missing = False
> > +
> > for sub_dsc_file in self.files:
> > - filetype = determine_
1 | === modified file 'lib/lp/archiveuploader/dscfile.py' | |||
2 | --- lib/lp/archiveuploader/dscfile.py 2009-11-25 09:40:38 +0000 | |||
3 | +++ lib/lp/archiveuploader/dscfile.py 2009-11-26 00:42:45 +0000 | |||
4 | @@ -451,7 +451,13 @@ | |||
5 | 451 | yield error | 451 | yield error |
6 | 452 | files_missing = True | 452 | files_missing = True |
7 | 453 | 453 | ||
9 | 454 | for error in format_to_file_checker_map[self.format]( | 454 | try: |
10 | 455 | file_checker = format_to_file_checker_map[self.format] | ||
11 | 456 | except KeyError: | ||
12 | 457 | raise AssertionError( | ||
13 | 458 | "No file checker for source format %s." % self.format) | ||
14 | 459 | |||
15 | 460 | for error in file_checker( | ||
16 | 455 | self.filename, file_type_counts, component_orig_tar_counts, | 461 | self.filename, file_type_counts, component_orig_tar_counts, |
17 | 456 | bzip2_count): | 462 | bzip2_count): |
18 | 457 | yield error | 463 | yield error |
19 | @@ -649,17 +655,23 @@ | |||
20 | 649 | "%s: is format 1.0 but uses bzip2 compression." | 655 | "%s: is format 1.0 but uses bzip2 compression." |
21 | 650 | % filename) | 656 | % filename) |
22 | 651 | 657 | ||
34 | 652 | if file_type_counts not in ({ | 658 | valid_file_type_counts = [ |
35 | 653 | SourcePackageFileType.NATIVE_TARBALL: 1, | 659 | { |
36 | 654 | SourcePackageFileType.ORIG_TARBALL: 0, | 660 | SourcePackageFileType.NATIVE_TARBALL: 1, |
37 | 655 | SourcePackageFileType.DEBIAN_TARBALL: 0, | 661 | SourcePackageFileType.ORIG_TARBALL: 0, |
38 | 656 | SourcePackageFileType.DIFF: 0, | 662 | SourcePackageFileType.DEBIAN_TARBALL: 0, |
39 | 657 | }, { | 663 | SourcePackageFileType.DIFF: 0, |
40 | 658 | SourcePackageFileType.ORIG_TARBALL: 1, | 664 | }, |
41 | 659 | SourcePackageFileType.DIFF: 1, | 665 | { |
42 | 660 | SourcePackageFileType.NATIVE_TARBALL: 0, | 666 | SourcePackageFileType.ORIG_TARBALL: 1, |
43 | 661 | SourcePackageFileType.DEBIAN_TARBALL: 0, | 667 | SourcePackageFileType.DIFF: 1, |
44 | 662 | }) or len(component_counts) > 0: | 668 | SourcePackageFileType.NATIVE_TARBALL: 0, |
45 | 669 | SourcePackageFileType.DEBIAN_TARBALL: 0, | ||
46 | 670 | }, | ||
47 | 671 | ] | ||
48 | 672 | |||
49 | 673 | if (file_type_counts not in valid_file_type_counts or | ||
50 | 674 | len(component_counts) > 0): | ||
51 | 663 | yield UploadError( | 675 | yield UploadError( |
52 | 664 | "%s: must have exactly one tar.gz, or an orig.tar.gz and diff.gz" | 676 | "%s: must have exactly one tar.gz, or an orig.tar.gz and diff.gz" |
53 | 665 | % filename) | 677 | % filename) |
54 | @@ -673,12 +685,17 @@ | |||
55 | 673 | compression are permissible. | 685 | compression are permissible. |
56 | 674 | """ | 686 | """ |
57 | 675 | 687 | ||
64 | 676 | if file_type_counts != { | 688 | valid_file_type_counts = [ |
65 | 677 | SourcePackageFileType.NATIVE_TARBALL: 1, | 689 | { |
66 | 678 | SourcePackageFileType.ORIG_TARBALL: 0, | 690 | SourcePackageFileType.NATIVE_TARBALL: 1, |
67 | 679 | SourcePackageFileType.DEBIAN_TARBALL: 0, | 691 | SourcePackageFileType.ORIG_TARBALL: 0, |
68 | 680 | SourcePackageFileType.DIFF: 0, | 692 | SourcePackageFileType.DEBIAN_TARBALL: 0, |
69 | 681 | } or len(component_counts) > 0: | 693 | SourcePackageFileType.DIFF: 0, |
70 | 694 | }, | ||
71 | 695 | ] | ||
72 | 696 | |||
73 | 697 | if (file_type_counts not in valid_file_type_counts or | ||
74 | 698 | len(component_counts) > 0): | ||
75 | 682 | yield UploadError("%s: must have only a tar.*." % filename) | 699 | yield UploadError("%s: must have only a tar.*." % filename) |
76 | 683 | 700 | ||
77 | 684 | 701 | ||
78 | @@ -690,12 +707,17 @@ | |||
79 | 690 | and at most one orig-COMPONENT.tar.* for each COMPONENT. Both gzip and | 707 | and at most one orig-COMPONENT.tar.* for each COMPONENT. Both gzip and |
80 | 691 | bzip2 compression are permissible. | 708 | bzip2 compression are permissible. |
81 | 692 | """ | 709 | """ |
88 | 693 | if file_type_counts != { | 710 | |
89 | 694 | SourcePackageFileType.ORIG_TARBALL: 1, | 711 | valid_file_type_counts = [ |
90 | 695 | SourcePackageFileType.DEBIAN_TARBALL: 1, | 712 | { |
91 | 696 | SourcePackageFileType.NATIVE_TARBALL: 0, | 713 | SourcePackageFileType.ORIG_TARBALL: 1, |
92 | 697 | SourcePackageFileType.DIFF: 0, | 714 | SourcePackageFileType.DEBIAN_TARBALL: 1, |
93 | 698 | }: | 715 | SourcePackageFileType.NATIVE_TARBALL: 0, |
94 | 716 | SourcePackageFileType.DIFF: 0, | ||
95 | 717 | }, | ||
96 | 718 | ] | ||
97 | 719 | |||
98 | 720 | if file_type_counts not in valid_file_type_counts: | ||
99 | 699 | yield UploadError( | 721 | yield UploadError( |
100 | 700 | "%s: must have only an orig.tar.*, a debian.tar.*, and " | 722 | "%s: must have only an orig.tar.*, a debian.tar.*, and " |
101 | 701 | "optionally orig-*.tar.*" % filename) | 723 | "optionally orig-*.tar.*" % filename) |
102 | 702 | 724 | ||
103 | === modified file 'lib/lp/archiveuploader/nascentuploadfile.py' | |||
104 | --- lib/lp/archiveuploader/nascentuploadfile.py 2009-11-14 02:55:15 +0000 | |||
105 | +++ lib/lp/archiveuploader/nascentuploadfile.py 2009-11-25 23:38:51 +0000 | |||
106 | @@ -35,7 +35,6 @@ | |||
107 | 35 | re_no_epoch, re_no_revision, re_valid_version, re_valid_pkg_name, | 35 | re_no_epoch, re_no_revision, re_valid_version, re_valid_pkg_name, |
108 | 36 | re_extract_src_version, determine_source_file_type) | 36 | re_extract_src_version, determine_source_file_type) |
109 | 37 | from canonical.encoding import guess as guess_encoding | 37 | from canonical.encoding import guess as guess_encoding |
110 | 38 | from lp.registry.interfaces.sourcepackage import SourcePackageFileType | ||
111 | 39 | from lp.soyuz.interfaces.binarypackagename import ( | 38 | from lp.soyuz.interfaces.binarypackagename import ( |
112 | 40 | IBinaryPackageNameSet) | 39 | IBinaryPackageNameSet) |
113 | 41 | from lp.soyuz.interfaces.binarypackagerelease import ( | 40 | from lp.soyuz.interfaces.binarypackagerelease import ( |
114 | @@ -49,6 +48,7 @@ | |||
115 | 49 | from lp.soyuz.interfaces.publishing import ( | 48 | from lp.soyuz.interfaces.publishing import ( |
116 | 50 | PackagePublishingPriority) | 49 | PackagePublishingPriority) |
117 | 51 | from lp.soyuz.interfaces.section import ISectionSet | 50 | from lp.soyuz.interfaces.section import ISectionSet |
118 | 51 | from lp.soyuz.model.files import SourceFileMixin | ||
119 | 52 | from canonical.librarian.utils import filechunks | 52 | from canonical.librarian.utils import filechunks |
120 | 53 | 53 | ||
121 | 54 | 54 | ||
122 | @@ -332,7 +332,7 @@ | |||
123 | 332 | return getUtility(ISectionSet)[self.section_name] | 332 | return getUtility(ISectionSet)[self.section_name] |
124 | 333 | 333 | ||
125 | 334 | 334 | ||
127 | 335 | class SourceUploadFile(PackageUploadFile): | 335 | class SourceUploadFile(SourceFileMixin, PackageUploadFile): |
128 | 336 | """Files mentioned in changesfile as source (orig, diff, tar). | 336 | """Files mentioned in changesfile as source (orig, diff, tar). |
129 | 337 | 337 | ||
130 | 338 | This class only check consistency on information contained in | 338 | This class only check consistency on information contained in |
131 | @@ -340,6 +340,11 @@ | |||
132 | 340 | Further checks on file contents and package consistency are done | 340 | Further checks on file contents and package consistency are done |
133 | 341 | in DSCFile. | 341 | in DSCFile. |
134 | 342 | """ | 342 | """ |
135 | 343 | |||
136 | 344 | @property | ||
137 | 345 | def filetype(self): | ||
138 | 346 | return determine_source_file_type(self.filename) | ||
139 | 347 | |||
140 | 343 | def verify(self): | 348 | def verify(self): |
141 | 344 | """Verify the uploaded source file. | 349 | """Verify the uploaded source file. |
142 | 345 | 350 | ||
143 | @@ -352,9 +357,7 @@ | |||
144 | 352 | "Architecture field." % (self.filename)) | 357 | "Architecture field." % (self.filename)) |
145 | 353 | 358 | ||
146 | 354 | version_chopped = re_no_epoch.sub('', self.version) | 359 | version_chopped = re_no_epoch.sub('', self.version) |
150 | 355 | if determine_source_file_type(self.filename) in ( | 360 | if self.is_orig: |
148 | 356 | SourcePackageFileType.ORIG_TARBALL, | ||
149 | 357 | SourcePackageFileType.COMPONENT_ORIG_TARBALL): | ||
151 | 358 | version_chopped = re_no_revision.sub('', version_chopped) | 361 | version_chopped = re_no_revision.sub('', version_chopped) |
152 | 359 | 362 | ||
153 | 360 | source_match = re_issource.match(self.filename) | 363 | source_match = re_issource.match(self.filename) |
154 | 361 | 364 | ||
155 | === modified file 'lib/lp/archiveuploader/tests/nascentuploadfile.txt' | |||
156 | --- lib/lp/archiveuploader/tests/nascentuploadfile.txt 2009-10-28 05:24:11 +0000 | |||
157 | +++ lib/lp/archiveuploader/tests/nascentuploadfile.txt 2009-11-26 00:36:18 +0000 | |||
158 | @@ -569,6 +569,115 @@ | |||
159 | 569 | ['File ed_0.2-20.dsc mentioned in the changes has a size mismatch. 578 != 500'] | 569 | ['File ed_0.2-20.dsc mentioned in the changes has a size mismatch. 578 != 500'] |
160 | 570 | 570 | ||
161 | 571 | 571 | ||
162 | 572 | === Format file type verification === | ||
163 | 573 | |||
164 | 574 | DSCFile performs additional verification on the types of the referenced | ||
165 | 575 | files, confirming that they are suitable for the source package's | ||
166 | 576 | format. There is an error generator to verify each format. | ||
167 | 577 | |||
168 | 578 | >>> from lp.archiveuploader.dscfile import (check_format_1_0_files, | ||
169 | 579 | ... check_format_3_0_native_files, check_format_3_0_quilt_files) | ||
170 | 580 | >>> from lp.registry.interfaces.sourcepackage import SourcePackageFileType | ||
171 | 581 | |||
172 | 582 | ==== 1.0 ==== | ||
173 | 583 | |||
174 | 584 | A 1.0 source can contain either a tar.gz or an orig.tar.gz and diff.gz. | ||
175 | 585 | |||
176 | 586 | >>> list(check_format_1_0_files('foo_1.dsc', { | ||
177 | 587 | ... SourcePackageFileType.ORIG_TARBALL: 1, | ||
178 | 588 | ... SourcePackageFileType.DIFF: 1, | ||
179 | 589 | ... SourcePackageFileType.DEBIAN_TARBALL: 0, | ||
180 | 590 | ... SourcePackageFileType.NATIVE_TARBALL: 0, | ||
181 | 591 | ... }, {}, 0)) | ||
182 | 592 | [] | ||
183 | 593 | |||
184 | 594 | >>> list(check_format_1_0_files('foo_1.dsc', { | ||
185 | 595 | ... SourcePackageFileType.NATIVE_TARBALL: 1, | ||
186 | 596 | ... SourcePackageFileType.ORIG_TARBALL: 0, | ||
187 | 597 | ... SourcePackageFileType.DIFF: 0, | ||
188 | 598 | ... SourcePackageFileType.DEBIAN_TARBALL: 0, | ||
189 | 599 | ... }, {}, 0)) | ||
190 | 600 | [] | ||
191 | 601 | |||
192 | 602 | But if we have some other combination, or bzip2 compression, errors | ||
193 | 603 | will be generated. | ||
194 | 604 | |||
195 | 605 | >>> list(check_format_1_0_files('foo_1.dsc', { | ||
196 | 606 | ... SourcePackageFileType.NATIVE_TARBALL: 1, | ||
197 | 607 | ... SourcePackageFileType.ORIG_TARBALL: 1, | ||
198 | 608 | ... SourcePackageFileType.DIFF: 1, | ||
199 | 609 | ... SourcePackageFileType.DEBIAN_TARBALL: 0, | ||
200 | 610 | ... }, {}, 1)) | ||
201 | 611 | [UploadError('foo_1.dsc: is format 1.0 but uses bzip2 compression.',), UploadError('foo_1.dsc: must have exactly one tar.gz, or an orig.tar.gz and diff.gz',)] | ||
202 | 612 | |||
203 | 613 | The files are also bad if there are any components: | ||
204 | 614 | |||
205 | 615 | >>> list(check_format_1_0_files('foo_1.dsc', { | ||
206 | 616 | ... SourcePackageFileType.ORIG_TARBALL: 1, | ||
207 | 617 | ... SourcePackageFileType.DIFF: 1, | ||
208 | 618 | ... SourcePackageFileType.DEBIAN_TARBALL: 0, | ||
209 | 619 | ... SourcePackageFileType.NATIVE_TARBALL: 0, | ||
210 | 620 | ... }, {'foo': 1}, 0)) | ||
211 | 621 | [UploadError('foo_1.dsc: must have exactly one tar.gz, or an orig.tar.gz and diff.gz',)] | ||
212 | 622 | |||
213 | 623 | ==== 3.0 (native) ==== | ||
214 | 624 | |||
215 | 625 | A 3.0 (native) source must contain just a tar.(gz|bz2). | ||
216 | 626 | |||
217 | 627 | >>> list(check_format_3_0_native_files('foo_1.dsc', { | ||
218 | 628 | ... SourcePackageFileType.NATIVE_TARBALL: 1, | ||
219 | 629 | ... SourcePackageFileType.ORIG_TARBALL: 0, | ||
220 | 630 | ... SourcePackageFileType.DIFF: 0, | ||
221 | 631 | ... SourcePackageFileType.DEBIAN_TARBALL: 0, | ||
222 | 632 | ... }, {}, 1)) | ||
223 | 633 | [] | ||
224 | 634 | |||
225 | 635 | >>> list(check_format_3_0_native_files('foo_1.dsc', { | ||
226 | 636 | ... SourcePackageFileType.NATIVE_TARBALL: 1, | ||
227 | 637 | ... SourcePackageFileType.ORIG_TARBALL: 1, | ||
228 | 638 | ... SourcePackageFileType.DIFF: 0, | ||
229 | 639 | ... SourcePackageFileType.DEBIAN_TARBALL: 0, | ||
230 | 640 | ... }, {}, 1)) | ||
231 | 641 | [UploadError('foo_1.dsc: must have only a tar.*.',)] | ||
232 | 642 | |||
233 | 643 | >>> list(check_format_3_0_native_files('foo_1.dsc', { | ||
234 | 644 | ... SourcePackageFileType.NATIVE_TARBALL: 1, | ||
235 | 645 | ... SourcePackageFileType.ORIG_TARBALL: 0, | ||
236 | 646 | ... SourcePackageFileType.DIFF: 0, | ||
237 | 647 | ... SourcePackageFileType.DEBIAN_TARBALL: 0, | ||
238 | 648 | ... }, {'foo': 1}, 0)) | ||
239 | 649 | [UploadError('foo_1.dsc: must have only a tar.*.',)] | ||
240 | 650 | |||
241 | 651 | ==== 3.0 (quilt) ==== | ||
242 | 652 | |||
243 | 653 | A 3.0 (quilt) source must have an orig.tar.*, a debian.tar.*, and at | ||
244 | 654 | most one orig-COMPONENT.tar.* for each COMPONENT. | ||
245 | 655 | |||
246 | 656 | >>> list(check_format_3_0_quilt_files('foo_1.dsc', { | ||
247 | 657 | ... SourcePackageFileType.ORIG_TARBALL: 1, | ||
248 | 658 | ... SourcePackageFileType.DEBIAN_TARBALL: 1, | ||
249 | 659 | ... SourcePackageFileType.NATIVE_TARBALL: 0, | ||
250 | 660 | ... SourcePackageFileType.DIFF: 0, | ||
251 | 661 | ... }, {'foo': 1}, 1)) | ||
252 | 662 | [] | ||
253 | 663 | |||
254 | 664 | >>> list(check_format_3_0_quilt_files('foo_1.dsc', { | ||
255 | 665 | ... SourcePackageFileType.NATIVE_TARBALL: 1, | ||
256 | 666 | ... SourcePackageFileType.ORIG_TARBALL: 1, | ||
257 | 667 | ... SourcePackageFileType.DIFF: 0, | ||
258 | 668 | ... SourcePackageFileType.DEBIAN_TARBALL: 1, | ||
259 | 669 | ... }, {}, 1)) | ||
260 | 670 | [UploadError('foo_1.dsc: must have only an orig.tar.*, a debian.tar.*, and optionally orig-*.tar.*',)] | ||
261 | 671 | |||
262 | 672 | >>> list(check_format_3_0_quilt_files('foo_1.dsc', { | ||
263 | 673 | ... SourcePackageFileType.ORIG_TARBALL: 1, | ||
264 | 674 | ... SourcePackageFileType.DEBIAN_TARBALL: 1, | ||
265 | 675 | ... SourcePackageFileType.NATIVE_TARBALL: 0, | ||
266 | 676 | ... SourcePackageFileType.DIFF: 0, | ||
267 | 677 | ... }, {'foo': 2}, 0)) | ||
268 | 678 | [UploadError('foo_1.dsc: has more than one orig-foo.tar.*.',)] | ||
269 | 679 | |||
270 | 680 | |||
271 | 572 | === Sub-DSC files or DSCUploadedFiles === | 681 | === Sub-DSC files or DSCUploadedFiles === |
272 | 573 | 682 | ||
273 | 574 | Sub-DSCFiles are DSCUploadedFile objects. | 683 | Sub-DSCFiles are DSCUploadedFile objects. |
274 | 575 | 684 | ||
275 | === modified file 'lib/lp/soyuz/interfaces/files.py' | |||
276 | --- lib/lp/soyuz/interfaces/files.py 2009-06-25 04:06:00 +0000 | |||
277 | +++ lib/lp/soyuz/interfaces/files.py 2009-11-25 23:23:30 +0000 | |||
278 | @@ -14,7 +14,7 @@ | |||
279 | 14 | 'ISourcePackageReleaseFileSet', | 14 | 'ISourcePackageReleaseFileSet', |
280 | 15 | ] | 15 | ] |
281 | 16 | 16 | ||
283 | 17 | from zope.schema import Int | 17 | from zope.schema import Bool, Int |
284 | 18 | from zope.interface import Interface | 18 | from zope.interface import Interface |
285 | 19 | from canonical.launchpad import _ | 19 | from canonical.launchpad import _ |
286 | 20 | 20 | ||
287 | @@ -68,6 +68,11 @@ | |||
288 | 68 | title=_('The type of this file'), required=True, readonly=False, | 68 | title=_('The type of this file'), required=True, readonly=False, |
289 | 69 | ) | 69 | ) |
290 | 70 | 70 | ||
291 | 71 | is_orig = Bool( | ||
292 | 72 | title=_('Whether this file is an original tarball'), | ||
293 | 73 | required=True, readonly=False, | ||
294 | 74 | ) | ||
295 | 75 | |||
296 | 71 | 76 | ||
297 | 72 | class ISourcePackageReleaseFileSet(Interface): | 77 | class ISourcePackageReleaseFileSet(Interface): |
298 | 73 | """The set of all `SourcePackageRelease`s.""" | 78 | """The set of all `SourcePackageRelease`s.""" |
299 | 74 | 79 | ||
300 | === modified file 'lib/lp/soyuz/model/files.py' | |||
301 | --- lib/lp/soyuz/model/files.py 2009-06-25 04:06:00 +0000 | |||
302 | +++ lib/lp/soyuz/model/files.py 2009-11-25 23:38:57 +0000 | |||
303 | @@ -60,7 +60,18 @@ | |||
304 | 60 | "binarypackagerelease.binarypackagename"]) | 60 | "binarypackagerelease.binarypackagename"]) |
305 | 61 | 61 | ||
306 | 62 | 62 | ||
308 | 63 | class SourcePackageReleaseFile(SQLBase): | 63 | class SourceFileMixin: |
309 | 64 | """Mix-in class for common functionality between source file classes.""" | ||
310 | 65 | |||
311 | 66 | @property | ||
312 | 67 | def is_orig(self): | ||
313 | 68 | return self.filetype in ( | ||
314 | 69 | SourcePackageFileType.ORIG_TARBALL, | ||
315 | 70 | SourcePackageFileType.COMPONENT_ORIG_TARBALL | ||
316 | 71 | ) | ||
317 | 72 | |||
318 | 73 | |||
319 | 74 | class SourcePackageReleaseFile(SourceFileMixin, SQLBase): | ||
320 | 64 | """See ISourcePackageFile""" | 75 | """See ISourcePackageFile""" |
321 | 65 | 76 | ||
322 | 66 | implements(ISourcePackageReleaseFile) | 77 | implements(ISourcePackageReleaseFile) |
323 | @@ -90,4 +101,3 @@ | |||
324 | 90 | prejoins=["libraryfile", "libraryfile.content", | 101 | prejoins=["libraryfile", "libraryfile.content", |
325 | 91 | "sourcepackagerelease", | 102 | "sourcepackagerelease", |
326 | 92 | "sourcepackagerelease.sourcepackagename"]) | 103 | "sourcepackagerelease.sourcepackagename"]) |
327 | 93 | |||
328 | 94 | 104 | ||
329 | === modified file 'lib/lp/soyuz/model/queue.py' | |||
330 | --- lib/lp/soyuz/model/queue.py 2009-11-14 02:55:15 +0000 | |||
331 | +++ lib/lp/soyuz/model/queue.py 2009-11-25 23:36:55 +0000 | |||
332 | @@ -61,7 +61,6 @@ | |||
333 | 61 | NonBuildableSourceUploadError, QueueBuildAcceptError, | 61 | NonBuildableSourceUploadError, QueueBuildAcceptError, |
334 | 62 | QueueInconsistentStateError, QueueSourceAcceptError, | 62 | QueueInconsistentStateError, QueueSourceAcceptError, |
335 | 63 | QueueStateWriteProtectedError) | 63 | QueueStateWriteProtectedError) |
336 | 64 | from lp.registry.interfaces.sourcepackage import SourcePackageFileType | ||
337 | 65 | from canonical.launchpad.mail import ( | 64 | from canonical.launchpad.mail import ( |
338 | 66 | format_address, signed_message_from_string, sendmail) | 65 | format_address, signed_message_from_string, sendmail) |
339 | 67 | from lp.soyuz.scripts.processaccepted import ( | 66 | from lp.soyuz.scripts.processaccepted import ( |
340 | @@ -1468,9 +1467,7 @@ | |||
341 | 1468 | published_sha1 = published_file.content.sha1 | 1467 | published_sha1 = published_file.content.sha1 |
342 | 1469 | 1468 | ||
343 | 1470 | # Multiple orig(s) with the same content are fine. | 1469 | # Multiple orig(s) with the same content are fine. |
347 | 1471 | if source_file.filetype in ( | 1470 | if source_file.is_orig: |
345 | 1472 | SourcePackageFileType.ORIG_TARBALL, | ||
346 | 1473 | SourcePackageFileType.COMPONENT_ORIG_TARBALL): | ||
348 | 1474 | if proposed_sha1 == published_sha1: | 1471 | if proposed_sha1 == published_sha1: |
349 | 1475 | continue | 1472 | continue |
350 | 1476 | raise QueueInconsistentStateError( | 1473 | raise QueueInconsistentStateError( |
Julian Edwards (julian-edwards) wrote : | # |
Looks good! Sorry for the delay in replying. I'll catch up with you about this my Monday morning.
Preview Diff
1 | === modified file 'lib/lp/archiveuploader/dscfile.py' | |||
2 | --- lib/lp/archiveuploader/dscfile.py 2009-11-16 22:06:14 +0000 | |||
3 | +++ lib/lp/archiveuploader/dscfile.py 2009-12-12 05:58:17 +0000 | |||
4 | @@ -30,9 +30,9 @@ | |||
5 | 30 | from lp.archiveuploader.tagfiles import ( | 30 | from lp.archiveuploader.tagfiles import ( |
6 | 31 | parse_tagfile, TagFileParseError) | 31 | parse_tagfile, TagFileParseError) |
7 | 32 | from lp.archiveuploader.utils import ( | 32 | from lp.archiveuploader.utils import ( |
11 | 33 | prefix_multi_line_string, safe_fix_maintainer, ParseMaintError, | 33 | determine_source_file_type, get_source_file_extension, |
12 | 34 | re_valid_pkg_name, re_valid_version, re_issource, | 34 | ParseMaintError, prefix_multi_line_string, re_is_component_orig_tar_ext, |
13 | 35 | determine_source_file_type) | 35 | re_issource, re_valid_pkg_name, re_valid_version, safe_fix_maintainer) |
14 | 36 | from canonical.encoding import guess as guess_encoding | 36 | from canonical.encoding import guess as guess_encoding |
15 | 37 | from lp.registry.interfaces.person import IPersonSet, PersonCreationRationale | 37 | from lp.registry.interfaces.person import IPersonSet, PersonCreationRationale |
16 | 38 | from lp.registry.interfaces.sourcepackage import SourcePackageFileType | 38 | from lp.registry.interfaces.sourcepackage import SourcePackageFileType |
17 | @@ -160,6 +160,9 @@ | |||
18 | 160 | 160 | ||
19 | 161 | Can raise UploadError. | 161 | Can raise UploadError. |
20 | 162 | """ | 162 | """ |
21 | 163 | # Avoid circular imports. | ||
22 | 164 | from lp.archiveuploader.nascentupload import EarlyReturnUploadError | ||
23 | 165 | |||
24 | 163 | SourceUploadFile.__init__( | 166 | SourceUploadFile.__init__( |
25 | 164 | self, filepath, digest, size, component_and_section, priority, | 167 | self, filepath, digest, size, component_and_section, priority, |
26 | 165 | package, version, changes, policy, logger) | 168 | package, version, changes, policy, logger) |
27 | @@ -186,6 +189,10 @@ | |||
28 | 186 | if 'format' not in self._dict: | 189 | if 'format' not in self._dict: |
29 | 187 | self._dict['format'] = "1.0" | 190 | self._dict['format'] = "1.0" |
30 | 188 | 191 | ||
31 | 192 | if self.format is None: | ||
32 | 193 | raise EarlyReturnUploadError( | ||
33 | 194 | "Unsupported source format: %s" % self._dict['format']) | ||
34 | 195 | |||
35 | 189 | if self.policy.unsigned_dsc_ok: | 196 | if self.policy.unsigned_dsc_ok: |
36 | 190 | self.logger.debug("DSC file can be unsigned.") | 197 | self.logger.debug("DSC file can be unsigned.") |
37 | 191 | else: | 198 | else: |
38 | @@ -208,7 +215,11 @@ | |||
39 | 208 | @property | 215 | @property |
40 | 209 | def format(self): | 216 | def format(self): |
41 | 210 | """Return the DSC format.""" | 217 | """Return the DSC format.""" |
43 | 211 | return self._dict['format'] | 218 | try: |
44 | 219 | return SourcePackageFormat.getTermByToken( | ||
45 | 220 | self._dict['format']).value | ||
46 | 221 | except LookupError: | ||
47 | 222 | return None | ||
48 | 212 | 223 | ||
49 | 213 | @property | 224 | @property |
50 | 214 | def architecture(self): | 225 | def architecture(self): |
51 | @@ -231,8 +242,6 @@ | |||
52 | 231 | This method is an error generator, i.e, it returns an iterator over all | 242 | This method is an error generator, i.e, it returns an iterator over all |
53 | 232 | exceptions that are generated while processing DSC file checks. | 243 | exceptions that are generated while processing DSC file checks. |
54 | 233 | """ | 244 | """ |
55 | 234 | # Avoid circular imports. | ||
56 | 235 | from lp.archiveuploader.nascentupload import EarlyReturnUploadError | ||
57 | 236 | 245 | ||
58 | 237 | for error in SourceUploadFile.verify(self): | 246 | for error in SourceUploadFile.verify(self): |
59 | 238 | yield error | 247 | yield error |
60 | @@ -271,14 +280,8 @@ | |||
61 | 271 | yield UploadError( | 280 | yield UploadError( |
62 | 272 | "%s: invalid version %s" % (self.filename, self.dsc_version)) | 281 | "%s: invalid version %s" % (self.filename, self.dsc_version)) |
63 | 273 | 282 | ||
64 | 274 | try: | ||
65 | 275 | format_term = SourcePackageFormat.getTermByToken(self.format) | ||
66 | 276 | except LookupError: | ||
67 | 277 | raise EarlyReturnUploadError( | ||
68 | 278 | "Unsupported source format: %s" % self.format) | ||
69 | 279 | |||
70 | 280 | if not self.policy.distroseries.isSourcePackageFormatPermitted( | 283 | if not self.policy.distroseries.isSourcePackageFormatPermitted( |
72 | 281 | format_term.value): | 284 | self.format): |
73 | 282 | yield UploadError( | 285 | yield UploadError( |
74 | 283 | "%s: format '%s' is not permitted in %s." % | 286 | "%s: format '%s' is not permitted in %s." % |
75 | 284 | (self.filename, self.format, self.policy.distroseries.name)) | 287 | (self.filename, self.format, self.policy.distroseries.name)) |
76 | @@ -347,8 +350,9 @@ | |||
77 | 347 | distribution=self.policy.distro, | 350 | distribution=self.policy.distro, |
78 | 348 | purpose=ArchivePurpose.PARTNER)] | 351 | purpose=ArchivePurpose.PARTNER)] |
79 | 349 | elif (self.policy.archive.purpose == ArchivePurpose.PPA and | 352 | elif (self.policy.archive.purpose == ArchivePurpose.PPA and |
82 | 350 | determine_source_file_type(filename) == | 353 | determine_source_file_type(filename) in ( |
83 | 351 | SourcePackageFileType.ORIG_TARBALL): | 354 | SourcePackageFileType.ORIG_TARBALL, |
84 | 355 | SourcePackageFileType.COMPONENT_ORIG_TARBALL)): | ||
85 | 352 | archives = [self.policy.archive, self.policy.distro.main_archive] | 356 | archives = [self.policy.archive, self.policy.distro.main_archive] |
86 | 353 | else: | 357 | else: |
87 | 354 | archives = [self.policy.archive] | 358 | archives = [self.policy.archive] |
88 | @@ -373,24 +377,36 @@ | |||
89 | 373 | and checksum. | 377 | and checksum. |
90 | 374 | """ | 378 | """ |
91 | 375 | 379 | ||
96 | 376 | diff_count = 0 | 380 | file_type_counts = { |
97 | 377 | orig_tar_count = 0 | 381 | SourcePackageFileType.DIFF: 0, |
98 | 378 | native_tar_count = 0 | 382 | SourcePackageFileType.ORIG_TARBALL: 0, |
99 | 379 | 383 | SourcePackageFileType.DEBIAN_TARBALL: 0, | |
100 | 384 | SourcePackageFileType.NATIVE_TARBALL: 0, | ||
101 | 385 | } | ||
102 | 386 | component_orig_tar_counts = {} | ||
103 | 387 | bzip2_count = 0 | ||
104 | 380 | files_missing = False | 388 | files_missing = False |
105 | 389 | |||
106 | 381 | for sub_dsc_file in self.files: | 390 | for sub_dsc_file in self.files: |
108 | 382 | filetype = determine_source_file_type(sub_dsc_file.filename) | 391 | file_type = determine_source_file_type(sub_dsc_file.filename) |
109 | 383 | 392 | ||
117 | 384 | if filetype == SourcePackageFileType.DIFF: | 393 | if file_type is None: |
111 | 385 | diff_count += 1 | ||
112 | 386 | elif filetype == SourcePackageFileType.ORIG_TARBALL: | ||
113 | 387 | orig_tar_count += 1 | ||
114 | 388 | elif filetype == SourcePackageFileType.NATIVE_TARBALL: | ||
115 | 389 | native_tar_count += 1 | ||
116 | 390 | else: | ||
118 | 391 | yield UploadError('Unknown file: ' + sub_dsc_file.filename) | 394 | yield UploadError('Unknown file: ' + sub_dsc_file.filename) |
119 | 392 | continue | 395 | continue |
120 | 393 | 396 | ||
121 | 397 | if file_type == SourcePackageFileType.COMPONENT_ORIG_TARBALL: | ||
122 | 398 | # Split the count by component name. | ||
123 | 399 | component = re_is_component_orig_tar_ext.match( | ||
124 | 400 | get_source_file_extension(sub_dsc_file.filename)).group(1) | ||
125 | 401 | if component not in component_orig_tar_counts: | ||
126 | 402 | component_orig_tar_counts[component] = 0 | ||
127 | 403 | component_orig_tar_counts[component] += 1 | ||
128 | 404 | else: | ||
129 | 405 | file_type_counts[file_type] += 1 | ||
130 | 406 | |||
131 | 407 | if sub_dsc_file.filename.endswith('.bz2'): | ||
132 | 408 | bzip2_count += 1 | ||
133 | 409 | |||
134 | 394 | try: | 410 | try: |
135 | 395 | library_file, file_archive = self._getFileByName( | 411 | library_file, file_archive = self._getFileByName( |
136 | 396 | sub_dsc_file.filename) | 412 | sub_dsc_file.filename) |
137 | @@ -435,37 +451,16 @@ | |||
138 | 435 | yield error | 451 | yield error |
139 | 436 | files_missing = True | 452 | files_missing = True |
140 | 437 | 453 | ||
172 | 438 | # Reject if we have more than one file of any type. | 454 | try: |
173 | 439 | if orig_tar_count > 1: | 455 | file_checker = format_to_file_checker_map[self.format] |
174 | 440 | yield UploadError( | 456 | except KeyError: |
175 | 441 | "%s: has more than one orig.tar.*." | 457 | raise AssertionError( |
176 | 442 | % self.filename) | 458 | "No file checker for source format %s." % self.format) |
177 | 443 | if native_tar_count > 1: | 459 | |
178 | 444 | yield UploadError( | 460 | for error in file_checker( |
179 | 445 | "%s: has more than one tar.*." | 461 | self.filename, file_type_counts, component_orig_tar_counts, |
180 | 446 | % self.filename) | 462 | bzip2_count): |
181 | 447 | if diff_count > 1: | 463 | yield error |
151 | 448 | yield UploadError( | ||
152 | 449 | "%s: has more than one diff.gz." | ||
153 | 450 | % self.filename) | ||
154 | 451 | |||
155 | 452 | if ((orig_tar_count == 0 and native_tar_count == 0) or | ||
156 | 453 | (orig_tar_count > 0 and native_tar_count > 0)): | ||
157 | 454 | yield UploadError( | ||
158 | 455 | "%s: must have exactly one tar.* or orig.tar.*." | ||
159 | 456 | % self.filename) | ||
160 | 457 | |||
161 | 458 | # Format 1.0 must be native (exactly one tar.gz), or | ||
162 | 459 | # have an orig.tar.gz and a diff.gz. It cannot have | ||
163 | 460 | # compression types other than 'gz'. | ||
164 | 461 | if self.format == '1.0': | ||
165 | 462 | if ((diff_count == 0 and native_tar_count == 0) or | ||
166 | 463 | (diff_count > 0 and native_tar_count > 0)): | ||
167 | 464 | yield UploadError( | ||
168 | 465 | "%s: must have exactly one diff.gz or tar.gz." | ||
169 | 466 | % self.filename) | ||
170 | 467 | else: | ||
171 | 468 | raise AssertionError("Unknown source format.") | ||
182 | 469 | 464 | ||
183 | 470 | if files_missing: | 465 | if files_missing: |
184 | 471 | yield UploadError( | 466 | yield UploadError( |
185 | @@ -648,3 +643,94 @@ | |||
186 | 648 | yield error | 643 | yield error |
187 | 649 | 644 | ||
188 | 650 | 645 | ||
189 | 646 | def check_format_1_0_files(filename, file_type_counts, component_counts, | ||
190 | 647 | bzip2_count): | ||
191 | 648 | """Check that the given counts of each file type suit format 1.0. | ||
192 | 649 | |||
193 | 650 | A 1.0 source must be native (with only one tar.gz), or have an orig.tar.gz | ||
194 | 651 | and a diff.gz. It cannot use bzip2 compression. | ||
195 | 652 | """ | ||
196 | 653 | if bzip2_count > 0: | ||
197 | 654 | yield UploadError( | ||
198 | 655 | "%s: is format 1.0 but uses bzip2 compression." | ||
199 | 656 | % filename) | ||
200 | 657 | |||
201 | 658 | valid_file_type_counts = [ | ||
202 | 659 | { | ||
203 | 660 | SourcePackageFileType.NATIVE_TARBALL: 1, | ||
204 | 661 | SourcePackageFileType.ORIG_TARBALL: 0, | ||
205 | 662 | SourcePackageFileType.DEBIAN_TARBALL: 0, | ||
206 | 663 | SourcePackageFileType.DIFF: 0, | ||
207 | 664 | }, | ||
208 | 665 | { | ||
209 | 666 | SourcePackageFileType.ORIG_TARBALL: 1, | ||
210 | 667 | SourcePackageFileType.DIFF: 1, | ||
211 | 668 | SourcePackageFileType.NATIVE_TARBALL: 0, | ||
212 | 669 | SourcePackageFileType.DEBIAN_TARBALL: 0, | ||
213 | 670 | }, | ||
214 | 671 | ] | ||
215 | 672 | |||
216 | 673 | if (file_type_counts not in valid_file_type_counts or | ||
217 | 674 | len(component_counts) > 0): | ||
218 | 675 | yield UploadError( | ||
219 | 676 | "%s: must have exactly one tar.gz, or an orig.tar.gz and diff.gz" | ||
220 | 677 | % filename) | ||
221 | 678 | |||
222 | 679 | |||
223 | 680 | def check_format_3_0_native_files(filename, file_type_counts, | ||
224 | 681 | component_counts, bzip2_count): | ||
225 | 682 | """Check that the given counts of each file type suit format 3.0 (native). | ||
226 | 683 | |||
227 | 684 | A 3.0 (native) source must have only one tar.*. Both gzip and bzip2 | ||
228 | 685 | compression are permissible. | ||
229 | 686 | """ | ||
230 | 687 | |||
231 | 688 | valid_file_type_counts = [ | ||
232 | 689 | { | ||
233 | 690 | SourcePackageFileType.NATIVE_TARBALL: 1, | ||
234 | 691 | SourcePackageFileType.ORIG_TARBALL: 0, | ||
235 | 692 | SourcePackageFileType.DEBIAN_TARBALL: 0, | ||
236 | 693 | SourcePackageFileType.DIFF: 0, | ||
237 | 694 | }, | ||
238 | 695 | ] | ||
239 | 696 | |||
240 | 697 | if (file_type_counts not in valid_file_type_counts or | ||
241 | 698 | len(component_counts) > 0): | ||
242 | 699 | yield UploadError("%s: must have only a tar.*." % filename) | ||
243 | 700 | |||
244 | 701 | |||
245 | 702 | def check_format_3_0_quilt_files(filename, file_type_counts, | ||
246 | 703 | component_counts, bzip2_count): | ||
247 | 704 | """Check that the given counts of each file type suit format 3.0 (native). | ||
248 | 705 | |||
249 | 706 | A 3.0 (quilt) source must have exactly one orig.tar.*, one debian.tar.*, | ||
250 | 707 | and at most one orig-COMPONENT.tar.* for each COMPONENT. Both gzip and | ||
251 | 708 | bzip2 compression are permissible. | ||
252 | 709 | """ | ||
253 | 710 | |||
254 | 711 | valid_file_type_counts = [ | ||
255 | 712 | { | ||
256 | 713 | SourcePackageFileType.ORIG_TARBALL: 1, | ||
257 | 714 | SourcePackageFileType.DEBIAN_TARBALL: 1, | ||
258 | 715 | SourcePackageFileType.NATIVE_TARBALL: 0, | ||
259 | 716 | SourcePackageFileType.DIFF: 0, | ||
260 | 717 | }, | ||
261 | 718 | ] | ||
262 | 719 | |||
263 | 720 | if file_type_counts not in valid_file_type_counts: | ||
264 | 721 | yield UploadError( | ||
265 | 722 | "%s: must have only an orig.tar.*, a debian.tar.*, and " | ||
266 | 723 | "optionally orig-*.tar.*" % filename) | ||
267 | 724 | |||
268 | 725 | for component in component_counts: | ||
269 | 726 | if component_counts[component] > 1: | ||
270 | 727 | yield UploadError( | ||
271 | 728 | "%s: has more than one orig-%s.tar.*." | ||
272 | 729 | % (filename, component)) | ||
273 | 730 | |||
274 | 731 | |||
275 | 732 | format_to_file_checker_map = { | ||
276 | 733 | SourcePackageFormat.FORMAT_1_0: check_format_1_0_files, | ||
277 | 734 | SourcePackageFormat.FORMAT_3_0_NATIVE: check_format_3_0_native_files, | ||
278 | 735 | SourcePackageFormat.FORMAT_3_0_QUILT: check_format_3_0_quilt_files, | ||
279 | 736 | } | ||
280 | 651 | 737 | ||
281 | === modified file 'lib/lp/archiveuploader/nascentuploadfile.py' | |||
282 | --- lib/lp/archiveuploader/nascentuploadfile.py 2009-12-07 10:53:13 +0000 | |||
283 | +++ lib/lp/archiveuploader/nascentuploadfile.py 2009-12-12 05:58:17 +0000 | |||
284 | @@ -35,7 +35,6 @@ | |||
285 | 35 | re_no_epoch, re_no_revision, re_valid_version, re_valid_pkg_name, | 35 | re_no_epoch, re_no_revision, re_valid_version, re_valid_pkg_name, |
286 | 36 | re_extract_src_version, determine_source_file_type) | 36 | re_extract_src_version, determine_source_file_type) |
287 | 37 | from canonical.encoding import guess as guess_encoding | 37 | from canonical.encoding import guess as guess_encoding |
288 | 38 | from lp.registry.interfaces.sourcepackage import SourcePackageFileType | ||
289 | 39 | from lp.soyuz.interfaces.binarypackagename import ( | 38 | from lp.soyuz.interfaces.binarypackagename import ( |
290 | 40 | IBinaryPackageNameSet) | 39 | IBinaryPackageNameSet) |
291 | 41 | from lp.soyuz.interfaces.binarypackagerelease import ( | 40 | from lp.soyuz.interfaces.binarypackagerelease import ( |
292 | @@ -49,6 +48,7 @@ | |||
293 | 49 | from lp.soyuz.interfaces.publishing import ( | 48 | from lp.soyuz.interfaces.publishing import ( |
294 | 50 | PackagePublishingPriority) | 49 | PackagePublishingPriority) |
295 | 51 | from lp.soyuz.interfaces.section import ISectionSet | 50 | from lp.soyuz.interfaces.section import ISectionSet |
296 | 51 | from lp.soyuz.model.files import SourceFileMixin | ||
297 | 52 | from canonical.librarian.utils import filechunks | 52 | from canonical.librarian.utils import filechunks |
298 | 53 | 53 | ||
299 | 54 | 54 | ||
300 | @@ -332,7 +332,7 @@ | |||
301 | 332 | return getUtility(ISectionSet)[self.section_name] | 332 | return getUtility(ISectionSet)[self.section_name] |
302 | 333 | 333 | ||
303 | 334 | 334 | ||
305 | 335 | class SourceUploadFile(PackageUploadFile): | 335 | class SourceUploadFile(SourceFileMixin, PackageUploadFile): |
306 | 336 | """Files mentioned in changesfile as source (orig, diff, tar). | 336 | """Files mentioned in changesfile as source (orig, diff, tar). |
307 | 337 | 337 | ||
308 | 338 | This class only check consistency on information contained in | 338 | This class only check consistency on information contained in |
309 | @@ -340,6 +340,11 @@ | |||
310 | 340 | Further checks on file contents and package consistency are done | 340 | Further checks on file contents and package consistency are done |
311 | 341 | in DSCFile. | 341 | in DSCFile. |
312 | 342 | """ | 342 | """ |
313 | 343 | |||
314 | 344 | @property | ||
315 | 345 | def filetype(self): | ||
316 | 346 | return determine_source_file_type(self.filename) | ||
317 | 347 | |||
318 | 343 | def verify(self): | 348 | def verify(self): |
319 | 344 | """Verify the uploaded source file. | 349 | """Verify the uploaded source file. |
320 | 345 | 350 | ||
321 | @@ -352,8 +357,7 @@ | |||
322 | 352 | "Architecture field." % (self.filename)) | 357 | "Architecture field." % (self.filename)) |
323 | 353 | 358 | ||
324 | 354 | version_chopped = re_no_epoch.sub('', self.version) | 359 | version_chopped = re_no_epoch.sub('', self.version) |
327 | 355 | if determine_source_file_type(self.filename) == ( | 360 | if self.is_orig: |
326 | 356 | SourcePackageFileType.ORIG_TARBALL): | ||
328 | 357 | version_chopped = re_no_revision.sub('', version_chopped) | 361 | version_chopped = re_no_revision.sub('', version_chopped) |
329 | 358 | 362 | ||
330 | 359 | source_match = re_issource.match(self.filename) | 363 | source_match = re_issource.match(self.filename) |
331 | 360 | 364 | ||
332 | === added directory 'lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_1.0-bzip2' | |||
333 | === added file 'lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_1.0-bzip2/bar_1.0-1.diff.gz' | |||
334 | 361 | Binary files lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_1.0-bzip2/bar_1.0-1.diff.gz 1970-01-01 00:00:00 +0000 and lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_1.0-bzip2/bar_1.0-1.diff.gz 2009-12-12 05:58:17 +0000 differ | 365 | Binary files lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_1.0-bzip2/bar_1.0-1.diff.gz 1970-01-01 00:00:00 +0000 and lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_1.0-bzip2/bar_1.0-1.diff.gz 2009-12-12 05:58:17 +0000 differ |
335 | === added file 'lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_1.0-bzip2/bar_1.0-1.dsc' | |||
336 | --- lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_1.0-bzip2/bar_1.0-1.dsc 1970-01-01 00:00:00 +0000 | |||
337 | +++ lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_1.0-bzip2/bar_1.0-1.dsc 2009-12-12 05:58:17 +0000 | |||
338 | @@ -0,0 +1,10 @@ | |||
339 | 1 | Format: 1.0 | ||
340 | 2 | Source: bar | ||
341 | 3 | Version: 1.0-1 | ||
342 | 4 | Binary: bar | ||
343 | 5 | Maintainer: Launchpad team <launchpad@lists.canonical.com> | ||
344 | 6 | Architecture: any | ||
345 | 7 | Standards-Version: 3.6.2 | ||
346 | 8 | Files: | ||
347 | 9 | f1b3ab12b2d0886bc5d87737bb933b83 170 bar_1.0.orig.tar.bz2 | ||
348 | 10 | 1e35b810764f140af9616de8274e6e73 537 bar_1.0-1.diff.gz | ||
349 | 0 | 11 | ||
350 | === added file 'lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_1.0-bzip2/bar_1.0-1_source.changes' | |||
351 | --- lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_1.0-bzip2/bar_1.0-1_source.changes 1970-01-01 00:00:00 +0000 | |||
352 | +++ lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_1.0-bzip2/bar_1.0-1_source.changes 2009-12-12 05:58:17 +0000 | |||
353 | @@ -0,0 +1,20 @@ | |||
354 | 1 | Format: 1.7 | ||
355 | 2 | Date: Thu, 16 Feb 2006 15:34:09 +0000 | ||
356 | 3 | Source: bar | ||
357 | 4 | Binary: bar | ||
358 | 5 | Architecture: source | ||
359 | 6 | Version: 1.0-1 | ||
360 | 7 | Distribution: breezy | ||
361 | 8 | Urgency: low | ||
362 | 9 | Maintainer: Launchpad team <launchpad@lists.canonical.com> | ||
363 | 10 | Changed-By: Daniel Silverstone <daniel.silverstone@canonical.com> | ||
364 | 11 | Description: | ||
365 | 12 | bar - Stuff for testing | ||
366 | 13 | Changes: | ||
367 | 14 | bar (1.0-1) breezy; urgency=low | ||
368 | 15 | . | ||
369 | 16 | * Initial version | ||
370 | 17 | Files: | ||
371 | 18 | 8e34d4e135decd09145c08a78a2a61ff 276 devel optional bar_1.0-1.dsc | ||
372 | 19 | f1b3ab12b2d0886bc5d87737bb933b83 170 devel optional bar_1.0.orig.tar.bz2 | ||
373 | 20 | 1e35b810764f140af9616de8274e6e73 537 devel optional bar_1.0-1.diff.gz | ||
374 | 0 | 21 | ||
375 | === added file 'lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_1.0-bzip2/bar_1.0.orig.tar.bz2' | |||
376 | 1 | Binary files lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_1.0-bzip2/bar_1.0.orig.tar.bz2 1970-01-01 00:00:00 +0000 and lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_1.0-bzip2/bar_1.0.orig.tar.bz2 2009-12-12 05:58:17 +0000 differ | 22 | Binary files lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_1.0-bzip2/bar_1.0.orig.tar.bz2 1970-01-01 00:00:00 +0000 and lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_1.0-bzip2/bar_1.0.orig.tar.bz2 2009-12-12 05:58:17 +0000 differ |
377 | === added file 'lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1.debian.tar.bz2' | |||
378 | 2 | Binary files lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1.debian.tar.bz2 1970-01-01 00:00:00 +0000 and lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1.debian.tar.bz2 2009-12-12 05:58:17 +0000 differ | 23 | Binary files lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1.debian.tar.bz2 1970-01-01 00:00:00 +0000 and lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1.debian.tar.bz2 2009-12-12 05:58:17 +0000 differ |
379 | === removed file 'lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1.debian.tar.gz' | |||
380 | 3 | Binary files lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1.debian.tar.gz 2009-11-12 11:54:56 +0000 and lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1.debian.tar.gz 1970-01-01 00:00:00 +0000 differ | 24 | Binary files lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1.debian.tar.gz 2009-11-12 11:54:56 +0000 and lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1.debian.tar.gz 1970-01-01 00:00:00 +0000 differ |
381 | === modified file 'lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1.dsc' | |||
382 | --- lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1.dsc 2009-11-12 11:54:56 +0000 | |||
383 | +++ lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1.dsc 2009-12-12 05:58:17 +0000 | |||
384 | @@ -6,11 +6,17 @@ | |||
385 | 6 | Maintainer: Launchpad team <launchpad@lists.canonical.com> | 6 | Maintainer: Launchpad team <launchpad@lists.canonical.com> |
386 | 7 | Standards-Version: 3.6.2 | 7 | Standards-Version: 3.6.2 |
387 | 8 | Checksums-Sha1: | 8 | Checksums-Sha1: |
388 | 9 | e7a106587e0f11220e27ccc5db7527cae05e4054 178 bar_1.0.orig-comp1.tar.gz | ||
389 | 10 | a645cc0856469f549f11bb9bdc4ca6dda4eedd4b 156 bar_1.0.orig-comp2.tar.bz2 | ||
390 | 9 | 73a04163fee97fd2257ab266bd48f1d3d528e012 164 bar_1.0.orig.tar.gz | 11 | 73a04163fee97fd2257ab266bd48f1d3d528e012 164 bar_1.0.orig.tar.gz |
392 | 10 | abce262314a7c0ca00e43598f21b41a3e6ff6b21 688 bar_1.0-1.debian.tar.gz | 12 | 727de2395d3a3e35c375159db01072935fea02f8 737 bar_1.0-1.debian.tar.bz2 |
393 | 11 | Checksums-Sha256: | 13 | Checksums-Sha256: |
394 | 14 | aff0bbc01c5883ac76e89cba7a9b6cd79b521183f0de86c93e93ab8804f5a256 178 bar_1.0.orig-comp1.tar.gz | ||
395 | 15 | 955131b3a5bd881c008ff822c0f9b7544350647fe1f355f65a138e0e5e5e8d71 156 bar_1.0.orig-comp2.tar.bz2 | ||
396 | 12 | f1ecff929899b567f45d6734b69d59a4f3c04dabce3cc8e6ed6d64073eda360e 164 bar_1.0.orig.tar.gz | 16 | f1ecff929899b567f45d6734b69d59a4f3c04dabce3cc8e6ed6d64073eda360e 164 bar_1.0.orig.tar.gz |
398 | 13 | ffdcce60fca14618f68483ca77a206f332a3773dc7ece1c3e6de55c0118c69c6 688 bar_1.0-1.debian.tar.gz | 17 | 3d2137f9f80f4b6c80f73acb8b3ac7986c962c4268d8948f54823d27148a6116 737 bar_1.0-1.debian.tar.bz2 |
399 | 14 | Files: | 18 | Files: |
400 | 19 | eed105761436486f7eebaa8c017bc59a 178 bar_1.0.orig-comp1.tar.gz | ||
401 | 20 | 0a30b50fa846e75261808ee1f41d1cbe 156 bar_1.0.orig-comp2.tar.bz2 | ||
402 | 15 | fc1464e5985b962a042d5354452f361d 164 bar_1.0.orig.tar.gz | 21 | fc1464e5985b962a042d5354452f361d 164 bar_1.0.orig.tar.gz |
404 | 16 | 056db4dfe7de8322296b6d417592ee01 688 bar_1.0-1.debian.tar.gz | 22 | e68110184d4d9e7afd81520cc490b396 737 bar_1.0-1.debian.tar.bz2 |
405 | 17 | 23 | ||
406 | === modified file 'lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1_source.changes' | |||
407 | --- lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1_source.changes 2009-11-12 11:54:56 +0000 | |||
408 | +++ lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1_source.changes 2009-12-12 05:58:17 +0000 | |||
409 | @@ -15,14 +15,20 @@ | |||
410 | 15 | . | 15 | . |
411 | 16 | * Initial version | 16 | * Initial version |
412 | 17 | Checksums-Sha1: | 17 | Checksums-Sha1: |
414 | 18 | bc97e185cf31af33bf8d109044ce51f32d09c229 645 bar_1.0-1.dsc | 18 | 762b018e756c1d9be905d40291bc8e975c57a8f0 1115 bar_1.0-1.dsc |
415 | 19 | e7a106587e0f11220e27ccc5db7527cae05e4054 178 bar_1.0.orig-comp1.tar.gz | ||
416 | 20 | a645cc0856469f549f11bb9bdc4ca6dda4eedd4b 156 bar_1.0.orig-comp2.tar.bz2 | ||
417 | 19 | 73a04163fee97fd2257ab266bd48f1d3d528e012 164 bar_1.0.orig.tar.gz | 21 | 73a04163fee97fd2257ab266bd48f1d3d528e012 164 bar_1.0.orig.tar.gz |
419 | 20 | abce262314a7c0ca00e43598f21b41a3e6ff6b21 688 bar_1.0-1.debian.tar.gz | 22 | 727de2395d3a3e35c375159db01072935fea02f8 737 bar_1.0-1.debian.tar.bz2 |
420 | 21 | Checksums-Sha256: | 23 | Checksums-Sha256: |
422 | 22 | ae0fb16941a95518332a8ee962d00d55963b491c2df94b3f230a65d2bdbeedf8 645 bar_1.0-1.dsc | 24 | 49f2656a0e221b0f07dc208f583e2523b09bc30104855372534b5562478efdb5 1115 bar_1.0-1.dsc |
423 | 25 | aff0bbc01c5883ac76e89cba7a9b6cd79b521183f0de86c93e93ab8804f5a256 178 bar_1.0.orig-comp1.tar.gz | ||
424 | 26 | 955131b3a5bd881c008ff822c0f9b7544350647fe1f355f65a138e0e5e5e8d71 156 bar_1.0.orig-comp2.tar.bz2 | ||
425 | 23 | f1ecff929899b567f45d6734b69d59a4f3c04dabce3cc8e6ed6d64073eda360e 164 bar_1.0.orig.tar.gz | 27 | f1ecff929899b567f45d6734b69d59a4f3c04dabce3cc8e6ed6d64073eda360e 164 bar_1.0.orig.tar.gz |
427 | 24 | ffdcce60fca14618f68483ca77a206f332a3773dc7ece1c3e6de55c0118c69c6 688 bar_1.0-1.debian.tar.gz | 28 | 3d2137f9f80f4b6c80f73acb8b3ac7986c962c4268d8948f54823d27148a6116 737 bar_1.0-1.debian.tar.bz2 |
428 | 25 | Files: | 29 | Files: |
430 | 26 | c320d2827f08f09ec2e1bbbac635225c 645 devel optional bar_1.0-1.dsc | 30 | 662977e76501561c902c34bf94a2054d 1115 devel optional bar_1.0-1.dsc |
431 | 31 | eed105761436486f7eebaa8c017bc59a 178 devel optional bar_1.0.orig-comp1.tar.gz | ||
432 | 32 | 0a30b50fa846e75261808ee1f41d1cbe 156 devel optional bar_1.0.orig-comp2.tar.bz2 | ||
433 | 27 | fc1464e5985b962a042d5354452f361d 164 devel optional bar_1.0.orig.tar.gz | 33 | fc1464e5985b962a042d5354452f361d 164 devel optional bar_1.0.orig.tar.gz |
435 | 28 | 056db4dfe7de8322296b6d417592ee01 688 devel optional bar_1.0-1.debian.tar.gz | 34 | e68110184d4d9e7afd81520cc490b396 737 devel optional bar_1.0-1.debian.tar.bz2 |
436 | 29 | 35 | ||
437 | === added file 'lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0.orig-comp1.tar.gz' | |||
438 | 30 | Binary files lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0.orig-comp1.tar.gz 1970-01-01 00:00:00 +0000 and lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0.orig-comp1.tar.gz 2009-12-12 05:58:17 +0000 differ | 36 | Binary files lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0.orig-comp1.tar.gz 1970-01-01 00:00:00 +0000 and lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0.orig-comp1.tar.gz 2009-12-12 05:58:17 +0000 differ |
439 | === added file 'lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0.orig-comp2.tar.bz2' | |||
440 | 31 | Binary files lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0.orig-comp2.tar.bz2 1970-01-01 00:00:00 +0000 and lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0.orig-comp2.tar.bz2 2009-12-12 05:58:17 +0000 differ | 37 | Binary files lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0.orig-comp2.tar.bz2 1970-01-01 00:00:00 +0000 and lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0.orig-comp2.tar.bz2 2009-12-12 05:58:17 +0000 differ |
441 | === added directory 'lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig' | |||
442 | === added file 'lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0-2.debian.tar.bz2' | |||
443 | 32 | Binary files lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0-2.debian.tar.bz2 1970-01-01 00:00:00 +0000 and lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0-2.debian.tar.bz2 2009-12-12 05:58:17 +0000 differ | 38 | Binary files lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0-2.debian.tar.bz2 1970-01-01 00:00:00 +0000 and lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0-2.debian.tar.bz2 2009-12-12 05:58:17 +0000 differ |
444 | === added file 'lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0-2.dsc' | |||
445 | --- lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0-2.dsc 1970-01-01 00:00:00 +0000 | |||
446 | +++ lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0-2.dsc 2009-12-12 05:58:17 +0000 | |||
447 | @@ -0,0 +1,22 @@ | |||
448 | 1 | Format: 3.0 (quilt) | ||
449 | 2 | Source: bar | ||
450 | 3 | Binary: bar | ||
451 | 4 | Architecture: any | ||
452 | 5 | Version: 1.0-2 | ||
453 | 6 | Maintainer: Launchpad team <launchpad@lists.canonical.com> | ||
454 | 7 | Standards-Version: 3.6.2 | ||
455 | 8 | Checksums-Sha1: | ||
456 | 9 | e7a106587e0f11220e27ccc5db7527cae05e4054 178 bar_1.0.orig-comp1.tar.gz | ||
457 | 10 | a645cc0856469f549f11bb9bdc4ca6dda4eedd4b 156 bar_1.0.orig-comp2.tar.bz2 | ||
458 | 11 | 73a04163fee97fd2257ab266bd48f1d3d528e012 164 bar_1.0.orig.tar.gz | ||
459 | 12 | 62776c07df0412798956af8b625a9f1744c8f0fb 807 bar_1.0-2.debian.tar.bz2 | ||
460 | 13 | Checksums-Sha256: | ||
461 | 14 | aff0bbc01c5883ac76e89cba7a9b6cd79b521183f0de86c93e93ab8804f5a256 178 bar_1.0.orig-comp1.tar.gz | ||
462 | 15 | 955131b3a5bd881c008ff822c0f9b7544350647fe1f355f65a138e0e5e5e8d71 156 bar_1.0.orig-comp2.tar.bz2 | ||
463 | 16 | f1ecff929899b567f45d6734b69d59a4f3c04dabce3cc8e6ed6d64073eda360e 164 bar_1.0.orig.tar.gz | ||
464 | 17 | a2a4a82e6f6b212e7de11df327fea18bf2b8e846d221e417b0a479d0f8bf9d79 807 bar_1.0-2.debian.tar.bz2 | ||
465 | 18 | Files: | ||
466 | 19 | eed105761436486f7eebaa8c017bc59a 178 bar_1.0.orig-comp1.tar.gz | ||
467 | 20 | 0a30b50fa846e75261808ee1f41d1cbe 156 bar_1.0.orig-comp2.tar.bz2 | ||
468 | 21 | fc1464e5985b962a042d5354452f361d 164 bar_1.0.orig.tar.gz | ||
469 | 22 | 8b17b1469943483df4d5093955553992 807 bar_1.0-2.debian.tar.bz2 | ||
470 | 0 | 23 | ||
471 | === added file 'lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0-2_source.changes' | |||
472 | --- lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0-2_source.changes 1970-01-01 00:00:00 +0000 | |||
473 | +++ lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0-2_source.changes 2009-12-12 05:58:17 +0000 | |||
474 | @@ -0,0 +1,25 @@ | |||
475 | 1 | Format: 1.8 | ||
476 | 2 | Date: Sun, 01 Nov 2009 10:49:22 +1100 | ||
477 | 3 | Source: bar | ||
478 | 4 | Binary: bar | ||
479 | 5 | Architecture: source | ||
480 | 6 | Version: 1.0-2 | ||
481 | 7 | Distribution: breezy | ||
482 | 8 | Urgency: low | ||
483 | 9 | Maintainer: Launchpad team <launchpad@lists.canonical.com> | ||
484 | 10 | Changed-By: William Grant <me@williamgrant.id.au> | ||
485 | 11 | Description: | ||
486 | 12 | bar - Stuff for testing | ||
487 | 13 | Changes: | ||
488 | 14 | bar (1.0-2) breezy; urgency=low | ||
489 | 15 | . | ||
490 | 16 | * Another version | ||
491 | 17 | Checksums-Sha1: | ||
492 | 18 | d9ccd09135965a759bd741fba1f5223a0314aac8 1115 bar_1.0-2.dsc | ||
493 | 19 | 62776c07df0412798956af8b625a9f1744c8f0fb 807 bar_1.0-2.debian.tar.bz2 | ||
494 | 20 | Checksums-Sha256: | ||
495 | 21 | 53ec1fb4c1671e203c433db570a667750bf4a503e4556ac2c9600389e119744a 1115 bar_1.0-2.dsc | ||
496 | 22 | a2a4a82e6f6b212e7de11df327fea18bf2b8e846d221e417b0a479d0f8bf9d79 807 bar_1.0-2.debian.tar.bz2 | ||
497 | 23 | Files: | ||
498 | 24 | 014288c2cdeca7a9a5e3201aca044c3b 1115 devel optional bar_1.0-2.dsc | ||
499 | 25 | 8b17b1469943483df4d5093955553992 807 devel optional bar_1.0-2.debian.tar.bz2 | ||
500 | 0 | 26 | ||
501 | === added file 'lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0.orig-comp1.tar.gz' | |||
502 | 1 | Binary files lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0.orig-comp1.tar.gz 1970-01-01 00:00:00 +0000 and lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0.orig-comp1.tar.gz 2009-12-12 05:58:17 +0000 differ | 27 | Binary files lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0.orig-comp1.tar.gz 1970-01-01 00:00:00 +0000 and lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0.orig-comp1.tar.gz 2009-12-12 05:58:17 +0000 differ |
503 | === added file 'lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0.orig-comp2.tar.bz2' | |||
504 | 2 | Binary files lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0.orig-comp2.tar.bz2 1970-01-01 00:00:00 +0000 and lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0.orig-comp2.tar.bz2 2009-12-12 05:58:17 +0000 differ | 28 | Binary files lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0.orig-comp2.tar.bz2 1970-01-01 00:00:00 +0000 and lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0.orig-comp2.tar.bz2 2009-12-12 05:58:17 +0000 differ |
505 | === added file 'lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0.orig.tar.gz' | |||
506 | 3 | Binary files lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0.orig.tar.gz 1970-01-01 00:00:00 +0000 and lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0.orig.tar.gz 2009-12-12 05:58:17 +0000 differ | 29 | Binary files lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0.orig.tar.gz 1970-01-01 00:00:00 +0000 and lib/lp/archiveuploader/tests/data/suite/bar_1.0-2_3.0-quilt_without_orig/bar_1.0.orig.tar.gz 2009-12-12 05:58:17 +0000 differ |
507 | === added directory 'lib/lp/archiveuploader/tests/data/suite/bar_1.0_3.0-native' | |||
508 | === added file 'lib/lp/archiveuploader/tests/data/suite/bar_1.0_3.0-native/bar_1.0.dsc' | |||
509 | --- lib/lp/archiveuploader/tests/data/suite/bar_1.0_3.0-native/bar_1.0.dsc 1970-01-01 00:00:00 +0000 | |||
510 | +++ lib/lp/archiveuploader/tests/data/suite/bar_1.0_3.0-native/bar_1.0.dsc 2009-12-12 05:58:17 +0000 | |||
511 | @@ -0,0 +1,13 @@ | |||
512 | 1 | Format: 3.0 (native) | ||
513 | 2 | Source: bar | ||
514 | 3 | Binary: bar | ||
515 | 4 | Architecture: any | ||
516 | 5 | Version: 1.0 | ||
517 | 6 | Maintainer: Launchpad team <launchpad@lists.canonical.com> | ||
518 | 7 | Standards-Version: 3.6.2 | ||
519 | 8 | Checksums-Sha1: | ||
520 | 9 | f931b8f8fe90b365ad19d84387712e64784cd5ef 776 bar_1.0.tar.bz2 | ||
521 | 10 | Checksums-Sha256: | ||
522 | 11 | 1193877b5fc00c410550ad01ec2ed6f97f98a3c8dd2de3753a49251734c842ab 776 bar_1.0.tar.bz2 | ||
523 | 12 | Files: | ||
524 | 13 | f9c5c454799806682e832bb4a73d8c5c 776 bar_1.0.tar.bz2 | ||
525 | 0 | 14 | ||
526 | === added file 'lib/lp/archiveuploader/tests/data/suite/bar_1.0_3.0-native/bar_1.0.tar.bz2' | |||
527 | 1 | Binary files lib/lp/archiveuploader/tests/data/suite/bar_1.0_3.0-native/bar_1.0.tar.bz2 1970-01-01 00:00:00 +0000 and lib/lp/archiveuploader/tests/data/suite/bar_1.0_3.0-native/bar_1.0.tar.bz2 2009-12-12 05:58:17 +0000 differ | 15 | Binary files lib/lp/archiveuploader/tests/data/suite/bar_1.0_3.0-native/bar_1.0.tar.bz2 1970-01-01 00:00:00 +0000 and lib/lp/archiveuploader/tests/data/suite/bar_1.0_3.0-native/bar_1.0.tar.bz2 2009-12-12 05:58:17 +0000 differ |
528 | === added file 'lib/lp/archiveuploader/tests/data/suite/bar_1.0_3.0-native/bar_1.0_source.changes' | |||
529 | --- lib/lp/archiveuploader/tests/data/suite/bar_1.0_3.0-native/bar_1.0_source.changes 1970-01-01 00:00:00 +0000 | |||
530 | +++ lib/lp/archiveuploader/tests/data/suite/bar_1.0_3.0-native/bar_1.0_source.changes 2009-12-12 05:58:17 +0000 | |||
531 | @@ -0,0 +1,25 @@ | |||
532 | 1 | Format: 1.8 | ||
533 | 2 | Date: Thu, 16 Feb 2006 15:34:09 +0000 | ||
534 | 3 | Source: bar | ||
535 | 4 | Binary: bar | ||
536 | 5 | Architecture: source | ||
537 | 6 | Version: 1.0 | ||
538 | 7 | Distribution: breezy | ||
539 | 8 | Urgency: low | ||
540 | 9 | Maintainer: Launchpad team <launchpad@lists.canonical.com> | ||
541 | 10 | Changed-By: Daniel Silverstone <daniel.silverstone@canonical.com> | ||
542 | 11 | Description: | ||
543 | 12 | bar - Stuff for testing | ||
544 | 13 | Changes: | ||
545 | 14 | bar (1.0) breezy; urgency=low | ||
546 | 15 | . | ||
547 | 16 | * Initial version | ||
548 | 17 | Checksums-Sha1: | ||
549 | 18 | 3662dbba7c9f5afcdb6aa240a579ffbe1307f64d 406 bar_1.0.dsc | ||
550 | 19 | f931b8f8fe90b365ad19d84387712e64784cd5ef 776 bar_1.0.tar.bz2 | ||
551 | 20 | Checksums-Sha256: | ||
552 | 21 | b874abb035c04a228272a45625bfd8259998addcbdfd8df0c5c61024b9d40857 406 bar_1.0.dsc | ||
553 | 22 | 1193877b5fc00c410550ad01ec2ed6f97f98a3c8dd2de3753a49251734c842ab 776 bar_1.0.tar.bz2 | ||
554 | 23 | Files: | ||
555 | 24 | 0fbea3d7be741c94c5f964ee023ef164 406 devel optional bar_1.0.dsc | ||
556 | 25 | f9c5c454799806682e832bb4a73d8c5c 776 devel optional bar_1.0.tar.bz2 | ||
557 | 0 | 26 | ||
558 | === modified file 'lib/lp/archiveuploader/tests/nascentuploadfile.txt' | |||
559 | --- lib/lp/archiveuploader/tests/nascentuploadfile.txt 2009-12-03 15:51:44 +0000 | |||
560 | +++ lib/lp/archiveuploader/tests/nascentuploadfile.txt 2009-12-12 05:58:17 +0000 | |||
561 | @@ -216,6 +216,16 @@ | |||
562 | 216 | >>> src_match.group(3) | 216 | >>> src_match.group(3) |
563 | 217 | 'tar.gz' | 217 | 'tar.gz' |
564 | 218 | 218 | ||
565 | 219 | >>> src_match = re_issource.match('foo_1.0.tar.bz2') | ||
566 | 220 | >>> src_match.group(0) | ||
567 | 221 | 'foo_1.0.tar.bz2' | ||
568 | 222 | >>> src_match.group(1) | ||
569 | 223 | 'foo' | ||
570 | 224 | >>> src_match.group(2) | ||
571 | 225 | '1.0' | ||
572 | 226 | >>> src_match.group(3) | ||
573 | 227 | 'tar.bz2' | ||
574 | 228 | |||
575 | 219 | >>> src_match = re_issource.match('foo_1.0.diff.gz') | 229 | >>> src_match = re_issource.match('foo_1.0.diff.gz') |
576 | 220 | >>> src_match.group(0) | 230 | >>> src_match.group(0) |
577 | 221 | 'foo_1.0.diff.gz' | 231 | 'foo_1.0.diff.gz' |
578 | @@ -236,6 +246,56 @@ | |||
579 | 236 | >>> src_match.group(3) | 246 | >>> src_match.group(3) |
580 | 237 | 'dsc' | 247 | 'dsc' |
581 | 238 | 248 | ||
582 | 249 | >>> src_match = re_issource.match('foo_1.0.debian.tar.gz') | ||
583 | 250 | >>> src_match.group(0) | ||
584 | 251 | 'foo_1.0.debian.tar.gz' | ||
585 | 252 | >>> src_match.group(1) | ||
586 | 253 | 'foo' | ||
587 | 254 | >>> src_match.group(2) | ||
588 | 255 | '1.0' | ||
589 | 256 | >>> src_match.group(3) | ||
590 | 257 | 'debian.tar.gz' | ||
591 | 258 | |||
592 | 259 | >>> src_match = re_issource.match('foo_1.0.debian.tar.bz2') | ||
593 | 260 | >>> src_match.group(0) | ||
594 | 261 | 'foo_1.0.debian.tar.bz2' | ||
595 | 262 | >>> src_match.group(1) | ||
596 | 263 | 'foo' | ||
597 | 264 | >>> src_match.group(2) | ||
598 | 265 | '1.0' | ||
599 | 266 | >>> src_match.group(3) | ||
600 | 267 | 'debian.tar.bz2' | ||
601 | 268 | |||
602 | 269 | >>> src_match = re_issource.match('foo_1.0.orig-foo.tar.gz') | ||
603 | 270 | >>> src_match.group(0) | ||
604 | 271 | 'foo_1.0.orig-foo.tar.gz' | ||
605 | 272 | >>> src_match.group(1) | ||
606 | 273 | 'foo' | ||
607 | 274 | >>> src_match.group(2) | ||
608 | 275 | '1.0' | ||
609 | 276 | >>> src_match.group(3) | ||
610 | 277 | 'orig-foo.tar.gz' | ||
611 | 278 | |||
612 | 279 | >>> src_match = re_issource.match('foo_1.0.orig-bar.tar.bz2') | ||
613 | 280 | >>> src_match.group(0) | ||
614 | 281 | 'foo_1.0.orig-bar.tar.bz2' | ||
615 | 282 | >>> src_match.group(1) | ||
616 | 283 | 'foo' | ||
617 | 284 | >>> src_match.group(2) | ||
618 | 285 | '1.0' | ||
619 | 286 | >>> src_match.group(3) | ||
620 | 287 | 'orig-bar.tar.bz2' | ||
621 | 288 | |||
622 | 289 | >>> src_match = re_issource.match('foo_1.0.porig-bar.tar.bz2') | ||
623 | 290 | >>> src_match.group(0) | ||
624 | 291 | 'foo_1.0.porig-bar.tar.bz2' | ||
625 | 292 | >>> src_match.group(1) | ||
626 | 293 | 'foo' | ||
627 | 294 | >>> src_match.group(2) | ||
628 | 295 | '1.0.porig-bar' | ||
629 | 296 | >>> src_match.group(3) | ||
630 | 297 | 'tar.bz2' | ||
631 | 298 | |||
632 | 239 | And finally some failures: | 299 | And finally some failures: |
633 | 240 | 300 | ||
634 | 241 | >>> re_isadeb.match('foo-bar_1.0_i386.bed') is None | 301 | >>> re_isadeb.match('foo-bar_1.0_i386.bed') is None |
635 | @@ -244,6 +304,9 @@ | |||
636 | 244 | >>> re_issource.match('foo_1.0.c') is None | 304 | >>> re_issource.match('foo_1.0.c') is None |
637 | 245 | True | 305 | True |
638 | 246 | 306 | ||
639 | 307 | >>> re_issource.match('foo_1.0.diff.bz2') is None | ||
640 | 308 | True | ||
641 | 309 | |||
642 | 247 | However a custom upload is essencially a tarball, so it also matches | 310 | However a custom upload is essencially a tarball, so it also matches |
643 | 248 | the is_source regexp: | 311 | the is_source regexp: |
644 | 249 | 312 | ||
645 | @@ -506,6 +569,115 @@ | |||
646 | 506 | ['File ed_0.2-20.dsc mentioned in the changes has a size mismatch. 578 != 500'] | 569 | ['File ed_0.2-20.dsc mentioned in the changes has a size mismatch. 578 != 500'] |
647 | 507 | 570 | ||
648 | 508 | 571 | ||
649 | 572 | === Format file type verification === | ||
650 | 573 | |||
651 | 574 | DSCFile performs additional verification on the types of the referenced | ||
652 | 575 | files, confirming that they are suitable for the source package's | ||
653 | 576 | format. There is an error generator to verify each format. | ||
654 | 577 | |||
655 | 578 | >>> from lp.archiveuploader.dscfile import (check_format_1_0_files, | ||
656 | 579 | ... check_format_3_0_native_files, check_format_3_0_quilt_files) | ||
657 | 580 | >>> from lp.registry.interfaces.sourcepackage import SourcePackageFileType | ||
658 | 581 | |||
659 | 582 | ==== 1.0 ==== | ||
660 | 583 | |||
661 | 584 | A 1.0 source can contain either a tar.gz or an orig.tar.gz and diff.gz. | ||
662 | 585 | |||
663 | 586 | >>> list(check_format_1_0_files('foo_1.dsc', { | ||
664 | 587 | ... SourcePackageFileType.ORIG_TARBALL: 1, | ||
665 | 588 | ... SourcePackageFileType.DIFF: 1, | ||
666 | 589 | ... SourcePackageFileType.DEBIAN_TARBALL: 0, | ||
667 | 590 | ... SourcePackageFileType.NATIVE_TARBALL: 0, | ||
668 | 591 | ... }, {}, 0)) | ||
669 | 592 | [] | ||
670 | 593 | |||
671 | 594 | >>> list(check_format_1_0_files('foo_1.dsc', { | ||
672 | 595 | ... SourcePackageFileType.NATIVE_TARBALL: 1, | ||
673 | 596 | ... SourcePackageFileType.ORIG_TARBALL: 0, | ||
674 | 597 | ... SourcePackageFileType.DIFF: 0, | ||
675 | 598 | ... SourcePackageFileType.DEBIAN_TARBALL: 0, | ||
676 | 599 | ... }, {}, 0)) | ||
677 | 600 | [] | ||
678 | 601 | |||
679 | 602 | But if we have some other combination, or bzip2 compression, errors | ||
680 | 603 | will be generated. | ||
681 | 604 | |||
682 | 605 | >>> list(check_format_1_0_files('foo_1.dsc', { | ||
683 | 606 | ... SourcePackageFileType.NATIVE_TARBALL: 1, | ||
684 | 607 | ... SourcePackageFileType.ORIG_TARBALL: 1, | ||
685 | 608 | ... SourcePackageFileType.DIFF: 1, | ||
686 | 609 | ... SourcePackageFileType.DEBIAN_TARBALL: 0, | ||
687 | 610 | ... }, {}, 1)) | ||
688 | 611 | [UploadError('foo_1.dsc: is format 1.0 but uses bzip2 compression.',), UploadError('foo_1.dsc: must have exactly one tar.gz, or an orig.tar.gz and diff.gz',)] | ||
689 | 612 | |||
690 | 613 | The files are also bad if there are any components: | ||
691 | 614 | |||
692 | 615 | >>> list(check_format_1_0_files('foo_1.dsc', { | ||
693 | 616 | ... SourcePackageFileType.ORIG_TARBALL: 1, | ||
694 | 617 | ... SourcePackageFileType.DIFF: 1, | ||
695 | 618 | ... SourcePackageFileType.DEBIAN_TARBALL: 0, | ||
696 | 619 | ... SourcePackageFileType.NATIVE_TARBALL: 0, | ||
697 | 620 | ... }, {'foo': 1}, 0)) | ||
698 | 621 | [UploadError('foo_1.dsc: must have exactly one tar.gz, or an orig.tar.gz and diff.gz',)] | ||
699 | 622 | |||
700 | 623 | ==== 3.0 (native) ==== | ||
701 | 624 | |||
702 | 625 | A 3.0 (native) source must contain just a tar.(gz|bz2). | ||
703 | 626 | |||
704 | 627 | >>> list(check_format_3_0_native_files('foo_1.dsc', { | ||
705 | 628 | ... SourcePackageFileType.NATIVE_TARBALL: 1, | ||
706 | 629 | ... SourcePackageFileType.ORIG_TARBALL: 0, | ||
707 | 630 | ... SourcePackageFileType.DIFF: 0, | ||
708 | 631 | ... SourcePackageFileType.DEBIAN_TARBALL: 0, | ||
709 | 632 | ... }, {}, 1)) | ||
710 | 633 | [] | ||
711 | 634 | |||
712 | 635 | >>> list(check_format_3_0_native_files('foo_1.dsc', { | ||
713 | 636 | ... SourcePackageFileType.NATIVE_TARBALL: 1, | ||
714 | 637 | ... SourcePackageFileType.ORIG_TARBALL: 1, | ||
715 | 638 | ... SourcePackageFileType.DIFF: 0, | ||
716 | 639 | ... SourcePackageFileType.DEBIAN_TARBALL: 0, | ||
717 | 640 | ... }, {}, 1)) | ||
718 | 641 | [UploadError('foo_1.dsc: must have only a tar.*.',)] | ||
719 | 642 | |||
720 | 643 | >>> list(check_format_3_0_native_files('foo_1.dsc', { | ||
721 | 644 | ... SourcePackageFileType.NATIVE_TARBALL: 1, | ||
722 | 645 | ... SourcePackageFileType.ORIG_TARBALL: 0, | ||
723 | 646 | ... SourcePackageFileType.DIFF: 0, | ||
724 | 647 | ... SourcePackageFileType.DEBIAN_TARBALL: 0, | ||
725 | 648 | ... }, {'foo': 1}, 0)) | ||
726 | 649 | [UploadError('foo_1.dsc: must have only a tar.*.',)] | ||
727 | 650 | |||
728 | 651 | ==== 3.0 (quilt) ==== | ||
729 | 652 | |||
730 | 653 | A 3.0 (quilt) source must have an orig.tar.*, a debian.tar.*, and at | ||
731 | 654 | most one orig-COMPONENT.tar.* for each COMPONENT. | ||
732 | 655 | |||
733 | 656 | >>> list(check_format_3_0_quilt_files('foo_1.dsc', { | ||
734 | 657 | ... SourcePackageFileType.ORIG_TARBALL: 1, | ||
735 | 658 | ... SourcePackageFileType.DEBIAN_TARBALL: 1, | ||
736 | 659 | ... SourcePackageFileType.NATIVE_TARBALL: 0, | ||
737 | 660 | ... SourcePackageFileType.DIFF: 0, | ||
738 | 661 | ... }, {'foo': 1}, 1)) | ||
739 | 662 | [] | ||
740 | 663 | |||
741 | 664 | >>> list(check_format_3_0_quilt_files('foo_1.dsc', { | ||
742 | 665 | ... SourcePackageFileType.NATIVE_TARBALL: 1, | ||
743 | 666 | ... SourcePackageFileType.ORIG_TARBALL: 1, | ||
744 | 667 | ... SourcePackageFileType.DIFF: 0, | ||
745 | 668 | ... SourcePackageFileType.DEBIAN_TARBALL: 1, | ||
746 | 669 | ... }, {}, 1)) | ||
747 | 670 | [UploadError('foo_1.dsc: must have only an orig.tar.*, a debian.tar.*, and optionally orig-*.tar.*',)] | ||
748 | 671 | |||
749 | 672 | >>> list(check_format_3_0_quilt_files('foo_1.dsc', { | ||
750 | 673 | ... SourcePackageFileType.ORIG_TARBALL: 1, | ||
751 | 674 | ... SourcePackageFileType.DEBIAN_TARBALL: 1, | ||
752 | 675 | ... SourcePackageFileType.NATIVE_TARBALL: 0, | ||
753 | 676 | ... SourcePackageFileType.DIFF: 0, | ||
754 | 677 | ... }, {'foo': 2}, 0)) | ||
755 | 678 | [UploadError('foo_1.dsc: has more than one orig-foo.tar.*.',)] | ||
756 | 679 | |||
757 | 680 | |||
758 | 509 | === Sub-DSC files or DSCUploadedFiles === | 681 | === Sub-DSC files or DSCUploadedFiles === |
759 | 510 | 682 | ||
760 | 511 | Sub-DSCFiles are DSCUploadedFile objects. | 683 | Sub-DSCFiles are DSCUploadedFile objects. |
761 | 512 | 684 | ||
762 | === modified file 'lib/lp/archiveuploader/tests/test_ppauploadprocessor.py' | |||
763 | --- lib/lp/archiveuploader/tests/test_ppauploadprocessor.py 2009-11-08 02:26:46 +0000 | |||
764 | +++ lib/lp/archiveuploader/tests/test_ppauploadprocessor.py 2009-12-12 05:58:17 +0000 | |||
765 | @@ -32,6 +32,8 @@ | |||
766 | 32 | from lp.registry.interfaces.pocket import PackagePublishingPocket | 32 | from lp.registry.interfaces.pocket import PackagePublishingPocket |
767 | 33 | from lp.soyuz.interfaces.publishing import PackagePublishingStatus | 33 | from lp.soyuz.interfaces.publishing import PackagePublishingStatus |
768 | 34 | from lp.soyuz.interfaces.queue import NonBuildableSourceUploadError | 34 | from lp.soyuz.interfaces.queue import NonBuildableSourceUploadError |
769 | 35 | from lp.soyuz.interfaces.sourcepackageformat import ( | ||
770 | 36 | ISourcePackageFormatSelectionSet, SourcePackageFormat) | ||
771 | 35 | from canonical.launchpad.interfaces import ( | 37 | from canonical.launchpad.interfaces import ( |
772 | 36 | ILaunchpadCelebrities, ILibraryFileAliasSet, NotFoundError) | 38 | ILaunchpadCelebrities, ILibraryFileAliasSet, NotFoundError) |
773 | 37 | from canonical.launchpad.testing.fakepackager import FakePackager | 39 | from canonical.launchpad.testing.fakepackager import FakePackager |
774 | @@ -1161,6 +1163,51 @@ | |||
775 | 1161 | self.uploadprocessor.last_processed_upload.queue_root.status, | 1163 | self.uploadprocessor.last_processed_upload.queue_root.status, |
776 | 1162 | PackageUploadStatus.DONE) | 1164 | PackageUploadStatus.DONE) |
777 | 1163 | 1165 | ||
778 | 1166 | def test30QuiltMultipleReusedOrigs(self): | ||
779 | 1167 | """Official orig*.tar.* can be reused for PPA uploads. | ||
780 | 1168 | |||
781 | 1169 | The 3.0 (quilt) format supports multiple original tarballs. In a | ||
782 | 1170 | PPA upload, any number of these can be reused from the primary | ||
783 | 1171 | archive. | ||
784 | 1172 | """ | ||
785 | 1173 | # We need to accept unsigned .changes and .dscs, and 3.0 (quilt) | ||
786 | 1174 | # sources. | ||
787 | 1175 | self.options.context = 'absolutely-anything' | ||
788 | 1176 | getUtility(ISourcePackageFormatSelectionSet).add( | ||
789 | 1177 | self.breezy, SourcePackageFormat.FORMAT_3_0_QUILT) | ||
790 | 1178 | |||
791 | 1179 | # First upload a complete 3.0 (quilt) source to the primary | ||
792 | 1180 | # archive. | ||
793 | 1181 | upload_dir = self.queueUpload("bar_1.0-1_3.0-quilt") | ||
794 | 1182 | self.processUpload(self.uploadprocessor, upload_dir) | ||
795 | 1183 | |||
796 | 1184 | self.assertEqual( | ||
797 | 1185 | self.uploadprocessor.last_processed_upload.queue_root.status, | ||
798 | 1186 | PackageUploadStatus.NEW) | ||
799 | 1187 | |||
800 | 1188 | [queue_item] = self.breezy.getQueueItems( | ||
801 | 1189 | status=PackageUploadStatus.NEW, name="bar", | ||
802 | 1190 | version="1.0-1", exact_match=True) | ||
803 | 1191 | queue_item.setAccepted() | ||
804 | 1192 | queue_item.realiseUpload() | ||
805 | 1193 | self.layer.commit() | ||
806 | 1194 | unused = stub.test_emails.pop() | ||
807 | 1195 | |||
808 | 1196 | # Now upload a 3.0 (quilt) source with missing orig*.tar.* to a | ||
809 | 1197 | # PPA. All of the missing files will be retrieved from the | ||
810 | 1198 | # primary archive. | ||
811 | 1199 | upload_dir = self.queueUpload( | ||
812 | 1200 | "bar_1.0-2_3.0-quilt_without_orig", "~name16/ubuntu") | ||
813 | 1201 | self.assertEquals( | ||
814 | 1202 | self.processUpload(self.uploadprocessor, upload_dir), | ||
815 | 1203 | ['accepted']) | ||
816 | 1204 | |||
817 | 1205 | queue_item = self.uploadprocessor.last_processed_upload.queue_root | ||
818 | 1206 | |||
819 | 1207 | self.assertEqual(queue_item.status, PackageUploadStatus.DONE) | ||
820 | 1208 | self.assertEqual( | ||
821 | 1209 | queue_item.sources[0].sourcepackagerelease.files.count(), 5) | ||
822 | 1210 | |||
823 | 1164 | 1211 | ||
824 | 1165 | class TestPPAUploadProcessorQuotaChecks(TestPPAUploadProcessorBase): | 1212 | class TestPPAUploadProcessorQuotaChecks(TestPPAUploadProcessorBase): |
825 | 1166 | """Functional test for uploadprocessor.py quota checks in PPA.""" | 1213 | """Functional test for uploadprocessor.py quota checks in PPA.""" |
826 | 1167 | 1214 | ||
827 | === modified file 'lib/lp/archiveuploader/tests/test_uploadprocessor.py' | |||
828 | --- lib/lp/archiveuploader/tests/test_uploadprocessor.py 2009-11-16 22:06:14 +0000 | |||
829 | +++ lib/lp/archiveuploader/tests/test_uploadprocessor.py 2009-12-12 05:58:17 +0000 | |||
830 | @@ -40,6 +40,7 @@ | |||
831 | 40 | from lp.registry.interfaces.distribution import IDistributionSet | 40 | from lp.registry.interfaces.distribution import IDistributionSet |
832 | 41 | from lp.registry.interfaces.distroseries import DistroSeriesStatus | 41 | from lp.registry.interfaces.distroseries import DistroSeriesStatus |
833 | 42 | from lp.registry.interfaces.pocket import PackagePublishingPocket | 42 | from lp.registry.interfaces.pocket import PackagePublishingPocket |
834 | 43 | from lp.registry.interfaces.sourcepackage import SourcePackageFileType | ||
835 | 43 | from lp.soyuz.interfaces.archive import ArchivePurpose, IArchiveSet | 44 | from lp.soyuz.interfaces.archive import ArchivePurpose, IArchiveSet |
836 | 44 | from lp.soyuz.interfaces.queue import PackageUploadStatus | 45 | from lp.soyuz.interfaces.queue import PackageUploadStatus |
837 | 45 | from lp.soyuz.interfaces.publishing import PackagePublishingStatus | 46 | from lp.soyuz.interfaces.publishing import PackagePublishingStatus |
838 | @@ -1501,6 +1502,124 @@ | |||
839 | 1501 | "breezy." in raw_msg, | 1502 | "breezy." in raw_msg, |
840 | 1502 | "Source was not rejected properly:\n%s" % raw_msg) | 1503 | "Source was not rejected properly:\n%s" % raw_msg) |
841 | 1503 | 1504 | ||
842 | 1505 | def test30QuiltUpload(self): | ||
843 | 1506 | """Ensure that 3.0 (quilt) uploads work properly. """ | ||
844 | 1507 | self.setupBreezy( | ||
845 | 1508 | permitted_formats=[SourcePackageFormat.FORMAT_3_0_QUILT]) | ||
846 | 1509 | self.layer.txn.commit() | ||
847 | 1510 | self.options.context = 'absolutely-anything' | ||
848 | 1511 | uploadprocessor = UploadProcessor( | ||
849 | 1512 | self.options, self.layer.txn, self.log) | ||
850 | 1513 | |||
851 | 1514 | # Upload the source. | ||
852 | 1515 | upload_dir = self.queueUpload("bar_1.0-1_3.0-quilt") | ||
853 | 1516 | self.processUpload(uploadprocessor, upload_dir) | ||
854 | 1517 | # Make sure it went ok: | ||
855 | 1518 | from_addr, to_addrs, raw_msg = stub.test_emails.pop() | ||
856 | 1519 | self.assertTrue( | ||
857 | 1520 | "rejected" not in raw_msg, | ||
858 | 1521 | "Failed to upload bar source:\n%s" % raw_msg) | ||
859 | 1522 | spph = self._publishPackage("bar", "1.0-1") | ||
860 | 1523 | |||
861 | 1524 | self.assertEquals( | ||
862 | 1525 | sorted((sprf.libraryfile.filename, sprf.filetype) | ||
863 | 1526 | for sprf in spph.sourcepackagerelease.files), | ||
864 | 1527 | [('bar_1.0-1.debian.tar.bz2', | ||
865 | 1528 | SourcePackageFileType.DEBIAN_TARBALL), | ||
866 | 1529 | ('bar_1.0-1.dsc', | ||
867 | 1530 | SourcePackageFileType.DSC), | ||
868 | 1531 | ('bar_1.0.orig-comp1.tar.gz', | ||
869 | 1532 | SourcePackageFileType.COMPONENT_ORIG_TARBALL), | ||
870 | 1533 | ('bar_1.0.orig-comp2.tar.bz2', | ||
871 | 1534 | SourcePackageFileType.COMPONENT_ORIG_TARBALL), | ||
872 | 1535 | ('bar_1.0.orig.tar.gz', | ||
873 | 1536 | SourcePackageFileType.ORIG_TARBALL)]) | ||
874 | 1537 | |||
875 | 1538 | def test30QuiltUploadWithSameComponentOrig(self): | ||
876 | 1539 | """Ensure that 3.0 (quilt) uploads with shared component origs work. | ||
877 | 1540 | """ | ||
878 | 1541 | self.setupBreezy( | ||
879 | 1542 | permitted_formats=[SourcePackageFormat.FORMAT_3_0_QUILT]) | ||
880 | 1543 | self.layer.txn.commit() | ||
881 | 1544 | self.options.context = 'absolutely-anything' | ||
882 | 1545 | uploadprocessor = UploadProcessor( | ||
883 | 1546 | self.options, self.layer.txn, self.log) | ||
884 | 1547 | |||
885 | 1548 | # Upload the first source. | ||
886 | 1549 | upload_dir = self.queueUpload("bar_1.0-1_3.0-quilt") | ||
887 | 1550 | self.processUpload(uploadprocessor, upload_dir) | ||
888 | 1551 | # Make sure it went ok: | ||
889 | 1552 | from_addr, to_addrs, raw_msg = stub.test_emails.pop() | ||
890 | 1553 | self.assertTrue( | ||
891 | 1554 | "rejected" not in raw_msg, | ||
892 | 1555 | "Failed to upload bar source:\n%s" % raw_msg) | ||
893 | 1556 | spph = self._publishPackage("bar", "1.0-1") | ||
894 | 1557 | |||
895 | 1558 | # Upload another source sharing the same (component) orig. | ||
896 | 1559 | upload_dir = self.queueUpload("bar_1.0-2_3.0-quilt_without_orig") | ||
897 | 1560 | self.assertEquals( | ||
898 | 1561 | self.processUpload(uploadprocessor, upload_dir), ['accepted']) | ||
899 | 1562 | |||
900 | 1563 | queue_item = uploadprocessor.last_processed_upload.queue_root | ||
901 | 1564 | self.assertEquals( | ||
902 | 1565 | sorted((sprf.libraryfile.filename, sprf.filetype) for sprf | ||
903 | 1566 | in queue_item.sources[0].sourcepackagerelease.files), | ||
904 | 1567 | [('bar_1.0-2.debian.tar.bz2', | ||
905 | 1568 | SourcePackageFileType.DEBIAN_TARBALL), | ||
906 | 1569 | ('bar_1.0-2.dsc', | ||
907 | 1570 | SourcePackageFileType.DSC), | ||
908 | 1571 | ('bar_1.0.orig-comp1.tar.gz', | ||
909 | 1572 | SourcePackageFileType.COMPONENT_ORIG_TARBALL), | ||
910 | 1573 | ('bar_1.0.orig-comp2.tar.bz2', | ||
911 | 1574 | SourcePackageFileType.COMPONENT_ORIG_TARBALL), | ||
912 | 1575 | ('bar_1.0.orig.tar.gz', | ||
913 | 1576 | SourcePackageFileType.ORIG_TARBALL)]) | ||
914 | 1577 | |||
915 | 1578 | def test30NativeUpload(self): | ||
916 | 1579 | """Ensure that 3.0 (native) uploads work properly. """ | ||
917 | 1580 | self.setupBreezy( | ||
918 | 1581 | permitted_formats=[SourcePackageFormat.FORMAT_3_0_NATIVE]) | ||
919 | 1582 | self.layer.txn.commit() | ||
920 | 1583 | self.options.context = 'absolutely-anything' | ||
921 | 1584 | uploadprocessor = UploadProcessor( | ||
922 | 1585 | self.options, self.layer.txn, self.log) | ||
923 | 1586 | |||
924 | 1587 | # Upload the source. | ||
925 | 1588 | upload_dir = self.queueUpload("bar_1.0_3.0-native") | ||
926 | 1589 | self.processUpload(uploadprocessor, upload_dir) | ||
927 | 1590 | # Make sure it went ok: | ||
928 | 1591 | from_addr, to_addrs, raw_msg = stub.test_emails.pop() | ||
929 | 1592 | self.assertTrue( | ||
930 | 1593 | "rejected" not in raw_msg, | ||
931 | 1594 | "Failed to upload bar source:\n%s" % raw_msg) | ||
932 | 1595 | spph = self._publishPackage("bar", "1.0") | ||
933 | 1596 | |||
934 | 1597 | self.assertEquals( | ||
935 | 1598 | sorted((sprf.libraryfile.filename, sprf.filetype) | ||
936 | 1599 | for sprf in spph.sourcepackagerelease.files), | ||
937 | 1600 | [('bar_1.0.dsc', | ||
938 | 1601 | SourcePackageFileType.DSC), | ||
939 | 1602 | ('bar_1.0.tar.bz2', | ||
940 | 1603 | SourcePackageFileType.NATIVE_TARBALL)]) | ||
941 | 1604 | |||
942 | 1605 | def test10Bzip2UploadIsRejected(self): | ||
943 | 1606 | """Ensure that 1.0 sources with bzip2 compression are rejected.""" | ||
944 | 1607 | self.setupBreezy() | ||
945 | 1608 | self.layer.txn.commit() | ||
946 | 1609 | self.options.context = 'absolutely-anything' | ||
947 | 1610 | uploadprocessor = UploadProcessor( | ||
948 | 1611 | self.options, self.layer.txn, self.log) | ||
949 | 1612 | |||
950 | 1613 | # Upload the source. | ||
951 | 1614 | upload_dir = self.queueUpload("bar_1.0-1_1.0-bzip2") | ||
952 | 1615 | self.processUpload(uploadprocessor, upload_dir) | ||
953 | 1616 | # Make sure it was rejected. | ||
954 | 1617 | from_addr, to_addrs, raw_msg = stub.test_emails.pop() | ||
955 | 1618 | self.assertTrue( | ||
956 | 1619 | "bar_1.0-1.dsc: is format 1.0 but uses bzip2 compression." | ||
957 | 1620 | in raw_msg, | ||
958 | 1621 | "Source was not rejected properly:\n%s" % raw_msg) | ||
959 | 1622 | |||
960 | 1504 | 1623 | ||
961 | 1505 | def test_suite(): | 1624 | def test_suite(): |
962 | 1506 | return unittest.TestLoader().loadTestsFromName(__name__) | 1625 | return unittest.TestLoader().loadTestsFromName(__name__) |
963 | 1507 | 1626 | ||
964 | === modified file 'lib/lp/archiveuploader/tests/test_utils.py' | |||
965 | --- lib/lp/archiveuploader/tests/test_utils.py 2009-11-17 21:38:28 +0000 | |||
966 | +++ lib/lp/archiveuploader/tests/test_utils.py 2009-12-12 05:58:17 +0000 | |||
967 | @@ -23,18 +23,52 @@ | |||
968 | 23 | """lp.archiveuploader.utils.determine_source_file_type should work.""" | 23 | """lp.archiveuploader.utils.determine_source_file_type should work.""" |
969 | 24 | from lp.archiveuploader.utils import determine_source_file_type | 24 | from lp.archiveuploader.utils import determine_source_file_type |
970 | 25 | 25 | ||
983 | 26 | self.assertEquals( | 26 | # .dsc -> DSC |
984 | 27 | SourcePackageFileType.DSC, | 27 | self.assertEquals( |
985 | 28 | determine_source_file_type('foo_1.0-1.dsc')) | 28 | determine_source_file_type('foo_1.0-1.dsc'), |
986 | 29 | self.assertEquals( | 29 | SourcePackageFileType.DSC) |
987 | 30 | SourcePackageFileType.DIFF, | 30 | |
988 | 31 | determine_source_file_type('foo_1.0-1.diff.gz')) | 31 | # .diff.gz -> DIFF |
989 | 32 | self.assertEquals( | 32 | self.assertEquals( |
990 | 33 | SourcePackageFileType.ORIG_TARBALL, | 33 | determine_source_file_type('foo_1.0-1.diff.gz'), |
991 | 34 | determine_source_file_type('foo_1.0.orig.tar.gz')) | 34 | SourcePackageFileType.DIFF) |
992 | 35 | self.assertEquals( | 35 | |
993 | 36 | SourcePackageFileType.NATIVE_TARBALL, | 36 | # DIFFs can only be gzipped. |
994 | 37 | determine_source_file_type('foo_1.0.tar.gz')) | 37 | self.assertEquals( |
995 | 38 | determine_source_file_type('foo_1.0.diff.bz2'), None) | ||
996 | 39 | |||
997 | 40 | # Plain original tarballs can be gzipped or bzip2ed. | ||
998 | 41 | self.assertEquals( | ||
999 | 42 | determine_source_file_type('foo_1.0.orig.tar.gz'), | ||
1000 | 43 | SourcePackageFileType.ORIG_TARBALL) | ||
1001 | 44 | self.assertEquals( | ||
1002 | 45 | determine_source_file_type('foo_1.0.orig.tar.bz2'), | ||
1003 | 46 | SourcePackageFileType.ORIG_TARBALL) | ||
1004 | 47 | |||
1005 | 48 | # Component original tarballs too. | ||
1006 | 49 | self.assertEquals( | ||
1007 | 50 | determine_source_file_type('foo_1.0.orig-foo.tar.gz'), | ||
1008 | 51 | SourcePackageFileType.COMPONENT_ORIG_TARBALL) | ||
1009 | 52 | self.assertEquals( | ||
1010 | 53 | determine_source_file_type('foo_1.0.orig-bar.tar.bz2'), | ||
1011 | 54 | SourcePackageFileType.COMPONENT_ORIG_TARBALL) | ||
1012 | 55 | |||
1013 | 56 | # And Debian tarballs... | ||
1014 | 57 | self.assertEquals( | ||
1015 | 58 | determine_source_file_type('foo_1.0-1.debian.tar.gz'), | ||
1016 | 59 | SourcePackageFileType.DEBIAN_TARBALL) | ||
1017 | 60 | self.assertEquals( | ||
1018 | 61 | determine_source_file_type('foo_1.0-2.debian.tar.bz2'), | ||
1019 | 62 | SourcePackageFileType.DEBIAN_TARBALL) | ||
1020 | 63 | |||
1021 | 64 | # And even native tarballs! | ||
1022 | 65 | self.assertEquals( | ||
1023 | 66 | determine_source_file_type('foo_1.0.tar.gz'), | ||
1024 | 67 | SourcePackageFileType.NATIVE_TARBALL) | ||
1025 | 68 | self.assertEquals( | ||
1026 | 69 | determine_source_file_type('foo_1.0.tar.bz2'), | ||
1027 | 70 | SourcePackageFileType.NATIVE_TARBALL) | ||
1028 | 71 | |||
1029 | 38 | self.assertEquals(None, determine_source_file_type('foo_1.0')) | 72 | self.assertEquals(None, determine_source_file_type('foo_1.0')) |
1030 | 39 | self.assertEquals(None, determine_source_file_type('foo_1.0.blah.gz')) | 73 | self.assertEquals(None, determine_source_file_type('foo_1.0.blah.gz')) |
1031 | 40 | 74 | ||
1032 | 41 | 75 | ||
1033 | === modified file 'lib/lp/archiveuploader/uploadpolicy.py' | |||
1034 | --- lib/lp/archiveuploader/uploadpolicy.py 2009-11-05 21:57:35 +0000 | |||
1035 | +++ lib/lp/archiveuploader/uploadpolicy.py 2009-12-12 05:58:17 +0000 | |||
1036 | @@ -373,6 +373,10 @@ | |||
1037 | 373 | """Nothing, let it go.""" | 373 | """Nothing, let it go.""" |
1038 | 374 | pass | 374 | pass |
1039 | 375 | 375 | ||
1040 | 376 | def rejectPPAUploads(self, upload): | ||
1041 | 377 | """We allow PPA uploads.""" | ||
1042 | 378 | return False | ||
1043 | 379 | |||
1044 | 376 | AbstractUploadPolicy._registerPolicy(AnythingGoesUploadPolicy) | 380 | AbstractUploadPolicy._registerPolicy(AnythingGoesUploadPolicy) |
1045 | 377 | 381 | ||
1046 | 378 | 382 | ||
1047 | 379 | 383 | ||
1048 | === modified file 'lib/lp/archiveuploader/utils.py' | |||
1049 | --- lib/lp/archiveuploader/utils.py 2009-11-11 21:50:56 +0000 | |||
1050 | +++ lib/lp/archiveuploader/utils.py 2009-12-12 05:58:17 +0000 | |||
1051 | @@ -9,6 +9,7 @@ | |||
1052 | 9 | 're_taint_free', | 9 | 're_taint_free', |
1053 | 10 | 're_isadeb', | 10 | 're_isadeb', |
1054 | 11 | 're_issource', | 11 | 're_issource', |
1055 | 12 | 're_is_component_orig_tar_ext', | ||
1056 | 12 | 're_no_epoch', | 13 | 're_no_epoch', |
1057 | 13 | 're_no_revision', | 14 | 're_no_revision', |
1058 | 14 | 're_valid_version', | 15 | 're_valid_version', |
1059 | @@ -34,13 +35,15 @@ | |||
1060 | 34 | 35 | ||
1061 | 35 | re_isadeb = re.compile(r"(.+?)_(.+?)_(.+)\.(u?d?deb)$") | 36 | re_isadeb = re.compile(r"(.+?)_(.+?)_(.+)\.(u?d?deb)$") |
1062 | 36 | 37 | ||
1064 | 37 | source_file_exts = ['orig.tar.gz', 'diff.gz', 'tar.gz', 'dsc'] | 38 | source_file_exts = [ |
1065 | 39 | 'orig(?:-.+)?\.tar\.(?:gz|bz2)', 'diff.gz', | ||
1066 | 40 | '(?:debian\.)?tar\.(?:gz|bz2)', 'dsc'] | ||
1067 | 38 | re_issource = re.compile( | 41 | re_issource = re.compile( |
1073 | 39 | r"(.+)_(.+?)\.(%s)" % "|".join( | 42 | r"(.+)_(.+?)\.(%s)" % "|".join(ext for ext in source_file_exts)) |
1074 | 40 | re.escape(ext) for ext in source_file_exts)) | 43 | re_is_component_orig_tar_ext = re.compile(r"^orig-(.+).tar.(?:gz|bz2)$") |
1075 | 41 | 44 | re_is_orig_tar_ext = re.compile(r"^orig.tar.(?:gz|bz2)$") | |
1076 | 42 | re_is_orig_tar_ext = re.compile(r"^orig.tar.gz$") | 45 | re_is_debian_tar_ext = re.compile(r"^debian.tar.(?:gz|bz2)$") |
1077 | 43 | re_is_native_tar_ext = re.compile(r"^tar.gz$") | 46 | re_is_native_tar_ext = re.compile(r"^tar.(?:gz|bz2)$") |
1078 | 44 | 47 | ||
1079 | 45 | re_no_epoch = re.compile(r"^\d+\:") | 48 | re_no_epoch = re.compile(r"^\d+\:") |
1080 | 46 | re_no_revision = re.compile(r"-[^-]+$") | 49 | re_no_revision = re.compile(r"-[^-]+$") |
1081 | @@ -75,6 +78,10 @@ | |||
1082 | 75 | return SourcePackageFileType.DIFF | 78 | return SourcePackageFileType.DIFF |
1083 | 76 | elif re_is_orig_tar_ext.match(extension): | 79 | elif re_is_orig_tar_ext.match(extension): |
1084 | 77 | return SourcePackageFileType.ORIG_TARBALL | 80 | return SourcePackageFileType.ORIG_TARBALL |
1085 | 81 | elif re_is_component_orig_tar_ext.match(extension): | ||
1086 | 82 | return SourcePackageFileType.COMPONENT_ORIG_TARBALL | ||
1087 | 83 | elif re_is_debian_tar_ext.match(extension): | ||
1088 | 84 | return SourcePackageFileType.DEBIAN_TARBALL | ||
1089 | 78 | elif re_is_native_tar_ext.match(extension): | 85 | elif re_is_native_tar_ext.match(extension): |
1090 | 79 | return SourcePackageFileType.NATIVE_TARBALL | 86 | return SourcePackageFileType.NATIVE_TARBALL |
1091 | 80 | else: | 87 | else: |
1092 | 81 | 88 | ||
1093 | === modified file 'lib/lp/registry/interfaces/sourcepackage.py' | |||
1094 | --- lib/lp/registry/interfaces/sourcepackage.py 2009-11-21 08:56:44 +0000 | |||
1095 | +++ lib/lp/registry/interfaces/sourcepackage.py 2009-12-12 05:58:17 +0000 | |||
1096 | @@ -310,7 +310,9 @@ | |||
1097 | 310 | This is an Ubuntu "diff" file, containing changes that need to be | 310 | This is an Ubuntu "diff" file, containing changes that need to be |
1098 | 311 | made to upstream code for the packaging on Ubuntu. Typically this | 311 | made to upstream code for the packaging on Ubuntu. Typically this |
1099 | 312 | diff creates additional directories with patches and documentation | 312 | diff creates additional directories with patches and documentation |
1101 | 313 | used to build the binary packages for Ubuntu. """) | 313 | used to build the binary packages for Ubuntu. |
1102 | 314 | |||
1103 | 315 | This is only part of the 1.0 source package format.""") | ||
1104 | 314 | 316 | ||
1105 | 315 | NATIVE_TARBALL = DBItem(6, """ | 317 | NATIVE_TARBALL = DBItem(6, """ |
1106 | 316 | Native Tarball | 318 | Native Tarball |
1107 | @@ -318,6 +320,22 @@ | |||
1108 | 318 | This is a tarball, usually of a mixture of Ubuntu and upstream code, | 320 | This is a tarball, usually of a mixture of Ubuntu and upstream code, |
1109 | 319 | used in the build process for this source package. """) | 321 | used in the build process for this source package. """) |
1110 | 320 | 322 | ||
1111 | 323 | DEBIAN_TARBALL = DBItem(7, """ | ||
1112 | 324 | Debian Tarball | ||
1113 | 325 | |||
1114 | 326 | This file is an Ubuntu "orig" file, typically an upstream tarball or | ||
1115 | 327 | other lightly-modified upstreamish thing. | ||
1116 | 328 | |||
1117 | 329 | This is only part of the 3.0 (quilt) source package format.""") | ||
1118 | 330 | |||
1119 | 331 | COMPONENT_ORIG_TARBALL = DBItem(8, """ | ||
1120 | 332 | Component Orig Tarball | ||
1121 | 333 | |||
1122 | 334 | This file is an Ubuntu component "orig" file, typically an upstream | ||
1123 | 335 | tarball containing a component of the source package. | ||
1124 | 336 | |||
1125 | 337 | This is only part of the 3.0 (quilt) source package format.""") | ||
1126 | 338 | |||
1127 | 321 | 339 | ||
1128 | 322 | class SourcePackageType(DBEnumeratedType): | 340 | class SourcePackageType(DBEnumeratedType): |
1129 | 323 | """Source Package Format | 341 | """Source Package Format |
1130 | 324 | 342 | ||
1131 | === modified file 'lib/lp/soyuz/interfaces/files.py' | |||
1132 | --- lib/lp/soyuz/interfaces/files.py 2009-06-25 04:06:00 +0000 | |||
1133 | +++ lib/lp/soyuz/interfaces/files.py 2009-12-12 05:58:17 +0000 | |||
1134 | @@ -14,7 +14,7 @@ | |||
1135 | 14 | 'ISourcePackageReleaseFileSet', | 14 | 'ISourcePackageReleaseFileSet', |
1136 | 15 | ] | 15 | ] |
1137 | 16 | 16 | ||
1139 | 17 | from zope.schema import Int | 17 | from zope.schema import Bool, Int |
1140 | 18 | from zope.interface import Interface | 18 | from zope.interface import Interface |
1141 | 19 | from canonical.launchpad import _ | 19 | from canonical.launchpad import _ |
1142 | 20 | 20 | ||
1143 | @@ -68,6 +68,11 @@ | |||
1144 | 68 | title=_('The type of this file'), required=True, readonly=False, | 68 | title=_('The type of this file'), required=True, readonly=False, |
1145 | 69 | ) | 69 | ) |
1146 | 70 | 70 | ||
1147 | 71 | is_orig = Bool( | ||
1148 | 72 | title=_('Whether this file is an original tarball'), | ||
1149 | 73 | required=True, readonly=False, | ||
1150 | 74 | ) | ||
1151 | 75 | |||
1152 | 71 | 76 | ||
1153 | 72 | class ISourcePackageReleaseFileSet(Interface): | 77 | class ISourcePackageReleaseFileSet(Interface): |
1154 | 73 | """The set of all `SourcePackageRelease`s.""" | 78 | """The set of all `SourcePackageRelease`s.""" |
1155 | 74 | 79 | ||
1156 | === modified file 'lib/lp/soyuz/model/files.py' | |||
1157 | --- lib/lp/soyuz/model/files.py 2009-06-25 04:06:00 +0000 | |||
1158 | +++ lib/lp/soyuz/model/files.py 2009-12-12 05:58:17 +0000 | |||
1159 | @@ -60,7 +60,18 @@ | |||
1160 | 60 | "binarypackagerelease.binarypackagename"]) | 60 | "binarypackagerelease.binarypackagename"]) |
1161 | 61 | 61 | ||
1162 | 62 | 62 | ||
1164 | 63 | class SourcePackageReleaseFile(SQLBase): | 63 | class SourceFileMixin: |
1165 | 64 | """Mix-in class for common functionality between source file classes.""" | ||
1166 | 65 | |||
1167 | 66 | @property | ||
1168 | 67 | def is_orig(self): | ||
1169 | 68 | return self.filetype in ( | ||
1170 | 69 | SourcePackageFileType.ORIG_TARBALL, | ||
1171 | 70 | SourcePackageFileType.COMPONENT_ORIG_TARBALL | ||
1172 | 71 | ) | ||
1173 | 72 | |||
1174 | 73 | |||
1175 | 74 | class SourcePackageReleaseFile(SourceFileMixin, SQLBase): | ||
1176 | 64 | """See ISourcePackageFile""" | 75 | """See ISourcePackageFile""" |
1177 | 65 | 76 | ||
1178 | 66 | implements(ISourcePackageReleaseFile) | 77 | implements(ISourcePackageReleaseFile) |
1179 | @@ -90,4 +101,3 @@ | |||
1180 | 90 | prejoins=["libraryfile", "libraryfile.content", | 101 | prejoins=["libraryfile", "libraryfile.content", |
1181 | 91 | "sourcepackagerelease", | 102 | "sourcepackagerelease", |
1182 | 92 | "sourcepackagerelease.sourcepackagename"]) | 103 | "sourcepackagerelease.sourcepackagename"]) |
1183 | 93 | |||
1184 | 94 | 104 | ||
1185 | === modified file 'lib/lp/soyuz/model/queue.py' | |||
1186 | --- lib/lp/soyuz/model/queue.py 2009-12-07 10:04:25 +0000 | |||
1187 | +++ lib/lp/soyuz/model/queue.py 2009-12-12 05:58:17 +0000 | |||
1188 | @@ -61,7 +61,6 @@ | |||
1189 | 61 | NonBuildableSourceUploadError, QueueBuildAcceptError, | 61 | NonBuildableSourceUploadError, QueueBuildAcceptError, |
1190 | 62 | QueueInconsistentStateError, QueueSourceAcceptError, | 62 | QueueInconsistentStateError, QueueSourceAcceptError, |
1191 | 63 | QueueStateWriteProtectedError) | 63 | QueueStateWriteProtectedError) |
1192 | 64 | from lp.registry.interfaces.sourcepackage import SourcePackageFileType | ||
1193 | 65 | from canonical.launchpad.mail import ( | 64 | from canonical.launchpad.mail import ( |
1194 | 66 | format_address, signed_message_from_string, sendmail) | 65 | format_address, signed_message_from_string, sendmail) |
1195 | 67 | from lp.soyuz.scripts.processaccepted import ( | 66 | from lp.soyuz.scripts.processaccepted import ( |
1196 | @@ -1471,8 +1470,7 @@ | |||
1197 | 1471 | published_sha1 = published_file.content.sha1 | 1470 | published_sha1 = published_file.content.sha1 |
1198 | 1472 | 1471 | ||
1199 | 1473 | # Multiple orig(s) with the same content are fine. | 1472 | # Multiple orig(s) with the same content are fine. |
1202 | 1474 | if source_file.filetype == ( | 1473 | if source_file.is_orig: |
1201 | 1475 | SourcePackageFileType.ORIG_TARBALL): | ||
1203 | 1476 | if proposed_sha1 == published_sha1: | 1474 | if proposed_sha1 == published_sha1: |
1204 | 1477 | continue | 1475 | continue |
1205 | 1478 | raise QueueInconsistentStateError( | 1476 | raise QueueInconsistentStateError( |
This is hopefully the last of my Debian source format 3.0 branches. It is a pretty simple extension and testing of existing code.
The two new formats are:
- 3.0 (native): Like 1.0's native variant, but with bz2 compression permitted on the tarball. .tar.(gz| bz2) for each COMPONENT.
- 3.0 (quilt): Replaces 1.0's non-native variant. Requires an orig.tar.(gz|bz2), a debian.tar.(gz|bz2) (replacing 1.0's diff.gz), and at most one orig-$COMPONENT
determine_ source_ file_type is extended to identify bz2 compression, debian tarballs, and component orig tarballs. All checks to allow duplicated ORIG_TARBALLS are extended to also permit COMPONENT_ ORIG_TARBALLs, as they should be treated identically.
There are pretty simple additional checks in NascentUpload. Additional file type counters are added, as is one for bz2 compression. Compression and new file checks are added to the 1.0 section, as are fairly obvious new 3.0 (quilt) and 3.0 (native) sections.
A few new test source packages are required. I also convinced the 'absolutely- anything' upload policy to permit PPA uploads, since I needed to test with an unsigned PPA upload. I haven't tested all filetype-related rejection cases (the old code did not either), since that would require constructing several more bad source packages.