Sometimes you need a quick change to an existing .deb package’s dependencies.
For instance, I have downloaded the community edition of
Odoo version 19 for Debian/Ubuntu, and one of its
dependencies is python3-pypdf2. Unfortunately, that package does not exist
on Debian/testing at the time of writing (it did on Debian bookworm),
but the package python3-pypdf does.
What’s more, the upstream author of PyPDF has
confirmed
that pypdf (in lowercase) is in fact a newer release over PyPDF2.
It’s confusing, but at least it’s clarified.
Ideally the Debian package should have a virtual package name to transition
nicely or implement “Provides” or “Replaces”, but that’s a different topic.
TL;DR I want to change the package dependency from python3-pypdf2 to python3-pypdf
in Odoo’s .deb package.
Unpacking the .deb file #
We want to extract the package, including those files that include the
installation steps with the dependencies. For this we need the -R
or --raw-extract parameter in dpkg-deb. In this example, my .deb
package file is called odoo_19.0.20251014_all.deb and I add _custom
at the end of the name (without .deb extension) as destination directory
where my files will be extracted.
As a regular user, I execute:
dpkg-deb --raw-extract odoo_19.0.20251014_all.deb odoo_19.0.20251014_all_custom
Modifying the control file #
The installation logic is contained in files under the DEBIAN/ folder.
More specifically, the dependencies are defined in DEBIAN/control.
I want to search for “python3-pypdf2” and then just remove the “2” at the end.
With Perl I can change the content of that file directly with the -i parameter.
In Perl regular expressions, whatever I put in parentheses in the search query
can be recycled in the replacement query as $1 (or \1 but that has been
deprecated).
perl -pi -e 's/(python3-pypdf)2/$1/' odoo_19.0.20251014_all_custom/DEBIAN/control
Repackaging #
It’s time to repackage the content of the custom folder into a new, custom
.deb file.
dpkg-deb -b odoo_19.0.20251014_all_custom odoo_19.0.20251014_all_custom.deb
To make sure we have made the correct change, let’s check the “Depends” field of the control file within the package directly.
dpkg-deb -f odoo_19.0.20251014_all_custom.deb Depends | grep --colour=yes python3-pypdf
Installation #
And finally, it is time to install the package with elevated permissions.
sudo dpkg -i odoo_19.0.20251014_all_custom.deb