Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 2938 - unmerge should have a reverse dependency safety check
Summary: unmerge should have a reverse dependency safety check
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
: 4227 10740 32303 43902 51412 97946 100379 154160 (view as bug list)
Depends on:
Blocks: 155723 181949
  Show dependency tree
 
Reported: 2002-05-22 18:42 UTC by Dan Lund
Modified: 2011-10-30 22:37 UTC (History)
20 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Unified diff against 2.0.51_pre20 (emerge-unmerge-rdep-v5.diff,10.27 KB, patch)
2004-08-17 08:08 UTC, Stephen Bennett (RETIRED)
Details | Diff
Implements revdeps in vardbapi (rdep2-v1.diff,3.13 KB, patch)
2004-09-15 15:44 UTC, Stephen Bennett (RETIRED)
Details | Diff
allow --depclean accept atoms and act like a safe version of --unmerge (depclean.patch,8.66 KB, patch)
2007-07-21 05:12 UTC, Zac Medico
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Lund 2002-05-22 18:42:04 UTC
I believe including a dependency ability into portage (at least using a switch 
if you really want it) would be nice.  If you remove a component, and you want 
to know if it is needed by anything, then portage could tell you.
Comment 1 Dan Lund 2002-05-22 18:49:15 UTC
 As it stands right now, you can remove a major component of a working item 
and render it destroyed without even realizing it. 
Comment 2 Dan Lund 2002-07-22 23:54:01 UTC
Changing to normal priority considering the alternatives that have become
available via the forum.
Comment 3 Jeff Shipman 2002-10-08 17:50:26 UTC
Is it possible someone could round up all of the suggestions from the forum and
post them as a sticky item in the Newbies or Portage forum? Then, the FAQ could
point to it because this is a feature I'd really like to see, but I'm fine with
using scripts for now. I think Newbies would like a really easy place to find
them, though.

Thanks.
Comment 4 Jeroen Versteeg 2002-11-21 14:09:26 UTC
Suggestion: implement reverse dependency tracking using reference counts:
every package has a reference counter indicating how many packages that depend
on it are installed. Whenever reference count for a package is 0, it will be
automatically removed.
Maybe extra feature: at the end of the "dependency chain" the reference count is
inherently always 0, which means that end-user applications will always be
automatically removed. To avoid this, we could have a flag indicating that it is
an end user app. 
Comment 5 SpanKY gentoo-dev 2003-01-08 12:37:08 UTC
*** Bug 4227 has been marked as a duplicate of this bug. ***
Comment 6 SpanKY gentoo-dev 2003-01-08 13:59:42 UTC
*** Bug 10740 has been marked as a duplicate of this bug. ***
Comment 7 hydralisk 2003-06-19 13:37:29 UTC
Implementation suggestion: add a new command to emerge called 
"depunmerge." The user would type "emerge depunmerge 
<package>" to unmerge with dependencies. Portage would simulate 
the removal of the package (temporarily remove it from the 
package database) and then look at each package and see if it 
has missing dependencies. If it's dependencies are not there, then 
this package must be removed as well. If more packages are removed, 
portage does another loop to see if more packages will have missing 
dependencies because of these new removals, and so on until there 
are no more missing dependencies. 
 
This is just a suggestion, of course. 
Comment 8 SpanKY gentoo-dev 2003-09-09 05:33:35 UTC
qpkg provides -q ...
  -q,  --query-deps     display all installed packages 
                        depending on selected packages
Comment 9 hydralisk 2003-09-10 14:08:51 UTC
The dependency ability of qpkg -q is not sufficient, mostly because it is not recursive. For example:

$ qpkg -I -q python-2.2.3-r1
dev-lang/python-2.2.3-r1 *
DEPENDED ON BY:
        app-portage/gentoolkit-0.1.30
        dev-libs/libxml2-2.5.8
        dev-libs/libxslt-1.0.31
        gnome-base/libglade-2.0.1
        sys-apps/portage-2.0.49-r3

