Created
June 15, 2018 15:16
-
-
Save qub1750ul/66271e20a2ae714663b0ff7dc1b4996e to your computer and use it in GitHub Desktop.
A garbage collector for pacman
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/sh | |
# Create a database directory that | |
# ignore pacman database lock without forcefully unlock it | |
pacmanDb=/var/lib/pacman | |
noLockDb=/tmp/pacman-garbageCollector | |
mkdir -p $noLockDb/local $noLockDb/sync | |
mount --bind $pacmanDb/local $noLockDb/local | |
mount --bind $pacmanDb/sync $noLockDb/sync | |
orphanPkgs="$( pacman -Qdt | grep -Eoe '^.+\ ' )" | |
if [ -n "$orphanPkgs" ] ; then | |
pacman --noconfirm -Rsnb $noLockDb $orphanPkgs | |
fi | |
paccache -qrk 3 | |
paccache -qruk 0 | |
umount $noLockDb/* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment