Skip to content

Holy shit... (just updated after maybe a couple weeks of not updating this computer)

Not downloaded yet
110 points62 comments
Open on Reddit
About this post
Posted
Archived
Score
110 · 100% up
Kind
Image
ID
72xtty

Author

52
posts
133
comments
8
media
View profile

63 comments

pacman hooks. This will leave the last 3 installed and the last uninstalled.

[Trigger]
Operation = Install
Operation = Upgrade
Operation = Remove
Type = Package
Target = *

[Action]
Description = Removing old cached pacakges ...
When = PostTransaction
Exec = /usr/bin/env bash -c "/usr/bin/paccache -vrk3; /usr/bin/paccache -vruk1;"

edit1: hooks should be placed at /etc/pacman.d/hooks/ and must have .hook as extension.
edit2: you can also use paccache to remove cached aur packages if you specify the directory with -c. It's slightly harder since different helpers use different folders. --dry-run is useful here while you try to figure things out.

41 points

I really wish this hook was included in pacman by default. It's something all users are going to have to add, and as you can see by these comments, not enough people know about it.

Like, having a default hook doesn't make it any less customizable. It just makes it so it fits the majority of user's needs, instead of nothing at all which is going to fit very few user's needs.

4 points

I didn't know you could add hooks to pacman. That's really neat.

2 points

sudo nano /usr/share/libalpm/hooks/mine-clear-paccache.hook
.
Then insert your hook
.
Anything else I should do/know about it? :o

1 points

Well, I just found out about paccache thanks to your post and cleared up 13.78 GiB...

22 points

And now you can't temporarily rollback a package if you need to

14 points
190nOP4 hidden

Well...I run this after pretty much every update so I didn't have a version to roll back to anyway :P

Guess I should stop running it with -k0

3 points

Well it depends on the criticality of the system. I have arch installed on my work machine so I want to be able to rollback a package if it makes my machine unstable and hinders my work. But if it's a personnal one it's totally acceptable I think.

3 points

I've had good experiences with downgrade in these cases, even when not cached locally.

1 points

Depends on whether he has btrfs snapshots. I just cd into my preupgrade or weekly snapshots and pacman -U the downgrade I need; if the package is installed but not in cache on the snapshot, just chroot and use bacman to generate a package first. Or if it breaks on boot, just boot into a prior snapshot, chroot into the broken one and then fix it that way.

Btrfs snapshots are like cheating. I hope that BTRFS either finally gets considered stable or another next gen filesystem becomes stable.

1 points

I'm on a Windows machine at work, I was curious on the options so I google "man paccache" to check out the man page and try the command when I get home. Google decides I meant to search "man package", filling the top of my search results page with pictures of gorgeous men in underwear showing off their male attributes. Turns out there's no man page, it's a script and should have searched for it in the Arch Wiki.... Lesson learned

6 points

Haha lol.

Next time you could try searching paccache(1) or paccache(8) if you knew what section it would be in. But yeah there isn't a man page in this case.

1 points

That's why you should always add "Arch" or "Arch Linux" to your search term ;)

1 points

Wouldn't it be sensible to make -rk3 a default behaviour?

1 points

It is. From the help page:

-k, --keep <num>      keep "num" of each package in the cache (default: 3).
2 points

FWIW - I have two pacman hooks that I really like, one of them is the aforementioned hook that removes old cached packages, and another updates my mirrors using reflector.

[Trigger]
Operation = Upgrade
Type = Package
Target = pacman-mirrorlist

[Action]
Description = Updating pacman-mirrorlist with reflector and removing pacnew...
When = PostTransaction
Depends = reflector
Exec = /usr/bin/env sh -c "reflector --country 'United States' --age 12 --protocol http --protocol https --sort rate --save /etc/pacman.d/mirrorlist; if [[ -f /etc/pacman.d/mirrorlist.pacnew ]]; then rm /etc/pacman.d/mirrorlist.pacnew; fi"
1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.