Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oci_image does not accept tar.xz #249

Closed
prestonvanloon opened this issue May 19, 2023 · 3 comments
Closed

oci_image does not accept tar.xz #249

prestonvanloon opened this issue May 19, 2023 · 3 comments

Comments

@prestonvanloon
Copy link
Contributor

I read the example in the aspect.dev migration guide from rules_docker. The example is as follows:

genrule(
    name = "new_layer",
    srcs = [":deb"],
    outs = ["data.tar.xz"],
    cmd = "tar -xvf -c $@/ $(location :deb)",
)

oci_image(
    tars = [":new_layer"]
)

However, this fails as the tars attributes only accepts tar and tar.gz.

"tars": attr.label_list(allow_files = [".tar", ".tar.gz"], doc = """\

A real world example with a workaround looks as follows:

# WORKSPACE
http_file(
    name = "bash_amd64",
    urls = [
        "http://ftp.us.debian.org/debian/pool/main/b/bash/bash_5.1-2+deb11u1_amd64.deb",
    ],
    sha256 = "f702ef058e762d7208a9c83f6f6bbf02645533bfd615c54e8cdcce842cd57377",
)

http_file(
    name = "bash_arm64",
    urls = [
        "http://ftp.us.debian.org/debian/pool/main/b/bash/bash_5.1-2+deb11u1_arm64.deb",
    ],
    sha256 = "d7c7af5d86f43a885069408a89788f67f248e8124c682bb73936f33874e0611b",
)


# Some build file
genrule(
    name = "bash_tar",
    srcs = select({
        "@platforms//cpu:x86_64": ["@bash_amd64//file:file"],
        "@platforms//cpu:arm64": ["@bash_arm64//file:file"],
    }),
    outs = ["bash.tar"],
    cmd = "ar x $< && xz -d data.tar.xz -c >> $@",
    visibility = ["//visibility:public"],
)

oci_image(
    name = "image",
    tars = [
        ":bash_tar",
        ":binary_tar",
    ],
)

It would be nice to simply use this genrule, which doesn't un-xz the tarball, but I don't think that tar -xvf works for a deb file so I had to use ar.

genrule(
    name = "new_layer",
    srcs = [":deb"],
    outs = ["data.tar.xz"],
    cmd = "ar x $< --output=$(@D)",
)
@thesayyn
Copy link
Collaborator

this can be fixed by simply adding tar.xz. we didn't add every possible extension on purpose to make sure we handle them correctly.

@thesayyn
Copy link
Collaborator

up for sending a PR adding it to this list?

alexeagle added a commit that referenced this issue May 22, 2023
alexeagle added a commit that referenced this issue May 22, 2023
alexeagle added a commit that referenced this issue May 22, 2023
alexeagle added a commit that referenced this issue May 22, 2023
alexeagle added a commit that referenced this issue May 22, 2023
@thesayyn
Copy link
Collaborator

fixed by #250

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants