Add LZMA functions for xz, fixing build errors.

This commit is contained in:
Bastian Kleineidam 2014-06-27 17:59:58 +02:00
parent e6018f0cff
commit 47929ecac8
3 changed files with 40 additions and 3 deletions

View File

@ -226,10 +226,10 @@ ArchivePrograms = {
None: ('lzop',),
},
'lzma': {
'extract': ('7z', 'lzma') + py_lzma,
'extract': ('7z', 'lzma', 'xz') + py_lzma,
'list': ('7z', 'py_echo'),
'test': ('7z', 'lzma'),
'create': ('lzma',) + py_lzma,
'test': ('7z', 'lzma', 'xz'),
'create': ('lzma', 'xz') + py_lzma,
},
'rzip': {
'extract': ('rzip',),

View File

@ -16,6 +16,7 @@
"""Archive commands for the xz program."""
from . import extract_singlefile_standard, \
test_singlefile_standard, create_singlefile_standard
from .. import util
extract_xz = extract_singlefile_standard
@ -30,3 +31,34 @@ def list_xz (archive, compression, cmd, verbosity):
cmdlist.append('-v')
cmdlist.append(archive)
return cmdlist
def extract_lzma(archive, compression, cmd, verbosity, outdir):
"""Extract an LZMA archive."""
cmdlist = [util.shell_quote(cmd), '--format=lzma']
if verbosity > 1:
cmdlist.append('-v')
outfile = util.get_single_outfile(outdir, archive)
cmdlist.extend(['-c', '-d', '--', util.shell_quote(archive), '>',
util.shell_quote(outfile)])
return (cmdlist, {'shell': True})
def test_lzma(archive, compression, cmd, verbosity):
"""Test an LZMA archive."""
cmdlist = [cmd, '--format=lzma']
if verbosity > 1:
cmdlist.append('-v')
cmdlist.extend(['--test', archive])
return cmdlist
def create_lzma(archive, compression, cmd, verbosity, filenames):
"""Create an LZMA archive."""
cmdlist = [util.shell_quote(cmd), '--format=lzma']
if verbosity > 1:
cmdlist.append('-v')
cmdlist.extend(['-c', '--'])
cmdlist.extend([util.shell_quote(x) for x in filenames])
cmdlist.extend(['>', util.shell_quote(archive)])
return (cmdlist, {'shell': True})

View File

@ -30,3 +30,8 @@ class TestXz (ArchiveTest):
self.archive_test('t.txt.xz.foo')
self.archive_extract('t.txt.xz.foo', check=Content.Singlefile)
@needs_program(program)
def test_lzma(self):
self.archive_test('t.txt.lzma')
self.archive_extract('t.txt.lzma', check=Content.Singlefile)
self.archive_create('t.txt.lzma', check=Content.Singlefile)