Commits

Vincent authored and md_5 committed 689f429c508
#634: Cross platform patch scripts

Removes the need for installing gnu sed on Mac
No tags

applyPatches.sh

Modified
1 1 #!/bin/bash
2 2
3 3 if [ -z "$1" ]
4 4 then
5 5 echo "Please run this script again with the clean decompile sources as an argument. In most cases this will be ../work/decompile-XXXX"
6 6 exit
7 7 fi
8 8
9 +# https://stackoverflow.com/a/38595160
10 +# https://stackoverflow.com/a/800644
11 +if sed --version >/dev/null 2>&1; then
12 + strip_cr() {
13 + sed -i -- "s/\r//" "$@"
14 + }
15 +else
16 + strip_cr () {
17 + sed -i "" "s/$(printf '\r')//" "$@"
18 + }
19 +fi
20 +
9 21 nms=$1/net/minecraft/server
10 22 cb=src/main/java/net/minecraft/server
11 23 #clean up and rebuild
12 24 rm -rf $cb
13 25 mkdir -p $cb
14 26 for file in $(/bin/ls nms-patches)
15 27 do
16 28 patchFile="nms-patches/$file"
17 29 file="$(echo $file | cut -d. -f1).java"
18 30
19 31 echo "Patching $file < $patchFile"
20 - sed -i 's/\r//' "$nms/$file" > /dev/null
32 + strip_cr "$nms/$file" > /dev/null
21 33
22 34 cp "$nms/$file" "$cb/$file"
23 35 patch -d src/main/java/ "net/minecraft/server/$file" < "$patchFile"
24 36 done

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut