-
Notifications
You must be signed in to change notification settings - Fork 2
/
pack.bash
102 lines (81 loc) · 2.26 KB
/
pack.bash
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
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash
echo "-------------------------------------------------------------------------"
echo " Packing script for Minecraft mod \"Jaffas and More!\" and \"monnef core\""
echo " Created by monnef"
echo "-------------------------------------------------------------------------"
echo
current="$(readlink -f $(dirname "$0"))"
combined_jar="build/libs/combined.jar"
output_dir="jar_output"
dir_all="$output_dir/all"
dir_core="$output_dir/core"
dir_jaffas="$output_dir/jaffas"
current_phase=""
function ensureDir {
if [ \! -d "$1" ]; then
echo "Creating \"$1\"."
mkdir -p "$1"
fi
}
function printStart {
current_phase="$1"
echo "$current_phase ... "
}
function printDone {
echo "$current_phase ... done"
}
if [ \! -f "$combined_jar" ]; then
echo "Combined jar is missing."
exit 1
fi
printStart "Version parsing"
mod_version=`bash get_mod_version.bash`
core_version=`bash get_version.bash`
printDone
echo "mod version: ${mod_version}, core version: ${core_version}"
rm -fr "./$output_dir"
ensureDir "$output_dir"
ensureDir "$dir_all"
ensureDir "$dir_core"
ensureDir "$dir_jaffas"
printStart "Unpacking jar"
unzip -q "$combined_jar" -d "$dir_all"
printDone
printStart "Categorizing directories"
cd "$current"
if [ -d "$dir_all/assets/monnef core" ]; then
ensureDir "$dir_core/assets"
mv "$dir_all/assets/monnef core" "$dir_core/assets"
fi
mv "$dir_all/assets" "$dir_jaffas"
# remove soft APIs
rm -fr "$dir_all/mcp"
# APIs
mv "$dir_all/cofh" "$dir_core"
mv "$dir_all/forestry" "$dir_jaffas"
mv "$dir_all/powercrystals" "$dir_jaffas"
# mostly my classes
ensureDir "$dir_core/monnef"
mv "$dir_all/monnef/core" "$dir_core/monnef"
mv "$dir_all/monnef/external" "$dir_core/monnef"
mv "$dir_all/monnef" "$dir_jaffas"
# rest
mv "$dir_all"/* "$dir_jaffas"
printDone
printStart "Creating core manifest"
dir_core_manifest="$dir_core/META-INF"
ensureDir "$dir_core_manifest"
echo -e 'Manifest-Version: 1.0\nFMLCorePlugin: monnef.core.MonnefCorePlugin\nFMLCorePluginContainsFMLMod: yeah\n' > "$dir_core_manifest/MANIFEST.MF"
printDone
printStart "Packing core"
cd "$current"
cd "$dir_core"
zip -q -9r "../monnef_core_${core_version}.jar" ./*
cd "$current"
printDone
printStart "Packing mod"
cd "$current"
cd "$dir_jaffas"
zip -q -9r "../jaffas_${mod_version}.jar" ./*
cd "$current"
printDone