Skip to content

feat: add stamp support for pkg_rpm Release tag#1039

Draft
wade-arista wants to merge 1 commit intobazelbuild:mainfrom
wade-arista:main
Draft

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

Conversation

@wade-arista
Copy link
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
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
"""Get BUILD_TIMESTAMP."""
"""Workspace status file utilities."""

def get_status_vars(status_file, include_empty=True):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you lift most of the docstring from get_timestamp and add it here.

"DEBUGINFO_TYPE_NONE",
)

_stamp_condition = Label("//pkg/private:private_stamp_detect")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way to access this changed in #1035
This might still work, but take a look at that.

doc = """File containing RPM "Version" tag.""",
allow_single_file = True,
),
"release": attr.string(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you expand the docstring here to say that that you can turn on stamping to substitution for things like $BUILD_STAMP to work.

Also, adding this to examples/rpm would be good. Otherwise no one will find the feature.

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

2 participants