You are not logged in.
/var/cache/pacman/pkg can get filled up with packages that you intalled once, just to try out, but then uninstalled and never plan to install again. I am thinking of a script that removes pkg.tar.gz's that are not installed, which will clear up some truly "dead" space on your hard drive. What do you think?
Offline
pacman -Sc and pacman -Scc
I am a gated community.
Offline
No... I have read the pacman manpage, thank you very much.
I guess my first post lacks explanation. I don't want to do pacman -Scc, but I want to remove ... oh man just read my first post. I still want to keep the pkg.tar.gz's which are currently installed.
Offline
For example, I have already uninstalled xfce, but pacman -Sc will not remove the most recent xfce pkgs in /var/cache/pacman/pkg, and I don't want to do pacman -Scc either.
Right now it would have to be done manually.
(Sorry if this is not a "contribution"; I guess my "contribution" is the idea...)
Last edited by Galdona (2007-02-04 21:55:19)
Offline
now, now, no need to get so exasperated. I whipped up a quick script that'll do the job for you:
-- edit -- Er.. script had a bug that may make it remove more packages than expected. I'll fix and repost in one sec. -- /edit --
Last edited by Cerebral (2007-02-04 22:52:16)
Offline
O gee that would be really nice!
Offline
There, this should be a 'fixed' version. As always, use at own risk.
#!/bin/bash
for pkgname in $(ls /var/cache/pacman/pkg/ | sed "s#\(.*\)-.*-.*#\1#g" | sort | uniq ); do
pacman -Q $pkgname 2>/dev/null >/dev/null
if [ $? -ne 0 ]; then
echo "$pkgname in cache but not installed, removing."
pkgs=$(ls /var/cache/pacman/pkg/$pkgname-* | grep -e "$pkgname-[0-9]")
rm $pkgs
fi
done
Offline
I'm afraid to try it! Your disclaimer hints at some uncertainty...
Anyway, the worst that can happen is I lose all cached pkgs... right?
Alright, I'll try it a bit later!
Offline
shall we name it... ccup? (Clear Cache of Uninstalled Packages)
Offline
I once asked same question. As an answer maniel quickly wrote this script, which does the job. It requires ruby. Works for me, but NO WARRANTY, use it at your own risk.
ls /var/cache/pacman/pkg/ |ruby -wne 'x=$_.split(/-/)[0..-3].join("-"); `pacman -Qi #{x} &>/dev/null`; `rm /var/cache/pacman/pkg/#{$_}` if $?!=0'
Offline
I usually use this script:
#!/bin/bash
for i in $(ls -1 /var/cache/pacman/pkg);do j=${i%-*};pacman -Q ${j%-*}|grep found;done
It doesn't remove anything. It just list the pkgname.
Offline
Haha I only just now saw the output of pacman -V. cute!
It would be nice to have the above-discussed functionality included in pacman3. eherm.
Offline
A script posted previously:
#!/bin/bash
##Remove packages from cache not installed
#and download any installed pkgs not cached
pacman -Sc
pacman -Q | sed s/' '/-/g > /tmp/installed
for pkg in `ls /var/cache/pacman/pkg`
do
name=${pkg%%.pkg.tar.gz}
if [[ ! `grep $name /tmp/installed` ]]
then
echo Removing $name
rm -f /var/cache/pacman/pkg/$pkg
fi
done
pacman -Q | cut -d ' ' -f 1 > /tmp/installed
pacman -Sl | cut -d ' ' -f 2 >> /tmp/installed
pacman -Sw `sort /tmp/installed | uniq -d`
/path/to/Truth
Offline
One of my goals for Pacman 3.1 is to implement some more cache-cleaning functionality, including ensuring the installed version of a package is not removed (currently only the newest version is kept, whether or not it is installed). However, this will take some reworking of the pacman internals to make it easier to implement, so it will not likely make it into the first release of pacman 3.
Offline
Well, I would just put pacman -Scc in my /etc/rc.local, but these solutions are a lot more cleaner than that.
Regards,
Picpak
Offline
Well, I would just put pacman -Scc in my /etc/rc.local, but these solutions are a lot more cleaner than that.
You *totally* did not read the entire thread.
Last edited by Galdona (2007-02-11 03:32:32)
Offline
Yeah I did, that's why I said that these solutions are a lot more cleaner than that.
Regards,
Picpak
Offline
you could also try pajman. It is a script that i wrote that also performs package name based searches at light speed.
Offline
I have another alternative; my /var/cache/pacman/pkg is mounted by many clients to save diskspace. This means I cannot simply check if it is installed locally; since another machine might have it installed. I use the following script to check if the version in the cache is the latest version. If it is not, I assume it is not being used anywhere [my machines frequently update, so that should work fine] and then delete it. Also; if it would be in use anywhere that doesn't matter since the old version won't be used anyway
Here is the script:
for f in $(ls /var/cache/pacman/pkg);do p=${f%-*};p=${p%-*};v=${f/#$p-/};v=${v/%\.pkg\.tar\.gz/}; pacman -Si $p 2>/dev/null|grep -q $v || rm -v /var/cache/pacman/pkg/$f; done
Last edited by Spider.007 (2007-03-08 08:40:28)
Offline
There, this should be a 'fixed' version.
As always, use at own risk.
#!/bin/bash for pkgname in $(ls /var/cache/pacman/pkg/ | sed "s#\(.*\)-.*-.*#\1#g" | sort | uniq ); do pacman -Q $pkgname 2>/dev/null >/dev/null if [ $? -ne 0 ]; then echo "$pkgname in cache but not installed, removing." pkgs=$(ls /var/cache/pacman/pkg/$pkgname-* | grep -e "$pkgname-[0-9]") rm $pkgs fi done
Sorry to ressurect such an old thread, but I just came across this and the script above worked great for me; cleared over 700MB from my .../pacman/pkg directory. I am curious though, why we want to keep the tar.gz's of installed programs in the cache. If the program is already installed, what purpose do they serve there? Just curious...
If the advice you're given in this forum solves your issue, please mark the post as [SOLVED] in consideration to others.
"More than any time in history mankind faces a crossroads. One path leads to despair and utter hopelessness, the other to total extinction.
Let us pray that we have the wisdom to choose correctly." -- Woody Allen
Offline
Arch, currently, doesn't have a unique packaging suffix (such as .deb or .rpm), it just uses the following scheme:
packagename-version-revision-architecture.pkg.tar.gz
The way to package Arch applications is to install them to a fakeroot directory and tar it. The resulting pkg.tar.gz does not contain the original source code, but rather the application's files that have been compiled and organized for your specific architecture.
When you install a package with Pacman, its pkg.tar.gz is downloaded to /var/cache/pacman/pkg and unpacked to your root ( / ) directory. The tarball is left in your cache in case you need to (re)install it without having to (re)download it. It's also handy to have an older version of a package readily available in case a newer one doesn't work well.
Dylon
Offline
oh okay, so they aren't necessary to keep, and they're never used unless you want to reinstall a program.
thank you.
If the advice you're given in this forum solves your issue, please mark the post as [SOLVED] in consideration to others.
"More than any time in history mankind faces a crossroads. One path leads to despair and utter hopelessness, the other to total extinction.
Let us pray that we have the wisdom to choose correctly." -- Woody Allen
Offline
hi, i'm a noob at Arch and having trouble understanding the difference between 'pacman -Sc' and the aforementioned script... when do i need to use which?
doesn't pacman -Sc wipe off packages that i have uninstalled?
Offline
i'm not sure if this info still applies to pacman, since it's been updated from version 3.0, but a very helpful individual (MrElendig) on the #archlinux irc channel clarified on the utility of the script. i'm pasting it here:
(21:51:54) MrElendig: erythrocyte: example:
(21:52:05) MrElendig: you have 2 apps foo and bar
(21:52:12) MrElendig: you installed foo1 and bar 1
(21:52:23) MrElendig: then you upgraded to foo2 and bar2
(21:52:32) MrElendig: then you -R bar
(21:52:49) MrElendig: if you -Sc then that will remove foo1, bar1 and bar2
(21:53:03) MrElendig: if you use the script, only bar1 and bar2 will be removed
hope that clears up a few doubts for users new to Arch linux
Offline
oh okay, so they aren't necessary to keep, and they're never used unless you want to reinstall a program.
thank you.
Sometimes a package will cause trouble, which is easily escaped by downgrading. If you have trouble that brakes your internet connection it is so easy to fix by referring to your /var/log/pacman.log (if you have to) & downgrading, using the following method from the Arch Wiki:
You may be able to downgrade the package trivially by visiting /var/cache/pacman/pkg/ on your system and seeing if the older version of the package is stored there. (If you haven't run pacman -Scc recently, it should be there). If the package is there, you can install that version using pacman -U pkgname-olderpkgver.pkg.tar.gz. If pacman complains about file conflicts, you could force it to do the installation anyway with pacman -Uf pkgname-olderpkgver.pkg.tar.gz.
We had a kernel bug last October that caused many who did not have a copy of a previous kernel in their cache some extra trouble & education. ;-)
If you ever need a superseded kernel have a look here:
http://ubuntuforums.org/showthread.php?t=954481
Last edited by handy (2008-12-19 02:10:46)
I used to be surprised that I was still surprised by my own stupidity, finding it strangely refreshing.
Well, now I don't find it refreshing.
I'm over it!
Offline