Download and Unzip gz file.

20 views
Skip to first unread message

Artem Sierikov

unread,
May 2, 2021, 10:38:45 PMMay 2
to bazel-discuss
Hi! I'm new to bazel. I need to unzip file file.gz  to two files:
  • one.txt
  • two.mmdb
So I can pass them to the binary rule as resource files. 

I can download it with the HTTP rule but how can I unzip it and reuse its content later?

Daniel Halperin

unread,
May 3, 2021, 12:55:46 AMMay 3
to Artem Sierikov, bazel-discuss
You probably want to use http_archive with build_file_content.


In the example, you could refer to @openjdk15_darwin_archive//:runtime . If you ditched the java_runtime bit and instead did

exports_files(["one.txt", "two.mmdb"], visibility = ["//visibility:public"])

it you could refer to @openjdk15_darwin_archive//:one.txt.

Dan

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/2da40414-1d42-4038-96b9-fde0742f8f47n%40googlegroups.com.

Artem Sierikov

unread,
May 5, 2021, 2:59:42 PMMay 5
to bazel-discuss
Thanks for the solution! Turns out I need to download and extract the single file with a .gz extension. And use its content. For example, I download some_file.db.gz, and then I need to be able to reference some_file.db

Can I simply do something like this?


load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")

http_file(
  name = "my_gz_file",
  sha256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
)

And then reference its content 

@my_gz_file//file

If not how can I do it properly?

Artem
Reply all
Reply to author
Forward
0 new messages