Skip to content

Avoid depending on the value of the --stamp flag if possible#1035

Merged
aiuto merged 8 commits into
bazelbuild:mainfrom
justinhorvitz:patch-1
Mar 7, 2026
Merged

Avoid depending on the value of the --stamp flag if possible#1035
aiuto merged 8 commits into
bazelbuild:mainfrom
justinhorvitz:patch-1

Conversation

@justinhorvitz
Copy link
Copy Markdown
Contributor

@justinhorvitz justinhorvitz commented Feb 23, 2026

pkg_tar and pkg_zip use a config_setting to read the value of the --stamp build option. This is suboptimal for some new Google-internal caching features. We can restrict this dependency to cases where stamp = -1 on the rule level. The default rule-level attribute is stamp = 0, so this removes the dependency by default.

@cgrindel
Copy link
Copy Markdown
Collaborator

cgrindel commented Mar 1, 2026

I won't merge this PR yet so that @aiuto can take a look.

Copy link
Copy Markdown
Collaborator

@aiuto aiuto left a comment

Choose a reason for hiding this comment

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

Sorry for the delay.
This is a subtle one, but I see what you're doing now.

@aiuto aiuto merged commit 94084b0 into bazelbuild:main Mar 7, 2026
6 checks passed
wade-arista added a commit to wade-arista/rules_pkg that referenced this pull request Mar 10, 2026
- 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
rdesgroppes added a commit to DataDog/datadog-agent that referenced this pull request Mar 20, 2026
What does this PR do?
bump rules_pkg to Mar 17 main, picking up:
- bazelbuild/rules_pkg#1024: RPM build errors would go unnoticed without it
- bazelbuild/rules_pkg#1035: affects reproducibiliy of builds
- bazelbuild/rules_pkg#1044
- bazelbuild/rules_pkg#1046: a contribution of ours (@chouquette)
- bazelbuild/rules_pkg#1047: we might need this
gh-worker-dd-mergequeue-cf854d Bot pushed a commit to DataDog/datadog-agent that referenced this pull request Mar 20, 2026
### What does this PR do?
Bump `rules_pkg` to current `main`.

### Motivation
Pick up:
- bazelbuild/rules_pkg#1021: a contribution of ours
- bazelbuild/rules_pkg#1024: RPM build errors would go unnoticed without it
- bazelbuild/rules_pkg#1035: affects reproducibiliy of builds
- bazelbuild/rules_pkg#1044
- bazelbuild/rules_pkg#1046: another contribution of ours (@chouquette)
- bazelbuild/rules_pkg#1047: we might need this feature

Co-authored-by: regis.desgroppes <regis.desgroppes@datadoghq.com>
aiuto pushed a commit that referenced this pull request Apr 9, 2026
* feat: add stamp support for pkg_rpm Release tag

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 #1038

* clean up uses of str.strip() in build_info.py

We don't need to call it multiple times on the same line value, we can
just call it once and save it.

* Address PR #1039 review feedback

- 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 #1035
- Expand release attr docstring to document stamp variable substitution
- Add stamped RPM example to examples/rpm/system_rpmbuild_pfg
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.

3 participants