You are not logged in.
Hello people,
In order to remove all but the currently installed and the previously used cache, I want to create a hook for pacman (as suggested in the Arch Wiki) to run paccache -rkv2 in the PostTransaction phase.
So I have created the file /etc/pacman.d/hooks/remove_old_cache.hook in which I wrote in:
[Trigger]
Operation = Remove
Type = Package
Target = *
[Action]
Description = Keep the last cache and the currently installed.
When = PostTransaction
Exec = paccache -rvk2
However, when I do for example sudo pacman -Syu and upgrade my system, nothing about removing cache is displayed. So I think the hook doesn't work. Is there anything wrong with it?
Last edited by linux_dream (2017-03-02 19:56:28)
Offline
Doesn't Operation = Remove mean that the hook will only be triggered when you remove a package?
Offline
Operation = Remove
I think that is only triggered by pacman -R .
Try removing something small that's easy to re-install to verify if i'm correct.
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
Doesn't Operation = Remove mean that the hook will only be triggered when you remove a package?
That makes sense, thanks a lot. I added the Operation = Install and Operation = Upgrade lines. I'll keep you up to date with how this goes.
Offline
There is an "Upgrade" operation you can specify if you want this to run during an upgrade. You can specify multiple operations (one per line) if you want the hook to be triggered by multiple scenarios.
EDIT: Too slow
Last edited by WorMzy (2017-03-01 14:43:23)
Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD
Making lemonade from lemons since 2015.
Online
Ok I get
:: Running post-transaction hooks...
(1/2) Keep the last cache and the currently installed.
call to execv failed (No such file or directory)
I modified paccache to /usr/bin/paccache. I'll let you know how it goes.
Edit: Works fine! Thank you all.
Last edited by linux_dream (2017-03-01 19:36:44)
Offline
paccache -rvk2
Are the flags correct?
Last edited by philo (2017-03-01 20:14:58)
Offline
paccache -rvk2
Are the flags correct?
Hmm you're right, I think it should be paccache -vk2. The above command returned no error though.
Offline
Very strange. When I type
paccache -dvk2
in a terminal, I get that there's no candidate packages found for pruning which is normal because I accidentally removed all the cache.
Now when putting
Exec = paccache -vk2
in the hook file, I get:
(2/5) Keep the last cache and the currently installed.
==> ERROR: no operation specified (use -h for help)
error: command failed to execute correctly
So in the hook file the command fails to work? Any idea why?
Offline
So in the hook file the command fails to work? Any idea why?
because you didn't specify an operation...
Offline
linux_dream wrote:So in the hook file the command fails to work? Any idea why?
because you didn't specify an operation...
Ah I thought -k was an operation. Ok so -rvk2 (remove operation, verbose, keep the last 2 cache).
Edit: But this brings out the post of Philo who asked whether these flags were correct. Are they?
Last edited by linux_dream (2017-03-02 09:16:30)
Offline
You may get some inspiration from the examples of commands given for paccache in:
Offline
You may get some inspiration from the examples of commands given for paccache in:
Done. So what I had done, i.e. paccache -rvk2 looks fine to me. I just tried paccache -rvk 2 (with a space) and this yielded the same result. So I still can't find anything wrong now. Am I missing something?
Offline
Can you post the entire updated hook?
Here is a hook I created to do something similar and it works:
[Trigger]
Operation = Upgrade
Operation = Install
Operation = Remove
Type = Package
Target = *
[Action]
Description = Cleaning pacman cache...
When = PostTransaction
Exec = /usr/bin/paccache -r
Last edited by rdeckard (2017-03-02 13:19:37)
Offline
Can you post the entire updated hook?
Here is a hook I created to do something similar and it works:
[Trigger] Operation = Upgrade Operation = Install Operation = Remove Type = Package Target = * [Action] Description = Cleaning pacman cache... When = PostTransaction Exec = /usr/bin/paccache -r
Mine also works, hence my question to Philo as to why he asks whether the flags are correct and whether I'm missing something.
Here it goes:
[Trigger]
Operation = Remove
Operation = Install
Operation = Upgrade
Type = Package
Target = *
[Action]
Description = Keep the last cache and the currently installed.
When = PostTransaction
Exec = /usr/bin/paccache -rvk2
Offline
@linux_dream
Sorry for bringing confusion since you have now something that works well.
Offline
Oh ok, edit the thread title to mark as [Solved]. I'm going to link this thread to that tip in the wiki since we now have two examples posted.
Offline
Thanks for all guys! Done rdeckard.
Offline