5

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!

closed as unclear what you're asking by Braiam, jimmij, Celada, jasonwryan, slm Feb 5 '15 at 2:44

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Do you mean that you want to remove package P but not the packages that depend on P, or to remove package P but not the packages that P depends on? – Gilles Feb 4 '15 at 23:43
  • 3
    This question is not clearly written. If could mean I want to remove package P without removing the dependencies of P, or remove P with removing the packages that depend on P. The former is trivial, so I assume you mean the latter. – Faheem Mitha Feb 4 '15 at 23:49
  • Re: edit comment "This community is so damn picky, I've been as clear as I can be. Downv": No. While I understand that you got the answer you were looking for, you really didn't substantially clarify that you are talking about things that depend on the package in question rather than dependencies, which are things that the package in question depends upon. Voting to leave closed. – Celada Feb 5 '15 at 6:31
  • 1
    Editing in the accepted answer is duplication of information and a waste of bandwidth. Thanks have no place on SE either. Hence I voted not to reopen. Please read the help page, especially the part about no chit-chat, just questions (and answers). – Anthon Feb 5 '15 at 7:05
12

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) ...

Not the answer you're looking for? Browse other questions tagged or ask your own question.