Build Debian packages and offer them in PPAs
Wrapped with a Bow on Top

© Lead Image © belchonock, 123RF.com
Is the current package for your favorite Ubuntu program woefully behind the times? No problem: Just a few steps creates an updated Debian package that you can then share with others in a PPA.
Although your favorite Debian distro comes with many thousands of packages, some updated tools are still occasionally missing. Eventually, the maintainers might offer the corresponding packages themselves, but packaging these tools in a timely manner for each release of a distribution can be difficult.
If you want to use a new version of a program that is not yet included in your current distribution, you can create a solution yourself without any expertise in building Debian packages. If the package sources for the old version are available, constructing packages from them for the new version is usually pretty easy to do. A positive side effect is that you have the opportunity to do something good for the open source community: Provide your packages to Launchpad [1] via a PPA (Personal Package Archive) and share the results of your work with other users.
In this article, I describe an example of how to build a new, updated Debian package from old sources for the KDE backup software Kup. Most of your work will be in the terminal, because you'll be working in a chroot
environment, which only makes sense from the command line. Basic knowledge of the command line's general functionality is therefore required, and you should be familiar with the important commands. The first step involves creating a suitable environment for constructing the package.
Preparation
Ubuntu currently uses the same package manager as is used in Debian, dpkg
, so when I talk about "Debian packages," I am referring to archives for this kind of software management and not those that have been compiled for the Debian distribution.
The option to build and compile packages for Dpkg directly on the system already exists, although it is frowned on for several reasons – the main being that the required development environment is often missing, and Ubuntu desktop installations do not usually include any developer packages. The compiler (GCC or G++) and the development files for the libraries on the system are thus missing.
It might be possible to install all required packages later, but they would bloat the installation, and it would be more difficult to remove the installed software when you're done: Even the build-essential meta-package involves a good dozen packages as dependencies. Debootstrap is the better alternative: Using this tool you can create a virtual base installation of Ubuntu in the blink of an eye, which you can then access using the chroot
command. Forget the tricks and gimmicks needed for bootloaders, because a simple environment does not act as a bootable system for the construction of packages.
Debootstrap creates a complete installation of a base system within a folder. To start, install the debootstrap package on an Ubuntu system – you can install the software either via the package manager in the graphical interface or at the command line – and then create a folder for building the packages. Next, create the environment according to the following format:
debootstrap <path> <suite>
Replace <suite>
with the code name for the desired Ubuntu version. For example, if you want to create the package for version Ubuntu 15.04, the appropriate value would be vivid
. If you want Debootstrap to use a local mirror rather than the default mirror, specify this by suffixing /ubuntu
as the last parameter:
$ debootstrap vivid-chroot vivid \ http://en.archive.ubuntu.com/ubuntu/ $ chroot vivid-chroot # locale-gen <locale> # apt-get install build-essential \ devscripts fakeroot
Doing so will install the required packages in the vivid-chroot
folder. Depending on your Internet connection, downloading the required packages could take a while.
The second line accesses the virtual Ubuntu system for the first time, and the next line adapts it to suit your needs. In fact, up to now you've only had a basic system with all the goodies missing. Therefore, the third command generates the locales, which can save some error messages if you don't speak American English (locale -a
lists available locales), and the final command then sets up the developer packages you need within the virtual environment.
An editor for the command line is still missing: The Nano or Vim package provides this function. Installing Wget also ensures that you can download files from the command line. Your setup now provides the basic functions for building packages. The next step is to download the Ubuntu package sources on which you want to base the new package version.
Loading Old Sources
Developers have often created program packages that are not yet officially available in a package manager; however, they don't usually keep up with new versions for current distributions.
The backup program Kup [2] provides a perfect example: Kup has no packages for Ubuntu 15.04. The new version 0.6.0 is not packaged for Ubuntu, so you'll only find the old v0.5.1 from Ubuntu 14.10 on offer.
What looks like a dead end at first glance is really an opportunity: You can simply use the old packages from Ubuntu 4.10 as a basis for the new packages. The challenge is that you need to find the sources for the old packages.
The author, Simon Persson, supplies his software via KDE-look.org [3], which has a link to the project on the openSUSE Build Service [4]. This service also produces Debian packages on request, and I have used this option on many occasions.
At the time I was building a new Kup package, the table to the right on the Build Service page had xUbuntu_15.04 labeled as unresolvable, rather than the more desired succeeded; this informs you that Ubuntu 15.04 has no packages for the current version of the program.
Note, however, that Ubuntu 14.10 is labeled succeeded. If you click on the name of the distribution, you find the link Go to download repository – click this to get to the directory with the source files. Three files on this page form the basis for the Debian packages you will find in the amd64
and i386
folders also listed:
kup_0.5.1-1.diff.gz
kup_0.5.1-1.dsc
kup_0.5.1.orig.tar.gz
You need these three files so you can extract the sources and generate, together with the Debian changes, packages for version 0.6.0. Download the packages to the virtual chroot environment using wget
and then extract the sources (Listing 1), which you will find in the ./kup-0.5.1/
folder.
Listing 1
Getting the Package Sources
You can get (wget
) the sources for version 0.6.0 online [5]. Make sure to save the archive under the correct name straightaway; otherwise, dpkg-buildpackage
will not be able to find it. The correct name is kup_0.6.0.orig.tar.gz
. Enter
tar xvfz kup_0.6.0.orig.tar.gz
to extract the tarball. Finally, rename the newly created folder kup-0.6.0/
.
Differences
The folder with the extracted Kup 0.5.1 Debian package differs from that for the Kup 0.6.0 sources by the presence of a debian/
folder, in which resides all the files with the rules for creating a Debian package. For logical reasons, copy this folder from the kup-0.5.1
directory into the kup-0.6.0
directory.
Now create a new entry in the changelog. Each Debian package has a file in which the most important changes are noted. You will find the changelog in the file debian/changelog
. However, it is often a struggle to create the entry manually, especially because the log's syntax is not immediately obvious to everybody and the default syntax is strict. Instead, use the dch
tool, which does most of the work for you. The tool derives the important values, such as your name and email address, from environment variables:
export DEBEMAIL="<Email address>" export DEBFULLNAME="<First name surname>" export EDITOR=nano
The above also sets the EDITOR
variable to the desired value (Nano is the default in Ubuntu) to ensure the program uses your editor of choice.
Once these variables have been set, the dch -i
command causes the tool to create a new entry in debian/changelog
with the correct email and name values; then, the file opens in the editor specified (Figure 1).

