[deb] Avoid `UTF-8` roundtrip for `{pre,post}-{inst,rm}` hooks (#1054)
This change allows the Debian package hooks to be arbitrary files (including
executable binary files), which failed with the following error before:
```
Traceback (most recent call last):
File "/Users/yannic/Library/Caches/bazel/_bazel_yannic/bb6c3b02ccc98aaca966df445b5024eb/sandbox/darwin-sandbox/3472/execroot/_main/bazel-out/darwin_x86_64-opt-exec/bin/external/rules_pkg+/pkg/private/deb/make_deb.runfiles/rules_pkg+/pkg/private/deb/_make_deb_stage2_bootstrap.py", line 499, in <module>
main()
~~~~^^
File "/Users/yannic/Library/Caches/bazel/_bazel_yannic/bb6c3b02ccc98aaca966df445b5024eb/sandbox/darwin-sandbox/3472/execroot/_main/bazel-out/darwin_x86_64-opt-exec/bin/external/rules_pkg+/pkg/private/deb/make_deb.runfiles/rules_pkg+/pkg/private/deb/_make_deb_stage2_bootstrap.py", line 493, in main
_run_py_path(main_filename, args=sys.argv[1:])
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yannic/Library/Caches/bazel/_bazel_yannic/bb6c3b02ccc98aaca966df445b5024eb/sandbox/darwin-sandbox/3472/execroot/_main/bazel-out/darwin_x86_64-opt-exec/bin/external/rules_pkg+/pkg/private/deb/make_deb.runfiles/rules_pkg+/pkg/private/deb/_make_deb_stage2_bootstrap.py", line 287, in _run_py_path
runpy.run_path(main_filename, run_name="__main__")
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen runpy>", line 287, in run_path
File "<frozen runpy>", line 98, in _run_module_code
File "<frozen runpy>", line 88, in _run_code
File "/Users/yannic/Library/Caches/bazel/_bazel_yannic/bb6c3b02ccc98aaca966df445b5024eb/sandbox/darwin-sandbox/3472/execroot/_main/bazel-out/darwin_x86_64-opt-exec/bin/external/rules_pkg+/pkg/private/deb/make_deb.runfiles/rules_pkg+/pkg/private/deb/make_deb.py", line 433, in <module>
main()
~~~~^^
File "/Users/yannic/Library/Caches/bazel/_bazel_yannic/bb6c3b02ccc98aaca966df445b5024eb/sandbox/darwin-sandbox/3472/execroot/_main/bazel-out/darwin_x86_64-opt-exec/bin/external/rules_pkg+/pkg/private/deb/make_deb.runfiles/rules_pkg+/pkg/private/deb/make_deb.py", line 392, in main
prerm=helpers.GetFlagValue(options.prerm, False),
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yannic/Library/Caches/bazel/_bazel_yannic/bb6c3b02ccc98aaca966df445b5024eb/sandbox/darwin-sandbox/3472/execroot/_main/bazel-out/darwin_x86_64-opt-exec/bin/external/rules_pkg+/pkg/private/deb/make_deb.runfiles/rules_pkg+/pkg/private/helpers.py", line 81, in GetFlagValue
flagvalue = f.read().decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcf in position 0: invalid continuation byte
```
(the example used a `go_binary` for `prerm`)Bazel rules for building tar, zip, deb, and rpm for packages.
For the latest version, see Releases (with WORKSPACE setup) / Documentation
Use rules-pkg-discuss@googlegroups.com for discussion.
As of Bazel 4.x, Bazel uses this rule set for packaging its distribution. Bazel still contains a limited version of pkg_tar but its feature set is frozen. Any new capabilities will be added here.
Sample, but see releases for the current release.
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "rules_pkg", urls = [ "https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.9.1/rules_pkg-0.9.1.tar.gz", "https://github.com/bazelbuild/rules_pkg/releases/download/0.9.1/rules_pkg-0.9.1.tar.gz", ], sha256 = "8f9ee2dc10c1ae514ee599a8b42ed99fa262b757058f65ad3c384289ff70c4b8", ) load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies") rules_pkg_dependencies()
To use pkg_rpm(), you must provide a copy of rpmbuild. You can use the system installed rpmbuild with this stanza.
load("@rules_pkg//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild") find_system_rpmbuild( name = "rules_pkg_rpmbuild", verbose = False, )
bazel_dep(name = "rules_pkg", version = "0.0.10")
To use pkg_rpm(), you must provide a copy of rpmbuild. You can use the system installed rpmbuild with this stanza.
find_rpm = use_extension("//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild_bzlmod") use_repo(find_rpm, "rules_pkg_rpmbuild") register_toolchains("@rules_pkg_rpmbuild//:all")
We hold an engineering status meeting on the first Monday of every month at 10am USA East coast time. Add to calendar / meeting notes