-
-
Notifications
You must be signed in to change notification settings - Fork 89
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
[Bug]: mtree_spec
generates incorrect spec file if the root directory has a file and a directory
#851
Labels
bug
Something isn't working
Comments
cc @thesayyn |
That makes sense, IMHO non-breaking way to fix this is to add trailing slash to the dir entries so they are not interpreted as any special entry. Do you want to make a pr for it? |
Sure! |
sin-ack
added a commit
to sin-ack/bazel-lib
that referenced
this issue
May 23, 2024
bsdtar's mtree format has a quirk wherein entries without "/" in their first word are treated as "relative" entries, and "relative" directories will cause tar to "change directory" into the declared directory entry. If such a directory is followed by a "relative" entry, then the file will be created within the directory, instead of at top-level as expected. To mitigate, we append a slash to top-level directory entries. Fixes bazel-contrib#851.
sin-ack
added a commit
to sin-ack/bazel-lib
that referenced
this issue
May 27, 2024
bsdtar's mtree format has a quirk wherein entries without "/" in their first word are treated as "relative" entries, and "relative" directories will cause tar to "change directory" into the declared directory entry. If such a directory is followed by a "relative" entry, then the file will be created within the directory, instead of at top-level as expected. To mitigate, we append a slash to top-level directory entries. Fixes bazel-contrib#851.
sin-ack
added a commit
to sin-ack/bazel-lib
that referenced
this issue
May 27, 2024
bsdtar's mtree format has a quirk wherein entries without "/" in their first word are treated as "relative" entries, and "relative" directories will cause tar to "change directory" into the declared directory entry. If such a directory is followed by a "relative" entry, then the file will be created within the directory, instead of at top-level as expected. To mitigate, we append a slash to top-level directory entries. Fixes bazel-contrib#851.
sin-ack
added a commit
to sin-ack/bazel-lib
that referenced
this issue
Jun 19, 2024
bsdtar's mtree format has a quirk wherein entries without "/" in their first word are treated as "relative" entries, and "relative" directories will cause tar to "change directory" into the declared directory entry. If such a directory is followed by a "relative" entry, then the file will be created within the directory, instead of at top-level as expected. To mitigate, we append a slash to top-level directory entries. Fixes bazel-contrib#851.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What happened?
I'm using a vendored version of
py_layer
at work (from https://github.com/aspect-build/bazel-examples/blob/fba56194cd925b8d12b0339becbfc10bb9504c26/oci_python_image/py_layer.bzl).py_layer
usesmtree_spec
andtar
fromaspect_bazel_lib
to create multiple tar files which are then passed tooci_image
. As the input, I'm passing apy_binary
like this:However, this doesn't work properly. The reason is because the mtree spec generated by
aspect_bazel_lib
looks like this:This unfortunately hits some (frankly very bizarre) rules in the mtree file format, specifically this one:
This means that when
bsdtar
processes the first line, it "switches directory" toproject/
, and createsproject/project_bin
in the tar file rather thanproject_bin
.Additionally, we can't use
/project_bin
becausemtree
treats leading slashes as "special":./project_bin
works, but shows up as./project_bin
intar tf
output as well (not sure if that breaks anything). It seems the only proper way to place files at the root directory is to make sure that files at root are always listed before the first directory entry.Version
Development (host) and target OS/architectures: Gentoo Linux amd64
Output of
bazel --version
: 7.1.2Version of the Aspect rules, or other relevant rules from your
WORKSPACE
orMODULE.bazel
file:Language(s) and/or frameworks involved: Python
How to reproduce
Any other information?
No response
The text was updated successfully, but these errors were encountered: