Skip to content

Instantly share code, notes, and snippets.

@thomasdarimont
Last active February 27, 2024 09:08
Show Gist options
  • Select an option

  • Save thomasdarimont/964c01ae3274eb0124af to your computer and use it in GitHub Desktop.

Select an option

Save thomasdarimont/964c01ae3274eb0124af to your computer and use it in GitHub Desktop.

Revisions

  1. Thomas Darimont revised this gist Mar 12, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions howto.md
    Original 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
    ```
  2. Thomas Darimont revised this gist Mar 12, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion howto.md
    Original 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
    ```

    # Abtain bsdiff / bspatch
    # Obtain bsdiff / bspatch
    http://www.daemonology.net/bsdiff/

    #Create the binary patch file
  3. Thomas Darimont revised this gist Mar 12, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion howto.md
    Original 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 newly created file
    #Compute the MD5 hash of the new file
    ```
    $ md5 guava-18.0.jar
    MD5 (guava-18.0.jar) = 947641f6bb535b1d942d1bc387c45290
  4. Thomas Darimont revised this gist Mar 12, 2015. 1 changed file with 10 additions and 7 deletions.
    17 changes: 10 additions & 7 deletions howto.md
    Original 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:
    # 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:
    # 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:
    #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 aroung 900kb
    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
    ```

    The checksums match as one can see :)
    As one can see the checksums match :)

    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.
    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...
  5. Thomas Darimont created this gist Mar 12, 2015.
    68 changes: 68 additions & 0 deletions howto.md
    Original 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.