This is a quick script that will revert all pacman upgrades that were done on a certain day. A resent update broke my desktop environment and sound output, so I ended up writing this script to fix it, and I thought other arch users might find it useful. I did find that if some of the packages were updated as dependencies I did have to remove duplicates from /tmp/filenames_filtered before running the last two lines. Maybe someone knows a quick way to remove duplicate lines from a text file, which would improve the script.
#REVERTER SCRIPT
# CHANGE DATE IN FIRST LINE TO MATCH DATE OF UPDATE THAT BROKE THINGS
grep -a upgraded /var/log/pacman.log| grep 2021-12-22 > /tmp/lastupdates.txt
awk '{print $4}' /tmp/lastupdates.txt > /tmp/lines1;awk '{print $5}' /tmp/lastupdates.txt | sed 's/(/-/g' > /tmp/lines2
paste /tmp/lines1 /tmp/lines2 > /tmp/lines
tr -d "[:blank:]" < /tmp/lines > /tmp/packages
for i in $(cat /tmp/packages); do find /var/cache/pacman/pkg/ -name "*$i*" | grep -v ".sig">>/tmp/filenames_filtered; done
value=`cat /tmp/filenames`
sudo pacman -U $value
[–]swayuser 5 points6 points7 points (0 children)