bazelbuild / rules_pkg

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

The files map in pkg_tar is the wrong way around #753

Closed njlr closed 10 months ago

njlr commented 11 months ago

Currently, pkg_tar works with the keys as the source-files and the values as the paths in the tar:

pkg_tar(
  name = "jq_1_7_linux_amd_64",
  strip_prefix = "",
  files = {
    "@jq_1_7_linux_amd_64//file": "/usr/bin/jq",
  },
)

However, this makes little sense, since the file path must be unique, but plausibly the same input could be included twice.

The key-value semantics should be flipped:

pkg_tar(
  name = "jq_1_7_linux_amd_64",
  strip_prefix = "",
  files = {
    "/usr/bin/jq": "@jq_1_7_linux_amd_64//file",
    "/usr/bin/jq17": "@jq_1_7_linux_amd_64//file",
  },
)
aiuto commented 11 months ago

files is a deprecated feature. It's insufficient for so many cases and only works with tar. You could use 2 pkg_files targets to take the same input and put it in to distinct output paths, then have those as input to the pkg_tar target.

aiuto commented 10 months ago

Closing because there is no way to change this silly behavior without breaking everyone who uses it and there are other ways to accomplish the desired effect.