wiki:AnatomyOfAPackage

Version 14 (modified by jdreed, 9 years ago) (diff)

--

This page duplicates (and plagiarizes) the information at http://debathena.mit.edu/packaging/. However, this page is aimed more at working within the Athena repository.

Components

Within a package source, you'll find the debian/ directory, which must contain the following files:

  • debian/changelog: The Debian changelog for the package. The changelog is the authoritative source for the Debian version number of the package. It is typically installed to /usr/share/doc/package/changelog.Debian.gz. Although it is a plain text file, it should be edited using Debian-specific tools such as dch or the Emacs mode change-log-mode. See Changelog for more information, including how version numbers are calculated in the Debathena repository.
  • debian/compat: The debhelper compatability level of the package. See CompatLevels for the correct value.
  • debian/control: The Debian packaging system’s metadata for the package. See Control. Note that while this can be auto-updated with CDBS from control.in, it is essential that it exists.
  • debian/control.in: CDBS packages will often have a file called debian/control.in that looks exactly like debian/control except that it has @cdbs@ as a build dependency. This is replaced with various build dependencies that CDBS knows about (like debhelper and cdbs) at build time to generate debian/control.
  • debian/copyright: A human-readable description of the copyright status of the package. See Copyright for what to use in the Athena repository.
  • debian/rules: The executable makefile used to build the binary package. See Rules.
  • debian/source/format: If present, it contains the version of the source package (either 1.0 or 3.0). If absent, debuild will generally create a version 1.0 source package.

N.B. The control file can be generated from the control.in file with the following invocation, from within the package's root directory:

`DEB_AUTO_UPDATE_DEBIAN_CONTROL=yes debian/rules debian/control`

While that looks complicated, all it does is set a variable to 'yes', and then run debian/rules (remember, it's executable) with the argument: debian/control.

Other special files in debian/

  • debian/package.install: Pairs, one per line, of files and directories to install them to. Understands “*” and copies directories recursively.
  • debian/package.links: Pairs, one per line, of a target and the name of the symlink to create.
  • debian/package.init: The package’s init script. Code to run update-rc.d and run the init script at package installation and removal is automatically added to maintainer scripts.
  • debian/package.cron.d: cron job to be automatically installed into /etc/cron.d.
  • debian/package.docs: List documentation files/directories to be automatically installed into /usr/share/doc/package.
  • debian/package.dirs: List directories to be automatically created.
  • debian/package.postinst, debian/package.preinst, debian/package.postrm, debian/package.prerm: The package's maintainer scripts. See MaintainerScripts for more information.

Creating a package

While you can create all the special files listed above from scratch, Debhelper provides a tool to make things easy for you. Assuming you have a piece of software in a directory whose name is of the format package-version (e.g. foobar-1.0), you can use the dh_make command:

dh_make -c gpl -s --createorig

That will create a single binary (-s) package with the GPL license (-c gpl), and will create a .orig tarball for you in the parent directory (--createorig). It will create all the required files for you in the debian directory, and then a variety of optional example files (with the .ex extension), which you can either customize or delete.

Next: BuildingAPackage