bazelbuild / rules_pkg

Bazel rules for creating packages of many types (zip, tar, deb, rpm, ...)
Apache License 2.0
221 stars 174 forks source link

Fix RPM package release and version files expansion #816

Closed k0walik closed 8 months ago

k0walik commented 8 months ago

What

While trying to migrate from version 0.9.1 to 0.10.0 I stumbled across following error:

Traceback (most recent call last):
        File "/home/tomasz.wojno/code/rules_pkg/pkg/rpm_pfg.bzl", line 352, column 47, in _pkg_rpm_impl
                content = substitute_package_variables(ctx, "\n".join(preamble_pieces)),
        File "/home/tomasz.wojno/code/rules_pkg/pkg/private/util.bzl", line 95, column 34, in substitute_package_variables
                return attribute_value.format(**vars)
Error in format: Missing argument 'VERSION_FROM_FILE'

In #787 a helper function for expanding RPM preamble with user-defined variables was introduced. The function uses Starlark format expression to replace {var} occurrences with defined variables. However, this does not work when we pass release or version file to the build target. The rpm_pfg.bzl appends Release: ${RELEASE_FROM_FILE} and Version: ${VERSION_FROM_FILE} to preamble, which are later expanded by make_rpm.py script. Thus, those variables are failed to be expanded as they are not defined.

Changes

This pull request introduces following changes:

cgrindel commented 8 months ago

@aiuto Do you want to review or can I merge this PR?