Ξ

How to create a debian package from scratch

Published on 2019-05-02 code linux

The process of creating a debian package is, admittedly, tedious. However, that statement only applies if your goal is to create a real debian package that passes all lintian checks and could be included in the official repositories. If you just want to use the package for yourself, the process is not actually that hard.

Why should I create a debian package?

If you are using debian or any of its derivatives such as ubuntu or mint, you typically install software on your system as debian packages using the apt command line tool.

This is great, as it allows you to install, remove, and update all software from a central place. Compare that to your classical windows desktop where at least 5 tools will prompt you to update them individually directly after startup. But this also means that you cannot easily install software that is not packaged for your distribution.

Of course, you can install most software using the classic make && make install, but that leaves you with unmanaged files scattered across your file system as well as manually installed dependencies. You will have to clean all that up manually if you ever want to get rid of the software again.

A much cleaner approach is to create a debian package. That way your system knows about both the files and dependencies and can remove them automatically. As an added benefit, you get an automatic update if your distribution starts packaging the software.

The joy of meta-packages

A special kind of package you may want to create are meta-packages. A meta-package is one that only defines dependencies and contains no files of its own.

I use this extensively to install groups of packages. For example, I have a package called xi-desktop which depends on all the packages I usually use for my desktop. On a new system, I can simply install this single package and everything else gets installed automatically. That way, the list of manually installed packages stays short and concise. Meta-packages are also great to manage build-dependencies for other packages.

How to create a package

So here is the tutorial:

Simple as that.

You can install the package using sudo dpkg -i {package}. This will not install the dependencies though. For that, simply run sudo apt install -f afterwards.

Taking the next step

Now that you have a simple package, there are some things you could look into to improve it:

Conclusion

Creating debian packages is not so hard after all. It may not be as refined as the PKGBUILD system in arch, but it is not as bad by far as people may tell you.