tree: 043e69dba729dbecf25dfa4fd5e7dcfe7ee59dab [path history] [tgz]
  1. proto/
  2. BUILD.gn
  3. compression_util.cc
  4. compression_util.h
  5. compression_util_test.cc
  6. DIR_METADATA
  7. directory_util.cc
  8. directory_util.h
  9. file_util.cc
  10. file_util.h
  11. managed_directory.cc
  12. managed_directory.h
  13. managed_directory_test.cc
  14. OWNERS
  15. patch_util.cc
  16. patch_util.h
  17. patch_util_test.cc
  18. patchmaker.cc
  19. README.md
patchmaker/README.md

This utility allows a directory of binary files to be selectively bsdiff-encoded, and reconstructed on the fly.

The first consumer of this tool is ChromeOS cellular team, where modem firmware is stored in binary formats.

Patch storage can provide benefits in several scenarios:

  • Shipping several FW versions for the same modem (MR1 + MR2, or several carrier custpacks)
  • Shipping two identical modems (FM101 + RW101 or EM060 + LCK54) that are different in name only.
  • Shipping two similar modems (FM101 + EM060) should have some overlap from the shared underlying modem

bsdiff allows efficient patches to be generated between two similar binary files. To try and identify files that are similar and address the above use-cases, the following greedy algorithm will process all files present to determine which must be shipped in a full copy, and which can use existing full copies to produce a diff.

  1. As it is unintuitive and arbitrary to take diffs of files with very different sizes, a preprocessing step gathers the files into clusters, where files whose sizes are within 20% of each other will be clustered together. Each cluster can then be processed independently with the next steps.

  2. All modem firmware is put into a compressed squashfs before being installed on the ChromeOS device. For each file we process, we first compress it to get a baseline size. If the following patch generation attempts don‘t result in sizes smaller than compression, we won’t use a patch.

  3. First priority, we attempt patch generation between files with matching filename and depth. Clearly, the following file pairs are for the same purpose:

`fm101/19500.0000.00.01.01.52/NON-HLOS.ubi`
`fm101/19500.0000.00.01.02.73/NON-HLOS.ubi`

`fm101/19500.0000.00.01.01.52/NON-HLOS.ubi`
`rw101/19512.0000.00.11.02.01/NON-HLOS.ubi`
  1. Second priority, we attempt patch generation between files with matching extensions.
`fm350/OP_OTA_000.042.img`
`fm350/OP_OTA_000.043.img`
  1. Finally, we attempt patch generation between the remaining files in the cluster, which have similar file size. As mentioned above, if none of the patches beat compression, we use compression.