1

I need to create a Debian package. Easy with dpkg, works great. But for reasons beyond my control, I must switch to a RHEL5 environment for my build, so dpkg is not available.

What's my best attack strategy here? These are my thoughts:

  • Idea: Grab dpkg binaries and include in source. Problem: I don't really know what that entails.
  • Idea: Find a proper tool for creating a .deb on other distros. Problem: No success searching for that.
  • Idea: Build it up and tarball it by hand. (Reinvent dpkg) Problem: laborious, error prone, brittle, redundant

TLDR Best Answer below: Build in a Docker Container. Thanks, Giacomo.

1 Answers1

0

It depends on what you are doing.

If you are building an "binary" package (binary as architecture specific), you need an environment like the target one (e.g. libraries, etc.). But if you are building an architecture independent package, this may be easier (e.g. a Python library made just by Python code or other interpreters).

In any case, if you cannot test it (and doing correct automatic testing), the output need to be considered trash. Do no distribute it.

As Debian Developer, we build packages in a clean environment, either as virtual machine/docker or a chroot environment (but so with all base packages). This really help on finding the correct dependencies, but also to do install/deinstall test (with piuparts), etc. And this was done already 10 years ago, so now it is much easier. Just install a minimal docker image to build Debian package, and use it. Then install an other (more standard) and test your package on "real" Debian environment. Debian packaging documentation should have information on that (see e.g. https://wiki.debian.org/PackagingWithDocker , just you should change the first part: installing docker on RH, but this should be trivial: docker is the same on RH or Debian (or also on Windows or Mac, but here one may not have bash shell, so also how to call docker may change)).

If you never built a .deb, you must have at minimum an environment. Packaging operation may be tedious (many sources code doesn't allow to install binaries on a custom directory).

Note: on older time, one may do a mix between your second and third solution. You may build packages manually (they are just ar files, RH instead use cpio archive format), but also the main tools of Debian are scripts (mainly Perl). You should just find few other tools (e.g. fakeroot, which you may already find as binary, or you should build it). And in any case, it is not so complex building such tools from sources (they are not the huge "modern" packages, they are just very small tools with few dependencies).

Giacomo Catenazzi
  • 8,519
  • 2
  • 24
  • 32
  • Accepted for the abridged answer: "Build in a docker container". Though in my case, no binaries are being built on the server. It is literally only the deb archive that needs to be constructed. All binaries are built in a Debian environment. But since my setup is bizarre (I'm not in a position to change it), I accept this as a better general answer. But even in my case, running a proper dpkg distribution in the container is the best way to do this. – Ormly Rucket Jul 29 '21 at 16:09
  • Note: in such case, you can copy and use dpkg (and dpkg-buildpackage). I think they are still just few perl scripts. – Giacomo Catenazzi Jul 29 '21 at 16:52