mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-26 22:56:15 +01:00
support zst compressed control files in deb archives
eg. some packages Ubuntu 21.10
This commit is contained in:
parent
16ec3ff9f9
commit
fe311c7ae5
@ -16,6 +16,13 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
HAVE_LZMA = False
|
HAVE_LZMA = False
|
||||||
|
|
||||||
|
HAVE_ZSTD = True
|
||||||
|
try:
|
||||||
|
# Note: zstd is not supporting stream compression types
|
||||||
|
import zstandard
|
||||||
|
except ImportError:
|
||||||
|
HAVE_ZSTD = False
|
||||||
|
|
||||||
|
|
||||||
if (not hasattr(itertools, 'zip_longest')
|
if (not hasattr(itertools, 'zip_longest')
|
||||||
and hasattr(itertools, 'izip_longest')):
|
and hasattr(itertools, 'izip_longest')):
|
||||||
@ -52,13 +59,23 @@ class DebQuery(packagequery.PackageQuery, packagequery.PackageQueryResult):
|
|||||||
tar = tarfile.open(name='control.tar.gz', fileobj=control)
|
tar = tarfile.open(name='control.tar.gz', fileobj=control)
|
||||||
else:
|
else:
|
||||||
control = arfile.get_file(b'control.tar.xz')
|
control = arfile.get_file(b'control.tar.xz')
|
||||||
if control is None:
|
if control:
|
||||||
raise DebError(self.__path, 'missing control.tar')
|
|
||||||
if not HAVE_LZMA:
|
if not HAVE_LZMA:
|
||||||
raise DebError(self.__path, 'can\'t open control.tar.xz without python-lzma')
|
raise DebError(self.__path, 'can\'t open control.tar.xz without python-lzma')
|
||||||
decompressed = lzma.decompress(control.read())
|
decompressed = lzma.decompress(control.read())
|
||||||
tar = tarfile.open(name="control.tar.xz",
|
tar = tarfile.open(name="control.tar.xz",
|
||||||
fileobj=BytesIO(decompressed))
|
fileobj=BytesIO(decompressed))
|
||||||
|
else:
|
||||||
|
control = arfile.get_file(b'control.tar.zst')
|
||||||
|
if control:
|
||||||
|
if not HAVE_ZSTD:
|
||||||
|
raise DebError(self.__path, 'can\'t open control.tar.zst without python-zstandard')
|
||||||
|
with zstandard.ZstdDecompressor().stream_reader(BytesIO(control.read())) as reader:
|
||||||
|
decompressed = reader.read()
|
||||||
|
tar = tarfile.open(name="control.tar.zst",
|
||||||
|
fileobj=BytesIO(decompressed))
|
||||||
|
if control is None:
|
||||||
|
raise DebError(self.__path, 'missing control.tar')
|
||||||
try:
|
try:
|
||||||
name = './control'
|
name = './control'
|
||||||
# workaround for python2.4's tarfile module
|
# workaround for python2.4's tarfile module
|
||||||
|
Loading…
Reference in New Issue
Block a user