You are not logged in.

#1 2008-02-14 21:34:58

venox
Member
From: Curitiba, Brazil
Registered: 2003-08-23
Posts: 137
Website

lupac: script that sorts system packages by usage

Some days ago, while I was removing unused packages from my system, I thought it would be nice to have a tool that sorts all the installed packages by usage. Here is what I've come with after a bit of tinkering: a python script that grabs a list of all installed packages and sorts them by the last time you've accessed any of the packages' files.

The script is kinda slow since it has to read the access date of every single file of every single package (and recursively read the dependency tree, if you're using it without -d), but it gives helpful results if you're trying to get rid of that packages you've installed a long time ago and don't even remember of their existence, or if you just want some fancy statistics on which packages you use most.

Usage

Usage: lupac [OPTIONS]
Lists the installed packages sorted by usage.
  -a <N>, --ago=<N>   lists only packages that have not been used for <N> days or more
  -q, --quiet         don't display status messages
  -n, --notable       don't display output in a fancy table
  -d, --nodeps        don't check for dependencies while processing (faster, poor results)
  -s, --stripdeps     don't show dependencies on the output list (doesn't work with -d)
  -y, --days          shows for how long, in days, each package hasn't been used
  -h, --help          shows this help screen

Download
Install from the AUR or just download the script http://files.venox.qc.to/lupac-0.0.7a then chmod +x it.

Example output
Here's what I get on my machine after running lupac -ya 75: http://files.venox.qc.to/results.txt
(the script lists all the packages that have been unused for 75 days or more)

Last edited by venox (2008-02-16 16:39:11)

Offline

#2 2008-02-15 19:39:52

wain
Member
From: France
Registered: 2005-05-01
Posts: 289
Website

Re: lupac: script that sorts system packages by usage

Excellent work !!
My result: http://pastebin.archlinux.fr/6324

Can you add an option to show only packages that are not requierd by others packages ?

Last edited by wain (2008-02-15 19:47:44)

Offline

#3 2008-02-15 19:55:53

F
Member
Registered: 2006-10-09
Posts: 322

Re: lupac: script that sorts system packages by usage

I'm curious if the output is for files that you, yourself, have accessed or for any user (ie. even, say, users your create for your httpd or ftpd or mpd or what have you)?

In that case this may not even be entirely useful without some more information. Its not like this information is good enough to allow you to, with a clear concious, get rid of files that only your user has not accessed in the past, say, 300 days.

Know what I mean?

Offline

#4 2008-02-15 20:21:32

venox
Member
From: Curitiba, Brazil
Registered: 2003-08-23
Posts: 137
Website

Re: lupac: script that sorts system packages by usage

wain wrote:

Excellent work !!
My result: http://pastebin.archlinux.fr/6324

Can you add an option to show only packages that are not requierd by others packages ?

Thank you! big_smile
There's already that option, try running with -s (or --stripdeps).

F wrote:

I'm curious if the output is for files that you, yourself, have accessed or for any user (ie. even, say, users your create for your httpd or ftpd or mpd or what have you)?

In that case this may not even be entirely useful without some more information. Its not like this information is good enough to allow you to, with a clear concious, get rid of files that only your user has not accessed in the past, say, 300 days.

Know what I mean?

Short answer: The access time in the output is based ou any user access.
Explanation: That happens because the access times of any files on the file system are updated when any user access them. You can prove it by creating a simple file 'as a regular user and `ls -ltu` it, so you can see the access time. Then you can go as another user (or root) and read it. The access time should be updated and you'll see the difference if you run `ls -ltu` on the file again with any user. For example:

[luiz@pearl ~]$ echo "hello" > bam
[luiz@pearl ~]$ ls -ltu bam
-rw-r--r-- 1 luiz users 6 2008-02-15 18:18 bam
[luiz@pearl ~]$ sleep 2m
[luiz@pearl ~]$ sudo cat bam 
hello
[luiz@pearl ~]$ ls -ltu bam
-rw-r--r-- 1 luiz users 6 2008-02-15 18:20 bam

Offline

#5 2008-02-15 20:25:43

F
Member
Registered: 2006-10-09
Posts: 322

Re: lupac: script that sorts system packages by usage

In that case, awesome idea. smile

Offline

#6 2008-02-15 20:44:46

PJ
Member
From: Sweden
Registered: 2005-10-11
Posts: 602

Re: lupac: script that sorts system packages by usage

Nice work!
With the help of your script I could remove 28 packages. Thanks! smile

Offline

#7 2008-02-15 21:05:02

wain
Member
From: France
Registered: 2005-05-01
Posts: 289
Website

Re: lupac: script that sorts system packages by usage

venox wrote:

There's already that option, try running with -s (or --stripdeps).

lupac -s -ya 75 give me some packages installed as deps too: like fontcacheproto, printproto

LC_ALL=C pacman -Qi printproto | grep Reason
Install Reason : Installed as a dependency for another package

 LC_ALL=C pacman -Qi fontcacheproto | grep Reason
Install Reason : Installed as a dependency for another package

Last edited by wain (2008-02-15 21:05:40)

Offline

#8 2008-02-15 21:08:39

strankan
Member
From: Sundsvall - Sweden
Registered: 2006-11-08
Posts: 97

Re: lupac: script that sorts system packages by usage

venox wrote:

Some days ago, while I was removing unused packages from my system, I thought it would be nice to have a tool that sorts all the installed packages by usage. Here is what I've come with after a bit of tinkering: a python script that grabs a list of all installed packages and sorts them by the last time you've accessed any of the packages' files.

