Skip to content

Commit bb6a684

Browse files
authored
Merge pull request #286 from desultory/dev
handle both .zst and .zstd as known extensions for zstandard compression
2 parents b15cfdb + 5c8e49b commit bb6a684

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

src/ugrd/base/core.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = "desultory"
2-
__version__ = "4.4.0"
2+
__version__ = "4.4.1"
33

44
from os import environ, makedev, mknod
55
from pathlib import Path
@@ -206,13 +206,25 @@ def deploy_dependencies(self) -> None:
206206
self._copy(dependency)
207207

208208

209-
def _deploy_compressed(self, compression_type: str, decompressor, compression_extension=None) -> None:
210-
"""Decompresses all dependencies of the specified compression type into the build directory."""
211-
compression_extension = compression_extension or f".{compression_type}"
209+
def _deploy_compressed(self, compression_type: str, decompressor, compression_extensions=None) -> None:
210+
"""Decompresses all dependencies of the specified compression type into the build directory.
211+
Remove the compression extension if there is a match between compression_extensions and the file name.
212+
"""
213+
compression_extensions = compression_extensions or [f".{compression_type}"]
212214

213215
for dependency in self[f"{compression_type}_dependencies"]:
214216
self.logger.debug(f"[{compression_type}] Decompressing: {dependency}")
215-
out_path = self._get_build_path(str(dependency).replace(compression_extension, ""))
217+
218+
for extension in compression_extensions:
219+
if str(dependency).endswith(extension):
220+
break
221+
else:
222+
self.logger.warning(f"[{compression_type}] Dependency missing extension: {dependency}")
223+
extension = ""
224+
225+
self.logger.debug(f"[{compression_type}] Found compressed file: {dependency}")
226+
# Replace the extension, do nothing if there is no match
227+
out_path = self._get_build_path(str(dependency).replace(extension, ""))
216228
if not out_path.parent.is_dir():
217229
self.logger.debug(f"Creating parent directory: {out_path.parent}")
218230
self._mkdir(out_path.parent, resolve_build=False)
@@ -243,17 +255,8 @@ def deploy_zstd_dependencies(self) -> None:
243255
Entries should only be added to zstd_dependencies if the zstandard library is available.
244256
"""
245257
from zstandard import decompress
246-
from zstandard.backend_cffi import ZstdError
247258

248-
try:
249-
_deploy_compressed(self, "zstd", decompress, compression_extension=".zst")
250-
except ZstdError as e:
251-
self.logger.error("Unable to decompress zstd dependency: %s" % e)
252-
raise e
253-
self.logger.warning(
254-
"Ensure the zstandard library is installed, or remove the zstd dependency from the configuration."
255-
)
256-
raise e
259+
_deploy_compressed(self, "zstd", decompress, compression_extensions=[".zst", ".zstd"])
257260

258261

259262
@contains("gz_dependencies", "No gz dependencies defined, skipping.", log_level=10)

src/ugrd/kmod/kmod.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = "desultory"
2-
__version__ = "3.3.6"
2+
__version__ = "3.3.7"
33

44
from pathlib import Path
55
from platform import uname
@@ -384,7 +384,7 @@ def add_kmod_deps(self):
384384
self["dependencies"] = filename
385385
elif filename.endswith(".ko.xz"):
386386
self["xz_dependencies"] = filename
387-
elif filename.endswith(".ko.zstd"):
387+
elif filename.endswith(".ko.zstd") or filename.endswith(".ko.zst"):
388388
self["zstd_dependencies"] = filename
389389
elif filename.endswith(".ko.gz"):
390390
self["gz_dependencies"] = filename

0 commit comments

Comments
 (0)