bii internals: Automating DEB pkg generation

To continue with our series about packaging and distributing biicode, today we are talking about deb packages generation. Even though deb packages are broadly documented, sometimes a concrete example is more helpful.

To create a debian package we need to create a folder called DEBIAN. In that folder we will place our program files, recreating the structure we want in the client’s machines. This means that if we want biicode installed inside /usr/lib/biicode then we place biicode inside DEBIAN/usr/lib/biicode. Following the same schema, copyright file should be placed in DEBIAN/usr/share/doc/biicode/copyright. Along with these contents we should also place the control file and the scripts needed to finish installation or removal process. In this case we need postinst and prerm, that will run with sudo permissions.

To sum up this is how our DEBIAN directory should look like:

You can read control file documentation at debian’s page, our control file looks like this:

In the postinstallation step we just create a symlink in the PATH:

Which is removed in the pre-remove step:

We also have a small bash script to set the permissions, calculate md5sum and creates the package.
Md5sum contains a list of MD5 checksums for all files contained within the package so they can be verified when they are extracted to the client’s machine:

Finally everything is wired up with a python script that grabs cythonized, pyinstalled biicode, creates the folder structure and invokes mentioned bash script:

Have you tried to package your own installer now? We hope you have!

Did you miss how to package an app for other OS?

Happy hacking!

Stay tuned


Related Posts