10min: Create Debian packages

Posted on 8 May 2008 - 21:30 in Ubuntu - Comments (1)

Ever wanted to pack your scripts into .deb packages?

Here we go…

You need:

  • ‘devscripts’ package (over apt-get)
  • your script(s)
  • 10 minutes


Create a directory structure like this:

package tree

All files not inside the DEBIAN directory will get copied to the corresponding system path.
package/usr/sbin/script gets copied to /usr/sbin/script .

Put at least README, copyright and changelog inside
package/usr/share/doc/package/ .

README should be self explaining.
copyright includes informations about the creator and the license (link to /usr/share/common-licenses/GPL for example).
changelog documents the changes.
Create the changelog and gzip it

$ dch --create -c changelog -v 1.0
$ gzip -9 changelog

Be aware that the changelog has to follow the Debian Policy.
dch gives you the correct layout, just fill in the required information.

When maintaining, add a new version with

$ gunzip changelog.gz
$ dch -c changelog -v 1.1
$ gzip -9 changelog

Create the DEBIAN/control file, the information about the package will reside there.
The file should look like this:

Package: package
Version: 1.0
Priority: optional
Section: utils
Architecture: all
Depends: gzip (>= 1.3), exim | mail-transport-agent
Installed-Size: 64
Maintainer: some one <somename@somedomain.com>
Description: the description header
 more description, make a
 .
 for empty lines.
  • Package is the package name
  • Version is the current version of the package
  • Priority should be optional
  • Section can be gathered from the Ubuntu package search, check out the linked name to a section
  • Architecture if the package is for a specific, else ‘all’ will do it
  • Depends on one or more specific package, here it’s gzip 1.3 or higher and exim or an other MTA
    Recommends and Suggests are also common, more here
  • Installed-Size with ‘du -k’ in the main directory of the package
  • Maintainer with email address
  • Description of the package, first line is the header, other lines for more detailed description

Optionally, you can create preinstall, postinstall, prerm and postrm scripts inside the DEBIAN directory.
They will run before de-/installation (prerm, preinst) or after de-/installation (postrm, postinst) of the package.

Change out of the package directory and create the package.
Use the standard naming format: packagename_version_architecture.deb

$ dpkg -b package/ package_1.0_all.deb

Done.

Sources:
Debian New Maintainers’ Guide
Debian Policy Manual


1 Comment »

  1. #1 — Pingback by 10min: Create Debian packages : HowtoMatrix — 9 May 2008 - 17:43

    [...] * ‘devscripts’ package (over apt-get) * your script(s) * 10 minutes Create a directory structure like this: Read more at wag-net [...]


RSS Comments - TrackBack URL

Leave a comment

This work is licensed under a Creative Commons Attribution 2.5 Switzerland License
Powered by WordPress