summaryrefslogtreecommitdiffstats
path: root/makePatches.sh
blob: e2e1dbbc4a45f159b7b58862458f553eae3bc4f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash

if [ -z "$1" ]
then
    echo "Please run this script again with the clean decompile sources as an argument. In most cases this will be ../work/decompile-XXXX"
    exit
fi
cb=src/main/java/net/minecraft/server
nms="$1/net/minecraft/server"
show_diff_msg=true

if [ $# -ge 2 ]
then
    show_diff_msg=$2
    if [ "$show_diff_msg" = false ]
    then
        echo "Suppressing normal output. Will only output for changed or created patches."
    fi
fi

for file in $(/bin/ls $cb)
do
    if [ "$show_diff_msg" = true ]
    then
        echo "Diffing $file"
    fi
    sed -i 's/\r//' "$nms/$file"
	sed -i 's/\r//' "$cb/$file"
    outName=$(echo nms-patches/"$(echo $file | cut -d. -f1)".patch)
    patchNew=$(diff -u --label a/net/minecraft/server/$file "$nms/$file" --label b/net/minecraft/server/$file "$cb/$file")
    if [ -f "$outName" ]
    then
        patchCut=$(echo "$patchNew" | tail -n +3)
        patchOld=$(cat "$outName" | tail -n +3)
        if [ "$patchCut" != "$patchOld" ] ; then
            echo "$outName changed"
            echo "$patchNew" > "$outName"
        fi
    else
        echo "New patch $outName"
        echo "$patchNew" > "$outName"
    fi
done