1

I mean to get rid of a large number of probably useless installers (I have currently 3.5Gb "immobilized") from my Portable Msys2 under Win10. I will probably keep the last version, at least of some installers.

To do this, I mean to install paccache.

$ pacman -S paccache
error: target not found: paccache

OTOH, I found https://github.com/Alexpux/MSYS2-pacman/blob/master/contrib/paccache.sh.in

How should I use this paccache?

Using paccache is equivalent to

$ cd /var/cache/pacman/pkg/
$ rm python3-pip-10.0.1-1-any.pkg.tar.xz
$ rm ...

in a more versatile/fine-tuned way, or does it perform any additional action?

  • 1
    Run: `/usr/bin/paccache` – Biswapriyo Mar 05 '19 at 13:21
  • According to the [documentation](https://wiki.archlinux.org/index.php/pacman#Cleaning_the_package_cache) the Paccache script is provided by the Pacman package itself, so you don’t have to install it at all, just call it as described in the above link. You may find a tutorial [here](https://www.ostechnix.com/recommended-way-clean-package-cache-arch-linux/). Let me know if this helps and what you need to include in an answer. – harrymc Mar 05 '19 at 18:36
  • @harrymc - The page mentions `pacman-contrib`, which I couldn´t find. – sancho.s ReinstateMonicaCellio Mar 05 '19 at 19:24
  • On seconds thought, Linux advice may not apply to Msys2. First check if `/usr/bin/paccache` exists. If it doesn't, you may need to generate it from the `paccache.sh.in` file that you found, which seems like an M4 script. Examine the `m4_include` found in the script to find out in which folder it should be stored and processed by M4. M4 seems like a package that Msys2 should know about. – harrymc Mar 05 '19 at 20:23
  • @Biswapriyo - Yes, I checked it, and I found `/usr/bin/paccache`. – sancho.s ReinstateMonicaCellio Mar 06 '19 at 00:04
  • It seems that also in Msys2, `paccache` is a part of the Pacman package. You may then use it as explained in the links I have listed above. – harrymc Mar 06 '19 at 07:36
  • @Biswapriyo - I suggest you post your comment as an answer (it was crucial for me), with additional info regarding the questions in the OP. – sancho.s ReinstateMonicaCellio Mar 06 '19 at 08:55
  • @harrymc - I had already found out the latest info you posted. I do not know how to use files like `paccache.sh.in` (even if finally not needed here). – sancho.s ReinstateMonicaCellio Mar 06 '19 at 08:57

3 Answers3

2

According to the documentation, the Paccache script is provided by the Pacman package itself and is found in /usr/bin/paccache, so you don’t have to install it at all.

Its usage is described as follows:

The paccache script, provided within the pacman-contrib package, deletes all cached versions of installed and uninstalled packages, except for the most recent 3, by default:

# paccache -r

You can also define how many recent versions you want to keep. To retain only one past version use:

# paccache -rk1

Add the u switch to limit the action of paccache to uninstalled packages. For example to remove all cached versions of uninstalled packages, use the following:

# paccache -ruk0

See paccache -h for more options.

A tutorial for using the package is found in the article
The Recommended Way To Clean The Package Cache In Arch Linux.

As the documentation is all for Linux, while you are running Msys2 on Windows, some of the documentation might not apply to your environment.

For your question if paccache is equivalent to only a bunch of rm commands, the package MSYS2-pacman terminates with the code:

if (( delete )); then
    printf '%s\0' "${candidates[@]}" | runcmd xargs -0 rm "${cmdopts[@]}"
    [...]
fi

So, yes, all it does is issue rm commands.

harrymc
  • 455,459
  • 31
  • 526
  • 924
  • The ambiguity pacman vs. pacman-contrib still puzzles me. And the differences between Linux and Msys2 possibly laid at the heart of my problem. Plus, I still wonder if `paccache` is equivalent to only a bunch of `rm`s. – sancho.s ReinstateMonicaCellio Mar 06 '19 at 08:58
  • It is. You can see that it's so at the very end of the [script](https://github.com/Alexpux/MSYS2-pacman/blob/master/contrib/paccache.sh.in) that you found. – harrymc Mar 06 '19 at 09:47
  • The comment (later answer) that led me to the solution was [this](https://superuser.com/a/1411826/245595). Yours is a detailed and useful answer, and I would have split the bounty... unfortunately this is not possible as of now. – sancho.s ReinstateMonicaCellio Mar 15 '19 at 12:16
  • Do you also think the description of pacman-contrib as a separate package is ambiguous? Or is it a separate package in systems other than msys2? – sancho.s ReinstateMonicaCellio Mar 15 '19 at 12:20
2

The problem of not finding paccache was simple. For some reason, I was not finding paccache (I do not recall if I even tried pacc+tab-completion, which would have given me paccache, and then which paccache). The key was given by this comment (added as answer later), which indicated I already had paccache. I might have required updating some databases (for sure, at least pkgfile, see below).

I first expected to find paccache in package paccache and then in package pacman-contrib, as a separate package from pacman. But I found no pacman-contrib. I must have been searching the wrong way (or I have now some databases updated as compared to what I had a couple of days ago, I am not sure), since

$ pacman -Q pacman
pacman 5.1.2-2
$ pacman -Q pacman-contrib
pacman 5.1.2-2

And also,

$ pkgfile -s /usr/bin/paccache
error: No repo files found. Please run `pkgfile --update'.
$ pkgfile --update
:: Updating 3 repos...
  download complete: msys                 [   951.1 KiB  61.2K/s  2 remaining]
  download complete: mingw32              [     3.5 MiB  81.6K/s  1 remaining]
  download complete: mingw64              [     3.5 MiB  73.1K/s  0 remaining]
:: download complete in 49.44s            <     8.0 MiB   165K/s  3 files    >
:: waiting for 1 process to finish repacking repos...
$ pkgfile -s /usr/bin/paccache
msys/pacman
$ pacman -Qo paccache
/usr/bin/paccache is owned by pacman 5.1.2-2

As for how to use paccache once available, I did previously find several good links, including those posted by harrymc.

So everything is clear now, except for:

  1. The (ambiguous?) description pacman vs. pacman-contrib.

  2. Whether paccache is exactly equivalent to a fine-tuned way of replacing rm commands only.

1

paccache script is already placed in /usr/bin/paccache. It is installed by msys2 installer with pacman, default package manager in msys2/mingw-w64 toolchain. For further details see msys2-packages/pacman repository.

Biswapriyo
  • 10,831
  • 10
  • 47
  • 78