This page follows deb(5) and deb-old(5) from dpkg. The
format has been used since Debian 0.93. The .deb format is supported since dpkg 0.93.76 and generated by default since dpkg 1.2.0 and 1.1.1elf (i386/ELF builds) (deb(5)). Its media type is
application/vnd.debian.binary-package (formerly
application/x-debian-package or application/x-deb). What goes
inside the control archive is on the control
files page.
The ar container
A .deb is an ar archive in the common
format only, without the long file name extensions. The file starts with the 8 bytes
!<arch>\n (21 3C 61 72 63 68 3E 0A); each member is a
60-byte header followed by its data, padded with one \n to an even
length.
| Offset | Size | Field | Contents |
|---|---|---|---|
0 | 16 | name | Member name, padded with spaces; an optional trailing / is allowed, which limits names to 15 characters. |
16 | 12 | date | Modification time, decimal seconds since 1970. |
28 | 6 | owner | User ID, decimal. |
34 | 6 | group | Group ID, decimal. |
40 | 8 | mode | File mode, octal. |
48 | 10 | size | Data size, decimal; ten digits limit a member to 9,999,999,999 bytes (about 9536.74 MiB). |
58 | 2 | end | `\n (60 0A). |
Members
The members must come in this order. Programs should ignore any member after
data.tar, and should stop on an unexpected member anywhere else.
| Order | Name | Contents |
|---|---|---|
| 1 | debian-binary | The format version as newline-terminated lines; today one line, 2.0. Readers accept a higher minor number and extra lines, ignoring them; a different major number is an incompatible format, so the program stops. |
| — | _name | Optional extension members, which older programs ignore, go here, between debian-binary and control.tar, with names starting with an underscore. |
| 2 | control.tar, .tar.gz, .tar.xz, .tar.zst | The control archive: control and the other control files, as plain files at its root; it may also have an entry for .. |
| 3 | data.tar and the suffixes below | The files to install, as a tar archive of the filesystem, for the target system. |
A new member that older programs cannot safely ignore must not start with an
underscore and goes before data.tar; or the change raises the major
version.
Compression
| Suffix | Compression | control.tar since dpkg | data.tar since dpkg |
|---|---|---|---|
| none | Uncompressed | 1.17.6 | 1.10.24 |
.gz | gzip | Always | Always |
.xz | xz | 1.17.6 | 1.15.6 |
.zst | Zstandard | 1.21.18 | 1.21.18 |
.bz2 | bzip2 | — | 1.10.24 |
.lzma | LZMA (legacy) | — | 1.13.25 |
Each member’s compression is chosen separately and shown by its suffix.
Tar rules
Both archives are tar files in one of: the old v7 format, pre-POSIX ustar, a subset of the GNU format, or POSIX ustar. A type flag dpkg does not know is an error.
| Feature | Since dpkg |
|---|---|
GNU long path and link names (L and K entries) | 1.4.1.17 |
POSIX ustar long names (the prefix field) | 1.15.0 |
| GNU large-number (base-256) fields: sizes to 95 bits, negative times, 63-bit user, group and device numbers | 1.18.24 |
Without the base-256 extension, a member’s size is limited to 11 octal digits (8 GiB).
Worked example
The first 72 bytes of every new-format package:
| Offset | Bytes | Meaning |
|---|---|---|
0 | !<arch>\n | ar magic |
8 | debian-binary␣␣␣ | Name, 16 bytes |
24 | 1700000000␣␣ | Date (example), 12 bytes |
36 | 0␣␣␣␣␣ | Owner |
42 | 0␣␣␣␣␣ | Group |
48 | 100644␣␣ | Mode |
56 | 4␣␣␣␣␣␣␣␣␣ | Size: 4 bytes of data |
66 | `\n | Header end |
68 | 2.0\n | The data; even length, so no padding |
72 | control.tar.xz␣␣… | Next member header |
(␣ stands for a space. The date, owner, group and mode values are
examples; the field widths come from the common ar header, described on the
ar pages.)
The old format (before Debian 0.93)
Not an ar archive: two ASCII lines each ending in \n, then two gzipped tar
files back to back.
- The format version padded to 8 digits: always
0.939000. - The size in bytes of the first gzipped tar, in decimal without leading zeros.
- The control archive (gzipped tar), which must contain
control; in very old packages the files may be in aDEBIANfolder inside it, and there may be an entry for.. - The data archive (gzipped ustar), paths relative to the root without a leading slash.
Multi-part packages (deb-split)
A big package can be cut into pieces to move on small media. Each piece is itself an
ar archive, with the same !<arch>\n magic and a file name that
may carry a trailing slash (since dpkg 1.15.6) (deb-split(5), raw
man/deb-split.pod). It is not a normal .deb: it has two required members, in
this exact order.
| Member | Contents |
|---|---|
debian-split | Text, one value per line, separated by newlines; currently eight lines, in this order: (1) the format version number, 2.1 at the time of the manual page; (2) the package name; (3) the package version; (4) the md5sum of the package; (5) the total size of the package; (6) the maximum part size; (7) the current part number, a slash and the total number of parts, as 1/10; (8) the package architecture (supported since dpkg 1.16.1). |
data.N | The raw data of part N, the last required member. |
- Readers should expect the minor part of the version number to increase and further lines to appear, and ignore them.
- If the major part of the version changes, an incompatible change was made and the program should stop. Otherwise it can continue safely, unless it meets an unexpected member in the archive other than at the end.
- The members must occur in exactly this order. Current implementations should ignore any members after
data.N; further members may be defined later and, if possible, will be placed after these two. - How
dpkg-splitmakes and joins the parts (dpkg-split(1), rawman/dpkg-split.pod):- the parts are named
prefix.NofM.deb, where N is the part number starting at 1 and M the total number of parts, both in decimal; with no prefix given, the original file name (directory included) is used with any trailing.debremoved; - the maximum part size is set in kibibytes (1,024 bytes) with
--partsize, default 450 KiB; - to be joined, the parts must be all the parts of exactly the same original file, each given once, in any order, and all made with the same part size (in practice, by the same
--splitrun); - the part files’ names are not significant for reassembly; the joined file is named
package_version_arch.debby default; - when
SOURCE_DATE_EPOCHis set, it is the timestamp (seconds since the epoch) written in the parts’ ar container (since dpkg 1.18.11).
- the parts are named
Sources
dpkg manual pages deb(5) (container, members, compression and tar rules
with dpkg versions, extension members, media types), deb-old(5) (old
format) and deb-split(5) (multi-part format), dpkg 1.23. The ar header layout is the common ar format; see the site’s
ar pages and their sources.