From 2af0b50e8206a66e3c046667c7341c14a6c4f31e Mon Sep 17 00:00:00 2001 From: Javier Maestro Date: Mon, 16 Dec 2024 17:18:18 +0000 Subject: [PATCH] fix: remove unnecessary basename Fixes #141 In #99 I added a dependency to basename when it's not really needed. Credit and thanks to @birunts for finding the issue and providing the solution! --- apt/private/deb_import.bzl | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/apt/private/deb_import.bzl b/apt/private/deb_import.bzl index 864d887..a956e15 100644 --- a/apt/private/deb_import.bzl +++ b/apt/private/deb_import.bzl @@ -27,20 +27,25 @@ genrule( # Bazel needs the output filename to be fixed in advanced so we settle for # gzip compression. - data_file="$$(basename $<)" + data_file="$<" + layer="$@" - if [[ "$$data_file" == "data.tar.bz2" ]]; then - # TODO: support bz2 - echo "ERROR: unsupported compression: bz2" - exit 1 - elif [[ "$$data_file" == "data.tar.gz" ]]; then - mv $< $@ - elif [[ "$$data_file" == "data.tar" ]]; then - $(ZSTD_BIN) --compress --format=gzip $< >$@ - else - $(ZSTD_BIN) --force --decompress --stdout $< | - $(ZSTD_BIN) --compress --format=gzip - >$@ - fi + case "$$data_file" in + *data.tar.gz) + mv "$$data_file" "$$layer" + ;; + *data.tar) + $(ZSTD_BIN) --compress --format=gzip "$$data_file" > "$$layer" + ;; + *data.tar.xz|*data.tar.zst|*data.tar.lzma) + $(ZSTD_BIN) --force --decompress --stdout "$$data_file" | + $(ZSTD_BIN) --compress --format=gzip - > "$$layer" + ;; + *) + echo "ERROR: data file not supported: $$data_file" + exit 1 + ;; + esac """, toolchains = ["@zstd_toolchains//:resolved_toolchain"], visibility = ["//visibility:public"],