[PATCH 01/14] backports: Add support deb with zstd compression

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The recent mainline .deb files from Ubuntu are using zstd compression.
The default python tarfile API does not support zstd compression. Use
the zpystd package from pip to decompress the stream and then use
tarfile to unpack it.

Signed-off-by: Hauke Mehrtens <hauke@xxxxxxxxxx>
---
 devel/backports-update-manager | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/devel/backports-update-manager b/devel/backports-update-manager
index 4d63de8c..9177be76 100755
--- a/devel/backports-update-manager
+++ b/devel/backports-update-manager
@@ -5,6 +5,7 @@ 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
@@ -541,8 +542,14 @@ class backport_kernel_updater:
                 sys.stdout.write("%s - extracting new %s ...\n" % (kver.get('ver'), target))
                 data, dpath = tempfile.mkstemp(prefix=tmp_prefix)
                 ar.print_data(target, data)
-                tar = tarfile.open(name=dpath, mode='r')
-                tar.extractall(path=tmpdir_path, members=bk_tar_members(tar))
+                try:
+                   tar = tarfile.open(name=dpath, mode='r')
+                   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()
                 os.unlink(dpath)
 
                 self.sanitize_and_install_kernel_dirs(tmpdir_path)
-- 
2.30.2

--
To unsubscribe from this list: send the line "unsubscribe backports" in



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux