Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add package_file_name to pkg_deb and pkg_zip #282

Merged
merged 17 commits into from
Feb 4, 2021
Merged

Conversation

aiuto
Copy link
Collaborator

@aiuto aiuto commented Jan 26, 2021

This unifies pkg_deb, pkg_tar, and pkg_zip so that they all have these 3 parameters

  • out: an an output file name. This will end up being an actual file, or a symlink to a file with a more complex name
  • package_file_name: The parameterizable name for the output file. The name can include template variables which might be calculated at analysis time, such as the C++ library version specified by the selected C++ toolchain.
  • package_variable: The label of a rule that provides variables to use for substitution in package_file_name.

If package_file_name is not specified, out is the single output file. If it is specified, the default output of the target (DefaultInfo.files) will be the file named by package_file_name and out will be a symlink to it.

The examples are expanded to show how this is used in practice.

See #193 for discussion.

Also, a partial fix for #161. runfiles now includes all the outputs of these pkg_* rules

pkg_rpm is excluded from this PR. We need to resolve #283 first.

RELNOTES:

Copy link
Collaborator

@nacl nacl left a comment

Choose a reason for hiding this comment

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

I like it.

The comments are largely nitpicky or can be deferred. I don't feel that I need to look at this again unless you want me to.

I'm interested in a common attribute for package names. If that isn't done now, I'd like to see it done later.

examples/naming_package_files/BUILD Outdated Show resolved Hide resolved
examples/naming_package_files/package_upload.bzl Outdated Show resolved Hide resolved
examples/naming_package_files/package_upload.bzl Outdated Show resolved Hide resolved
pkg/distro/BUILD Outdated Show resolved Hide resolved
pkg/distro/BUILD Show resolved Hide resolved
pkg/pkg.bzl Outdated Show resolved Hide resolved
pkg/pkg.bzl Show resolved Hide resolved
pkg/pkg.bzl Show resolved Hide resolved
pkg/pkg.bzl Outdated Show resolved Hide resolved
pkg/tests/package_naming_aggregate_test.sh Show resolved Hide resolved
@aiuto aiuto merged commit e2fb5d9 into bazelbuild:main Feb 4, 2021
@aiuto aiuto deleted the name2 branch February 4, 2021 05:09
nacl pushed a commit to nacl/rules_pkg that referenced this pull request Mar 22, 2021
…ule attribute

This change modifies the `pkg_filegroup`-using `pkg_rpm` rule to use the same
naming attributes and output system as other packaging rules, specifically:

- `package_variables` corresponds to a rule providing `PackageVariablesInfo`,
   used for templating of various package attributes.

- `package_file_name` corresponds to the output filename, and uses the value
  provided to `package_variables` to construct an "expanded" output file name.

- `package_name` corresponds to the "name" of the package, as recognized by the
  package manager.  This replaces `rpm_name`.

- The expanded output file name is identified via a `PackageArtifactInfo`
  provider.  The default, unexpanded name is derived from `package_name`, or
  `name` if not provided.

If `package_file_name` is not provided, then the default name is formatted
according to the preferred RPM "NVRA" format.  File names will look like
`$name-$version-$release.$architecture.rpm`.

As a side-effect, this removes the deprecated `outputs` output from `pkg_rpm`.
This resolves bazelbuild#282 for this rule, but not the soon-to-be-legacy rule in
`rpm.bzl`.   If it is desired to do this, I will do so in a follow-on-change.

Since (both versions of) `pkg_rpm` are structured differently from the other
packaging rules, `setup_output_files` in `private/util.bzl` was modified to
support deriving the default output file name from a macro argument instead of
relying on `ctx.outputs.out`, as it is not present in `pkg_rpm`.  The
documentation was also updated to mention this and to improve clarity.

Documentation was also opportunistically fixed in `experimental/rpm.bzl`.

Tests are also provided.
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.

pkg_rpm rule definition uses deprecated 'outputs' parameter
3 participants