$ qpkg -I -q libxml2-2.5.8
dev-libs/libxml2-2.5.8 *
DEPENDED ON BY:
        app-office/abiword-1.0.6-r1
        app-office/abiword-1.99.5
        app-text/docbook-xml-dtd-4.1.2-r4
        app-text/docbook-xsl-stylesheets-1.60.1
        app-text/scrollkeeper-0.3.11-r1
        dev-libs/libxslt-1.0.31
        gnome-base/bonobo-activation-2.2.4
        gnome-base/control-center-2.2.2
        gnome-base/eel-2.2.4
        gnome-base/gconf-2.2.1
        gnome-base/gdm-2.4.1.6
        gnome-base/gnome-vfs-2.2.5
        gnome-base/libbonoboui-2.2.4
        gnome-base/libglade-2.0.1
        gnome-base/libgnome-2.2.3
        gnome-base/libgnomeprint-2.2.1.3
        gnome-base/librsvg-2.2.5
        gnome-base/nautilus-2.2.4
        gnome-extra/bug-buddy-2.2.106
        gnome-extra/gal-1.99.8
        gnome-extra/gnome-media-2.2.2
        gnome-extra/libgsf-1.8.1
        gnome-extra/libgtkhtml-2.2.3
        gnome-extra/libgtkhtml-3.0.7
        media-libs/gstreamer-0.6.2
        media-libs/libwmf-0.2.8
        net-mail/evolution-1.4.3
        net-print/foomatic-db-20030716
        net-print/foomatic-db-engine-3.0.0
        net-www/galeon-1.3.7
        x11-misc/xscreensaver-4.10

As you can see, all the packages in the second listing should have also been in the first, because they indirectly depend on python (they depend on libxml2, which depends on python).

In addition, can this functionality be included in emerge --unmerge?
Comment 10 Brian Harring gentoo-dev 2004-08-10 22:43:33 UTC
*** Bug 32303 has been marked as a duplicate of this bug. ***
Comment 11 Stephen Bennett (RETIRED) gentoo-dev 2004-08-17 06:04:20 UTC
Is there still interest in getting this functionality? I've been working on a patch to do this; see http://forums.gentoo.org/viewtopic.php?t=210288 for info (check down for the latest version of the patch). It seems to be working properly in most cases now, and I'd appreciate feedback. ;)
Comment 12 Jason Stubbs (RETIRED) gentoo-dev 2004-08-17 07:27:24 UTC
Can you attach a unified diff here please? There is still interest. It's on my TODO list. ;)
Comment 13 Stephen Bennett (RETIRED) gentoo-dev 2004-08-17 08:08:01 UTC
Created attachment 37600 [details, diff]
Unified diff against 2.0.51_pre20

As requested.
Comment 14 Stephen Bennett (RETIRED) gentoo-dev 2004-09-15 15:44:36 UTC
Created attachment 39666 [details, diff]
Implements revdeps in vardbapi

Adds a revdeps() method to portage.vardbapi; carpaski suggested this was a
better way to do things.
Comment 15 Henrik Sankala 2004-12-09 03:41:59 UTC
I think something that works in the other direction too would be usefull, something like emerge unmerge --deep <package> that would unmerge all unneded dependencies of the package we are unmerging. This would make unmerging monsters like Gnome that install 100+ dependencies much smoother.
Comment 16 Mathieu Jobin 2004-12-11 18:12:51 UTC
I also like to be able to list package that are not dependencies of anything else.

these packages should be end program and the list should be <= world

good way to clean up what you dont need.
Comment 17 Chris L. Mason 2004-12-11 18:29:48 UTC
Yeah, basically a gentoo version of deborphan.  That would be nice.

Of course, it should also show unused libs, not just apps.
Comment 18 Jason Stubbs (RETIRED) gentoo-dev 2005-07-17 19:43:28 UTC
*** Bug 97946 has been marked as a duplicate of this bug. ***
Comment 19 Alec Warner archtester Gentoo Infrastructure gentoo-dev Security 2005-08-06 09:26:06 UTC
*** Bug 100379 has been marked as a duplicate of this bug. ***
Comment 20 Alec Warner archtester Gentoo Infrastructure gentoo-dev Security 2005-08-06 09:44:20 UTC
*** Bug 43902 has been marked as a duplicate of this bug. ***
Comment 21 Benjamin Schulz 2005-08-06 14:20:19 UTC
Portage of the actual version also has a problem with updates that is dependend
from such a "package-dependency" function.

Imagine: 
you emerged kde. Kde is in the world file now.
And kde needs a component. You later unmerge kde because you don't need it
anymore, but the component installed with, is not unmerged. This is right for
you, since you want to use this component sometimes.

But this component was installed as a dependency, it is not in the world file
and does not get updated with emerge -uD world.

This behaviour is described, for example, in the last post of bug 100527 which,
of course, is related to other update problems.

I wonder how much gentoo users out there have a pretty old system and do not
know it.

If portage would have more information about packaged installed, such
misbehaviour could be cured.
Comment 22 Jason Stubbs (RETIRED) gentoo-dev 2005-10-07 09:20:53 UTC
*** Bug 51412 has been marked as a duplicate of this bug. ***
Comment 23 F mayer 2005-11-03 10:26:52 UTC
Hello, I made a small script "fixing" that problem
http://florianmayer.fl.funpic.de/source/unmerge
Have fun with it :-)
Comment 24 F mayer 2005-11-03 10:28:06 UTC
#!/bin/bash
/usr/bin/emerge -avC $1 `equery depends $1 -D |grep --invert-match Searching |
grep --invert-match \* | grep --invert-match done`;
# Written by Florian Mayer(aka name) ;)

Thats the whole source :)
If my webspace is down out you can still download the script :)
Comment 25 Aniruddha Shankar 2006-05-30 13:17:48 UTC
Can someone on this bug that doesn't already have w3m test this: ?

1. emerge w3m 

On my system, the following packages are merged:

[ebuild  N    ] www-client/w3m-0.5.1-r3  USE="X async gpm gtk imlib nls ssl unicode xface -fbcon -lynxkeymap -migemo" 0 kB
[ebuild  N    ]  media-libs/compface-1.5.2  0 kB
[ebuild  N    ]  dev-libs/boehm-gc-6.5  USE="threads -nocxx" 0 kB

unmerge (as according to Florian's script) w3m

for me, it gave very shocking results - the system asked me if I wanted to unmerge gentoo-sources, kdelibs and hal, for example
Comment 26 Alec Warner archtester Gentoo Infrastructure gentoo-dev Security 2006-08-19 15:59:23 UTC
Afaik this requires a VDB change, at least you need to record which atom you picked out of the || ( A B ) so that portage doesn't have to guess at unmerge time.  You also need to store the refcounts of course ;)
Comment 27 Zac Medico gentoo-dev 2006-08-19 16:13:13 UTC
(In reply to comment #26)
> Afaik this requires a VDB change, at least you need to record which atom you
> picked out of the || ( A B ) so that portage doesn't have to guess at unmerge
> time.  You also need to store the refcounts of course ;)

Isn't it possible that the package satisfying an || ( A B ) dep could change over time?  If so, why not just find evaluate which package satisfies the dep on the fly?  That's basically that way that depclean works.  It finds all the packages that no longer have any references.  The new depclean implementation (from bug 67179) is pretty quick too, even on my system that has 1600+ packages installed.
Comment 28 Jakub Moc (RETIRED) gentoo-dev 2006-11-05 10:56:14 UTC
*** Bug 154160 has been marked as a duplicate of this bug. ***
Comment 29 Zac Medico gentoo-dev 2006-12-17 14:07:48 UTC
The --depclean implementation is fast emough in recent versions of portage that we can use it to make --unmerge do the reverse dependency check by default (and allow the user to override it with --nodeps).  It's just a matter of generalizing the code so that it's usable for both --unmerge and --depclean (or else write a similar but separate implementation for --unmerge).
Comment 30 Zac Medico gentoo-dev 2007-07-21 05:12:05 UTC
Created attachment 125536 [details, diff]
allow --depclean accept atoms and act like a safe version of --unmerge

This implements the requested feature as an extension of --depclean.  Just give it a list of atoms like you would with --unmerge.  With --verbose, it will display reverse dependencies.  The patch also makes --prune safe (use --nodeps if you want to ignore reverse dependencies).
Comment 31 Zac Medico gentoo-dev 2007-07-22 22:52:43 UTC
This has been released in 2.1.3_rc9.