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