Ubuntu – How to manually assemble the own package “the hard way”

debpackaging

I would like to know how to create my own .deb packages from the source of a program without the aid of a package manager or any other similar tool (in other words, doing it manually). How difficult is this? Do I need to create my own repository for this to work? Do I need to sign it with my public key or something? Will one deb package work for all Debian-based distributions, or do I need to build a separate version for each flavor?

Edit: I would like to point out the main difference between my question and "Simplest Debian Packaging Guide?", which is that, while the asker of that question wishes to create a package with minimal time and effort, I want to go the long way around, not for the sake of making it harder, but because I want to understand how the packaging system works. In short, I want to learn.

Best Answer

How difficult is this?

Not so difficult at all. I do all my packaging from scratch. Once you know a few tools, and understand what's going on, the process is fairly simple. Be prepared to spend some time, learning the processes, though.

Do I need to create my own repository for this to work?

A repository (such as a PPA) is for publishing your package to the wider world. So, yes, if you want people to be able to install the package, either you need to get it included in Debian/Ubuntu, or you need to publish it in a repository.

PPAs also have access to the Launchpad build farm, so they can build binary packages from source packages. But you can do this locally, too. And while packaging something, you really want to be test-building locally, rather than waiting for LP to build your package (the LP build queues can be hours long).

Do I need to sign it with my public key or something?

If you want to upload to a PPA, you need to sign your source package with your private key.

Will one deb package work for all Debian-based distributions, or do I need to build a separate version for each flavour?

The safe answer is no. But sometimes it's fairly straightforward to produce once deb that will work on all current Debian and Ubuntu releases. It depends on the package and the toolchain you used.

I suggest: