Building simple Debian / Ubuntu Pakets for Deployment

Ähnliche Inhalte

Build simple *.deb Pakets for Debian / Ubuntu

There are various tools around to create source and binary pakets for debian. But sometimes you just want to deploy some files in the file system, like scripts or web applications that are plattform independent. And it is also handy to run a post install script after the installation.

This post desribes how you can do this for debian packages. It copies a few files to a target location in the system and runs a post install script after the installation of the package.


The first step would be to create a sub folder "DEBIAN" in your project folder. This folder contains the specific fields that describe the debian package:


mkdir -p ./debianpackage/DEBIAN

The Debian control and postins file

The DEBIAN folder needs at least to contain the "control" file. This control file contains meta information about the package. We also create a file "postinst" that contains a bash script that will be executed after the installation. We also need to make sure that the postinst file is executable:


touch ./debpackage/DEBIAN/control
touch ./debpackage/DEBIAN/postinst
chmod 770 ./debpackage/DEBIAN/postinst

For the control file (debpackage/DEBIAN/control) it is important, that the syntax is completly correct:

Package: myapp
Priority: optional 
Section: misc 
Maintainer: You Name <> 
Architecture: all 
Version: 1.0       
Description: The Package description

Beside the meta files in the DEBIAN directory we need for sure the acctual files that should be deployed. To achieve that you need to place the files into the root folder of the package as the should be deployed in the target system:


touch ./debpackage/usr/sbin/

Building the Debian / Ubuntu Package

Finally, we need to build the package:


dpkg -b ./debpackage indexpicker.deb

Building packages like this can only be used to deploye simple, plattform independent stuff, but in general the possibilities of the debian package system are very flexible. I