You are not logged in.

#1 2006-06-26 15:10:20

ujjwal
Member
Registered: 2006-01-31
Posts: 27

Clearing cache of uninstalled packages

Is there a way to remove only those packages from the pacman cache which are not installed in the system? That is, supposing I install gnome-desktop and later choose to remove it, the package will still remain in /var/cache/pacman/pkg. Is there a way to delete all such packages from the cache?

Offline

#2 2006-06-26 15:24:10

Snowman
Developer/Forum Fellow
From: Montreal, Canada
Registered: 2004-08-20
Posts: 5,212

Re: Clearing cache of uninstalled packages

I recently wrote the following script to do the same thing. It only list the package to remove. You'll need to remove them manually or modify the script.

#!/bin/bash
for i in $(ls -1 /var/cache/pacman/pkg);do j=${i%-*};pacman -Q ${j%-*}|grep found;done

Offline

#3 2006-06-28 12:25:54

ujjwal
Member
Registered: 2006-01-31
Posts: 27

Re: Clearing cache of uninstalled packages

Thanks for the script, it help me free some 100 odd MB on y disk smile

Offline

#4 2017-10-25 22:50:10

strpeter
Member
From: Geneva
Registered: 2012-11-24
Posts: 24

Re: Clearing cache of uninstalled packages

Eventhough that this is a quite old post, I want to refer people to the very useful tool paccache which removes all older versions up to the most recent (default: 3) packages.

Summarizing: (I have not tested it myself)
To remove all cached versions of uninstalled packages, re-run paccache with:

# paccache -ruk0

Another reason is that the script from Snowman is not working (at least not on my machine). I had to change his code to do the following:

for i in $(ls /var/cache/pacman/pkg/*);do j=${i:22}; k=${j%-*}; l=${k%-*}; m=${l%-*}; pacman -Q $m | grep found ;done

Explaining the code: The variable j removes the path, the variables k, l, and m remove the ending after the hyphens. So we are left with only the package name when checking the installed version with pacman -Q.

Offline

#5 2017-10-25 23:04:39

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Clearing cache of uninstalled packages

Please don't necrobump: https://wiki.archlinux.org/index.php/Co … bumping.22


paccache is alos well documented in the wiki.


Closing


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB