mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 23:10:16 +01:00
#634: Cross platform patch scripts
Removes the need for installing gnu sed on Mac
This commit is contained in:
parent
ab85433d7f
commit
689f429c50
2 changed files with 28 additions and 3 deletions
|
@ -6,6 +6,18 @@ then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# https://stackoverflow.com/a/38595160
|
||||||
|
# https://stackoverflow.com/a/800644
|
||||||
|
if sed --version >/dev/null 2>&1; then
|
||||||
|
strip_cr() {
|
||||||
|
sed -i -- "s/\r//" "$@"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
strip_cr () {
|
||||||
|
sed -i "" "s/$(printf '\r')//" "$@"
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
nms=$1/net/minecraft/server
|
nms=$1/net/minecraft/server
|
||||||
cb=src/main/java/net/minecraft/server
|
cb=src/main/java/net/minecraft/server
|
||||||
#clean up and rebuild
|
#clean up and rebuild
|
||||||
|
@ -17,7 +29,7 @@ do
|
||||||
file="$(echo $file | cut -d. -f1).java"
|
file="$(echo $file | cut -d. -f1).java"
|
||||||
|
|
||||||
echo "Patching $file < $patchFile"
|
echo "Patching $file < $patchFile"
|
||||||
sed -i 's/\r//' "$nms/$file" > /dev/null
|
strip_cr "$nms/$file" > /dev/null
|
||||||
|
|
||||||
cp "$nms/$file" "$cb/$file"
|
cp "$nms/$file" "$cb/$file"
|
||||||
patch -d src/main/java/ "net/minecraft/server/$file" < "$patchFile"
|
patch -d src/main/java/ "net/minecraft/server/$file" < "$patchFile"
|
||||||
|
|
|
@ -5,6 +5,19 @@ then
|
||||||
echo "Please run this script again with the clean decompile sources as an argument. In most cases this will be ../work/decompile-XXXX"
|
echo "Please run this script again with the clean decompile sources as an argument. In most cases this will be ../work/decompile-XXXX"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# https://stackoverflow.com/a/38595160
|
||||||
|
# https://stackoverflow.com/a/800644
|
||||||
|
if sed --version >/dev/null 2>&1; then
|
||||||
|
strip_cr() {
|
||||||
|
sed -i -- "s/\r//" "$@"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
strip_cr () {
|
||||||
|
sed -i "" "s/$(printf '\r')//" "$@"
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
cb=src/main/java/net/minecraft/server
|
cb=src/main/java/net/minecraft/server
|
||||||
nms="$1/net/minecraft/server"
|
nms="$1/net/minecraft/server"
|
||||||
show_diff_msg=true
|
show_diff_msg=true
|
||||||
|
@ -24,8 +37,8 @@ do
|
||||||
then
|
then
|
||||||
echo "Diffing $file"
|
echo "Diffing $file"
|
||||||
fi
|
fi
|
||||||
sed -i 's/\r//' "$nms/$file"
|
strip_cr "$nms/$file" > /dev/null
|
||||||
sed -i 's/\r//' "$cb/$file"
|
strip_cr "$cb/$file" > /dev/null
|
||||||
outName=$(echo nms-patches/"$(echo $file | cut -d. -f1)".patch)
|
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")
|
patchNew=$(diff -u --label a/net/minecraft/server/$file "$nms/$file" --label b/net/minecraft/server/$file "$cb/$file")
|
||||||
if [ -f "$outName" ]
|
if [ -f "$outName" ]
|
||||||
|
|
Loading…
Reference in a new issue