How to remove a package on a debian-based system WITHOUT removing dependencies?

I’m running Linux Mint, a Debian-based distro, and I want to remove a package WITHOUT removing its reverse dependencies; or I want to target the removal of one package without removing anything else.

For example:
I want to remove PACKAGE_A, but (PACKAGE_X, PACKAGE_Y, PACKAGE_Z) depend on PACKAGE_A and would be automatically removed. I need to keep X,Y,Z installed and only remove A. Unfortunately, if I were to reinstall X,Y,Z it would also reinstall PACKAGE_A.

For the particular package I’d like to remove, there are about 20 dependencies and some dependencies appear to be critical to proper GUI functionality.

On Arch Linux, the pacman documentation says:

To remove a package, which is required by another package, without removing the dependent package:

pacman -Rdd package_name

Since my Debian-based distro doesn’t use pacman, how can I achieve the same functionality with apt-get, Aptitude, or the Mint Software Manager?

EDIT: Faheem Mitha’s answer was exactly what I was looking for.

dpkg -r –force-depends foo

That removed the package in question without removing the dependencies apt-get and the Mint Software Manager complained about. Thank you!

Asked By: CauselessEffect

||

If I understand you correctly, you want to remove a package that other packages depend on, without removing those other packages as well. Bearing in mind this might not be a good idea, you can do this with.

dpkg -r --force-depends foo

for removal of a package (conf files are not removed).

dpkg -P --force-depends foo

for purge of a package (conf files are removed).

Example usage:

root@orwell:/home/faheem# dpkg -P --force-depends gcc-4.6-base:amd64
dpkg: gcc-4.6-base:amd64: dependency problems, but removing anyway as you requested:
 gcc-4.6 depends on gcc-4.6-base (= 4.6.3-14).
 libstdc++6-4.6-dev depends on gcc-4.6-base (= 4.6.3-14).
 g++-4.6 depends on gcc-4.6-base (= 4.6.3-14).
 cpp-4.6 depends on gcc-4.6-base (= 4.6.3-14).

(Reading database ... 454279 files and directories currently installed.)
Removing gcc-4.6-base:amd64 ...
Processing triggers for ccache ...
Updating symlinks in /usr/lib/ccache ...

It is occasionally useful to perform such an action. Of course, leaving the system in this broken/inconsistent state for any length of time is highly undesirable. However, given a chance, apt will restore balance to its universe as follows:

root@orwell:/home/faheem# apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  libavdevice53 libavfilter2 libglade2-dev python-cairo-dbg python-cairo-dev python-gnupginterface python-gobject-2-dev
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  gcc-4.6-base
The following NEW packages will be installed:
  gcc-4.6-base
0 upgraded, 1 newly installed, 0 to remove and 62 not upgraded.
Need to get 142 kB of archives.
After this operation, 159 kB of additional disk space will be used.
Do you want to continue [Y/n]? 
Get:1 http://debian.lcs.mit.edu/debian/ wheezy/main gcc-4.6-base amd64 4.6.3-14 [142 kB]
Fetched 142 kB in 7s (19.1 kB/s)                   
Selecting previously unselected package gcc-4.6-base:amd64.
(Reading database ... 454274 files and directories currently installed.)
Unpacking gcc-4.6-base:amd64 (from .../gcc-4.6-base_4.6.3-14_amd64.deb) ...
Processing triggers for ccache ...
Updating symlinks in /usr/lib/ccache ...
Setting up gcc-4.6-base:amd64 (4.6.3-14) ...
Answered By: Faheem Mitha