Skip to content

feat: add stamp support for pkg_rpm Release tag#1039

Open
wade-arista wants to merge 4 commits intobazelbuild:mainfrom
wade-arista:main
Open

feat: add stamp support for pkg_rpm Release tag#1039
wade-arista wants to merge 4 commits intobazelbuild:mainfrom
wade-arista:main

Conversation

@wade-arista
Copy link
Copy Markdown
Contributor

Allow {VARIABLE_NAME} placeholders in the release attribute of pkg_rpm. When stamp = 1 (or stamp = -1 with --stamp), workspace status variables from volatile-status.txt are substituted at build time.

  • Add get_workspace_status_vars() to pkg/private/build_info.py
  • Add --volatile_status_file arg to make_rpm.py; apply substitution in RpmBuilder.__init__ via the new stamp_vars parameter
  • Add stamp and private_stamp_detect attrs to the pkg_rpm rule; rename the rule to _pkg_rpm_rule and expose a pkg_rpm macro that injects private_stamp_detect via select(), matching the pattern used by pkg_tar and pkg_zip
  • Avoid embedding template placeholders in the output filename when stamp is active

Fixes #1038

@wade-arista
Copy link
Copy Markdown
Contributor Author

Actually, I think I should read both stable and volatile status files. Update coming.

@wade-arista wade-arista marked this pull request as draft March 5, 2026 21:32
Allow `{VARIABLE_NAME}` placeholders in the `release` attribute of
`pkg_rpm`. When `stamp = 1` (or `stamp = -1` with `--stamp`), workspace
status variables from volatile-status.txt are substituted at build time.

- Add `get_status_vars()` to `pkg/private/build_info.py`
- Add `--volatile_status_file` and `--stable_status_file` args to
  `make_rpm.py`; apply substitution in `RpmBuilder.__init__` via the
  new `stamp_vars` parameter
- Add `stamp` and `private_stamp_detect` attrs to the `pkg_rpm` rule;
  rename the rule to `_pkg_rpm_rule` and expose a `pkg_rpm` macro that
  injects `private_stamp_detect` via `select()`, matching the pattern
  used by `pkg_tar` and `pkg_zip`
- Avoid embedding template placeholders in the output filename when stamp
  is active

Fixes bazelbuild#1038
We don't need to call it multiple times on the same line value, we can
just call it once and save it.
- Add docstring to get_status_vars() in build_info.py
- Use get_stamp_detect() from util.bzl instead of inline select()
  to match the pattern from PR bazelbuild#1035
- Expand release attr docstring to document stamp variable substitution
- Add stamped RPM example to examples/rpm/system_rpmbuild_pfg
@wade-arista wade-arista requested a review from aiuto March 10, 2026 00:10
@wade-arista wade-arista marked this pull request as ready for review March 10, 2026 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pkg_rpm support for stamping the RPM release string

3 participants