Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@bazel_tools//tools/zip:zipper: allow glob exclusion to prevent files from being extracted from a zip file #23662

Open
bendavini opened this issue Sep 18, 2024 · 6 comments
Labels
team-Core Skyframe, bazel query, BEP, options parsing, bazelrc type: feature request untriaged

Comments

@bendavini
Copy link

Description of the feature request:

unzip (https://infozip.sourceforge.net/) allows users to specify files to exclude while unzipping a file:

unzip file.zip -x $(<excl_file.txt)

In order to use zipper x in a similar way, a user needs to perform some additional shell magic to get the same result (we've a full (currently non-hermetic) unzip.bzl that uses system unzip to achieve this.)

Which category does this issue belong to?

CLI, Core

What underlying problem are you trying to solve with this feature?

Make zipper's extract (x) functionally equivalent to the widely-used unzip utility

Which operating system are you running Bazel on?

Mac(x86/aarch64) / Linux (x86)

What is the output of bazel info release?

7.2.1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

Have you found anything relevant by searching the web?

No. Have scoured slack, github, email threads, and our internal tools

Any other information, logs, or outputs that you want to share?

No response

@github-actions github-actions bot added team-CLI Console UI team-Core Skyframe, bazel query, BEP, options parsing, bazelrc labels Sep 18, 2024
@tjgq
Copy link
Contributor

tjgq commented Sep 18, 2024

AIUI @bazel_tools//tools/zip:zipper is not meant to be a general-purpose zip utility, just one that caters to the needs of build rules built into Bazel. What's the use case for this?

@bendavini
Copy link
Author

TL;DR we want to be able to extract (a subset of) files from a zip archive in a way that is consumable by other actions (mostly rules_pkg).

I asked here what is the most proper way to hermetically unzip things; the answer was to use zipper .

The use case is described in the first link. We have a custom rule which is a wrapper around a non-hermetic unzip command that provides an alternative to a genrule that does not require the list of files to be extracted.

If @bazel_tools//tools/zip:zipper is not meant to be a general purpose zip utility, do you know of something that is (and is also hermetic)?

@fmeum
Copy link
Collaborator

fmeum commented Sep 18, 2024

https://registry.bazel.build/modules/ape has cross-platform binaries for common utilities, including unzip.

@bendavini
Copy link
Author

Thanks @fmeum ! Learn about a new module every day :)

I am happy to use a new module, but would prefer to lean on a built-in if possible. If zipper is meant to be exclusive to bazel internals, should I file another ticket to make it be 'advertised' as such? (i.e., something like a readme recommending the APE module for cases like this, reduced visibility of zipper, output of said information in the help, etc.

@tjgq
Copy link
Contributor

tjgq commented Sep 19, 2024

@lberki @meteorcloudy Do we have a stance on expanding the scope of @bazel_tools//tools/zip:zipper and/or intentionally supporting its use outside of built-in rules?

@lberki
Copy link
Contributor

lberki commented Sep 19, 2024

@tjgq @bendavini @ahumesky I'd much, much rather no one use that built-in zipper tool. It was added in support of Android rules, which are in the process of being removed from the Bazel proper and thus ideally, this binary would also vanish from @bazel_tools.

@coeuvre coeuvre removed the team-CLI Console UI label Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Core Skyframe, bazel query, BEP, options parsing, bazelrc type: feature request untriaged
Projects
None yet
Development

No branches or pull requests

8 participants