Merge lp:~cjwatson/launchpad/tar-xz into lp:launchpad

Proposed by Colin Watson
Status: Merged
Approved by: Robert Collins
Approved revision: no longer in the source branch.
Merged at revision: 12667
Proposed branch: lp:~cjwatson/launchpad/tar-xz
Merge into: lp:launchpad
Diff against target: 352 lines (+74/-36)
7 files modified
lib/lp/archiveuploader/dscfile.py (+16/-9)
lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1.dsc (+3/-0)
lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1_source.changes (+6/-3)
lib/lp/archiveuploader/tests/test_dscfile.py (+21/-11)
lib/lp/archiveuploader/tests/test_utils.py (+19/-4)
lib/lp/archiveuploader/utils.py (+6/-6)
lib/lp/soyuz/enums.py (+3/-3)
To merge this branch: bzr merge lp:~cjwatson/launchpad/tar-xz
Reviewer Review Type Date Requested Status
Steve Kowalik (community) code Approve
Robert Collins (community) Approve
William Grant code* Approve
Review via email: mp+54215@code.launchpad.net

Commit message

[r=lifeless,stevenk,wgrant][bug=742408] Add support for xz-compressed tarballs in source packages.

Description of the change

Summary:

dpkg 1.15.5 and newer supports xz compression for source package tarballs. Debian doesn't quite support this yet, so this hasn't been a huge issue for us, but there is pressure for it to do so soon because GNOME is going to switch to shipping tar.xz (http://lists.debian.org/debian-project/2011/03/msg00047.html). Over time, this would be a straightforward way for us to shrink the size of many source packages.

Proposed fix:

Add orig.tar.xz, orig-component.tar.xz, and debian.tar.xz to the locations where corresponding *.bz2 versions are currently mentioned.

Pre-implementation notes:

Discussed with wgrant. *.xz is only available in the 3.0 (quilt) format, which is supported for Ubuntu 9.10 and newer, while *.xz specifically should strictly only be supported for Ubuntu 10.04 LTS and newer. However, such a constraint would be quite a lot of work to add, karmic is going to be EOL soon anyway, and the only downside of uploading an xz-compressed source package to karmic should be that it fails to build; so we agreed that enforcing this constraint in Launchpad is unnecessary.

Tests:

This branch adjusts various tests that already checked bzip2 support to check xz support as well. I ran 'testr run -- -t archiveuploader'.

QA plan:

Convert an Ubuntu-specific package to tar.xz. We could easily do this with some Ubuntu-native package such as ubiquity.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote :

It's very close to needing generalisation of the compression type checking, but I think duplication is OK until next time.

review: Approve (code*)
Revision history for this message
Robert Collins (lifeless) :
review: Approve
Revision history for this message
Steve Kowalik (stevenk) wrote :

I agree with William -- it's okay for now.

review: Approve (code)
Revision history for this message
Colin Watson (cjwatson) wrote :

I don't have direct landing access, and would appreciate help in getting this landed.

Revision history for this message
William Grant (wgrant) wrote :

I'm landing this.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/archiveuploader/dscfile.py'
2--- lib/lp/archiveuploader/dscfile.py 2011-03-07 03:08:47 +0000
3+++ lib/lp/archiveuploader/dscfile.py 2011-03-25 16:46:32 +0000
4@@ -460,6 +460,7 @@
5 }
6 component_orig_tar_counts = {}
7 bzip2_count = 0
8+ xz_count = 0
9 files_missing = False
10
11 for sub_dsc_file in self.files:
12@@ -481,6 +482,8 @@
13
14 if sub_dsc_file.filename.endswith('.bz2'):
15 bzip2_count += 1
16+ elif sub_dsc_file.filename.endswith('.xz'):
17+ xz_count += 1
18
19 try:
20 library_file, file_archive = self._getFileByName(
21@@ -534,7 +537,7 @@
22
23 for error in file_checker(
24 self.filename, file_type_counts, component_orig_tar_counts,
25- bzip2_count):
26+ bzip2_count, xz_count):
27 yield error
28
29 if files_missing:
30@@ -773,16 +776,20 @@
31
32
33 def check_format_1_0_files(filename, file_type_counts, component_counts,
34- bzip2_count):
35+ bzip2_count, xz_count):
36 """Check that the given counts of each file type suit format 1.0.
37
38 A 1.0 source must be native (with only one tar.gz), or have an orig.tar.gz
39- and a diff.gz. It cannot use bzip2 compression.
40+ and a diff.gz. It cannot use bzip2 or xz compression.
41 """
42 if bzip2_count > 0:
43 yield UploadError(
44 "%s: is format 1.0 but uses bzip2 compression."
45 % filename)
46+ if xz_count > 0:
47+ yield UploadError(
48+ "%s: is format 1.0 but uses xz compression."
49+ % filename)
50
51 valid_file_type_counts = [
52 {
53@@ -807,11 +814,11 @@
54
55
56 def check_format_3_0_native_files(filename, file_type_counts,
57- component_counts, bzip2_count):
58+ component_counts, bzip2_count, xz_count):
59 """Check that the given counts of each file type suit format 3.0 (native).
60
61- A 3.0 (native) source must have only one tar.*. Both gzip and bzip2
62- compression are permissible.
63+ A 3.0 (native) source must have only one tar.*. Any of gzip, bzip2, and
64+ xz compression are permissible.
65 """
66
67 valid_file_type_counts = [
68@@ -829,12 +836,12 @@
69
70
71 def check_format_3_0_quilt_files(filename, file_type_counts,
72- component_counts, bzip2_count):
73+ component_counts, bzip2_count, xz_count):
74 """Check that the given counts of each file type suit format 3.0 (native).
75
76 A 3.0 (quilt) source must have exactly one orig.tar.*, one debian.tar.*,
77- and at most one orig-COMPONENT.tar.* for each COMPONENT. Both gzip and
78- bzip2 compression are permissible.
79+ and at most one orig-COMPONENT.tar.* for each COMPONENT. Any of gzip,
80+ bzip2, and xz compression are permissible.
81 """
82
83 valid_file_type_counts = [
84
85=== modified file 'lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1.dsc'
86--- lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1.dsc 2009-11-14 02:59:34 +0000
87+++ lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1.dsc 2011-03-25 16:46:32 +0000
88@@ -8,15 +8,18 @@
89 Checksums-Sha1:
90 e7a106587e0f11220e27ccc5db7527cae05e4054 178 bar_1.0.orig-comp1.tar.gz
91 a645cc0856469f549f11bb9bdc4ca6dda4eedd4b 156 bar_1.0.orig-comp2.tar.bz2
92+ bda4aae72bc911d25db3837f644c21fa60a30394 192 bar_1.0.orig-comp3.tar.xz
93 73a04163fee97fd2257ab266bd48f1d3d528e012 164 bar_1.0.orig.tar.gz
94 727de2395d3a3e35c375159db01072935fea02f8 737 bar_1.0-1.debian.tar.bz2
95 Checksums-Sha256:
96 aff0bbc01c5883ac76e89cba7a9b6cd79b521183f0de86c93e93ab8804f5a256 178 bar_1.0.orig-comp1.tar.gz
97 955131b3a5bd881c008ff822c0f9b7544350647fe1f355f65a138e0e5e5e8d71 156 bar_1.0.orig-comp2.tar.bz2
98+ 189ca14ff5de56e9ee1ad119992d8dada416b4d3e527a3c1ea6c068e6c9ab04f 192 bar_1.0.orig-comp3.tar.xz
99 f1ecff929899b567f45d6734b69d59a4f3c04dabce3cc8e6ed6d64073eda360e 164 bar_1.0.orig.tar.gz
100 3d2137f9f80f4b6c80f73acb8b3ac7986c962c4268d8948f54823d27148a6116 737 bar_1.0-1.debian.tar.bz2
101 Files:
102 eed105761436486f7eebaa8c017bc59a 178 bar_1.0.orig-comp1.tar.gz
103 0a30b50fa846e75261808ee1f41d1cbe 156 bar_1.0.orig-comp2.tar.bz2
104+ 151443692da0d20731ff79df1e22cc37 192 bar_1.0.orig-comp3.tar.xz
105 fc1464e5985b962a042d5354452f361d 164 bar_1.0.orig.tar.gz
106 e68110184d4d9e7afd81520cc490b396 737 bar_1.0-1.debian.tar.bz2
107
108=== modified file 'lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1_source.changes'
109--- lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1_source.changes 2009-11-14 02:59:34 +0000
110+++ lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0-1_source.changes 2011-03-25 16:46:32 +0000
111@@ -15,20 +15,23 @@
112 .
113 * Initial version
114 Checksums-Sha1:
115- 762b018e756c1d9be905d40291bc8e975c57a8f0 1115 bar_1.0-1.dsc
116+ e7422c6fba68e168e0d19c691a4a125eed1d7e23 1347 bar_1.0-1.dsc
117 e7a106587e0f11220e27ccc5db7527cae05e4054 178 bar_1.0.orig-comp1.tar.gz
118 a645cc0856469f549f11bb9bdc4ca6dda4eedd4b 156 bar_1.0.orig-comp2.tar.bz2
119+ bda4aae72bc911d25db3837f644c21fa60a30394 192 bar_1.0.orig-comp3.tar.xz
120 73a04163fee97fd2257ab266bd48f1d3d528e012 164 bar_1.0.orig.tar.gz
121 727de2395d3a3e35c375159db01072935fea02f8 737 bar_1.0-1.debian.tar.bz2
122 Checksums-Sha256:
123- 49f2656a0e221b0f07dc208f583e2523b09bc30104855372534b5562478efdb5 1115 bar_1.0-1.dsc
124+ e400747cc2d24517e9303ddddc008e0be678d622a0d36c929bbb572c11d36bad 1347 bar_1.0-1.dsc
125 aff0bbc01c5883ac76e89cba7a9b6cd79b521183f0de86c93e93ab8804f5a256 178 bar_1.0.orig-comp1.tar.gz
126 955131b3a5bd881c008ff822c0f9b7544350647fe1f355f65a138e0e5e5e8d71 156 bar_1.0.orig-comp2.tar.bz2
127+ 189ca14ff5de56e9ee1ad119992d8dada416b4d3e527a3c1ea6c068e6c9ab04f 192 bar_1.0.orig-comp3.tar.xz
128 f1ecff929899b567f45d6734b69d59a4f3c04dabce3cc8e6ed6d64073eda360e 164 bar_1.0.orig.tar.gz
129 3d2137f9f80f4b6c80f73acb8b3ac7986c962c4268d8948f54823d27148a6116 737 bar_1.0-1.debian.tar.bz2
130 Files:
131- 662977e76501561c902c34bf94a2054d 1115 devel optional bar_1.0-1.dsc
132+ 7db2a612a48d87116b7b3651c4a43aa1 1347 devel optional bar_1.0-1.dsc
133 eed105761436486f7eebaa8c017bc59a 178 devel optional bar_1.0.orig-comp1.tar.gz
134 0a30b50fa846e75261808ee1f41d1cbe 156 devel optional bar_1.0.orig-comp2.tar.bz2
135+ 151443692da0d20731ff79df1e22cc37 192 devel optional bar_1.0.orig-comp3.tar.xz
136 fc1464e5985b962a042d5354452f361d 164 devel optional bar_1.0.orig.tar.gz
137 e68110184d4d9e7afd81520cc490b396 737 devel optional bar_1.0-1.debian.tar.bz2
138
139=== added file 'lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0.orig-comp3.tar.xz'
140Binary files lib/lp/archiveuploader/tests/data/suite/bar_1.0-1_3.0-quilt/bar_1.0.orig-comp3.tar.xz 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-comp3.tar.xz 2011-03-25 16:46:32 +0000 differ
141=== modified file 'lib/lp/archiveuploader/tests/test_dscfile.py'
142--- lib/lp/archiveuploader/tests/test_dscfile.py 2010-12-22 01:08:48 +0000
143+++ lib/lp/archiveuploader/tests/test_dscfile.py 2011-03-25 16:46:32 +0000
144@@ -143,7 +143,7 @@
145 class BaseTestSourceFileVerification(TestCase):
146
147 def assertErrorsForFiles(self, expected, files, components={},
148- bzip2_count=0):
149+ bzip2_count=0, xz_count=0):
150 """Check problems with the given set of files for the given format.
151
152 :param expected: a list of expected errors, as strings.
153@@ -152,6 +152,7 @@
154 :param components: a dict mapping orig component tarball components
155 to counts.
156 :param bzip2_count: number of files using bzip2 compression.
157+ :param xz_count: number of files using xz compression.
158 """
159 full_files = {
160 NATIVE_TARBALL: 0,
161@@ -163,9 +164,9 @@
162 self.assertEquals(
163 expected,
164 [str(e) for e in format_to_file_checker_map[self.format](
165- 'foo_1.dsc', full_files, components, bzip2_count)])
166+ 'foo_1.dsc', full_files, components, bzip2_count, xz_count)])
167
168- def assertFilesOK(self, files, components={}, bzip2_count=0):
169+ def assertFilesOK(self, files, components={}, bzip2_count=0, xz_count=0):
170 """Check that the given set of files is OK for the given format.
171
172 :param format: the `SourcePackageFormat` to check against.
173@@ -173,8 +174,9 @@
174 :param components: a dict mapping orig component tarball components
175 to counts.
176 :param bzip2_count: number of files using bzip2 compression.
177+ :param xz_count: number of files using xz compression.
178 """
179- self.assertErrorsForFiles([], files, components, bzip2_count)
180+ self.assertErrorsForFiles([], files, components, bzip2_count, xz_count)
181
182
183 class Test10SourceFormatVerification(BaseTestSourceFileVerification):
184@@ -184,6 +186,7 @@
185 wrong_files_error = ('foo_1.dsc: must have exactly one tar.gz, or an '
186 'orig.tar.gz and diff.gz')
187 bzip2_error = 'foo_1.dsc: is format 1.0 but uses bzip2 compression.'
188+ xz_error = 'foo_1.dsc: is format 1.0 but uses xz compression.'
189
190 def testFormat10Debian(self):
191 # A 1.0 source can contain an original tarball and a Debian diff
192@@ -209,7 +212,12 @@
193 def testFormat10CannotUseBzip2(self):
194 # 1.0 sources cannot use bzip2 compression.
195 self.assertErrorsForFiles(
196- [self.bzip2_error], {NATIVE_TARBALL: 1}, {}, 1)
197+ [self.bzip2_error], {NATIVE_TARBALL: 1}, {}, 1, 0)
198+
199+ def testFormat10CannotUseXz(self):
200+ # 1.0 sources cannot use xz compression.
201+ self.assertErrorsForFiles(
202+ [self.xz_error], {NATIVE_TARBALL: 1}, {}, 0, 1)
203
204
205 class Test30QuiltSourceFormatVerification(BaseTestSourceFileVerification):
206@@ -223,12 +231,13 @@
207 def testFormat30Quilt(self):
208 # A 3.0 (quilt) source must contain an orig tarball and a debian
209 # tarball. It may also contain at most one component tarball for
210- # each component, and can use gzip or bzip2 compression.
211+ # each component, and can use gzip, bzip2, or xz compression.
212 for components in ({}, {'foo': 1}, {'foo': 1, 'bar': 1}):
213 for bzip2_count in (0, 1):
214- self.assertFilesOK(
215- {ORIG_TARBALL: 1, DEBIAN_TARBALL: 1}, components,
216- bzip2_count)
217+ for xz_count in (0, 1):
218+ self.assertFilesOK(
219+ {ORIG_TARBALL: 1, DEBIAN_TARBALL: 1}, components,
220+ bzip2_count, xz_count)
221
222 def testFormat30QuiltCannotHaveConflictingComponentTarballs(self):
223 # Multiple conflicting tarballs for a single component are
224@@ -253,10 +262,11 @@
225
226 def testFormat30Native(self):
227 # 3.0 (native) sources must contain just a native tarball. They
228- # may use gzip or bzip2 compression.
229+ # may use gzip, bzip2, or xz compression.
230 for bzip2_count in (0, 1):
231 self.assertFilesOK({NATIVE_TARBALL: 1}, {},
232- bzip2_count)
233+ bzip2_count, 0)
234+ self.assertFilesOK({NATIVE_TARBALL: 1}, {}, 0, 1)
235
236 def testFormat30NativeCannotHaveWrongFiles(self):
237 # 3.0 (quilt) sources may not have a diff, Debian tarball, orig
238
239=== modified file 'lib/lp/archiveuploader/tests/test_utils.py'
240--- lib/lp/archiveuploader/tests/test_utils.py 2010-12-09 16:20:20 +0000
241+++ lib/lp/archiveuploader/tests/test_utils.py 2011-03-25 16:46:32 +0000
242@@ -47,6 +47,9 @@
243 self.assertEquals(
244 determine_source_file_type('foo_1.0.orig.tar.bz2'),
245 SourcePackageFileType.ORIG_TARBALL)
246+ self.assertEquals(
247+ determine_source_file_type('foo_1.0.orig.tar.xz'),
248+ SourcePackageFileType.ORIG_TARBALL)
249
250 # Component original tarballs too.
251 self.assertEquals(
252@@ -55,6 +58,9 @@
253 self.assertEquals(
254 determine_source_file_type('foo_1.0.orig-bar.tar.bz2'),
255 SourcePackageFileType.COMPONENT_ORIG_TARBALL)
256+ self.assertEquals(
257+ determine_source_file_type('foo_1.0.orig-bar.tar.xz'),
258+ SourcePackageFileType.COMPONENT_ORIG_TARBALL)
259
260 # And Debian tarballs...
261 self.assertEquals(
262@@ -63,6 +69,9 @@
263 self.assertEquals(
264 determine_source_file_type('foo_1.0-2.debian.tar.bz2'),
265 SourcePackageFileType.DEBIAN_TARBALL)
266+ self.assertEquals(
267+ determine_source_file_type('foo_1.0-2.debian.tar.xz'),
268+ SourcePackageFileType.DEBIAN_TARBALL)
269
270 # And even native tarballs!
271 self.assertEquals(
272@@ -71,6 +80,9 @@
273 self.assertEquals(
274 determine_source_file_type('foo_1.0.tar.bz2'),
275 SourcePackageFileType.NATIVE_TARBALL)
276+ self.assertEquals(
277+ determine_source_file_type('foo_1.0.tar.xz'),
278+ SourcePackageFileType.NATIVE_TARBALL)
279
280 self.assertEquals(None, determine_source_file_type('foo_1.0'))
281 self.assertEquals(None, determine_source_file_type('foo_1.0.blah.gz'))
282@@ -235,9 +247,11 @@
283 def test_re_issource(self):
284 # Verify that various source extensions match the regexp.
285 extensions = (
286- 'dsc', 'tar.gz', 'tar.bz2', 'diff.gz', 'orig.tar.gz',
287- 'orig.tar.bz2', 'orig-bar.tar.gz', 'orig-bar.tar.bz2',
288- 'orig-foo_bar.tar.gz', 'debian.tar.gz', 'debian.tar.bz2')
289+ 'dsc', 'tar.gz', 'tar.bz2', 'tar.xz', 'diff.gz',
290+ 'orig.tar.gz', 'orig.tar.bz2', 'orig.tar.xz',
291+ 'orig-bar.tar.gz', 'orig-bar.tar.bz2', 'orig-bar.tar.xz',
292+ 'orig-foo_bar.tar.gz',
293+ 'debian.tar.gz', 'debian.tar.bz2', 'debian.tar.xz')
294 for extension in extensions:
295 self.assertEquals(
296 ('foo-bar', '1.0', extension),
297@@ -255,8 +269,9 @@
298 # A badly formatted name also doesn't match.
299 self.assertIs(None, re_issource.match('foo-bar.dsc'))
300
301- # bzip2 compression for files which must be gzipped is invalid.
302+ # bzip2/xz compression for files which must be gzipped is invalid.
303 self.assertIs(None, re_issource.match('foo-bar_1.0.diff.bz2'))
304+ self.assertIs(None, re_issource.match('foo-bar_1.0.diff.xz'))
305
306
307 class DdpkgExtractSourceTests(TestCase):
308
309=== modified file 'lib/lp/archiveuploader/utils.py'
310--- lib/lp/archiveuploader/utils.py 2011-02-17 17:02:54 +0000
311+++ lib/lp/archiveuploader/utils.py 2011-03-25 16:46:32 +0000
312@@ -57,14 +57,14 @@
313 re_isadeb = re.compile(r"(.+?)_(.+?)_(.+)\.(u?d?deb)$")
314
315 source_file_exts = [
316- 'orig(?:-.+)?\.tar\.(?:gz|bz2)', 'diff.gz',
317- '(?:debian\.)?tar\.(?:gz|bz2)', 'dsc']
318+ 'orig(?:-.+)?\.tar\.(?:gz|bz2|xz)', 'diff.gz',
319+ '(?:debian\.)?tar\.(?:gz|bz2|xz)', 'dsc']
320 re_issource = re.compile(
321 r"([^_]+)_(.+?)\.(%s)" % "|".join(ext for ext in source_file_exts))
322-re_is_component_orig_tar_ext = re.compile(r"^orig-(.+).tar.(?:gz|bz2)$")
323-re_is_orig_tar_ext = re.compile(r"^orig.tar.(?:gz|bz2)$")
324-re_is_debian_tar_ext = re.compile(r"^debian.tar.(?:gz|bz2)$")
325-re_is_native_tar_ext = re.compile(r"^tar.(?:gz|bz2)$")
326+re_is_component_orig_tar_ext = re.compile(r"^orig-(.+).tar.(?:gz|bz2|xz)$")
327+re_is_orig_tar_ext = re.compile(r"^orig.tar.(?:gz|bz2|xz)$")
328+re_is_debian_tar_ext = re.compile(r"^debian.tar.(?:gz|bz2|xz)$")
329+re_is_native_tar_ext = re.compile(r"^tar.(?:gz|bz2|xz)$")
330
331 re_no_epoch = re.compile(r"^\d+\:")
332 re_no_revision = re.compile(r"-[^-]+$")
333
334=== modified file 'lib/lp/soyuz/enums.py'
335--- lib/lp/soyuz/enums.py 2010-08-24 15:29:01 +0000
336+++ lib/lp/soyuz/enums.py 2011-03-25 16:46:32 +0000
337@@ -523,14 +523,14 @@
338 3.0 (quilt)
339
340 Specifies a non-native package, with an orig.tar.* and a debian.tar.*.
341- Supports gzip and bzip2 compression.
342+ Supports gzip, bzip2, and xz compression.
343 """)
344
345 FORMAT_3_0_NATIVE = DBItem(2, """
346 3.0 (native)
347
348- Specifies a native package, with a single tar.*. Supports gzip and
349- bzip2 compression.
350+ Specifies a native package, with a single tar.*. Supports gzip,
351+ bzip2, and xz compression.
352 """)
353
354