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:
TLDR Best Answer below: Build in a Docker Container. Thanks, Giacomo.
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).