Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 151653 - prune (-P) removes all but the most recently installed slot
Summary: prune (-P) removes all but the most recently installed slot
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Interface (emerge) (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks: 155723 181949
  Show dependency tree
 
Reported: 2006-10-16 16:15 UTC by Chris Smith
Modified: 2007-07-22 22:53 UTC (History)
0 users

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


Attachments
keep the highest version whenever possible (higest_version.patch,1.41 KB, patch)
2007-07-20 02:07 UTC, Zac Medico
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Smith 2006-10-16 16:15:40 UTC
Notice in the output below that emerge thinks that 2.6.17-r8 is a later version than 2.6.18.

+++++++++++++++++++++++++++++++
# emerge -Paq sys-kernel/gentoo-sources

 sys-kernel/gentoo-sources
    selected: 2.6.18 2.6.17-r7
   protected: 2.6.17-r8
     omitted: none
Comment 1 Zac Medico gentoo-dev 2006-10-16 18:13:28 UTC
--prune has always been broken by design.  I'd recommend --depclean, which works pretty well in >=portage-2.1.1.
Comment 2 Marius Mauch (RETIRED) gentoo-dev 2006-10-17 15:01:31 UTC
(In reply to comment #1)
> --prune has always been broken by design.  I'd recommend --depclean, which
> works pretty well in >=portage-2.1.1.

How so? (I guess it depends on what you expect from it, but to my expectations it worked just fine so far). And --depclean can't be the replacement solution for this specific use case anyway, assuming gentoo-sources is in world, as it can't know if I care about the different slots or not (unless we record slot atoms in world which would be very new behavior).
Comment 3 Zac Medico gentoo-dev 2006-10-17 15:11:55 UTC
(In reply to comment #2)
> How so? (I guess it depends on what you expect from it, but to my expectations
> it worked just fine so far).

All that I meant is that it doesn't check dependencies (or even masking status?).  I've never really used --prune but I know that it can be unsafe (just like --umerge though).

I think --prune could be greatly improved if it used something similar to the depclean algorithm to ensure that it doesn't remove slots that are required by other packages.
Comment 4 Marius Mauch (RETIRED) gentoo-dev 2006-10-18 10:29:49 UTC
--prune used to be the same as --unmerge except that it kept the highest version. Its main use (with these semantics) was to clean out old slots, in particular kernels (actually that's the only real use I can think of).
Additionally protecting slots that are required by the depgraph makes sense, but doesn't change the fact that this bug (wrong version being protected) is valid.
Comment 5 Zac Medico gentoo-dev 2006-11-08 13:16:58 UTC
The --prune code will use the counter, /var/db/pkg/sys-kernel/gentoo-sources-2.6.17-r8/COUNTER for example, to determine the most recently merged version (highest counter means most recently merged).  Should we assume that the user wants to keep the most recently merged version or not?
Comment 6 Chris Smith 2006-11-10 15:11:35 UTC
(In reply to comment #5)
> The --prune code will use the counter,
> /var/db/pkg/sys-kernel/gentoo-sources-2.6.17-r8/COUNTER for example, to
> determine the most recently merged version (highest counter means most recently
> merged).  Should we assume that the user wants to keep the most recently merged
> version or not?
> 

I thought --prune was supposed to keep the newest version level. Using gentoo-sources as an example, if one has 2.6.17, 2.6.18 and 2.6.18-r1 installed, --prune should unmerge all except 2.6.18-r1, regardless of when they were merged (but apparently that was wishful thinking on my part).

In examining a system where the I see the problem still exhibited (one where I haven't manually unmerged the old kernels yet), I find this exhibited:
==========================================
irobot ~ # emerge -Ppq gentoo-sources

 sys-kernel/gentoo-sources
    selected: 2.6.15-r4 2.6.15-r5 2.6.18
   protected: 2.6.17-r5
     omitted: none
==========================================

How I thought --prune should work would be to unmerge everything except 2.6.18.

However if the COUNTERS are examined:
==========================================
gentoo-sources-2.6.15-r4/COUNTER = 3701
gentoo-sources-2.6.15-r5/COUNTER = 3813
gentoo-sources-2.6.17-r5/COUNTER = 4804
gentoo-sources-2.6.18/COUNTER = 4803
==========================================

So according to the counters gentoo-sources-2.6.17-r5 was emerged last. And genlop confirms this:
==========================================
Tue Oct 10 02:31:55 2006 >>> sys-kernel/gentoo-sources-2.6.18
Tue Oct 10 02:33:53 2006 >>> sys-kernel/gentoo-sources-2.6.17-r5
==========================================

However, I never manually emerged 2.6.17-r5 after 2.6.18, the reversal must have occurred during something like an "emerge -e world" when I was rebuilding after a toolchain update, thereby causing --prune to exhibit unexpected behavior. So I guess in some ways this is my bad. If --prune worked as I thought it did then rebuilding world would not have caused this problem.

Chris
Comment 7 Marius Mauch (RETIRED) gentoo-dev 2006-11-11 05:37:54 UTC
(In reply to comment #6)
> I thought --prune was supposed to keep the newest version level. Using
> gentoo-sources as an example, if one has 2.6.17, 2.6.18 and 2.6.18-r1
> installed, --prune should unmerge all except 2.6.18-r1, regardless of when they
> were merged.

Correct. Well, "last version" in the manpage can be read both ways, but I'd say "highest version" is more useful and more deterministic than "most recently merged version" in this case. And changing existing behavior without a good reason isn't very nice anyway.
Comment 8 Alec Warner (RETIRED) archtester gentoo-dev Security 2007-01-30 03:10:13 UTC
       --prune (-P)
              WARNING: This action can remove important packages!  Prune looks
              at each installed package and attempts to  remove  all  but  the
              most  recently  installed  version.  Prune ignores slots, if you
              require a slot-aware Prune use  emerge --clean.  Prune may inad-
              vertently  remove  important  packages  from  your  system.  Use
              --clean instead unless you really know what you're doing.

I just rewrote this manpage (should have been released in 2.1.2) for this exact reason.  See "most recently installed" as opposed to highest version.  
Comment 9 Zac Medico gentoo-dev 2007-07-20 02:07:09 UTC
Created attachment 125408 [details, diff]
keep the highest version whenever possible

This is fixed in svn r7314.
Comment 10 Zac Medico gentoo-dev 2007-07-22 22:53:02 UTC
This has been released in 2.1.3_rc9.