Giter VIP home page Giter VIP logo

zipref's Introduction

zipref

zipref is a script that generates (uncompressed) ZIP files on copy-on-write filesystems by ref-linking the contents of the source files inside the archive.

It does so by (ab)using the fact that the ZIP format allows padding between entries to carefully align the file header for each entry so that the data starts at an offset which is a multiple of block size. This allows cloning the data from the source file directly.

The resulting archive is a proper ZIP64 archive and should barely take up any extra space. It has been tested to extract properly in WinRAR, 7z and unzip.

Note that the process is not instantaneous: the data still has to be read in order to compute the CRC32 for each entry. Additionally, if the clone ioctl fails, the script will revert to copying the data manually.

Usage

The script takes the name of the output archive as first argument, as well as the name of files to add as additional arguments. It's possible to use @ to specify a file containing a list of files, and to use - to read said list from standard input.

The output file must not exist already, and the input files are added as-is in the specified order, using their paths verbatim as they are specified.

Some examples:

# Specify file list on the command line
zipref output.zip *.mp3

# Specify file list from an input file
zipref output.zip @files.txt

# Specify file list from standard input
find -type f | zipref output.zip

Additionally, it is possible to generate a reproducible archive using the SOURCE_DATE_EPOCH environment variable:

# Generate reproducible archive
export TZ=UTC
export SOURCE_DATE_EPOCH=1600000000 # or $(stat -c %Y reference_file)
find -type f | sort -f | zipref output.zip

References

zipref's People

Contributors

koro666 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.