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:
Avoid expanding RELEASE_FROM_FILE and VERSION_FROM_FILE by wrapping them in double curly braces. This way ${{RELEASE_FROM_FILE}} becomes expanded to ${RELEASE_FROM_FILE}, so it can be processed later by make_rpm.py
Add tests that uses version_file and release_file attributes
What
While trying to migrate from version 0.9.1 to 0.10.0 I stumbled across following error:
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. Therpm_pfg.bzl
appendsRelease: ${RELEASE_FROM_FILE}
andVersion: ${VERSION_FROM_FILE}
to preamble, which are later expanded bymake_rpm.py
script. Thus, those variables are failed to be expanded as they are not defined.Changes
This pull request introduces following changes:
RELEASE_FROM_FILE
andVERSION_FROM_FILE
by wrapping them in double curly braces. This way${{RELEASE_FROM_FILE}}
becomes expanded to${RELEASE_FROM_FILE}
, so it can be processed later bymake_rpm.py
version_file
andrelease_file
attributes