Last active
February 27, 2024 09:08
-
-
Save thomasdarimont/964c01ae3274eb0124af to your computer and use it in GitHub Desktop.
Revisions
-
Thomas Darimont revised this gist
Mar 12, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -43,6 +43,7 @@ MD5 (guava-18.0.jar.orig) = 947641f6bb535b1d942d1bc387c45290 ``` # Apply the binary patch file where `guava-18.0.jar` denotes the target file. ``` $ bspatch guava-16.0.1.jar guava-18.0.jar guava-16.0.1-18.0.patch ``` -
Thomas Darimont revised this gist
Mar 12, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ $ wget http://central.maven.org/maven2/com/google/guava/guava/18.0/guava-18.0.ja $ wget http://central.maven.org/maven2/com/google/guava/guava/16.0.1/guava-16.0.1.jar ``` # Obtain bsdiff / bspatch http://www.daemonology.net/bsdiff/ #Create the binary patch file -
Thomas Darimont revised this gist
Mar 12, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -57,7 +57,7 @@ total 14928 -rw-r--r-- 1 tom staff 2.2M Aug 25 2014 guava-18.0.jar.orig ``` #Compute the MD5 hash of the new file ``` $ md5 guava-18.0.jar MD5 (guava-18.0.jar) = 947641f6bb535b1d942d1bc387c45290 -
Thomas Darimont revised this gist
Mar 12, 2015 . 1 changed file with 10 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,21 +4,22 @@ This is a simple example how to generate and apply a binary patch to a jar file. In the hope that some tooling vendor or gradle / maven / repository backend guru might pick this up to unban us from too long dependency download times :) # Download test jars For testing we download two versions of the commonly used google-guava library. ``` $ wget http://central.maven.org/maven2/com/google/guava/guava/18.0/guava-18.0.jar $ wget http://central.maven.org/maven2/com/google/guava/guava/16.0.1/guava-16.0.1.jar ``` # Abtain bsdiff / bspatch http://www.daemonology.net/bsdiff/ #Create the binary patch file ``` $ bsdiff guava-16.0.1.jar guava-18.0.jar guava-16.0.1-18.0.patch ``` #List directory ``` $ ll total 10520 @@ -27,7 +28,7 @@ total 10520 -rw-r--r-- 1 tom staff 2.2M Aug 25 2014 guava-18.0.jar ``` As one can see the binary patch file is around 900kb #Rename the original jar file ``` @@ -62,7 +63,9 @@ $ md5 guava-18.0.jar MD5 (guava-18.0.jar) = 947641f6bb535b1d942d1bc387c45290 ``` As one can see the checksums match :) I think it would be a nice feature and a huge bandwidth-saver if maven / gradle and the repository backends would support binary diffs for jars. It could be as simple as ... I have version x ... I want to upgrade to x+4, please generate the diff and send it to me... -
Thomas Darimont created this gist
Mar 12, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,68 @@ # How to do binary diffs with Java jars This is a simple example how to generate and apply a binary patch to a jar file. In the hope that some tooling vendor or gradle / maven / repository backend guru might pick this up to unban us from too long dependency download times :) # Download test jars: ``` $ wget http://central.maven.org/maven2/com/google/guava/guava/18.0/guava-18.0.jar $ wget http://central.maven.org/maven2/com/google/guava/guava/16.0.1/guava-16.0.1.jar ``` # Abtain bsdiff / bspatch: http://www.daemonology.net/bsdiff/ #Create the binary patch file ``` $ bsdiff guava-16.0.1.jar guava-18.0.jar guava-16.0.1-18.0.patch ``` #List directory: ``` $ ll total 10520 -rw-r--r-- 1 tom staff 878K Mar 12 10:45 guava-16.0.1-18.0.patch -rw-r--r-- 1 tom staff 2.1M Feb 3 2014 guava-16.0.1.jar -rw-r--r-- 1 tom staff 2.2M Aug 25 2014 guava-18.0.jar ``` As one can see the binary patch file is aroung 900kb #Rename the original jar file ``` $ mv guava-18.0.jar guava-18.0.jar.orig ``` #compute the MD5 hash of the original file ``` $ md5 guava-18.0.jar.orig MD5 (guava-18.0.jar.orig) = 947641f6bb535b1d942d1bc387c45290 ``` # Apply the binary patch file ``` $ bspatch guava-16.0.1.jar guava-18.0.jar guava-16.0.1-18.0.patch ``` # List the directory again ``` $ ll total 14928 -rw-r--r-- 1 tom staff 878K Mar 12 10:45 guava-16.0.1-18.0.patch -rw-r--r-- 1 tom staff 2.1M Feb 3 2014 guava-16.0.1.jar -rw-r--r-- 1 tom staff 2.2M Mar 12 10:51 guava-18.0.jar -rw-r--r-- 1 tom staff 2.2M Aug 25 2014 guava-18.0.jar.orig ``` #Compute the MD5 hash of the newly created file ``` $ md5 guava-18.0.jar MD5 (guava-18.0.jar) = 947641f6bb535b1d942d1bc387c45290 ``` The checksums match as one can see :) I think it would be a nice feature and a huge bandwith saver if maven / gradle and the repository backends would support binary diff for jars.