Package Details: paccache-hook 1.2.0-1

Git Clone URL: https://aur.archlinux.org/paccache-hook.git (read-only, click to copy)
Package Base: paccache-hook
Description: A configurable hook to cleanup the pacman package cache using paccache
Upstream URL: None
Keywords: cleanup hook paccache pacman
Licenses: BSD
Conflicts: pacman-cleanup-hook
Submitter: Skycoder42
Maintainer: Skycoder42
Last Packager: Skycoder42
Votes: 47
Popularity: 2.08
First Submitted: 2019-03-23 10:57 (UTC)
Last Updated: 2024-09-09 18:45 (UTC)

Pinned Comments

Skycoder42 commented on 2019-03-23 11:00 (UTC)

This packages was inspired by pacman-cleanup-hook and builds on top of it by making the hook configurable. For a basic, non-configurable cleanup, check out that one!

Latest Comments

1 2 Next › Last »

Skycoder42 commented on 2024-09-09 18:47 (UTC)

Hi everyone,

I updated the script to be more resiliant. It now expects arrays for all additional parameters and sets the --min-mtime "14 days ago" by default.

kageyama commented on 2024-08-28 03:16 (UTC) (edited on 2024-08-28 03:17 (UTC) by kageyama)

@bhe69 Thanks for the workaround. I won't be able to test it as it turns out i am runnning out of space so i ended up using installed_keep=0.

For your question on How did you get the "debug output" of ./paccache-hook.sh ?,

  1. I looked into this pkgfile for how/what was it installing.https://aur.archlinux.org/cgit/aur.git/tree/paccache-hook.sh?h=paccache-hook
  2. So it was installing a hook and .sh. https://aur.archlinux.org/cgit/aur.git/tree/paccache-hook.sh?h=paccache-hook
  3. looked into .sh file and it was sourcing the .conf file.
  4. So i copied .sh and .conf file into my home directory, changed .sh file to read .conf from my home directory and added set -x at start in .sh file. https://stackoverflow.com/questions/36273665/what-does-set-x-do

bhe69 commented on 2024-08-27 21:40 (UTC)

@kageyama thanks for the analysis. Out of interest: How did you get the "debug output" of ./paccache-hook.sh ?

Looking into the info document of date and time I found a workaround: Instead of using "14 days ago" we can use "-14 days". The fuzzy analysis of time also accepts "-14days". No spaces, no problems.

uninstalled_extra_args=--min-mtime=-14days

works like a charm :-)

kageyama commented on 2024-08-09 02:55 (UTC) (edited on 2024-08-13 20:07 (UTC) by kageyama)

@bhe69, you are right. I have the same config and its not working.

uninstalled_extra_args="'--min-mtime=14 days ago'"

This is silently failing. This is what gets ran. ->

[phoenix@ArchLinux ~]$ paccache -duk0 \'--min-mtime=14 days ago\'
==> no candidate packages found for pruning

This is how it should behave actually ->

[phoenix@ArchLinux ~]$ paccache -duk0 '--min-mtime=14 days ago'

==> finished dry run: 994 candidates (disk space saved: 5.21 GiB)

