Skip to content

Commit

Permalink
fix: remove unnecessary basename
Browse files Browse the repository at this point in the history
Fixes GoogleContainerTools#141

In GoogleContainerTools#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!
  • Loading branch information
jjmaestro committed Dec 17, 2024
1 parent 81c2dfd commit 2af0b50
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions apt/private/deb_import.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down

0 comments on commit 2af0b50

Please sign in to comment.