Skip to content

Instantly share code, notes, and snippets.

@sickcodes
Created November 30, 2021 12:27
Show Gist options
  • Save sickcodes/37760f4380c6cf22e7b010867a646685 to your computer and use it in GitHub Desktop.
Save sickcodes/37760f4380c6cf22e7b010867a646685 to your computer and use it in GitHub Desktop.
Unattended Reinstall All Arch Linux Packages and AUR Packages
#!/bin/bash
# Author: sickcodes
# Contact: https://twitter.com/sickcodes
# Copyright: sickcodes (C) 2021
# License: GPLv3+
# reinstall all packages, unattended
# does not include any manual makepkg'ed installations
# said packages, plus any unavailable AUR packages will be listed at ~/yay_reinstall_failed.log
# you need to be a NOPASSWD sudoer
# user ALL=(ALL) NOPASSWD: ALL
native_packages (){
ALL_PACKAGES="$(sudo pacman -Qqn)"
IGNORABLES="$(grep --no-filename ^IgnorePkg /etc/pacman.* 2>/dev/null \
| sed -E -e 's/IgnorePkg[\ ]+\=[\ ]+//g')"
yes | sudo pacman -Qqn \
| grep -v "${IGNORABLES}" \
| sudo pacman -Syu - --noconfirm
}
yays (){
MANUAL_PACKAGES=($(sudo pacman -Qm -q))
for PACKAGE in "${MANUAL_PACKAGES[@]}"; do
yes | yay -S "${PACKAGE}" --noconfirm
case $? in
0 ) true
;;
1 ) tee -a ~/yay_reinstall_failed.log <<< "${PACKAGE}"
;;
esac
yes | yay -Scc --noconfirm
done
}
native_packages
yays
@Kreijstal
Copy link

but woulnd't that also install dependencies as explicitly installed packages, removing it's dependency status?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment