Use the zstandard package from python pip instead of pystd. zstandard is more common and also integrated in later Ubuntu versions. Signed-off-by: Hauke Mehrtens <hauke@xxxxxxxxxx> --- .devcontainer/Dockerfile | 2 +- devel/backports-update-manager | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 3894196e..f758c9cb 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -4,7 +4,7 @@ RUN apt update && \ apt install -y git coccinelle build-essential python3 python3-pip python-is-python3 flex bison libelf1 libelf-dev && \ rm -rf /var/lib/apt/lists/* -RUN pip install pyzstd +RUN pip install pyzstd zstandard RUN git clone https://github.com/hauke/backports.git diff --git a/devel/backports-update-manager b/devel/backports-update-manager index c2900b64..79f0ae23 100755 --- a/devel/backports-update-manager +++ b/devel/backports-update-manager @@ -1,11 +1,11 @@ #!/usr/bin/env python3 import argparse, os, sys, errno, getopt, re import shutil +import zstandard from urllib.request import urlopen from urllib.parse import urljoin import tarfile, tempfile import fileinput, subprocess -from pyzstd import ZstdFile source_dir = os.path.abspath(os.path.dirname(__file__)) sys.path.append(source_dir + '/../') from lib import bpar as ar @@ -543,13 +543,14 @@ class backport_kernel_updater: data, dpath = tempfile.mkstemp(prefix=tmp_prefix) ar.print_data(target, data) try: - tar = tarfile.open(name=dpath, mode='r') - tar.extractall(path=tmpdir_path, members=bk_tar_members(tar)) + with tarfile.open(name=dpath, mode='r') as tar: + tar.extractall(path=tmpdir_path, members=bk_tar_members(tar)) except (tarfile.ReadError): - zstd_file = ZstdFile(dpath) - tar = tarfile.open(fileobj=zstd_file, mode='r') - tar.extractall(path=tmpdir_path, members=bk_tar_members(tar)) - zstd_file.close() + with open(dpath, 'rb') as file: + unzstd = zstandard.ZstdDecompressor() + with unzstd.stream_reader(file) as stream: + with tarfile.open(fileobj=stream, mode='r|') as tar: + tar.extractall(path=tmpdir_path, members=bk_tar_members(tar)) os.unlink(dpath) self.sanitize_and_install_kernel_dirs(tmpdir_path) -- 2.44.0