2.1. Creating package files - dpkg-deb
All manipulation of binary package files is done by dpkg-deb
; it’s the only program that has knowledge of the format. (dpkg-deb
may be invoked by calling dpkg
, as dpkg
will spot that the options requested are appropriate to dpkg-deb
and invoke that instead with the same arguments.)
In order to create a binary package, you must make a directory tree which contains all the files and directories you want to have in the file system data part of the package. In Debian-format source packages, this directory is usually either debian/tmp
or debian/pkg
, relative to the top of the package’s source tree.
They should have the locations (relative to the root of the directory tree you’re constructing) ownerships and permissions which you want them to have on the system when they are installed.
With current versions of dpkg
the uid/username and gid/groupname mappings for the users and groups being used should be the same on the system where the package is built and the one where it is installed.
You need to add one special directory to the root of the miniature file system tree you’re creating: DEBIAN
. It should contain the control information files, notably the binary package control file (see The main control information file: control).
The DEBIAN
directory will not appear in the file system archive of the package, and so won’t be installed by dpkg
when the package is unpacked.
When you’ve prepared the package, you should invoke:
dpkg --build directory
This will build the package in directory.deb
. (dpkg
knows that --build
is a dpkg-deb
option, so it invokes dpkg-deb
with the same arguments to build the package.)
See the dpkg-deb(8) man page for details of how to examine the contents of this newly-created file. You may find the output of following commands enlightening:
dpkg-deb --info filename.deb
dpkg-deb --contents filename.deb
dpkg --contents filename.deb
To view the copyright file for a package you could use this command:
dpkg --fsys-tarfile filename.deb | tar xOf - --wildcards \*/copyright | pager