rules_pkg icon indicating copy to clipboard operation
rules_pkg copied to clipboard

Create "make install" equivalent

Open nacl opened this issue 4 years ago • 2 comments

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.

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:

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)

nacl avatar Mar 02 '21 20:03 nacl

Is this done and should be split into distinct issues for improvements? Or do you consider pkg_install not yet ready.

aiuto avatar Feb 15 '22 17:02 aiuto

I can see that this is not yet ready. In particular, TreeArtifacts and symlinks are not supported yet.

https://github.com/bazelbuild/rules_pkg/blob/447fb8e246cb437630b9ecd09f9bf9fe857d2c3f/pkg/private/install.py.tpl#L106

In addition, docs have not been updated in https://bazelbuild.github.io/rules_pkg/ to include install.bzl.

I am going to contribute to pkg_install to support TreeArtifacts in a pull request to solve the imminent problem for our use cases.

jacky8hyf avatar Aug 19 '24 22:08 jacky8hyf