bazelbuild / rules_pkg

Bazel rules for creating packages of many types (zip, tar, deb, rpm, ...)
Apache License 2.0
216 stars 171 forks source link

Make pkg_zip compression configurable #737

Closed flode closed 1 year ago

flode commented 1 year ago

Zip offers different compression algorithms and levels. For packaging, sometimes faster compression speed is more important than size. With pkg_tar, there is already the option to use a custom compressor, there's no similar option for pkg_zip yet.

This PR exposes the zip compression_level and compression_type arguments for pkg_zip, thus enabling the use case.

The list of compressions is the same as Python's ZipFile: https://docs.python.org/3/library/zipfile.html#zipfile.ZIP_STORED

There's a new test case that verifies that the compression settings work by comparing the compressed file sizes.

The default compression level is the same as in this recent change for pkg_tar in #720

google-cla[bot] commented 1 year ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

flode commented 1 year ago

Awesome, thanks!

I wish the markdown change for the documentation was also part of this PR. I'm new to maintaining rules_pkg, my understanding is the docs are only generated later, if at all (#716). I'll try to convince @aiuto that we should change it.

I see there's some steps in docbuild/BUILD on how to regenerate the docs, running that now has some different changes in addition to mine. Not sure if having the docs as part of each commit is worth it. But docs should definitely be generated for each release.