bazelbuild / rules_pkg

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

Package JSON manifest should support generic attributes #385

Open nacl opened 3 years ago

nacl commented 3 years ago

I like the idea of the JSON manifest format -- it allows us to create backends for a generic packaging frontends.

I would like to adopt this for pkg_rpm at some point, but in order to do this, the manifest would need to support a generic "attributes" format to support file tags (like %config). This will also be needed for supporting packages in Windows.

So, instead of separate mode, user, and group fields, perhaps we should have an attributes object that can contain arbitrary information, mirroring pkg_attributes in the pkg_filegroup framework?

aiuto commented 3 years ago

We can do whatever we want. Since there is, so far, 1 method that writes the manifest, and one that decodes an entry, and they are both private interfaces, changing the format is fair game as we need it.

Another reason for moving to that now might be that we may have to add more user/owner types for #370 . Rather than add more fields at the top level, add them to the embedded struct.

aiuto commented 3 years ago

One more requirement: We need operators around this

nacl commented 2 years ago

Been thinking about this on and off. Initial thoughts:

So, something like this:

[
  {
    "label": "//:foo-config",
    "type": "FILE",
    "source": "bazel-out/k8-linux-fastbuild/foo", // or whatever bazel provides us
    "destination": "{PREFIX}/etc/foo", // Templated destination
    "mode": "rw-r--r--", // or 0644
    "user": "root",
    "group": "root",
    "rpm_filetag": "%config" // Custom attribute for pkg_rpm
    "zip_compression": "STORE" // Theoretical custom attribute for pkg_zip
    "unix_extended_permissions": "+i" // Theoretical custom attribute for UNIX-style installers (set immutable bit) 
   },
   ...
]

This is simple enough to meet all the above requirements and is also relatively futureproof. It also has the unfortunate consequences of requiring more code and redoing a bit of the logic that we already have for the manifest system as used in pkg_zip and pkg_tar. WDYT?