rules_pkg icon indicating copy to clipboard operation
rules_pkg copied to clipboard

Support for cross-platform RPM package generation

Open ogalbxela opened this issue 2 years ago • 10 comments

Please consider a patch aimed to add proper support for constructing RPM packages aimed for the CPU architecture other than the host machine. This addresses https://github.com/bazelbuild/rules_pkg/issues/727 issue.

The current version of the "pkg_rpm"-rule exposes an "architecture"-option, which is meant to indicate the package's intended platform. Unfortunately, this option is being incorrectly utilized. It is being used to define the "BuildArch"-option in the RPM spec file. However, as per RPM packaging guide (https://rpm-packaging-guide.github.io/): "'BuildArch' should be used if the package is not architecture dependent. For example, if written entirely in an interpreted programming language, set this to BuildArch: noarch. If not set, the package automatically inherits the Architecture of the machine on which it is built".

It appears that BuildArch is intended to represent either architecture of host machine or "noarch". Any efforts to designate an "alien" platform as a value for this field lead to a failure in the "rpmbuild"-utility, accompanied by an error message stating: "error: No compatible architectures found for build."

The purpose of this patch is to maintain backward compatibility while provide the solution for the described issue. It preserves the existing "architecture"-attribute of the "pkg_rpm" rule, as it might already be in use by someone. It introduces the "target_architecture"-attribute to the "pkg_rpm" rule, aiming to utilize it as a "arch"-suffix for the package name and to provide it to the "rpmbuild"-utility as the value for the "--target" option.

ogalbxela avatar Aug 13 '23 07:08 ogalbxela

Can we figure the right behavior out in the issue before jumping to code. I'll comment there.

aiuto avatar Aug 14 '23 18:08 aiuto

Can we figure the right behavior out in the issue before jumping to code. I'll comment there.

Thank you, Tony, I answered in the issue.

ogalbxela avatar Aug 14 '23 21:08 ogalbxela

Friendly ping

aiuto avatar Nov 06 '23 18:11 aiuto