有没有像 bsdiff/Courgette 这样的 jar 文件?
Google 使用 bsdiff 和 Courgette 用于修补二进制文件,例如 Chrome 发行版。是否存在用于修补 jar 文件的类似工具?
我正在通过带宽有限的连接远程更新 jar 文件,并希望最大限度地减少发送的数据量。我确实在某种程度上对客户端计算机有一定的控制权(即我可以在本地运行脚本),并且我保证目标应用程序当时不会运行。
我知道我可以通过将更新的类文件放入类路径中来修补 Java 应用程序,但我更喜欢使用更干净的方法来进行更新。如果我可以从目标 jar 文件开始,应用二进制补丁,然后得到与新 jar(从中创建补丁)相同(按位)的更新的 jar 文件,那就太好了。
Google uses bsdiff and Courgette for patching binary files like the Chrome distribution. Do any similar tools exist for patching jar files?
I am updating jar files remotely over a bandwidth-limited connection and would like to minimize the amount of data sent. I do have some control over the client machine to some extent (i.e. I can run scripts locally) and I am guaranteed that the target application will not be running at the time.
I know that I can patch java applications by putting updated class files in the classpath, but I would prefer a cleaner method for doing updates. It would be good if I could start with the target jar file, apply a binary patch, and then wind up with an updated jar file that is identical (bitwise) to the new jar (from which the patch was created).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试 Sourceforge 上的 javaxdelta 项目。它应该允许创建补丁并应用它们。
[编辑] 这个工具还不存在。使用常用工具打开 JAR 文件,然后使用 javaxdelta 为 JAR 中的每个条目创建一个补丁。将它们压缩并复制到服务器上。
另一方面,您需要安装一个小型可执行 JAR,它将补丁和 JAR 文件作为参数并应用补丁。您还必须写这篇文章,但这不会超过几个小时。
Try the javaxdelta project on Sourceforge. It should allow to create patches and to apply them.
[EDIT] This tool doesn't exist, yet. Open the JAR file with the usual tools and then use javaxdelta to create one patch per entry in the JAR. ZIP them up and copy them onto the server.
On the other side, you need to install a small executable JAR which takes the patch and the JAR file as arguments and applies the patch. You will have to write this one, too, but that shouldn't take much more than a few hours.
.jar 文件已经被压缩,因此您真正需要的是对 zip 文件运行良好的压缩;)。如果你在把它塞进罐子之前就得到了它,那么你就有更好的机会利用它是我期望的“java”的知识。我怀疑您可以调整这篇论文 作为java特定的压缩方法。
.jar files are already compressed, so what you're really asking for is a compression that works well on zip files ;). If you get at it before you stuff it in the jar you have better odds of taking advantage of the knowledge that it is "java" I expect. I suspect you could adapt the factorization described in this paper as a java specific compression method.
问题是源代码中的微小变化可能会对压缩的 .JAR 文件产生很大的变化。
这是消除冗余的产物。因此,无论您的 diff 工具有多好,它都面临着一项几乎不可能完成的任务。
然而,有一个解决方案,即生成差异并将补丁应用于未压缩数据。例如:
假设您有
project-v1.jar
project-v2.jar
生成这两个文件之间的差异可能会很大,即使内部更改可能非常小。假设我们有一个“unjar”和“rejar”程序 - 我们可以生成
project-v1.jar ->项目-v1.jar.unjar
项目-v2.jar -> project-v2.jar.unjar
然后,在“unjar”文件之间进行比较以生成补丁。要应用补丁,请执行以下操作:
project-v1.jar (unjar)-> project-v1.jar.unjar -(应用补丁)->项目-v1.patched.unjar(重新jar)-> 。
实际上,“unjar”(“rejar”则相反)程序应该采用源 ZIP 文件(或任何其他类型的文件),并解压缩内容 - 包括标头、属性和任何内容 输出流的其他详细信息(而不是创建单独的文件)。
这不应该是一个写起来非常复杂的过滤器。额外的好处是使其具有压缩感知和递归功能(这样您就可以将其应用于 WAR 文件)。
The problem is that very small changes in the source can have very big changes in the compressed .JAR file.
This is an artifact of removing redundancy. So no matter how good your diff tool is, it's got a nearly impossible task on its hands.
However - there is a solution, which is to generate the diffs and apply the patches to the uncompressed data. For example:
Say you have
project-v1.jar
project-v2.jar
Generating the diff between these two files is likely to be huge, even though the internal change could be very small. So say we have an 'unjar' and 'rejar' program - we can generate
project-v1.jar -> project-v1.jar.unjar
project-v2.jar -> project-v2.jar.unjar
Then, doing the diffs between the 'unjar' files to generate a patch. To apply the patch would be
project-v1.jar (unjar)-> project-v1.jar.unjar - (apply patch)-> project-v1.patched.unjar (rejar)-> project-v1.patched.jar
Effectively, the 'unjar' (and 'rejar' is the reverse) programs should take a source ZIP file (or any other type of file), and uncompress the contents - including the headers, attributes and any other detail to an output stream (rather than creating individual files).
This ought not to be a very complicated filter to write. Added bonus would be to make it compression-aware and recursive (so you could apply it, say, to a WAR file).
检查 delta-updater
它是为二进制差异和修补目录构建的,您可以使用 IOFilter 来过滤包含的文件
check delta-updater
it is build for binary diff and patching directories, you can use
IOFilter
to filter included files