You are not logged in.

#1 2012-01-24 15:54:11

Revelation60
Member
From: The Netherlands
Registered: 2009-03-19
Posts: 158
Website

unused: finds packages that are unused

I'm probably not the only Arch user who shivers at the thought of unused packages lingering on my filesystem. That's why I am making an attempt to detect which packages haven't been used recently.

I've come up with two ways to do this, one active and one passive method. The active strategy is to monitor access to files with an inotify hook, filtering out possibly irrelevant access from pacman and other applications or monitor the process-list. The second one is to query the access timestamp of all the files of a package and finding the most recent one. Because it's easier, I've started implementing the second option.

In the current version, you get a sorted output of all the applications you haven't used recently, together with the latest access date. Note that my Bash is terrible, and that this first version is very slow. In the code below, you'll see that I use tail -n 5000, else it will take too long to complete. Maybe I'll find a way to improve performance, or maybe someone with real bash skills.

Note that this method isn't perfect. Every package it finds is certainly unused, but it doesn't find every unused package. For example, if pacman upgrades an unused package, it will set the access flag to the current time. These packages will stay under the radar, unfortunately. Maybe I'll implement the ps-monitor or hook soon, I wonder if that'll work better.

You can download the code here:
https://gist.github.com/1670778

Last edited by Revelation60 (2012-01-24 16:00:01)

Offline

#2 2012-01-24 16:45:01

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: unused: finds packages that are unused

Or you can go through the list of installed packages and ask yourself "do I really need this?" :-)

Offline

#3 2012-01-26 16:51:15

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: unused: finds packages that are unused

The second one is to query the access timestamp...

Aren't most people using relatime or noatime these days?  I'm not sure about rel- but this surely won't work with no-


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#4 2012-01-26 22:29:54

VCoolio
Member
From: Netherlands
Registered: 2010-01-05
Posts: 120

Re: unused: finds packages that are unused

It' s a good idea to use for improving bash skills, but I don't think it's very usable for reasons mentioned above. You could take another view at it: check for apps that people thought would fit their needs, but that they don't use. I mean, don't check all pacman -Ql files, but only the ones in /usr/bin, /usr/local/bin, and report the ones least used, or the packages they belong to. That way you avoid checking all libraries and stuff. They are mostly dependencies, and there is the check for orphans to detect unneeded dependencies.

Offline

Board footer

Powered by FluxBB