dotfiles/util/usr/bin/merge-pacnews

21 lines
455 B
Text
Raw Permalink Normal View History

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