Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 416907

Summary: sys-apps/portage: emerge option to remove package and its dependencies (equivalent to emerge --deselect <packages> && emerge --depclean, but only remove specified <packages> and their dependencies which are no longer needed)
Product: Portage Development Reporter: Phil Stracchino (Unix Ronin) <phils>
Component: Core - Interface (emerge)Assignee: Portage team <dev-portage>
Status: CONFIRMED ---    
Severity: enhancement CC: dbarrett, esigra, gerion.entrup, kingjon3377, roothorick, sam
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=787755
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 155723    

Description Phil Stracchino (Unix Ronin) 2012-05-21 13:00:05 UTC
The emerge -C option removes a single package, but does not clean up its dependencies.  The --depclean option does a global dependency cleanup that usually wants to remove more than you intended.  It would be useful to have a less broad option in between -C and --edepclean that could be used along with -C to remove a specified package or packages, plus recursively remove orphaned dependencies of the listed package(s) upon which no other installed package depends.  I might suggest --remove-orphaned-deps as a good descriptive name.

Reproducible: Always
Comment 1 Michael Weber (RETIRED) gentoo-dev 2012-05-22 06:48:26 UTC
I see the point, iff your system is not completely up to date (emerge -avuND world ; emerge -a --depclean ; revdep-rebuild --ignore -- av ).

In all other cases 

emerge -a --deselect <atom>
emerge -a --depclean 

should do the trick.
Comment 2 Phil Stracchino (Unix Ronin) 2012-05-24 13:10:26 UTC
Actually, the use case I have in mind is less "not fully up-to-date system" than the case of a system with some packages locally built from source (or installed from non-Gentoo packages) outside of portage, but for which dependencies were installed from portage.  emerge --depclean sees those as orphan packages, because it doesn't know they're dependencies for something installed outside portage.  So then, if I remove a Gentoo package I'm no longer using, I may want to remove its orphaned dependencies, but *only* its orphaned dependencies, without scanning the entire system for installed packages that have no listed dependencies within portage.

My system, for example, has a lengthy list of Perl packages installed for either my own code or for non-Gentoo Perl programs, which it wants to remove on a depclean.  So what I wind up doing is running emerge --depclean -p, then selecting out of that list the packages I know I'm not using and removing them with emerge -C.
Comment 3 Zac Medico gentoo-dev 2012-05-24 18:46:51 UTC
(In reply to comment #2)
> My system, for example, has a lengthy list of Perl packages installed for
> either my own code or for non-Gentoo Perl programs, which it wants to remove
> on a depclean.  So what I wind up doing is running emerge --depclean -p,
> then selecting out of that list the packages I know I'm not using and
> removing them with emerge -C.

You should do one of the following:

1) Add the wanted packages to your world file with `emerge --noreplace atom`.

2) Create an ebuild (in an overlay) that does nothing more that pull in the wanted packages in RDEPEND, install it, and add it to your world file.
Comment 4 Phil Stracchino (Unix Ronin) 2012-05-25 12:04:21 UTC
Actually, my game plan is to make proper ebuilds for the leaf-node applications...
Comment 5 Joakim Tjernlund 2013-12-09 17:27:56 UTC
I was just about to file my own bug requesting the same when I found this one :)
Using --depclean isn't that easy in all cases as it requires the tree be in sync with your installed pkgs which isn't always easy to do.

An embedded system may not have the space needed to first emerge all new pkgs
the cleanout old stuff.
Comment 6 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-03-05 03:03:50 UTC Comment hidden (obsolete)
Comment 7 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-03-05 03:04:11 UTC
*** Bug 591960 has been marked as a duplicate of this bug. ***
Comment 8 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-03-05 03:04:34 UTC
*** Bug 336889 has been marked as a duplicate of this bug. ***
Comment 9 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-10-04 11:19:53 UTC
*** Bug 915149 has been marked as a duplicate of this bug. ***