Creating a deb package

Create a Debian package in 8 steps

Create a directory according to your package name, for instance superscript.

  $ mkdir superscript
  $ cd superscript

Create a directory structure that mirrors the place where the files should be located, i.e. if the files in your package must be installed in /usr/local/bin, create this directory:

  $ mkdir -p usr/local/bin

Now put the files in there that must be in the package. Suppose you created a script called superscript which you developed and tested in your home directory:

  $ cp ~/superscript usr/local/bin

Now create a DEBIAN directory and make it your current dir:

  $ mkdir DEBIAN
  $ cd DEBIAN

Create a file called control and put the following lines in there:

  Package: superscript
  Version: 0.1
  Section: admin
  Priority: optional
  Architecture: i386
  Maintainer: someone@somewhere.org
  Description: The Descrption

Also create a file called postinst and put the following line in there:

  #!/bin/sh
  chown root:root /usr/local/bin/superscript
  chmod 755 /usr/local/bin/superscript

Make this script executable:

  $ chmod 755 postinst

You're done. Build the package:

  $ cd ../../
  $ dpkg-deb --build superscript

Done. Install your package as follows:

  $ dpkg -i superscript.deb

The control file

To get a better control file, you can copy it from an existing package. Suppose you're creating a package with a few header files. First look up a package name from an existing header file:

  $ dpkg -S /usr/include/qhull/poly.h
  libqhull-dev: /usr/include/qhull/poly.h

Then display the control file for that package:

  $ dpkg -s libqhull-dev

See also the Debian policy.

Don't start from scratch

If you don't want to start from scratch, download this tarball: testpackage.tar.gz.

Unpack it and rename the directory. Put the file you want to install in yourpackagename/usr/local/bin, adjust yourpackagename/DEBIAN/postinst and control, and build the package according to the last step mentioned above.

Links

Mini-HOWTO binary package building from which this page is an abstract

APT HOWTO