5.11 Determinism
To make a package byte-reproducible (§5.10), the tar archive MUST obey every rule below. A consumer MUST reject a package that violates any of them.
- Tar entries MUST be ordered lexicographically by the entry name as
written into the tar header, compared byte-for-byte over its UTF-8
bytes. A directory's entry name carries a trailing
/, and that slash participates in the comparison. - Every entry's modification time MUST equal the value of
build.timestampin the manifest (§5.18), which MUST NOT carry sub-second precision. - Every entry's owner numeric ID and group numeric ID MUST be 0.
- Every entry's owner name and group name MUST be the string
root. - Entries MUST NOT carry extended attributes. Security descriptors are applied at file-creation time (§5.20), never through tar attributes; other install-time attributes are applied through side-effect declarations (§5.24) or by higher-level mechanisms outside this specification.
- Entry permission bits MUST be
0777for every entry, with the setuid and setgid bits cleared (§5.16). - PAX extended header records, when present, MUST appear in a fixed
canonical order:
pathfirst, thenlinkpathif present, then any other record sorted by record name lexicographically. - The tar header magic MUST be
ustar\0and the version MUST be00. - The
devmajoranddevminorheader fields MUST be 0 for every entry type this specification permits — none of which is a device entry. - Header padding bytes MUST be NUL (
0x00). - PAX global header records (typeflag
g) MUST NOT appear. - PAX extended header records (typeflag
x) MUST appear only when an entry'spathexceeds the ustar 100-byte limit, in which case apathrecord is emitted, or itslinknameexceeds that limit, in which case alinkpathrecord is emitted. A record with any other key MUST NOT be emitted. - A path exceeding the ustar 100-byte limit MUST be carried by a
pathrecord. The ustarprefixfield MUST NOT be used to split such a path acrossprefixandname. - An extended header entry's own name MUST be the containing
directory's path, then
PaxHeaders.0/, then the base name of the entry it describes. For an entry at the archive root the directory part is absent.
Rules 13 and 14 exist because a tar library given a long path may legitimately choose either encoding, and either choice produces a different byte stream from the same input. Determinism requires the choice be made here rather than by whichever library a producer reached for.