Re-Packaging Debian Packages
Introduction
There are times when the metadata on a Debian package needs to be modified to allow a package to be installed. For example, several QNAP packages require Ubuntu 18.04. The way this is implemented in the package is by a preinst script that parses the version. To allow installation on a Debian system only the preinst script needs to be modified. This document describes a process for updating package metadata without otherwise modifying the package contents.
Re-Packaging
Optain a copy of the raw Debian package file, i.e. the .deb.
Create a work directory and cd into it.
$ mkdir tmp $ cd tmpList the archive contents of the package to obtain the name of the control tar ball. This name changes depending on the compression used.
$ ar t ../QNAPQfinderProUbuntux64-7.9.0.0627.deb debian-binary control.tar.xz data.tar.xzExtract the control files for editing.
$ ar p ../QNAPQfinderProUbuntux64-7.9.0.0627.deb control.tar.xz | tar -x --xzEdit the metadata files as required. It makes sense to update the version as well as any files by adding ~1 to the version number. Adding ~1 treats the modification as a backport.
Tar the control files and replace the files in a new copy of the .deb file. Note, the new .deb file should follow the Debian Policy format, i.e. package-nameversionarch.deb.
$ cp ../QNAPQfinderProUbuntux64-7.9.0.0627.deb ../QNAPQfinderProUbuntux64-7.9.0.0627~1.deb $ tar --xz -cf control.tar.xz *[!z] $ ar r ../QNAPQfinderProUbuntux64-7.9.0.0627~1.deb control.tar.xz
The package QNAPQfinderProUbuntux64-7.9.0.0627~1.deb is ready to be installed using dpkg.