Conversation
ba6e562 to
027f82d
Compare
|
Can you start a bug about this so we can get the requirements right first. |
|
I want to make something like FROM ubuntu:22.04
...
COPY app /usr/local/bin/app
RUN setcap cap_sys_resource+ep /usr/local/bin/appIn load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("@io_bazel_rules_docker//container:container.bzl", "container_image")
...
pkg_tar(
name = "app-tar",
extension = "tar",
files = {
":app": "/usr/local/bin/app",
},
xattr = [
"security.capability=0x0100000200000001000000000000000000000000",
],
)
container_image(
name = "app-image",
...
tars = [
":app-tar",
],
)In this example xattrs = {
"usr/local/bin/app": [
"security.capability=0x0100000200000001000000000000000000000000",
]
}, |
|
Can you think about how this should be in pkg_files. Adding it only to pkg_tar is sort of a dead end. |
| key = item[:idx] | ||
| raw = item[idx+1:] | ||
| if raw.startswith("0x"): | ||
| xattrs[key] = bytes.fromhex(raw[2:]).decode('latin-1') |
There was a problem hiding this comment.
You probably want to use .decode('utf-8', "surrogateescape") here as certain xattrs will be re-encoded incorrectly otherwise. On re-encoding the tarfile module uses surrogateescape to restore any values that don't cleanly decode to UTF-8.
Motivation
I need tool to set "max locked memory" ulimit for
mongosinside Kubernetes environment.This tool need
etcap cap_sys_resource+epxattr on file.This PR allows set
xattron files inside .tar artchives.Example
Allow set
xattrinside tar archives, for example: