dotfiles/util/usr/bin/merge-pacnews

22 lines
460 B
Text
Raw Normal View History

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