-
Notifications
You must be signed in to change notification settings - Fork 175
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
make pkg_tar's "./" mandatory prefix optional #50
Comments
Currently wondering if it'd be enough to expose |
cc @damienmg @mattmoor who helped when I attempted to submit this the first time around I never entirely understood what broke, but I think it was something with the docker rules (but wasn't picked up in any unit tests, only breakages of downstream users). There's better test coverage on the docker rules now, so it might also be interesting to see if this still causes breakages. |
I think switching the default will end up breaking someone downstream, so if maintainers agree that this is worth tackling, I imagine it can only be done by adding an option to I ran a few experiments and added test cases to # Easiest sol'n exposes build_tar --root_directory to pkg_tar users.
# Documentation will be kind of confusing with regard to contrast to package_dir.
pkg_tar(
name = "my_tar",
root_directory = "",
)
# Targeted sol'n better communicates intent (esp. w/r/t package_dir) but naming is
# perhaps clumsier.
pkg_tar(
name = "my_tar",
prepend_dotslash = False, # or maybe interop_prepend_dotslash?
) |
also cc @aiuto |
I just looked into what |
Cool. I settled on |
Should we move this to the bazelbuild/rules_pkg repository? https://help.github.com/en/articles/transferring-an-issue-to-another-repository |
Now that 1.0 is here certainly anyone can agree that this should be implemented in a nonbreaking way. But it might also be a candidate to change the default for a future major version. Thinking of tar files across numerous contexts for many years, my impression is that mandatory prefix with “.” is relatively unusual. Not prefixing (by default) would match the expectations of more adopters. |
@kylecordes rules_pkg is decoupled from bazel, so it probably isn't strictly necessary to follow the same deprecation strategy. |
I'm not sure if it's a related issue, but forcing
If archives did not have to contain |
Any progress on this? would be great to have a |
I have not had a chance to work on it. I agree with @kylecordes that the initial "./" is strange, and also with @beasleyr-vmw that if we change the default that will break some people, and his analysis about using the package_root. How does everyone feel about this new behavior.
If you are broken by the change in default, you can fix that by adding a package_base. Yes, this is a breaking change but we are still at 0.x, and we know the next is 0.3.0 rather than 0.2.6. Would this be acceptable? |
Sounds good! For the record, here's my workaround using a genrule. Using pkg_tar would definitely be more elegant!
|
…current behaviour
…current behaviour
…current behaviour
…current behaviour
…current behaviour
…haviour (#261) Co-authored-by: Douglas Mayle <[email protected]>
I was happy to see the fix for this released today but it doesn't seem to have the right semantics. I need to package a file so that is shows the path as
otherwise the tar won't worm with the Helm tool. I thought I would get this behavior when using
but that results in a tar with a "/" prefix
Given that this is released now I sadly don't know how to fix this in a backwards compatible way |
Yup. This is not fixed right. The behavior for this
should be
but is
So there are 2 things wrong. The images folder is being flattened away in addition to the wrongly added '/' |
So, how does this fit in with the Following from this, does this mean we should change the behavior of |
Hacked on this a little bit. Some observations:
The question still remains: do we do with pkg_filegroup(
name = "reroot_tar_inputs",
srcs = [":all_the_srcs"],
prefix = "./",
) Or prefix everything with Another option would be to put this rooting stuff back in Remaining questions:
|
I'm working on this now. The least surprising solution that I am going for is
This way, you can have pkg_* rules do whatever they want to make a path, or you can use legacy constructions and add a path at file writing time. There is some layered stupidity in archive.py, but I am note ready to remove it yet. I think the debian packaging needs it. My patfh forward is to remove the mistake of insisting on a leading './' in archive in one PR, then remove the identical mistake at the pkg_tar level. |
- clean up tests appropriately - remove achive.add_dir because we do not use it This is a precursor change to removing the unwanted leading ./ from tar writers. See bazelbuild#50, bazelbuild#531
May be fixed by #554, except I'm not putting much work into the ability to set the package prefix to "./". |
We still never create a lone '.' as a directory in the archive. That is intentional There are a few parts to this: - Remove the root_directory logic from tar_writer. It was a needless feature inherited from an ancient implementation. It was not used by anything except the tests. - Stop re-normalizing paths in tar_writer. It should do what it is asked. The implication is that all the test which accounted for test data which which contained tar files with paths like './a', will now keep the './'. - Add a test to show prefix_dir == './' does work. Fixes bazelbuild#50
We still never create a lone '.' as a directory in the archive. That is intentional There are a few parts to this: - Remove the root_directory logic from tar_writer. It was a needless feature inherited from an ancient implementation. It was not used by anything except the tests. - Stop re-normalizing paths in tar_writer. It should do what it is asked. The implication is that all the test which accounted for test data which which contained tar files with paths like './a', will now keep the './'. - Add a test to show prefix_dir == './' does work. RELNOTES: pkg_tar no longer prefixes paths with './'. Fixes bazelbuild#50
We still never create a lone '.' as a directory in the archive. That is intentional There are a few parts to this: - Remove the root_directory logic from tar_writer. It was a needless feature inherited from an ancient implementation. It was not used by anything except the tests. - Stop re-normalizing paths in tar_writer. It should do what it is asked. The implication is that all the test which accounted for test data which which contained tar files with paths like './a', will now keep the './'. - Add a test to show prefix_dir == './' does work. RELNOTES: pkg_tar no longer prefixes paths with './'. You can use `package_dir` with an explicit "./" to get the old behavior. Fixes #50
Description of the problem / feature request:
Files embedded in a tar created by
pkg_tar
include a mandatory "./" prefix. I would like to make this prefix optional.Feature requests: what underlying problem are you trying to solve with this feature?
This is an interoperability/migration problem. My request incurs tech debt to finance Bazel adoption.
I'm trying to migrate a constellation of builds from Maven to Bazel. When I port project X to Bazel, I still need to support some number of preexisting downstream builds. These builds extract subsets of files from tars using whitelists which are not anchored with a leading "./". When fed a tar generated by Bazel's
pkg_tar
, a whitelist of "foo" doesn't match "./foo", and so the untar action is a no-op.Rather than have to discover/fix every trivial difference downstream, I would rather start by producing Bazel bits which are drop-in replacements for Maven bits. Our internal teams can then coordinate among themselves to pay down the debt and remove use of any interop flags.
For the record, a change to remove the "./" prefix was committed back in 2017 but soon rolled back. I think an option to remove the prefix would help folks like myself w/o risk of breaking existing Bazel users.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
n/a
What operating system are you running Bazel on?
Linux - CentOS 6.6 and 7.2
macOS - High Sierra (I think)
What's the output of
bazel info release
?"development version"
If
bazel info release
returns "development version" or "(@non-git)", tell us how you built Bazel.We track Bazel's Git repo and apply a small number of patches atop official releases. We're currently building against 0.21.0.
What's the output of
git remote get-url origin ; git rev-parse master ; git rev-parse HEAD
?n/a
Have you found anything relevant by searching the web?
Yes -- https://github.com/bazelbuild/bazel/commits/master/tools/build_defs/pkg/archive.py:
I chatted w/ @ixdy briefly in Slack about this on Fri Jan 25. (Thanks!)
Any other information, logs, or outputs that you want to share?
The text was updated successfully, but these errors were encountered: