App packaging on Linux
I gave a talk at this month’s Sydney Linux User Group meetup. There is a meeting on the last Friday of every month. It is a great way to meet fellow enthusiasts and learn something new. Join us next time if you are in the neighbourhood.
My talk was about application packaging in Linux. My goal before the talk was basically to figure what a deb package contained. I have never bothered to do this before, in spite of using Linux for a very long time.
I took a simple Go program and walked through compiling, packaging, installing, and finally looking in the deb file. As with any magic trick, once you know it, it seems obvious.
The crux of building the package can be seen in the Makefile
- In some sort of a build directory, create a sub-directory path
/usr/binand copy the binary there. - In the same build directory, create a sub-directry DEBIAN and create a
controlfile. This is nothing but a text file, with some metadata related to the package. This will be used during installation. - Use
dpkg-debto package this up in to a deb file
To look inside the package
ar x package-name.debto “unarchive” the package, revealing two compressed tar filescontrol.tar.zstanddata.tar.zst, which on extraction reveals the original files which we packaged up earlier
This glosses over a lot of things like signing the package or actually distributing it. But I think it makes clear what is in a package.
Go binaries being statically linked by default, made building the package very easy. It also enables compiling the code for multiple architectures without having to install any cross-compilers. The code and slides I used are here
I wrote the slides in markdown, using marp to present them. I’m still figuring out the best way to combine images and text on a slide. Other that it was easy to use and being text based, I could just use vim as my editor. 🎉