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 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.
Create the following directory structure in a place that is not managed by Debian APT itself, usually /usr/local/src.
test_0.1-1_i386
test_0.1-1_i386/DEBIAN
test_0.1-1_i386/etc
test_0.1-1_i386/usr
test_0.1-1_i386/usr/sbin
The package will be named test, version 0.1, build 1, and intended for the i386 architecture.
Create the configuration file, test_0.1-1_i386/etc/test.conf, with the following contents.
LOC=/var/local/debian
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.
#!/bin/sh
. /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.
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 <eparker@public1.ejp.cc>
Conffiles:
/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
http://www.ewan.cc/simple-binary-dpkg-deb-howto.shtml
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.
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.
© Copyright Ewan Parker 1999–2010. Last modified Friday, 18-Aug-2006 19:51:34 BST.