Correct the version number in the top line in parentheses – in the example, the new entry is 0.6.0-1 – and change UNRELEASED to vivid. This way, Launchpad knows the package is designed for Ubuntu version 15.04, and it builds appropriately for this platform. Use a brief description as the changelog entry – the example in Figure 1 is a reference to the new program version.
The steps completed so far always remain the same and are usually enough to package a new version of a program. The work then only involves
1. »Copying the debian
folder into the unzipped source code of the new version
2. Making a changelog entry
3. Building a Debian source package with the dpkg-buildpackage
tool
4. Uploading to the DEB package to the Launchpad auto-build.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Direct Download
Read full article as PDF:
Price $2.95
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
News
-
Mageia 9 Beta 2 is Ready for Testing
The latest beta of the popular Mageia distribution now includes the latest kernel and plenty of updated applications.
-
KDE Plasma 6 Looks to Bring Basic HDR Support
The KWin piece of KDE Plasma now has HDR support and color management geared for the 6.0 release.
-
Bodhi Linux 7.0 Beta Ready for Testing
The latest iteration of the Bohdi Linux distribution is now available for those who want to experience what's in store and for testing purposes.
-
Changes Coming to Ubuntu PPA Usage
The way you manage Personal Package Archives will be changing with the release of Ubuntu 23.10.
-
AlmaLinux 9.2 Now Available for Download
AlmaLinux has been released and provides a free alternative to upstream Red Hat Enterprise Linux.
-
An Immutable Version of Fedora Is Under Consideration
For anyone who's a fan of using immutable versions of Linux, the Fedora team is currently considering adding a new spin called Fedora Onyx.
-
New Release of Br OS Includes ChatGPT Integration
Br OS 23.04 is now available and is geared specifically toward web content creation.
-
Command-Line Only Peropesis 2.1 Available Now
The latest iteration of Peropesis has been released with plenty of updates and introduces new software development tools.
-
TUXEDO Computers Announces InfinityBook Pro 14
With the new generation of their popular InfinityBook Pro 14, TUXEDO upgrades its ultra-mobile, powerful business laptop with some impressive specs.
-
Linux Kernel 6.3 Release Includes Interesting Features
Although it's not a Long Term Release candidate, Linux 6.3 includes features that will benefit end users.