How to Create Deb Packages with Debreate

Ubuntu’s package management system, which it owes to it’s big brother Debian, makes it as simple as it gets to keep your system up to date. Whether through GUI programs or using “apt-get“, constantly impresses me. But there are still instances where you can’t get a particular program in DEB format, or maybe you want to distribute your own software for other Debian and Ubuntu users. Putting together a DEB package by hand is a daunting task… fortunately, Debreate makes it easy to package up software for easy installation.

Note: This is the second part of creating the deb packages series. You can read the first part: The Basics of Debian Package Management: DEB Packages [Linux 101] here.

Installing & Launching Debreate

The first thing we’ll need to do is install Debreate. You can download the package from Sourceforge here, then install with the package manager of your choice, or with the following command:

sudo dpkg -i debreate_0.7.7_all.deb

Then we can launch Debreate from KRunner by executing “debreate“, or by clicking the item in the “Development” section of the application menu.

Start up the program, and you’ll get the following (first-run) screen, as shown below at left, followed by an info screen, below at right.



Control Info

Clicking on the arrow in the upper corner brings us to a screen called “Control.” This where we’ll fill in the data that will end up in the “control.tar.gz” part of the package. You’ll need to fill in the following fields shown below:

  • Package: The name of the package must consist only of lower case letters, numbers, “+,” “-,” or “.” symbols.
  • Version: A version number—I’m using 0.0.1 for this initial version.
  • Maintainer: The name of the person packaging this application (that’s me).
  • Email: His/her (my) e-mail address.
  • Architecture: If this is a binary package (i.e. not a package of source code that will be compiled), this will probably be one of: “i386” (for 32-bit processors, like Pentium or Core processors), “amd64” (64-bit processors, like the AMD Phenom or newer Intel Core i3/5/7), or “all”, meaning it’s not processor-dependent. Since this is a shell script that will run on any version of Ubuntu, I’m selecting “all”.
  • Section: This is the category where the package will reside within a larger repository. Since our script allows us to easily output documents from text markup, I’ve selected the “Text” section (Pandoc itself is also in the “Text” Section).
  • Priority: According to the Debian/GNU FAQ, this should be “Optional” (and again, Pandoc itself is also “Optional”).
  • Short Description: This description of the package will display, for example, in a list view in a software manager like the Software Centre or Muon.
  • Long Description: This longer description will display in a detailed view, such as when a package is selected in a software manager, or by using apt-cache show [package]".


Click the right arrow at the upper right to move to the next screen.

The Dependencies

The next thing we’ll need to prepare is a list of any other packages that this program will use. Obviously, we’ll need “Pandoc” to be installed, since the script calls that program, and since we’re including a GUI, we’ll need to make sure “Zenity” is installed too. We’ll need to enter each of these on the Dependencies screen (we could also include a version number, but for this script, whatever version of Pandoc and Zenity the distribution has should suffice), and hit the “Add” button to add it to the list.


Now, let’s pack up some files!

The Files

The first thing to do is to gather all the files you’ll be including, and arrange them in the folder structure described above. For this article, I’m going to be packing up the script I created in a previous article. The Files screen allows you to select files one at a time, and indicate to what folder they should be installed, as shown below. I have three files I’d like to include:

  • The script itself… Since this program is a shell script, it’s self-contained. I’ll need to put this in “/usr/bin” according to FHS.
  • Next, I’m going to include a brief README file with usage instructions. This will go in “/usr/share/doc”.
  • Lastly, I’m going to include an icon. I’ll place this in “/usr/share/icons”.


Scripts, Changelog, Copyright

The next screen will allow you to specify the “preinst”, “postinst”, “prerm”, and/or “postrm” scripts described in the previous article on DEB basics. Three more will follow: Changelog (which allows you to describe changes since the last version), Copyright (a statement on how the software can be used), and Menu Launcher (which will automate the creation of an item in the main desktop menu). For the purposes of this test package, I’m not using any of these.


Build It!

The final screen will give you some “Extra Options” that we can safely ignore… let’s get to building. Click the big green button!


My package had some warnings (which is developer speak are different than errors, which are “show-stoppers” so to speak) like a missing Copyright statement, missing man page, etc… since this package is just for my own use, this is OK. But it’s built! You can install with the following standard “dpkg” command:

 sudo dpkg -i pandoc-pub_0.0.1_all.deb

But it fails… why? Because it has dependencies on Zenity and Pandoc (which I just removed, to test this feature). Double-clicking on the package in a file manager will let GDebi do the dependency installation for us, as shown below:


Once installed, I can now distribute this to my friends (who are, by and large, much better programmers than me). So find some of your more useful scripts or programs, and get packaging. Distributing helpful software to others is what makes the FOSS community so great!

Aaron Peters

Aaron is an interactive business analyst, information architect, and project manager who has been using Linux since the days of Caldera. A KDE and Android fanboy, he'll sit down and install anything at any time, just to see if he can make it work. He has a special interest in integration of Linux desktops with other systems, such as Android, small business applications and webapps, and even paper.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox