2

I have, for example, filesystem image which have some compressed files (with weak compression such as gzip), for example, manpages or archives with the same uncompressed content nearby.

How to pre-filter the data to "expand" compressed data to plain form (to re-compress it with strong compression) and then post-filter after decompression to restore original "semi-compressed" image? SHA-1 match is advices but not strictly required (but the resulting image must work, e.g. re-compressed files should not grow too much, be decompressible etc.)

Like improving compression ratio by reversing weak compression algorithms.

Are there programs for this?

Vi.
  • 17,755

1 Answers1

0

Assuming you're in an environment where you can write and run shell scripts this is fairly easy to do:

when doing a store:

  1. mount the filesystem image.
  2. look for all files with "weak compression" suffixes
  3. uncompress those files
  4. save the list of uncompressed files somewhere
  5. unmount the image
  6. compress the image

re-store:

  1. uncompress the image
  2. mount the system
  3. use the previously saved list to compress the files

This can be done using some of the file-detection code in lesspipe.sh from Gentoo, find and gzip, bzipt2, etc.

If you prefer to compress individual files with "strong compression" instead of the whole images, than this is certainly doable too.