Allow additional RPM macro defines (#794)
For some RPM packaging scenarios users may wish to define additional
macros. This change enables us to do this using the `--rpmbuild_arg`
argument to the `make_rpm.py` script by passing a dict of defines to
the `pkg_rpm()` rule.
diff --git a/pkg/rpm_pfg.bzl b/pkg/rpm_pfg.bzl
index 756482b..52fc872 100644
--- a/pkg/rpm_pfg.bzl
+++ b/pkg/rpm_pfg.bzl
@@ -642,6 +642,12 @@
"_binary_payload {}".format(ctx.attr.binary_payload_compression),
])
+ for key, value in ctx.attr.defines.items():
+ additional_rpmbuild_args.extend([
+ "--define",
+ "{} {}".format(key, value),
+ ])
+
args.extend(["--rpmbuild_arg=" + a for a in additional_rpmbuild_args])
for f in ctx.files.srcs:
@@ -1015,6 +1021,9 @@
overcommitting your system.
""",
),
+ "defines": attr.string_dict(
+ doc = """Additional definitions to pass to rpmbuild""",
+ ),
"rpmbuild_path": attr.string(
doc = """Path to a `rpmbuild` binary. Deprecated in favor of the rpmbuild toolchain""",
),