bazelbuild / bazelbuild/rules_pkg
Create "make install" equivalent
- Dominant language
- Starlark
- Stars
- 253
- Forks
- 221
- Avg merge
- 10h 33m
- Merged PRs (30d)
- 1
Description
Open source projects are typically built in three phases:
1) Configuration (`./configure`), where the project build is customized to target specific featuresets
2) Building (`make`), where the project is actually built
3) Installation (`make install`), where the project is installed to the filesystem, or staged for future packaging using the [`DESTDIR` convention](https://www.gnu.org/prep/standards/html_node/DESTDIR.html).
Bazel combines 1) and 2) (configuring is done with build flags), and 3) doesn't really exist. Currently, the closest bazel equivalent to have bazel create a package representing the installable outputs, most often a .zip or a .tar. While effective, it is wasteful when packages become quite large.
Since Bazel builds have no way to interact directly with the filesystem outside of the buildroot, we need to be a little more creative. Let's create a `pkg_install` rule that creates a (python?) script that knows how to install artifacts outside of the bazel buildroot, for example:
```starlark
load("@rules_pkg//:install.bzl", "pkg_install")
# pkg_files, pkg_filegroups, etc
pkg_install(
name = "install",
srcs = [
# pkg_filegroups here
],
)
```
And then you install using:
```
bazel run //:install -- DESTDIR=your/destination/directory
```
Acceptance criteria:
- `pkg_install` (or its equivalent) is created with tests
- `pkg_install` supports staging to an arbitrary destination (`DESTDIR`)
Contributor guide
Assessment
This issue has not been assessed yet.