dotfiles/util/usr/bin/merge-pacnews

21 lines
455 B
Text
Raw Normal View History

2019-01-10 02:13:54 -08:00
#!/usr/bin/env bash
files=$(find /etc -type f -name '*.pacnew')
2019-01-24 01:22:12 -08:00
for pacnew in $files; do
2019-01-10 02:13:54 -08:00
unprefixed=${pacnew%.pacnew}
2019-01-24 01:22:12 -08:00
if [[ ! -e $unprefixed ]]; then continue; fi
2019-01-10 02:13:54 -08:00
emacs -eval "(emerge-files nil \"$unprefixed\" \"$pacnew\" \"$unprefixed\")"
otime=$(stat -c %Y "$unprefixed")
ntime=$(stat -c %Y "$pacnew")
2019-01-24 01:22:12 -08:00
if [[ $otime -gt $ntime ]]; then
2019-01-10 02:13:54 -08:00
rm -v "$pacnew"
else
echo "Skipping removal of $pacnew"
fi
done