mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 21:09:03 +02:00

Where copyright headers were not present, add them to make things clear. (Bitbake rev: 1aa338a216350a2751fff52f866039343e9ac013) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
31 lines
830 B
Python
31 lines
830 B
Python
#
|
|
# Copyright BitBake Contributors
|
|
#
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
#
|
|
|
|
import bb.compress._pipecompress
|
|
import shutil
|
|
|
|
|
|
def open(*args, **kwargs):
|
|
return bb.compress._pipecompress.open_wrap(ZstdFile, *args, **kwargs)
|
|
|
|
|
|
class ZstdFile(bb.compress._pipecompress.PipeFile):
|
|
def __init__(self, *args, num_threads=1, compresslevel=3, **kwargs):
|
|
self.num_threads = num_threads
|
|
self.compresslevel = compresslevel
|
|
super().__init__(*args, **kwargs)
|
|
|
|
def _get_zstd(self):
|
|
if self.num_threads == 1 or not shutil.which("pzstd"):
|
|
return ["zstd"]
|
|
return ["pzstd", "-p", "%d" % self.num_threads]
|
|
|
|
def get_compress(self):
|
|
return self._get_zstd() + ["-c", "-%d" % self.compresslevel]
|
|
|
|
def get_decompress(self):
|
|
return self._get_zstd() + ["-d", "-c"]
|