Creating Debian Package

Debain package is a tar file that contains the files required by an application along with some script and description about the application and its depedency. This tutorial will guide you to create a simple debian package by hand.

  1. Create the directory to hold the project
mkdir /tmp/<package>_<version>_<architecture>

Please replace by package name, by version and by the architecture that the package has been created for.

  1. Create a directory call “DEBIAN” inside the project directory
mkdir /tmp/package_version_architecture/DEBIAN

This directory contains the metadata about the package.

  1. Copy files into project root directory and include the final paths For example files that needs to be put into /usr/bin should be placed into /tmp/package_version_architecture/usr/bin.

  2. Create and add necessary control to the control file

touch /tmp/package_version_architecture/DEBIAN/control

Control file contains information about the package being installed like name, version, description, dependencies, etc. A sample control file is given below.

Package: my-program
Version: 1.0
Architecture: all
Essential: no
Priority: optional
Depends: packages;my-program;needs;to;run
Maintainer: Your Name
Description: A short description of my-program that will be displayed when the package is being selected for installation. 
  1. Add “preinst” and/or “postinst” script if required When the debian package is installed preinst and postinst scripts are executed before or after the installation of the package.

  2. Now generate packages using the following command.

dpkg-deb --build
comments powered by Disqus