The problem is that, uninstalled_extra_args="--min-mtime=14 days ago" needs to passed as a single string, but if we quote it ourselves like this uninstalled_extra_args="'--min-mtime=14 days ago'" , that quotation (') gets preserved and gets passed as string to pacache command. It can be seen here ->

[phoenix@ArchLinux ~]$ ./paccache-hook.sh 
+ . /home/phoenix/paccache-hook.conf
++ extra_args=-v
++ cache_dirs=()
++ installed=true
++ installed_keep=3
++ installed_move_to=
++ uninstalled=true
++ uninstalled_keep=0
++ uninstalled_extra_args=''\''--min-mtime=14 days ago'\'''
++ uninstalled_move_to=
+ paccache -duk0 -v ''\''--min-mtime=14' days 'ago'\'''
==> no candidate packages found for pruning

But if we don't quote it and keep it like this uninstalled_extra_args="--min-mtime=14 days ago", then it gets passed as split arguments, this is what gets ran ->

[phoenix@ArchLinux ~]$ ./paccache-hook.sh 
+ . /home/phoenix/paccache-hook.conf
++ extra_args=-v
++ cache_dirs=()
++ installed=true
++ installed_keep=3
++ installed_move_to=
++ uninstalled=true
++ uninstalled_keep=0
++ uninstalled_extra_args='--min-mtime=14 days ago'
++ uninstalled_move_to=
+ paccache -duk0 -v --min-mtime=14 days ago
==> no candidate packages found for pruning

In BOTH cases, paccache is failing silently.


https://aur.archlinux.org/cgit/aur.git/tree/paccache-hook.sh?h=paccache-hook#n25 needs to contain either "$uninstalled_extra_args" or array expansion or maybe the developer knows someway.

bhe69 commented on 2024-08-08 21:06 (UTC)

@escorares yes, but I also have uninstalled_keep=0 and my issue are the uninstalled packages.

escorares commented on 2024-07-29 15:19 (UTC)

@bhe69,

Your config has installed_keep=2.

bhe69 commented on 2024-05-07 21:18 (UTC) (edited on 2024-05-07 21:19 (UTC) by bhe69)

For me removal of uninstalled packages is not working. Can anybody give me some pointers what I'm doing wrong?

I set up paccache-hook.conf as follows:

[bhe@box ~]$ cat /etc/paccache-hook.conf 
extra_args=-v
cache_dirs=()

installed=true
installed_keep=2
installed_extra_args=
installed_move_to=

uninstalled=true
uninstalled_keep=0
uninstalled_extra_args="'--min-mtime=14 days ago'"
uninstalled_move_to=

Alsa-plugins was uninstalled more than 14 days ago, and still is uninstalled: [2024-04-16T22:57:10+0200] [ALPM] removed alsa-plugins (1:1.2.7.1-2)

[bhe@box ~]$ sudo pacman -Q alsa-plugins
error: package 'alsa-plugins' was not found

Still the package file is in cache, even though mtime is way more than "14 days ago":

[bhe@box ~]$ stat /var/cache/pacman/pkg/alsa-plugins-1\:1.2.7.1-2-x86_64.pkg.tar.zst
  File: /var/cache/pacman/pkg/alsa-plugins-1:1.2.7.1-2-x86_64.pkg.tar.zst
  Size: 89425       Blocks: 176        IO Block: 4096   regular file
Device: 1,10    Inode: 562135      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2023-11-06 23:12:07.899236660 +0100
Modify: 2023-03-03 10:08:08.000000000 +0100
Change: 2023-11-06 23:12:03.082474118 +0100
 Birth: 2023-11-06 23:12:03.029139722 +0100

Has anybody an idea why this is not working?

kageyama commented on 2024-01-03 19:06 (UTC) (edited on 2024-01-03 19:10 (UTC) by kageyama)

I lost cache of uninstalld package because of uninstalled_keep=0 and even though i read the comment first, i didn't know any way to prevent it.

as mentioned by @archz, it would be nice to have those as defaults. i personally liked @escorares args, as it would remove cache of uninstalld package after 30 days.

setting uninstalled_keep=1 wil mean the package will be never removed unless explicitly done.

escorares commented on 2023-09-14 18:04 (UTC) (edited on 2023-09-14 18:06 (UTC) by escorares)

I personally configured paccache-hook.conf so that if I change my mind and install a package back, it doesn't have to be downloaded again if 30 days haven't passed.

uninstalled_extra_args="'--min-mtime=30 days ago'"

uninstalled_keep=0 can stay since

  --min-atime <time>, --min-mtime <time>
      Keep packages with an atime/mtime that is not older than the
      time given, **even if this means keeping more than specified
      through the --keep option.** Accepts arguments according to
      info "Date input formats", e.g.  30 days ago.

archz commented on 2023-08-20 02:21 (UTC) (edited on 2023-08-20 04:59 (UTC) by archz)

This is great, thank you!

I'd like to offer two suggestions for consideration (in light of a mistake I made):

1) set default uninstalled_keep=1 -> It's safer than 0. The user may need to reinstall a package from their cache in the event of an erroneous uninstall.

2) set default extra_args=-v -> The hook runs immediately after being installed, and may remove unexpected packages (as it did for me). With verbose logging, the user can easily determine what was removed. I see another user below mentioned they like verbosity off, but it's easier to remove the flag than it is to deal with lost info from a silent execution.

Thanks!