Comments (4)
Thanks, can you isolate this a bit more? Is that genrule that does the manipulation at fault, or can you reproduce a bug without it?
I think it's probably intentional that the order of mtree lines affects the tar. mtree has support for state, like you can effectively "cd somedir" and then subsequent lines are affected.
from bazel-lib.
Thanks for the reply and for taking a look! The issue seems to only reproduce for files the are in the root directory of the tar according to the mtree spec.
Here's a repro case without the genrule to illustrate. Resulting tar has nginx-template-based.conf
under conf.d
instead of at the root:
tar(
name = "foo",
srcs = [":foo_files"],
mtree = [
"conf.d uid=0 gid=0 time=1672560000 mode=0755 type=dir",
"conf.d/http.conf uid=0 gid=0 time=1672560000 mode=0755 type=file content=app/nginx/conf/conf.d/http.conf",
"nginx-template-based.conf uid=0 gid=0 time=1672560000 mode=0755 type=file content=app/nginx/conf/nginx-template-based.conf",
],
)
$ tar -tvf foo.tar
drwxr-xr-x 0/0 0 2023-01-01 02:00 conf.d/
-rwxr-xr-x 0/0 1426 2023-01-01 02:00 conf.d/http.conf
-rwxr-xr-x 0/0 636 2023-01-01 02:00 conf.d/nginx-template-based.conf
Reordered mtree has nginx-template-based.conf
in the root as expected:
tar(
name = "bar",
srcs = [":foo_files"],
mtree = [
"nginx-template-based.conf uid=0 gid=0 time=1672560000 mode=0755 type=file content=app/nginx/conf/nginx-template-based.conf",
"conf.d uid=0 gid=0 time=1672560000 mode=0755 type=dir",
"conf.d/http.conf uid=0 gid=0 time=1672560000 mode=0755 type=file content=app/nginx/conf/conf.d/http.conf",
],
)
$ tar -tvf bar.tar
-rwxr-xr-x 0/0 636 2023-01-01 02:00 nginx-template-based.conf
drwxr-xr-x 0/0 0 2023-01-01 02:00 conf.d/
-rwxr-xr-x 0/0 1426 2023-01-01 02:00 conf.d/http.conf
If the files are nested under a prefix, it also seems to work as I would expect:
tar(
name = "foobar",
srcs = [":foo_files"],
mtree = [
"app uid=0 gid=0 time=1672560000 mode=0755 type=dir",
"app/nginx uid=0 gid=0 time=1672560000 mode=0755 type=dir",
"app/nginx/conf uid=0 gid=0 time=1672560000 mode=0755 type=dir",
"app/nginx/conf/conf.d uid=0 gid=0 time=1672560000 mode=0755 type=dir",
"app/nginx/conf/conf.d/http.conf uid=0 gid=0 time=1672560000 mode=0755 type=file content=app/nginx/conf/conf.d/http.conf",
"app/nginx/conf/nginx-template-based.conf uid=0 gid=0 time=1672560000 mode=0755 type=file content=app/nginx/conf/nginx-template-based.conf",
],
)
$ tar -tvf foobar.tar
drwxr-xr-x 0/0 0 2023-01-01 02:00 app/
drwxr-xr-x 0/0 0 2023-01-01 02:00 app/nginx/
drwxr-xr-x 0/0 0 2023-01-01 02:00 app/nginx/conf/
drwxr-xr-x 0/0 0 2023-01-01 02:00 app/nginx/conf/conf.d/
-rwxr-xr-x 0/0 1426 2023-01-01 02:00 app/nginx/conf/conf.d/http.conf
-rwxr-xr-x 0/0 636 2023-01-01 02:00 app/nginx/conf/nginx-template-based.conf
Hope that helps clarify the issue. If it's intentional that the order of mtree lines affects the tar, seems like creating an mtree_spec
from a globbed filegroup will give different behavior just depending on the alphabetical ordering of the directories and files contained.
from bazel-lib.
this is how mtrees work, you either have to add ./
to the dir entry, or have /
as the suffix for the dir entry.
This is working as expected.
from bazel-lib.
Thanks @thesayyn,
Seems like this is a nuance to the mtrees that is easy to trip over if you naively try to strip off a prefix from the mtree_spec
output. I believe the genrule in the tests that is referenced from the tar documentation would be susceptible to this issue: https://github.com/aspect-build/bazel-lib/blob/main/lib/tests/tar/BUILD.bazel#L128-L145
Anyway, adding the /
suffix did the trick so I think this can be closed. Thanks again for the reply and explanation.
from bazel-lib.
Related Issues (20)
- [FR]: Add support for runtime_toolchain_type for jq/yq/... HOT 2
- `copy_to_directory` includes all files as runfiles HOT 3
- [FR]: Add option to `copy_to_directory` to flatten the output tree structure
- [Bug]: tar toolchain downloads from a mutable registry HOT 1
- [FR]: Propagate Tags to Tar HOT 1
- [FR]: write_source_files and write_source_file shall support select()
- [FR]: Tar should add !gzip:timestamp option when compress = gzip
- [Bug]: bsdtar toolchain fails on macOS if host tar is gnutar HOT 2
- [FR]: Support Expanding a filegroup via a rule HOT 2
- [Bug]: `mtree_spec` rule does not encode filenames with special characters HOT 7
- [FR]: Update libarchive to >= 3.7.1 HOT 1
- [Bug]: tar generates incorrect mtree for aspect_rules_js runfiles HOT 1
- [Bug]: unable to use expand_template in v2 HOT 1
- [Bug]: Cannot define custom `coreutils_toolchain`
- [Bug]: xz not found with new statically linked bsdtar HOT 5
- [Bug]: expand_template FORMATTED_DATE
- [FR]: `squash_tars` rule HOT 2
- [FR]: use sha256 instead of sha386 for integrity?
- [Bug]: 2.7.3 broke coreutils on x86 MacOS
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bazel-lib.