bazelbuild / rules_pkg

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

Support creating symbolic links to dynamic destinations #313

Open nacl opened 3 years ago

nacl commented 3 years ago

There is a general interest in supporting dynamic filesystem locations based on values such as versions, and platform OSes and CPU architectures. In #312, we discuss implementing this for the pkg_filegroup framework.

Users may want to create symbolic links to these dynamically-named destinations. To do this, they either need to share a template, or either have or be directly provided with information via a label. Template sharing should be avoided, as this can place an additional maintenance burden on users.

The other options potentially come with complexity of actually calculating the desired destination without arbitrarily restricting the user. Such restrictions should be avoided if possible, but it may not be avoidable to do so w/o creating additional complexity.

Some potential options and pitfalls are discussed in https://github.com/bazelbuild/rules_pkg/pull/293#discussion_r584810551, specifically this comment.

nacl commented 3 years ago

From https://github.com/bazelbuild/rules_pkg/pull/293#discussion_r585190693, and alluded to in the ticket summary, an option might be to associate links directly with basic parameters, but

Another option would be to create a links attribute associated with mapping rules (pkg_files), and then the individual rules could return a provider that represents symbolic links. This is not supported by the provider we have currently have, though. It would also make setting attributes difficult if not impossible.

The difficulties come in because there is nothing like a label_keyed_string_list_dict attribute supported by bazel at this time.

aiuto commented 3 years ago

What about using PackageVariablesInfo for the template dict, in the same way we can dynamically create file names. That seems like a win if we are dynamically naming, for example, an executable by CPU, and then we want a symlink to that. Using the same substitution dict will be easy to understand.