Introduction
A .deb file is a software package for Debian, Ubuntu, Linux Mint and the
other Linux distributions built on Debian. It holds the files to install, a description
of the package with the other packages it depends on, and scripts to run before and
after installing or removing it. The dpkg tool installs it, and APT fetches
packages and their dependencies from repositories.
Structure
A .deb file is an ar archive, the same simple format Unix uses
for static libraries. It starts with the 8 bytes !<arch>\n, and each
member after that has a 60-byte text header giving its name, date, owner, mode and size.
A package has three members, always in this order:
debian-binary, a text file holding the format version,2.0.control.tar, compressed (ascontrol.tar.gz,.xzor.zst), holding thecontrolfile that names the package and its version and dependencies, plus the install scripts.data.tar, compressed the same ways (and also.bz2or.lzma), holding the files to install, laid out as they will be on disk.
The member headers, every compression and the tar rules are on the
archive layout page, which also covers the
multi-part form; every control field and
the other files in control.tar (conffiles, md5sums, triggers, shlibs,
symbols and the maintainer scripts) are on the
control files page.
0ar magic!<arch>\n8 bytes8debian-binary: member header, then2.0\n64 bytes72control.tar.*: member header, then the compressed tarvaries…data.tar.*: member header, then the compressed tarvaries
Not described
Known, not yet covered
- Reference: the options and exit codes of
dpkg-gensymbols(1)(how a symbols file is generated and compared), which is tool behaviour rather than file layout. The symbol tags themselves are covered. - Reference: how dpkg orders and resolves relationships at run time (the unpack and configure order it picks, which break it chooses in a dependency loop, how front-ends choose packages). The rules Policy states are described; the algorithm is runtime behaviour, not part of the package file, and is out of scope in the same way as the order of maintainer-script calls (Policy 6.5 to 6.8).
- Viewer: there is no viewer for .deb files yet, so the ar members, control fields and file lists are not shown.
Links
Software
- dpkg – Debian’s package tool, which installs, removes and unpacks .deb files (Debian and its derivatives)
- APT – fetches packages and their dependencies from repositories (Debian and its derivatives)
- GNU Binutils – its
arunpacks the outer archive (Linux, macOS, Windows) - 7-Zip – free archiver that opens the archives inside (Windows)
Reference
- deb(5) – the format’s manual page
- Debian Policy Manual – Debian’s rules for packages, including the control file fields