Merge lp:~jelmer/bzr-builddeb/lzma into lp:bzr-builddeb
- lzma
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 579 | ||||
Proposed branch: | lp:~jelmer/bzr-builddeb/lzma | ||||
Merge into: | lp:bzr-builddeb | ||||
Diff against target: |
606 lines (+197/-58) 14 files modified
cmds.py (+4/-2) debian/changelog (+2/-1) dh_make.py (+2/-0) import_dsc.py (+6/-4) repack_tarball.py (+31/-7) tests/__init__.py (+35/-30) tests/test_import_dsc.py (+35/-0) tests/test_repack_tarball.py (+1/-1) tests/test_repack_tarball_extra.py (+6/-6) tests/test_upstream.py (+35/-0) tests/test_util.py (+27/-4) upstream/__init__.py (+2/-1) upstream/pristinetar.py (+8/-1) util.py (+3/-1) |
||||
To merge this branch: | bzr merge lp:~jelmer/bzr-builddeb/lzma | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Westby | Approve | ||
Review via email: mp+65802@code.launchpad.net |
Commit message
Description of the change
Add support for .tar.lzma orig tarballs and support for lzma/xz compressed tarballs in general.
This also removes RepackTarballAd
pristine-tar doesn't support lzma yet (bug 801588), so it will currently just ship a copy of the entire tarball when it encounters a lzma tarball. That might be problematic in some cases (say, openoffice as a .tar.xz), so we may want to raise PristineTarError if it complains about generating a full-size delta, or perhaps if the delta hits a particular size. What do you think?
- 583. By Jelmer Vernooij
-
remove unused imports.
- 584. By Jelmer Vernooij
-
Require lzma feature for lzma-dependent tests.
Jelmer Vernooij (jelmer) wrote : | # |
Hi James
On 27/06/11 21:11, James Westby wrote:
> This looks ok to me. Is lzma supported by dak yet?
I don't think it is yet, but it (still) seems like it will be in the
near future.
>
> I'm not sure about the delta questions, storing the full delta is certainly painful,
> but if this is supported in dak then we'll have to support it in bzr-builddeb soon,
> and that is certainly an easy way to do it.
>
> It's also something we could transition away from easily given that newer pristine-tar
> will still deal with the full-size deltas.
>
> My only pause is that as you say an openoffice.tar.xz would be painful, and large
> packages are the ones most likely to use lzma.
>
I'll see if I can spend some time adding lzma support to pristine-tar.
Cheers,
Jelmer
Preview Diff
1 | === modified file 'cmds.py' |
2 | --- cmds.py 2011-06-24 10:51:46 +0000 |
3 | +++ cmds.py 2011-06-24 15:14:30 +0000 |
4 | @@ -471,8 +471,8 @@ |
5 | |
6 | You must supply the source to import from, and in some cases |
7 | the version number of the new release. The source can be a .tar.gz, .tar, |
8 | - .tar.bz2, .tgz or .zip archive, a directory or a branch. The source may |
9 | - also be a remote file described by a URL. |
10 | + .tar.bz2, .tar.lzma, .tgz or .zip archive, a directory or a branch. The |
11 | + source may also be a remote file described by a URL. |
12 | |
13 | In most situations the version can be guessed from the upstream source. |
14 | If the upstream version can not be guessed or if it is guessed |
15 | @@ -577,6 +577,8 @@ |
16 | if v3: |
17 | if location.endswith(".tar.bz2") or location.endswith(".tbz2"): |
18 | format = "bz2" |
19 | + elif location.endswith(".tar.lzma"): |
20 | + format = "lzma" |
21 | dest_name = tarball_name(package, version, format=format) |
22 | tarball_filename = os.path.join(orig_dir, dest_name) |
23 | try: |
24 | |
25 | === modified file 'debian/changelog' |
26 | --- debian/changelog 2011-06-14 00:32:04 +0000 |
27 | +++ debian/changelog 2011-06-24 15:14:30 +0000 |
28 | @@ -15,8 +15,9 @@ |
29 | sources.list. LP: #796853 |
30 | * Fix deprecation warnings for TestCase.failUnlessExists and |
31 | TestCase.failIfExists in bzr 2.4. |
32 | + * Add support for xz and lzma tarballs. LP: #553668 |
33 | |
34 | - -- Jelmer Vernooij <jelmer@debian.org> Mon, 13 Jun 2011 23:10:20 +0100 |
35 | + -- Jelmer Vernooij <jelmer@debian.org> Fri, 24 Jun 2011 16:51:51 +0200 |
36 | |
37 | bzr-builddeb (2.7.4) unstable; urgency=low |
38 | |
39 | |
40 | === modified file 'dh_make.py' |
41 | --- dh_make.py 2011-06-23 10:29:54 +0000 |
42 | +++ dh_make.py 2011-06-24 15:14:30 +0000 |
43 | @@ -62,6 +62,8 @@ |
44 | if use_v3: |
45 | if tarball.endswith(".tar.bz2") or tarball.endswith(".tbz2"): |
46 | format = "bz2" |
47 | + elif tarball.endswith(".tar.lzma"): |
48 | + format = "lzma" |
49 | dest_name = util.tarball_name(package_name, version, format=format) |
50 | trace.note("Fetching tarball") |
51 | repack_tarball(tarball, dest_name, target_dir=orig_dir, |
52 | |
53 | === modified file 'import_dsc.py' |
54 | --- import_dsc.py 2011-06-23 21:34:52 +0000 |
55 | +++ import_dsc.py 2011-06-24 15:14:30 +0000 |
56 | @@ -1505,7 +1505,8 @@ |
57 | self.extracted_upstream = None |
58 | for part in self.dsc['files']: |
59 | if (part['name'].endswith(".tar.gz") |
60 | - or part['name'].endswith(".tar.bz2")): |
61 | + or part['name'].endswith(".tar.bz2") |
62 | + or part['name'].endswith(".tar.lzma")): |
63 | self.unextracted_debian_md5 = part['md5sum'] |
64 | |
65 | |
66 | @@ -1545,12 +1546,13 @@ |
67 | os.path.join(osutils.dirname(self.dsc_path), |
68 | part['name'])), part['md5sum'])) |
69 | elif (part['name'].endswith(".debian.tar.gz") |
70 | - or part['name'].endswith(".debian.tar.bz2")): |
71 | + or part['name'].endswith(".debian.tar.bz2") |
72 | + or part['name'].endswith(".debian.tar.lzma")): |
73 | self.unextracted_debian_md5 = part['md5sum'] |
74 | assert self.upstream_tarballs is not None, \ |
75 | - "Can't handle non gz|bz2 tarballs yet" |
76 | + "Can't handle non gz|bz2|lzma tarballs yet" |
77 | assert self.unextracted_debian_md5 is not None, \ |
78 | - "Can't handle non gz|bz2 tarballs yet" |
79 | + "Can't handle non gz|bz2|lzma tarballs yet" |
80 | |
81 | |
82 | SOURCE_EXTRACTORS = {} |
83 | |
84 | === modified file 'repack_tarball.py' |
85 | --- repack_tarball.py 2011-06-12 22:30:15 +0000 |
86 | +++ repack_tarball.py 2011-06-24 15:14:30 +0000 |
87 | @@ -36,8 +36,9 @@ |
88 | import zipfile |
89 | |
90 | from bzrlib.errors import ( |
91 | - FileExists, |
92 | - ) |
93 | + DependencyNotPresent, |
94 | + FileExists, |
95 | + ) |
96 | from bzrlib.transport import get_transport |
97 | |
98 | from bzrlib.plugins.builddeb.errors import UnsupportedRepackFormat |
99 | @@ -64,8 +65,8 @@ |
100 | raise NotImplementedError(self.repack) |
101 | |
102 | |
103 | -class TgzTgzRepacker(TgzRepacker): |
104 | - """A TgzRepacker that just copies.""" |
105 | +class CopyRepacker(TgzRepacker): |
106 | + """A Repacker that just copies.""" |
107 | |
108 | def repack(self, target_f): |
109 | shutil.copyfileobj(self.source_f, target_f) |
110 | @@ -94,6 +95,22 @@ |
111 | gz.close() |
112 | |
113 | |
114 | +class TarLzma2TgzRepacker(TgzRepacker): |
115 | + """A TgzRepacker that repacks from a .tar.lzma or .tar.xz.""" |
116 | + |
117 | + def repack(self, target_f): |
118 | + try: |
119 | + import lzma |
120 | + except ImportError, e: |
121 | + raise DependencyNotPresent('lzma', e) |
122 | + content = lzma.decompress(self.source_f.read()) |
123 | + gz = gzip.GzipFile(mode='w', fileobj=target_f) |
124 | + try: |
125 | + gz.write(content) |
126 | + finally: |
127 | + gz.close() |
128 | + |
129 | + |
130 | class ZipTgzRepacker(TgzRepacker): |
131 | """A TgzRepacker that repacks from a .zip file.""" |
132 | |
133 | @@ -124,7 +141,8 @@ |
134 | |
135 | |
136 | def get_filetype(filename): |
137 | - types = [".tar.gz", ".tgz", ".tar.bz2", ".tbz2", ".tar", ".zip"] |
138 | + types = [".tar.gz", ".tgz", ".tar.bz2", ".tar.xz", ".tar.lzma", ".tbz2", |
139 | + ".tar", ".zip"] |
140 | for filetype in types: |
141 | if filename.endswith(filetype): |
142 | return filetype |
143 | @@ -134,11 +152,17 @@ |
144 | """Return the appropriate repacker based on the file extension.""" |
145 | filetype = get_filetype(source_filename) |
146 | if (filetype == ".tar.gz" or filetype == ".tgz"): |
147 | - return TgzTgzRepacker |
148 | + return CopyRepacker |
149 | if (filetype == ".tar.bz2" or filetype == ".tbz2"): |
150 | if force_gz: |
151 | return Tbz2TgzRepacker |
152 | - return TgzTgzRepacker |
153 | + return CopyRepacker |
154 | + if filetype == ".tar.lzma": |
155 | + if force_gz: |
156 | + return TarLzma2TgzRepacker |
157 | + return CopyRepacker |
158 | + if filetype == ".tar.xz": |
159 | + return TarLzma2TgzRepacker |
160 | if filetype == ".tar": |
161 | return TarTgzRepacker |
162 | if filetype == ".zip": |
163 | |
164 | === modified file 'tests/__init__.py' |
165 | --- tests/__init__.py 2011-06-13 23:01:14 +0000 |
166 | +++ tests/__init__.py 2011-06-24 15:14:30 +0000 |
167 | @@ -23,10 +23,8 @@ |
168 | import tarfile |
169 | import zipfile |
170 | |
171 | -from copy import deepcopy |
172 | import doctest |
173 | import os |
174 | -from unittest import TestSuite |
175 | |
176 | from bzrlib import tests |
177 | |
178 | @@ -36,7 +34,7 @@ |
179 | # Prior to 0.1.15 the debian module was called debian_bundle |
180 | from debian_bundle.changelog import Version, Changelog |
181 | |
182 | -from bzrlib.tests import TestUtil, multiply_tests |
183 | +from bzrlib.tests import TestUtil, multiply_tests, ModuleAvailableFeature |
184 | |
185 | |
186 | def make_new_upstream_dir(source, dest): |
187 | @@ -84,33 +82,31 @@ |
188 | shutil.rmtree(source) |
189 | |
190 | |
191 | -tarball_functions = [('dir', make_new_upstream_dir, '../package-0.2'), |
192 | - ('.tar.gz', make_new_upstream_tarball, |
193 | - '../package-0.2.tar.gz'), |
194 | - ('.tar.bz2', make_new_upstream_tarball_bz2, |
195 | - '../package-0.2.tar.bz2'), |
196 | - ('.zip', make_new_upstream_tarball_zip, |
197 | - '../package-0.2.zip'), |
198 | - ('.tar', make_new_upstream_tarball_bare, |
199 | - '../package-0.2.tar'), |
200 | - ] |
201 | - |
202 | - |
203 | -class RepackTarballAdaptor(object): |
204 | - |
205 | - def adapt(self, test): |
206 | - result = TestSuite() |
207 | - for (name, function, source) in tarball_functions: |
208 | - new_test = deepcopy(test) |
209 | - source = os.path.basename(source) |
210 | - new_test.build_tarball = function(source) |
211 | - new_test.old_tarball = source |
212 | - def make_new_id(): |
213 | - new_id = '%s(%s)' % (test.id(), name) |
214 | - return lambda: new_id |
215 | - new_test.id = make_new_id() |
216 | - result.addTest(new_test) |
217 | - return result |
218 | +def make_new_upstream_tarball_xz(source, dest): |
219 | + import lzma |
220 | + f = lzma.LZMAFile(dest, 'w') |
221 | + try: |
222 | + tar = tarfile.open(None, 'w', f) |
223 | + try: |
224 | + tar.add(source) |
225 | + finally: |
226 | + tar.close() |
227 | + finally: |
228 | + f.close() |
229 | + shutil.rmtree(source) |
230 | + |
231 | +def make_new_upstream_tarball_lzma(source, dest): |
232 | + import lzma |
233 | + f = lzma.LZMAFile(dest, 'w', options={'format': 'alone'}) |
234 | + try: |
235 | + tar = tarfile.open(None, 'w', f) |
236 | + try: |
237 | + tar.add(source) |
238 | + finally: |
239 | + tar.close() |
240 | + finally: |
241 | + f.close() |
242 | + shutil.rmtree(source) |
243 | |
244 | |
245 | def load_tests(standard_tests, module, loader): |
246 | @@ -151,6 +147,12 @@ |
247 | old_tarball='../package-0.2.tar.gz')), |
248 | ('.tar.bz2', dict(build_tarball=make_new_upstream_tarball_bz2, |
249 | old_tarball='../package-0.2.tar.bz2')), |
250 | + ('.tar.xz', dict(build_tarball=make_new_upstream_tarball_xz, |
251 | + old_tarball='../package-0.2.tar.xz', |
252 | + _test_needs_features=[LzmaFeature])), |
253 | + ('.tar.lzma', dict(build_tarball=make_new_upstream_tarball_lzma, |
254 | + old_tarball='../package-0.2.tar.lzma', |
255 | + _test_needs_features=[LzmaFeature])), |
256 | ('.zip', dict(build_tarball=make_new_upstream_tarball_zip, |
257 | old_tarball='../package-0.2.zip')), |
258 | ('.tar', dict(build_tarball=make_new_upstream_tarball_bare, |
259 | @@ -435,3 +437,6 @@ |
260 | assert ret == 0, "dpkg-genchanges failed, output:\n%s" % \ |
261 | (proc.stdout.read(),) |
262 | shutil.rmtree(basedir) |
263 | + |
264 | + |
265 | +LzmaFeature = ModuleAvailableFeature("lzma") |
266 | |
267 | === modified file 'tests/test_import_dsc.py' |
268 | --- tests/test_import_dsc.py 2011-06-23 15:33:44 +0000 |
269 | +++ tests/test_import_dsc.py 2011-06-24 15:14:30 +0000 |
270 | @@ -45,6 +45,7 @@ |
271 | ) |
272 | from bzrlib.plugins.builddeb.tests import ( |
273 | BuilddebTestCase, |
274 | + LzmaFeature, |
275 | SourcePackageBuilder, |
276 | ) |
277 | |
278 | @@ -889,6 +890,40 @@ |
279 | self.assertEqual(rev.properties['deb-md5'], self.fake_md5_1) |
280 | self.assertTrue('deb-pristine-delta-bz2' in rev.properties) |
281 | |
282 | + def test_import_upstream_with_lzma_tarball(self): |
283 | + self.requireFeature(PristineTarFeature) |
284 | + self.requireFeature(LzmaFeature) |
285 | + import lzma |
286 | + version = Version("0.1-1") |
287 | + name = "package" |
288 | + basedir = name + "-" + str(version.upstream_version) |
289 | + os.mkdir(basedir) |
290 | + write_to_file(os.path.join(basedir, "README"), "Hi\n") |
291 | + write_to_file(os.path.join(basedir, "BUGS"), "") |
292 | + tar_path = "package_0.1.orig.tar.lzma" |
293 | + f = lzma.LZMAFile(tar_path, 'w') |
294 | + try: |
295 | + tf = tarfile.open(None, 'w', f) |
296 | + try: |
297 | + tf.add(basedir) |
298 | + finally: |
299 | + tf.close() |
300 | + finally: |
301 | + f.close() |
302 | + self.db1.import_upstream(basedir, "package", version.upstream_version, |
303 | + [], upstream_tarballs=[(os.path.abspath(tar_path), None, self.fake_md5_1)]) |
304 | + tree = self.up_tree1 |
305 | + branch = tree.branch |
306 | + rh = branch.revision_history() |
307 | + self.assertEqual(len(rh), 1) |
308 | + self.assertEqual(self.db1.revid_of_upstream_version( |
309 | + "package", version.upstream_version), rh[0]) |
310 | + rev = branch.repository.get_revision(rh[0]) |
311 | + self.assertEqual(rev.message, |
312 | + "Import upstream version %s" % str(version.upstream_version)) |
313 | + self.assertEqual(rev.properties['deb-md5'], self.fake_md5_1) |
314 | + self.assertTrue('deb-pristine-delta-lzma' in rev.properties) |
315 | + |
316 | def test_import_package_init_from_other(self): |
317 | self.requireFeature(PristineTarFeature) |
318 | version1 = Version("0.1-1") |
319 | |
320 | === modified file 'tests/test_repack_tarball.py' |
321 | --- tests/test_repack_tarball.py 2011-06-13 23:01:14 +0000 |
322 | +++ tests/test_repack_tarball.py 2011-06-24 15:14:30 +0000 |
323 | @@ -1,6 +1,6 @@ |
324 | # test_repack_tarball.py -- Testsuite for repacking of tarballs |
325 | # Copyright (C) 2007 James Westby <jw+debian@jameswestby.net> |
326 | -# |
327 | +# |
328 | # This file is part of bzr-builddeb. |
329 | # |
330 | # bzr-builddeb is free software; you can redistribute it and/or modify |
331 | |
332 | === modified file 'tests/test_repack_tarball_extra.py' |
333 | --- tests/test_repack_tarball_extra.py 2011-06-13 23:01:14 +0000 |
334 | +++ tests/test_repack_tarball_extra.py 2011-06-24 15:14:30 +0000 |
335 | @@ -48,7 +48,7 @@ |
336 | touch(filename) |
337 | |
338 | |
339 | -def make_new_upstream_tarball(tarball): |
340 | +def make_new_upstream_tarball_gz(tarball): |
341 | tar = tarfile.open(tarball, 'w:gz') |
342 | try: |
343 | tar.add('package-0.2') |
344 | @@ -79,11 +79,11 @@ |
345 | def test_conditional_repack_tarball_different(self): |
346 | tarball_name = 'package-0.2.tar.gz' |
347 | create_basedir('package-0.2/', files=['README']) |
348 | - make_new_upstream_tarball(tarball_name) |
349 | + make_new_upstream_tarball_gz(tarball_name) |
350 | target_dir = 'target' |
351 | os.mkdir(target_dir) |
352 | create_basedir('package-0.2/', files=['README', 'NEWS']) |
353 | - make_new_upstream_tarball(os.path.join(target_dir, tarball_name)) |
354 | + make_new_upstream_tarball_gz(os.path.join(target_dir, tarball_name)) |
355 | self.assertRaises(FileExists, repack_tarball, tarball_name, |
356 | tarball_name, target_dir=target_dir) |
357 | self.assertPathExists(tarball_name) |
358 | @@ -92,7 +92,7 @@ |
359 | def test_conditional_repack_tarball_same(self): |
360 | tarball_name = 'package-0.2.tar.gz' |
361 | create_basedir('package-0.2/', files=['README']) |
362 | - make_new_upstream_tarball(tarball_name) |
363 | + make_new_upstream_tarball_gz(tarball_name) |
364 | target_dir = 'target' |
365 | os.mkdir(target_dir) |
366 | shutil.copy(tarball_name, target_dir) |
367 | @@ -108,7 +108,7 @@ |
368 | target_dir = 'target' |
369 | os.mkdir(target_dir) |
370 | create_basedir('package-0.2/', files=['README']) |
371 | - make_new_upstream_tarball(os.path.join(target_dir, tarball_name)) |
372 | + make_new_upstream_tarball_gz(os.path.join(target_dir, tarball_name)) |
373 | self.assertRaises(FileExists, repack_tarball, bz2_tarball_name, |
374 | tarball_name, target_dir=target_dir) |
375 | self.assertPathExists(bz2_tarball_name) |
376 | @@ -129,7 +129,7 @@ |
377 | target_dir = 'target' |
378 | os.mkdir(target_dir) |
379 | create_basedir('package-0.2/', files=['COPYING']) |
380 | - make_new_upstream_tarball(os.path.join(target_dir, bz2_tarball_name)) |
381 | + make_new_upstream_tarball_gz(os.path.join(target_dir, bz2_tarball_name)) |
382 | self.assertRaises(FileExists, repack_tarball, bz2_tarball_name, |
383 | bz2_tarball_name, target_dir=target_dir) |
384 | self.assertPathExists(bz2_tarball_name) |
385 | |
386 | === modified file 'tests/test_upstream.py' |
387 | --- tests/test_upstream.py 2011-06-15 18:44:09 +0000 |
388 | +++ tests/test_upstream.py 2011-06-24 15:14:30 +0000 |
389 | @@ -35,6 +35,7 @@ |
390 | ) |
391 | from bzrlib.tests import ( |
392 | Feature, |
393 | + KnownFailure, |
394 | TestCase, |
395 | ) |
396 | from bzrlib.plugins.builddeb.config import ( |
397 | @@ -46,6 +47,7 @@ |
398 | WatchFileMissing, |
399 | ) |
400 | from bzrlib.plugins.builddeb.tests import ( |
401 | + LzmaFeature, |
402 | TestCaseWithTransport, |
403 | ) |
404 | from bzrlib.plugins.builddeb.upstream import ( |
405 | @@ -216,6 +218,18 @@ |
406 | _apt_pkg=apt_pkg) |
407 | self.assertEquals(paths, ["target/apackage_0.2.orig.tar.bz2"]) |
408 | |
409 | + def test_apt_provider_right_version_lzma(self): |
410 | + caller = MockAptCaller(work=True) |
411 | + sources = MockSources(["0.1-1", "0.2-1"], |
412 | + [[("checksum", 0L, "apackage_0.1.orig.tar.gz", "tar")], |
413 | + [("checksum", 0L, "apackage_0.2.orig.tar.lzma", "tar")]]) |
414 | + apt_pkg = MockAptPkg(sources) |
415 | + src = AptSource() |
416 | + src._run_apt_source = caller.call |
417 | + paths = src.fetch_tarball("apackage", "0.2", "target", |
418 | + _apt_pkg=apt_pkg) |
419 | + self.assertEquals(paths, ["target/apackage_0.2.orig.tar.lzma"]) |
420 | + |
421 | def test_apt_provider_right_version(self): |
422 | caller = MockAptCaller(work=True) |
423 | sources = MockSources(["0.1-1", "0.2-1"], |
424 | @@ -693,6 +707,11 @@ |
425 | rev.properties["deb-pristine-delta-bz2"] = "1" |
426 | self.assertEquals("bz2", self.source.pristine_tar_format(rev)) |
427 | |
428 | + def test_pristine_tar_format_lzma(self): |
429 | + rev = Revision("myrevid") |
430 | + rev.properties["deb-pristine-delta-lzma"] = "1" |
431 | + self.assertEquals("lzma", self.source.pristine_tar_format(rev)) |
432 | + |
433 | def test_pristine_tar_format_unknown(self): |
434 | rev = Revision("myrevid") |
435 | self.assertRaises(AssertionError, |
436 | @@ -769,6 +788,22 @@ |
437 | self.assertPathExists("bar/foo_1.0.orig.tar.gz") |
438 | gzip.open("bar/foo_1.0.orig.tar.gz").close() |
439 | |
440 | + def test_fetch_tarball_lzma(self): |
441 | + self.requireFeature(LzmaFeature) |
442 | + import lzma |
443 | + lzma_f = lzma.LZMAFile("foo-1.0.tar.lzma", 'w') |
444 | + try: |
445 | + tar = tarfile.open("foo-1.0.tar", "w", lzma_f) |
446 | + tar.close() |
447 | + finally: |
448 | + lzma_f.close() |
449 | + source = TarfileSource("foo-1.0.tar.lzma", "1.0") |
450 | + os.mkdir("bar") |
451 | + self.assertEquals(["bar/foo_1.0.orig.tar.gz"], |
452 | + source.fetch_tarball("foo", "1.0", "bar")) |
453 | + self.assertPathExists("bar/foo_1.0.orig.tar.gz") |
454 | + gzip.open("bar/foo_1.0.orig.tar.gz").close() |
455 | + |
456 | |
457 | class _MissingUpstreamProvider(UpstreamProvider): |
458 | """For tests""" |
459 | |
460 | === modified file 'tests/test_util.py' |
461 | --- tests/test_util.py 2011-06-16 11:11:36 +0000 |
462 | +++ tests/test_util.py 2011-06-24 15:14:30 +0000 |
463 | @@ -18,6 +18,8 @@ |
464 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
465 | # |
466 | |
467 | +import bz2 |
468 | +import gzip |
469 | try: |
470 | import hashlib as md5 |
471 | except ImportError: |
472 | @@ -33,7 +35,6 @@ |
473 | from debian_bundle.changelog import Changelog, Version |
474 | |
475 | from bzrlib.plugins.builddeb.config import ( |
476 | - DebBuildConfig, |
477 | BUILD_TYPE_MERGE, |
478 | BUILD_TYPE_NATIVE, |
479 | BUILD_TYPE_NORMAL, |
480 | @@ -45,6 +46,7 @@ |
481 | NoPreviousUpload, |
482 | ) |
483 | from bzrlib.plugins.builddeb.tests import ( |
484 | + LzmaFeature, |
485 | SourcePackageBuilder, |
486 | TestCaseInTempDir, |
487 | TestCaseWithTransport, |
488 | @@ -858,11 +860,24 @@ |
489 | if part is not None: |
490 | prefix += "-%s" % part |
491 | tar_path = os.path.abspath(prefix + ".tar." + compression) |
492 | - tf = tarfile.open(tar_path, 'w:%s' % compression) |
493 | + if compression == "gz": |
494 | + f = gzip.GzipFile(tar_path, "w") |
495 | + elif compression == "bz2": |
496 | + f = bz2.BZ2File(tar_path, "w") |
497 | + elif compression == "lzma": |
498 | + import lzma |
499 | + f = lzma.LZMAFile(tar_path, "w") |
500 | + else: |
501 | + raise AssertionError("Unknown compressin type %r" % |
502 | + compression) |
503 | try: |
504 | - tf.add(basedir) |
505 | + tf = tarfile.open(None, 'w', f) |
506 | + try: |
507 | + tf.add(basedir) |
508 | + finally: |
509 | + tf.close() |
510 | finally: |
511 | - tf.close() |
512 | + f.close() |
513 | finally: |
514 | shutil.rmtree(basedir) |
515 | return tar_path |
516 | @@ -881,6 +896,14 @@ |
517 | strip_components=1) |
518 | self.assertEquals(os.listdir("target"), ["README"]) |
519 | |
520 | + def test_single_orig_tar_lzma(self): |
521 | + self.requireFeature(LzmaFeature) |
522 | + tar_path = self.create_tarball("package", "0.1", "lzma") |
523 | + os.mkdir("target") |
524 | + extract_orig_tarballs([(tar_path, None)], "target", |
525 | + strip_components=1) |
526 | + self.assertEquals(os.listdir("target"), ["README"]) |
527 | + |
528 | def test_multiple_tarballs(self): |
529 | base_tar_path = self.create_tarball("package", "0.1", "bz2") |
530 | tar_path_extra = self.create_tarball("package", "0.1", "bz2", part="extra") |
531 | |
532 | === modified file 'upstream/__init__.py' |
533 | --- upstream/__init__.py 2011-06-17 01:37:55 +0000 |
534 | +++ upstream/__init__.py 2011-06-24 15:14:30 +0000 |
535 | @@ -451,7 +451,8 @@ |
536 | :param packagename: Name of the package (e.g. "bzr-builddeb") |
537 | """ |
538 | basename = os.path.basename(path) |
539 | - for extension in [".tar.gz", ".tgz", ".tar.bz2", ".zip"]: |
540 | + for extension in [".tar.gz", ".tgz", ".tar.bz2", ".tar.lzma", ".tar.xz", |
541 | + ".zip"]: |
542 | if basename.endswith(extension): |
543 | basename = basename[:-len(extension)] |
544 | break |
545 | |
546 | === modified file 'upstream/pristinetar.py' |
547 | --- upstream/pristinetar.py 2011-06-23 21:41:36 +0000 |
548 | +++ upstream/pristinetar.py 2011-06-24 15:14:30 +0000 |
549 | @@ -249,13 +249,16 @@ |
550 | |
551 | def has_pristine_tar_delta(self, rev): |
552 | return ('deb-pristine-delta' in rev.properties |
553 | - or 'deb-pristine-delta-bz2' in rev.properties) |
554 | + or 'deb-pristine-delta-bz2' in rev.properties |
555 | + or 'deb-pristine-delta-lzma' in rev.properties) |
556 | |
557 | def pristine_tar_format(self, rev): |
558 | if 'deb-pristine-delta' in rev.properties: |
559 | return 'gz' |
560 | elif 'deb-pristine-delta-bz2' in rev.properties: |
561 | return 'bz2' |
562 | + elif 'deb-pristine-delta-lzma' in rev.properties: |
563 | + return 'lzma' |
564 | assert self.has_pristine_tar_delta(rev) |
565 | raise AssertionError("Not handled new delta type in " |
566 | "pristine_tar_format") |
567 | @@ -265,6 +268,8 @@ |
568 | uuencoded = rev.properties['deb-pristine-delta'] |
569 | elif 'deb-pristine-delta-bz2' in rev.properties: |
570 | uuencoded = rev.properties['deb-pristine-delta-bz2'] |
571 | + elif 'deb-pristine-delta-lzma' in rev.properties: |
572 | + uuencoded = rev.properties['deb-pristine-delta-lzma'] |
573 | else: |
574 | assert self.has_pristine_tar_delta(rev) |
575 | raise AssertionError("Not handled new delta type in " |
576 | @@ -315,6 +320,8 @@ |
577 | uuencoded = standard_b64encode(delta) |
578 | if tarball.endswith(".tar.bz2"): |
579 | ret["deb-pristine-delta-bz2"] = uuencoded |
580 | + elif tarball.endswith(".tar.lzma"): |
581 | + ret["deb-pristine-delta-lzma"] = uuencoded |
582 | else: |
583 | ret["deb-pristine-delta"] = uuencoded |
584 | return ret |
585 | |
586 | === modified file 'util.py' |
587 | --- util.py 2011-06-15 19:09:24 +0000 |
588 | +++ util.py 2011-06-24 15:14:30 +0000 |
589 | @@ -692,7 +692,7 @@ |
590 | "invalid orig tarball file %s does not have expected prefix %s" % ( |
591 | tarball_filename, prefix)) |
592 | base = tarball_filename[len(prefix):] |
593 | - for ext in (".tar.gz", ".tar.bz2", ".tar.lzma", ".tar.xz"): |
594 | + for ext in (".tar.gz", ".tar.bz2", ".tar.lzma"): |
595 | if tarball_filename.endswith(ext): |
596 | base = base[:-len(ext)] |
597 | break |
598 | @@ -720,6 +720,8 @@ |
599 | tar_args = ["tar"] |
600 | if tarball_filename.endswith(".tar.bz2"): |
601 | tar_args.append('xjf') |
602 | + elif tarball_filename.endswith(".tar.lzma"): |
603 | + tar_args.append('xJf') |
604 | else: |
605 | tar_args.append('xzf') |
606 | if component is not None: |
This looks ok to me. Is lzma supported by dak yet?
I'm not sure about the delta questions, storing the full delta is certainly painful,
but if this is supported in dak then we'll have to support it in bzr-builddeb soon,
and that is certainly an easy way to do it.
It's also something we could transition away from easily given that newer pristine-tar
will still deal with the full-size deltas.
My only pause is that as you say an openoffice.tar.xz would be painful, and large
packages are the ones most likely to use lzma.
Thanks,
James