The script is kinda slow since it has to read the access date of every single file of every single package (and recursively read the dependency tree, if you're using it without -d), but it gives helpful results if you're trying to get rid of that packages you've installed a long time ago and don't even remember of their existence, or if you just want some fancy statistics on which packages you use most.

Usage

Usage: ./lupac-0.0.5a [OPTIONS]
Lists the installed packages sorted by usage.
  -a <N>, --ago=<N>   lists only packages that have not been used for <N> days or more
  -q, --quiet         don't display status messages
  -n, --notable       don't display output in a fancy table
  -d, --nodeps        don't check for dependencies while processing (faster, poor results)
  -s, --stripdeps     don't show dependencies on the output list (doesn't work with -d)
  -y, --days          shows for how long, in days, each package hasn't been used
  -h, --help          shows this help screen

Download
Install from the AUR or just download the script http://files.venox.qc.to/lupac-0.0.5a then chmod +x it.

Example output
Here's what I get on my machine after running ./lupac-0.0.5a -ya 75: http://files.venox.qc.to/results.txt
(the script lists all the packages that have been unused for 75 days or more)

Server seems down at the moment sad

Offline

#9 2008-02-15 21:12:40

venox
Member
From: Curitiba, Brazil
Registered: 2003-08-23
Posts: 137
Website

Re: lupac: script that sorts system packages by usage

@wain:
I'm not sure about this, but probably it was installed as a dependency for another package and it's not a dependency anymore (there are no packages that depend on it installed on your system).

Can you tell me if there are any installed packages on your system that still depend on printproto and fontcacheproto?

@strankan
Strangely, yes. The server seems to be down. You can download it from my personal webserver: http://luiz.ath.cx:8080/~luiz/lupac/lupac-0.0.5a

Edit: the server is up again.

Last edited by venox (2008-02-15 22:27:53)

Offline

#10 2008-02-15 22:42:07

wain
Member
From: France
Registered: 2005-05-01
Posts: 289
Website

Re: lupac: script that sorts system packages by usage

venox wrote:

@wain:
I'm not sure about this, but probably it was installed as a dependency for another package and it's not a dependency anymore (there are no packages that depend on it installed on your system).

printproto is requierd by libxp

$ LC_ALL=C pacman -Qi printproto
Name           : printproto
Version        : 1.0.3-1
....
Required By    : libxp  
...
Install Reason : Installed as a dependency for another package

fontcacheproto is requierd by libxfontcache

pacman -Qi fontcacheproto
Nom                   : fontcacheproto
Version               : 0.1.2-1
...
Requis par            : libxfontcache  
...
Motif d'installation  : Installé comme dépendance d'un autre paquet

Offline

#11 2008-02-15 23:22:59

venox
Member
From: Curitiba, Brazil
Registered: 2003-08-23
Posts: 137
Website

Re: lupac: script that sorts system packages by usage

That's odd. I tried running lupac -sy and lupac -y and the first one strips those printproto packages just fine.
Can you try running lupac with LC_ALL=C? I'm pretty sure your locale settings are messing with the 'pacman -Qi' parsing. If you confirm that, I'll fix it in version 0.0.6

Offline

#12 2008-02-15 23:29:48

wain
Member
From: France
Registered: 2005-05-01
Posts: 289
Website

Re: lupac: script that sorts system packages by usage

venox wrote:

That's odd. I tried running lupac -sy and lupac -y and the first one strips those printproto packages just fine.
Can you try running lupac with LC_ALL=C? I'm pretty sure your locale settings are messing with the 'pacman -Qi' parsing. If you confirm that, I'll fix it in version 0.0.6

Confirmed 8)
sorry, I din't realize lupac use pacman -Qi to parse database...

Offline

#13 2008-02-15 23:36:27

venox
Member
From: Curitiba, Brazil
Registered: 2003-08-23
Posts: 137
Website

Re: lupac: script that sorts system packages by usage

wain wrote:

Confirmed 8)
sorry, I din't realize lupac use pacman -Qi to parse database...

http://files.venox.qc.to/lupac-0.0.6a
Please confirm if this new version fixes the problem with your locale settings.

Last edited by venox (2008-02-15 23:37:34)

Offline

#14 2008-02-15 23:46:56

wain
Member
From: France
Registered: 2005-05-01
Posts: 289
Website

Re: lupac: script that sorts system packages by usage

lupac-0.0.6a doesn't work. Same locale problem :-/

Offline

#15 2008-02-16 00:07:04

venox
Member
From: Curitiba, Brazil
Registered: 2003-08-23
Posts: 137
Website

Re: lupac: script that sorts system packages by usage

Offline

#16 2008-02-16 08:26:20

wain
Member
From: France
Registered: 2005-05-01
Posts: 289
Website

Re: lupac: script that sorts system packages by usage

venox wrote:

0.0.7a works great with french locales smile
Good job !

Offline

#17 2008-02-19 22:42:50

wain
Member
From: France
Registered: 2005-05-01
Posts: 289
Website

Re: lupac: script that sorts system packages by usage

Can you add an option to list all packages where install date = last use date ?

Offline

#18 2008-08-06 14:19:56

Onwards
Member
From: Pakistan
Registered: 2007-04-18
Posts: 108

Re: lupac: script that sorts system packages by usage

That's why I love Arch !!

Great stuff bro smile

Offline

Board footer

Powered by FluxBB