-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplyPatches.sh
46 lines (39 loc) · 1.05 KB
/
applyPatches.sh
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
44
45
46
#!/bin/bash
# Script heavily based on CraftBukkit's applyPatches.sh:
# https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/applyPatches.sh
if [ -z "$1" ]
then
echo "Missing clean decompiled sources argument. The clean directory should have been generated by setupWorkspace.sh under 'decompile'"
exit
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
clean="$1"
modded="src/main/java"
# Reset Equilinox-exclusive source directories
for file in $modded/**/
do
if [[ ! $file = src/main/java/wtf/* ]]
then
rm -rf $file
mkdir -p $file
fi
done
for file in equilinox-patches/**/*
do
patchFile="$file"
file="$(echo ${file#"equilinox-patches/"} | cut -d. -f1).java"
echo "Patching $file with $patchFile"
strip_cr "$patchFile" > /dev/null
cp "$clean/$file" "$modded/$file"
patch -d $modded "$file" < "$patchFile"
done