aboutsummaryrefslogtreecommitdiffstats
path: root/util/usr/bin/merge-pacnews
blob: 019f44607fce1989b0ffdb4f766e87ca5e8b389c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/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