Skip to main content

1. Introduction

This brief HOWTO shows how a simple Debian DEB package file can be built. To keep it simple, various shortcuts have been taken and assumptions have been made.

  • The package will be usable for the i386 architecture only.
  • The source code will not be available (e.g. via apt-get source). This means that the package will be non-free.
  • The Debian Policy will not be adhered to. This means that the package will not be accepted into the official Debian archive.
  • By building a binary package, all the files must have permissions and ownerships that match the intended permissions and ownerships. Thus, all steps are expected to be run under the root account.

2. Steps

The steps to build a package that contains a script to update a local APT repository's Packages.gz file will be demonstrated. The package will contain one configuration file, /etc/test.conf, and one executable file, /usr/sbin/test.

2.1. Directory structure

Create the following directory structure in a place that is not managed by Debian APT itself, usually /usr/local/src.


The package will be named test, version 0.1, build 1, and intended for the i386 architecture.

2.2. Files

2.2.1. Files to be installed

Create the configuration file, test_0.1-1_i386/etc/test.conf, with the following contents.


By taking the special steps in creating a configuration file, Debian will allow you to make local changes, and will highlight these during a later package upgrade.

Create the executable file, test_0.1-1_i386/usr/sbin/test, with the following contents.

. /etc/test.conf
cd $LOC
dpkg-scanpackages -a i386 pool indices/override.sarge.opt|gzip >dists/sarge/opt/binary-i386/Packages.gz

Then make it executable using the command chmod 755 test_0.1-1_i386/usr/sbin/test.

2.2.2. Debian control file

Create the file, test_0.1-1_i386/DEBIAN/control, with the following contents.

Package: test
Version: 0.1-1
Section: non-free
Priority: optional
Architecture: i386
Installed-Size: 1
Maintainer: Ewan Parker <>
 /etc/test.conf 007b710b3f6846252e3712657195d665
Description: Test scripts to update a local APT repository
 This script is used as a test to show how a binary package can be built
 for Debian GNU/Linux.
 For more information about creating packages in Debian, please visit

The Installed-Size: is the size of all the installed files, in kB. The hexadecimal number after each of the Conffiles: is the MD5 checksum of the configuration file. For example, to calculate this for test.conf, use the command md5sum test_0.1-1_i386/etc/test.conf and use the value in the first column of the output.

2.2. Build

Use the command dpkg-deb --build test_0.1-1_i386. This will create the file test_0.1-1_i386.deb which can be installed using dpkg -i test_0.1-1_i386.deb or copied into an APT repository.

See also