Change Deb Dependencies

How to change the dependencies of deb packages

1. Unpack the package

Ref: https://unix.stackexchange.com/questions/138188/easily-unpack-deb-edit-postinst-and-repack-deb

Create a new directory (e.g., tmp) alongside the deb package:

mkdir tmp

Extract the deb package into the new directory:

sudo dpkg-deb -R original.deb tmp

2. Edit the dependencies

Ref: https://coderwall.com/p/hes3ha/change-the-dependencies-of-a-deb-package

Navigate to tmp/DEBIAN/ and edit the file named control using a text editor

3. Repack the package

Ref: https://unix.stackexchange.com/questions/138188/easily-unpack-deb-edit-postinst-and-repack-deb

Pack tmp back to a deb package by running the following:

sudo dpkg-deb -b tmp fixed.deb

Change the owner of the new deb package:

Ref: https://docs.oracle.com/cd/E19683-01/816-4883/6mb2joat0/index.html

sudo chown new-owner fixed.deb	

Additional notes

As per the references, it is possible to avoid the new directory and deb package being owned by the root user by running the whole sequence (steps 1 through 3) under fakeroot.

Another possible approach is to take advantage of the fact that deb packages are in the standard format of ar archives and extract/pack the package using ar instead of dpkg-deb.

Content Licensed under CC BY-SA 4.0. Code licensed under the MIT License.