bazel: create genrules to produce debs and RPMs without arch-specific names #74467
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
/kind bug
/kind cleanup
What this PR does / why we need it: this is a follow-up to #73930.
In that PR I implemented support for cross-compilation using Bazel.
One issue I ran into is that the
pkg_deb
andpkg_rpm
rules have anarchitecture
attribute which is used in their package metadata, but is also used in the output filenames. (For example,pkg_deb
actually creates both a$NAME.deb
and a$NAME-$ARCH.deb
.) Bazel disallows output filenames to be configured - you can't do something likeand similarly disallows configuring attributes which affect output filenames (like
architecture
).To work around this, instead of configuring the
architecture
attribute, I used macros and list comprehensions to create multiple rules, each with a-$ARCHITECTURE
suffix in their name.This meant that the debs and RPMs now had different filenames.
I created
alias
es to maintain the old target names, but thesealias
es had no effect on the output filenames. Thus downstream projects like Kind were broken, as the debs had new filenames.In this PR I'm basically restoring the old end-user functionality by replacing the
alias
es with simplegenrule
s that copy to the non-arched filename. The arch-specific outputs still exist, but are generally to be used indirectly.Which issue(s) this PR fixes:
Fixes kubernetes-sigs/kind#336
Does this PR introduce a user-facing change?:
/assign @BenTheElder
cc @neolit123