FS#8819 - Pacman autoclean (feature request)

Attached to Project: Pacman
Opened by Alberto Gonzalez (Luis) - Sunday, 02 December 2007, 20:41 GMT
Last edited by Dan McGee (toofishes) - Wednesday, 06 February 2008, 13:51 GMT
Task Type Feature Request
Category General
Status Closed
Assigned To No-one
Architecture All
Severity Low
Priority Normal
Reported Version 3.0.6
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

I think that a feature to autoclean old packages from the cache would be a good addition to pacman. It would be a useful feature in itself and also allow implementation of another nice feature (downgrade packages) that I will file as a different request depending on this one.

Maybe this has been discussed already, but I couldn't find it. So here's my idea:

Now by default pacman keeps all downloaded packages in the cache. This is useful to downgrade packages, but at some point the cache grows too big (mostly with old packages that are not useful anymore) and so you have to pacman -Scc. Unfortunately that removes all the packages, the useful and the not useful ones.

Since 90% of the time, the only useful packages to keep in the cache are the versions prior to the currently installed, here's what could be done:

When a package is upgraded, pacman would perform the following actions:
- Delete from the cache (if found) <packagename>-old
- Flag the currently installed package as <packagename>-old
- Upgrade the package normally to the newer version.

When a package is removed, I think that by default it should delete it from the cache too, though maybe a switch could be implemented to keep the package in the cache for the cases when it's needed (something like pacman -Rk <packagename>).

I think this shouldn't be too complicated to implement (but IANAP), and it's quite useful:
- It prevents your cache from growing forever
- It allows you to always keep a previous version of a package in case you need to downgrade
- It would allow the implementation of a "pacman --downgrade <packagename>" feature
- You can always do pacman -Scc if you really need the space.

Thanks.
This task depends upon

Closed by  Dan McGee (toofishes)
Wednesday, 06 February 2008, 13:51 GMT
Reason for closing:  Won't fix
Additional comments about closing:  Too complex of an idea for pacman itself, -Sc is sufficient for 95% of peoples' needs.
Comment by Alberto Gonzalez (Luis) - Sunday, 02 December 2007, 20:50 GMT
Here is the follow up feature request (auto downgrade packages):
http://bugs.archlinux.org/task/8821
Comment by Dan McGee (toofishes) - Wednesday, 05 December 2007, 14:02 GMT
See commit:
<http://projects.archlinux.org/git/?p=pacman.git;a=commit;h=16cb8e6e61c542731814192fc03e3988c7a26325>

Doubtful we are going to do anything as complex as you state. Feel free to develop a patch to keep the current + 1 additional version though.
Comment by Xavier (shining) - Friday, 07 December 2007, 01:01 GMT
"so you have to pacman -Scc. Unfortunately that removes all the packages, the useful and the not useful ones."

Why don't you just use -Sc then?

Here is what I would recommend to do (besides buying new hard drives, because they are cheap) :
1) run pacman -Su
2) wait a few days to make sure everything works
3) run pacman -Sc
and then repeat.
Comment by Roman Kyrylych (Romashka) - Tuesday, 11 December 2007, 11:52 GMT
> Since 90% of the time, the only useful packages to keep in the cache are the versions prior to the currently installed
Are you requesting pacman to keep only versions that are one release older than the current installed version? (this is useful for downgade).
Anyway that's not always helpful, because sometimes you discower you want to downgrade some package more than one version back.
Implementing this in -Sc is not welcomed ad seems complex (see #1 from  FS#6420 ).
So it's better to create a separate script for this, that will delete all packages downloaded before some _date_ - this will be more convenient solution IMO.
Comment by Alberto Gonzalez (Luis) - Tuesday, 11 December 2007, 12:22 GMT
Yes, I didn't know this was something so complicated. I thought that just using a flag -old in each upgraded package would be an easy task, but anyway, I didn't know about -Sc, so thanks for the tip too.

>Anyway that's not always helpful, because sometimes you discover you want to downgrade some package more than one version back.

Yes, exactly, that's why I said 90% of the time, not 100%. *Sometimes* you do need an older version. But in those rare cases you can build from source, I guess.

>So it's better to create a separate script for this, that will delete all packages downloaded before some _date_

I don't quite agree. Some packages get upgraded very seldom and others very often. With this approach you might end up deleting some useful packages and keeping in the cache lots of non useful ones. Keeping a copy of just the current and the previous (-old) would work better, IMHO. And looking for a specific flag (-old) is less expensive than checking all the dates. Besides, the auto-clean in my example would be performed automatically when you upgrade any package, while the other option should be run independently, so users should learn to use it.
Comment by Roman Kyrylych (Romashka) - Tuesday, 11 December 2007, 14:44 GMT
Well, actually I assumed all packages installed after some date _and_ previous versions of current packages
- which means, some packages could have more than one previous version, but always at least one of previous versions.
Comment by Dan McGee (toofishes) - Wednesday, 06 February 2008, 02:36 GMT
I really don't feel like this is something pacman will ever address. I'd like to close this with won't fix for the following reasons:
1. If you really want this functionality, use either a custom libalpm program or custom script.
2. pacman is not a disk cleanup utility- if you want old packages with more flexibility than -Sc and -Scc already provide, pacman isn't your tool.

Any objections?
Comment by Xavier (shining) - Wednesday, 06 February 2008, 07:08 GMT
No objections.

Besides, Luis said in his last comment he didn't know about -Sc. Though he would prefer something automatic instead of an independent operation like -Sc, but I personally prefer -Sc.
Comment by Alberto Gonzalez (Luis) - Wednesday, 06 February 2008, 08:36 GMT
No objections on my part either. It was just an idea, but it seems it's not worth the effort or people just don't need it or want it.

Besides, pacman -Sc is good enough, I guess.

Thanks.

Loading...