-
-
Notifications
You must be signed in to change notification settings - Fork 77
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
Properly support permissions and symlinks in Zip files (500USD Bounty) #356
Comments
Turned out the problem was all permission related. It worked after executable perm was given to files inside Anw can see 2 problems with |
https://unix.stackexchange.com/a/509337
|
Extra fields have been used to store information about POSIX permissions and symlink though.
Apache Commons and Apache Ant's own implementation of So for a quick fix I think can use |
@sideeffffect |
For Otherwise only supporting permissions for Adding a third party dependency is an option, but it would be great if we could find a solution just using the native JDK |
Yup JDK >= 14 is required. The thing is this is not without hiccups either. Using
I think |
Ah looks like using reflection to access private field for |
Looks like using Apache Commons Compress is the cleanest solution for now? Need to experiment though since their |
I think using a third party library is fine. We can shade it so it is totally encapsulated and collide with other versions on the classpath |
I don't think we should shade just because we can. Is there even a known risk, that anything can collide with other version of |
commons-compress is most likely not available for the scala-native version, I guess. |
I've played a bit with Apache Commons Compress and found that it's not possible to make On the Apache Commons Compress dependency thing may I suggest another approach? It's not a good idea to include it as a dependency. It is quite heavy since it also includes support for several other file formats, jdeps --multi-release 61 -cp commons-compress-1.27.1.jar org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.class
ZipArchiveOutputStream.class -> commons-compress-1.27.1.jar
ZipArchiveOutputStream.class -> java.base
ZipArchiveOutputStream.class -> not found
org.apache.commons.compress.archivers.zip -> java.io java.base
org.apache.commons.compress.archivers.zip -> java.lang java.base
org.apache.commons.compress.archivers.zip -> java.nio java.base
org.apache.commons.compress.archivers.zip -> java.nio.channels java.base
org.apache.commons.compress.archivers.zip -> java.nio.charset java.base
org.apache.commons.compress.archivers.zip -> java.nio.file java.base
org.apache.commons.compress.archivers.zip -> java.util java.base
org.apache.commons.compress.archivers.zip -> java.util.zip java.base
org.apache.commons.compress.archivers.zip -> org.apache.commons.compress.archivers commons-compress-1.27.1.jar
org.apache.commons.compress.archivers.zip -> org.apache.commons.compress.utils commons-compress-1.27.1.jar
org.apache.commons.compress.archivers.zip -> org.apache.commons.io not found Apache Commons Compress zip was actually lifted from Apache Ant jdeps -cp ant-1.10.15.jar org/apache/tools/zip/ZipOutputStream.class
ZipOutputStream.class -> java.base
org.apache.tools.zip -> java.io java.base
org.apache.tools.zip -> java.lang java.base
org.apache.tools.zip -> java.nio java.base
org.apache.tools.zip -> java.nio.file java.base
org.apache.tools.zip -> java.util java.base
org.apache.tools.zip -> java.util.zip java.base We could just include |
This was my thought too, but I figured we can open the ZIP after it is created, and add the permissions. Same with unzip, we extract the files, and then dig into the zip via zip filesystem to fetch the perms. See my POC #371 |
@sake92 jdk.zipfs does not support symlinks, and only supports permissions since JDK 14. Apache Commons Compress/Apache Ant zip supports both symlinks and permissions for I put up #372 and added more details there. I think we can use a combination of these 2 approaches since we do neeed jdk.zipfs to support |
Didn't try it but seems SN doesn't support zipfs at all, yet. |
We do want to support both permissions and symlinks, so it seems using a third-party lib is inevitable since the built in JVM ZipFs does not support symlinks regardless of version https://bugs.openjdk.org/browse/JDK-8268856. Not supporting features on scala-native is fine. We never supported 100% of OS-Lib on scala-native, and anyway the vast majority of usage is on the JVM, so we can leave the scala-native version of this library to catch up at its own rate. Pulling in
All options add a bunch of complexity to what was previously a thin dependency-free library, but I think it's worth doing in order to fully flesh out the I'd say option (4) looks the best right now, as it offers the most "idiomatic" setup, which should minimize confusion and pave the way for other dependency-heavy submodules in future(e.g. tar support?) |
@lihaoyi what about vendoring |
@kiendang sure that would be option (1) above. I do think it's better to start separating out the OS-Lib artifacts though (option 4), I don't think this will be the last third-party dependency we want to add |
I see. Then I'd like to argue a bit more for option (1). We don't need to include the whole 1mb jar, just the part that we need. We could also use the source code from the source jar instead. This allows us to modify the code before compiling, like changing the |
I'd be ok with (1) if the vendored/shaded artifact was a bit smaller. As is, adding 1mb to 600kb triples the size of the library, which seems a bit much to add support for some uncommonly-used functionality. I guess the question is: how small can we make make the third party dependency? I'd say if we can get it below 200mb I'd be fine with adding it |
I had a branch that goes with the vendoring route. It gets the ant source jar, extracts only the source code for zip and adds it to sources. The 3.3.1 jar for os-lib (using the |
That size seems reasonable. Is there a reason you chose to vendor a subfolder from Ant rather than Commons-Compress? I would assume that Commons-Compress would be more intended for external use and distribution, and would expect it to be better maintained than the Ant internal libraries |
Commons-Compress actually got the zip code from Ant, so they are the same (with some added minor, but not essential QoL). The Commons-Compress zip code also depends on Commons-IO, which makes vendoring a bit more complicated (but not impossible) compared to Ant, which is standalone. And yes, if we go the dependency route like (4), that means depending on Commons-IO as well.
|
I get what you mean though. Vendoring Commons-Compress would be the better choice, if not for the Commons-IO dependency. |
Got it. In that case I think using the zip code from Ant sounds reasonable; we can always fork it and maintain it ourselves if necessary, or replace the implementation later if a better option comes around |
From the maintainer Li Haoyi: I'm putting a 500USD bounty on this issue, payable by bank transfer on a merged PR fixing this.
See https://github.com/orgs/com-lihaoyi/discussions/6 for other bounties and the terms and conditions that bounties operate under
@kiendang hit some issues using
os.zip
in Mill (com-lihaoyi/mill#4503), some of which are permissions related. It seems that since 2019 the JDK's zip file APIs should be able to support permissions (https://bugs.java.com/bugdatabase/view_bug?bug_id=8213031), so we should make sure OS-Lib takes advantage to preserve permissions when zipping and unzipping files and foldersThe text was updated successfully, but these errors were encountered: