Format:Debian package
| Magic | !<arch>\n then a member named debian-binary |
|---|---|
| Extensions | .deb, .udeb, .ddeb |
| On this wiki | Facts · Code · Notes · Topics |
The .deb package of Debian, Ubuntu and derivatives: an ar archive with exactly three leading members, debian-binary ("2.0"), control.tar[.gz/.xz/.zst] and data.tar[.gz/.xz/.zst/.bz2/.lzma].
Structure
A .deb is an Format:ar archive (magic !<arch> and a linefeed). Per the Debian deb(5) manual page (dpkg-dev 1.21.22) there are three required members that must occur in this exact order; extra members after data.tar should be ignored, and members that older tools may skip start with an underscore:
debian-binary: text lines; currently one line, the format version2.0. A changed major number means an incompatible format.control.tarwith an optional compression suffix: uncompressed,.gz,.xzor.zst. It holdscontrol(mandatory: name, version, architecture, dependencies...) and optionallymd5sums,conffiles,triggers,shlibs,symbolsand the maintainer scriptspreinst,postinst,prerm,postrm.data.tarwith an optional suffix: uncompressed,.gz,.xz,.zst,.bz2or.lzma. This is the file tree installed under/.
The tar variants allowed are v7, pre-POSIX ustar, a GNU subset and POSIX ustar. Only the common ar format is supported (no long-name extension), so names such as control.tar.zst fit in the 16-byte name field with the trailing /.
Getting at the binaries
ar t file.deblists members;ar x file.debextracts them; ordpkg-deb -x file.deb diranddpkg-deb -e file.deb dir.- The compression of a member is told by its name suffix; also check magic: gzip
1F 8B, xzFD 37 7A 58 5A 00, zstd28 B5 2F FD, bzip2BZh(see Format:Gzip, Format:XZ, Format:Zstandard, Format:Bzip2). - Debug symbols ship separately as -dbgsym packages (.ddeb). They place build-id named files under /usr/lib/debug/.build-id/: debhelper's dh_strip extraction routine builds the path usr/lib/debug/.build-id/<first byte>/<rest>.debug from the build-id and records the ids in a dbgsym-build-ids file (Debian/debhelper, dh_strip, around line 292).
- Unverified:
Depends/Architecturefields incontrolidentify the target CPU (amd64, arm64, armhf, i386...) without opening any binary.
Sources
Debian deb(5) manual page (documentation, read online). The dpkg source (GPL) was not read for this page.