Visit Mozilla.org

Software Update:MAR

From MozillaWiki

Contents

Mozilla ARchive [edit]

This document describes the Mozilla ARchive (MAR) format used by the update system to deliver update packages. It is basically a series of files with an index tacked on to the end.

Details [edit]

The file structure in a nut-shell is a header (HEADER), followed by a list of variable length files, and finally ending with an index of the files (INDEX). The index is a list of variable length entries (INDEX_ENTRY).

HEADER

 4 bytes : "MAR1"
 4 bytes : offset to INDEX in bytes (big endian) relative to start of file

INDEX

 4 bytes : size of INDEX in bytes (big endian)
 variable number of INDEX_ENTRY elements

INDEX_ENTRY

 4 bytes : offset in bytes (big endian) relative to start of file
 4 bytes : length in bytes (big endian)
 4 bytes : flags (big endian)
 N bytes : name (byte array)
 1 byte  : null terminator

The flags field is used to store file permission bits (in the standard unix-style format).

Source Code [edit]

The source code can currently be found under mozilla/modules/libmar on the SOFTWARE_UPDATE_20050428_BRANCH branch in the Mozilla CVS repository.

See bug 296303

Why not use ZIP or some other standard file format? [edit]

This question was given a fair amount of consideration. Ultimately, we decided to go with a custom file format because using libjar would have required a fair bit of hacking. Writing custom code was a simpler option, and it resulted in less code (mar_read.c is less than 300 lines of code). Moreover, the update system does not need a standard file format. The elements stored in the archive are bzip2 compressed binary diffs, generated using a variation of bsdiff. So, being able to unpack the archive file using standard tools wouldn't be very useful in and of itself.