I am trying to install an apt package without one of its dependencies (specifically, git without Perl to reduce Docker image size by >50MB).
I can think of two options:
- installing the package without this specific dependency
- installing the package with all dependencies and removing the dependency
and I investigated them both, and none of them worked. So my question is: is there a clean way to do it?
Below is what I tried so far.
1. Installing the package without this specific dependency
Most suggestions recommend
apt download git
dpkg --ignore-depends=perl -i git*.deb
Unfortunately this does not install other dependencies, so
git clone fails due to the lack of
So in order to fix that, some other suggestions recommend using
apt-get -f install
afterwards, but this command tries to install Perl, which is what I am trying to avoid.
Ok, so I am telling to not touch Perl with:
apt-mark hold perl
apt-get -f install tries to remove git.
Ok, so the I am telling to leave git alone:
apt-mark hold git
apt-get -f install gives up, as it cannot install Perl and it cannot uninstall git. The end of story.
2. installing the package with all dependencies and removing the dependency
I installed git with Perl:
apt install -y git
then removed Perl with
dpkg -P --force-depends perl
but this does not remove other dependencies that have been brought by Perl eg. perl-modules. So the attempt is unsuccessful.