PkgClip: Cached Packages Trimmer Utility
Latest version: 1.3.0
You can find the source code on this GitHub, where you can also report bugs, send suggestions or other (constructive) feedback.
What is pkgclip ?
PkgClip is a little helper for Arch Linux users, that will scan your pacman cache directories and help you trim it a bit.
Whenever pacman downloads packages, it saves them in a cache directory, and never removes them. Over time, this cache can grow a lot.
While pacman does offer options to clean your cache, they are very basic. Its
-c) will remove packages that are no longer installed from
the cache (as well as currently unused sync databases. Note that PkgClip does
not touch databases, only packages.), or remove all packages if you specify it
PkgClip aims at giving you a little more options. To do so, it will classify all packages into different "groups" (also called "reasons", as in reason for the recommended action), each group having a recommendation (Keep or Remove), used as default choice.
You will of course be able to then review it all, and decides which packages shall be removed, and which shall not.
Find a reason for your action
When scanning pacman's cache, PkgClip will put every package into a group, also called "reason." Reasons, because they'll be used to determine whether a package should be kept, or removed. (Well, to determine the recommended action, up to you to go with it or not, of course.)
Note: All packages usually have a version number, that of the installed
software, alongside a package release number. That is, package
would be for foobar v1.2.3; and it is the fourth package release for that
For each package, PkgClip will check whether or not it is installed on the system. The test will determine whether this version of the package is installed, or another one. Based on this, each package will fall under one of the following :
- Package of a version more recent than the one currently installed; Marked to Keep.
- Package of the currently installed version; Marked to Keep
- Package of the same version but a previous package release (pkgrel); Marked to Remove
- Package of an older version. You can define how many of those you'd like to keep. As many will be marked to Keep, any other (i.e. the oldest ones, of course) will be marked to Remove
- Package for which no version is currently installed; Marked to Remove
As a result, you might have quite a few packages marked to be removed, but still
keep a few more than what
pacman -Sc would do. Of course you can tweak this
- You can define how many older versions to keeping
- You can set not to remove old package releases, that is a package of the same version but a previous package release will simply be treated as an old version
- Finally, all of this only defines the recommended/default values for each packages. You can obviously then review the list and manually add/remove packages to be removed as you wish.
Actual removal of the files: PolicyKit required
As you probably know, you cannot actually just run
pacman -Sc from your
terminal, if you're logged in as a regular user. Because those files belong to
root and therefore root privileges are required to do anything.
PkgClip is not intended to be run as root of course, and will use a little helper whose only purpose is to remove the files. This helper will run as root, and rely on PolicyKit to ensure correct authorization has been granted.
Obviously it requires you to have PolicyKit installed, but also (assuming default configuration) a PolicyKit agent, which is the one in charge of asking for your/root password and making sure you don't just press random keys and whatnot.