Add package_variables support to pkg_files and pkg_filegroup prefix (#1052)
Closes #781.
pkg_files and pkg_filegroup now accept a package_variables attribute, enabling
make-variable substitution in their prefix attribute. For example:
my_platform_vars(name = "platform_vars", os = "linux", arch = "x86_64")
pkg_filegroup(
name = "platform_libs",
srcs = [":my_libs"],
prefix = "usr/lib/$(os)_$(arch)",
package_variables = ":platform_vars",
)
Previously the only workaround was select() on prefix, while package_file_name already supported variable substitution via package_variables. This closes the inconsistency: the same mechanism now works for destination paths in the mapping rules.
The implementation follows the same pattern as pkg_deb and pkg_tar, reusing substitute_package_variables() from //pkg/private:util.bzl.
- Admittedly this was too small to use an agent, but it saved me time writing the tests.
- I created a hints file for the next time.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