-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
genredist.sh
executable file
·90 lines (73 loc) · 2.26 KB
/
genredist.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
basedir=$(pwd)
autooldir=$basedir/AutoOL
workdir=$basedir/work
OLAUNCHER_VERSION=1.7.3_01
AUTOOL_VERSION=0.1.0
finalname="olauncher-$OLAUNCHER_VERSION-redist.jar"
if [ ! -e "$autooldir" ]; then
echo "The AutoOL directory could not be found. Please run 'git submodule update --init'"
exit 1
fi
if [ ! -e "$workdir/redist" ]; then
mkdir -pv "$workdir/redist"
fi
cd "$workdir/redist"
if [ ! -e "jbsdiff" ]; then
echo jbsdiff not found! Downloading...
if ! git clone https://github.com/malensek/jbsdiff.git; then
echo "Error cloning jbsdiff repository"
exit 1
fi
pushd "jbsdiff"
git checkout 51b6981d97b4cf386069481707394f37c537b1d5
mvn clean package -Djdk.version=8
mvnresult="$?"
popd
if [ "$mvnresult" != "0" ]; then
echo "Error building jbsdiff"
exit 1
fi
fi
if [ ! -e "$autooldir/target" ]; then
echo "AutoOL target directory not found, compiling..."
pushd "$autooldir"
mvn clean package
mvnresult="$?"
popd
if [ "$mvnresult" != "0" ]; then
echo "Error building AutoOL"
exit 1
fi
fi
echo "Generating patch..."
if ! java -jar "jbsdiff/target/jbsdiff-1.0.jar" diff "../launcher.jar" "$basedir/olauncher/target/olauncher-${OLAUNCHER_VERSION}.jar" "launcher.patch" || [ ! -e "launcher.patch" ]; then
echo "Error creating patch"
exit 1
fi
echo "Generating properties..."
(
cat - << EOP
origurl=https://launcher.mojang.com/v1/objects/eabbff5ff8e21250e33670924a0c5e38f47c840b/launcher.jar
orighash=$(sha1sum "../launcher.jar" | cut -d ' ' -f 1)
origname=launcher.jar
origsz=$(du -b "../launcher.jar" | cut -f 1)
patchres=/launcher.patch
patchsz=$(du -b "launcher.patch" | cut -f 1)
finalhash=$(sha1sum "$basedir/olauncher/target/olauncher-${OLAUNCHER_VERSION}.jar" | cut -d ' ' -f 1)
finalname=patched.jar
finalsz=$(du -b "$basedir/olauncher/target/olauncher-${OLAUNCHER_VERSION}.jar" | cut -f 1)
interactive=true
#mainClass=
EOP
) > "patch.properties"
echo "Inserting patch and properties into jar..."
cp "$autooldir/target/AutoOL-${AUTOOL_VERSION}.jar" "$finalname"
jar -uf "$finalname" "launcher.patch" "patch.properties"
jarres="$?"
if [ "$jarres" != "0" ]; then
echo "jar returned nonzero exit status $jarres"
exit 1
fi
mv "$finalname" "$basedir/$finalname"
echo "Redistributable created with name $finalname"