-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdo
140 lines (123 loc) · 3.83 KB
/
do
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
. release
name=HEMA
targetname="$MOD_NAME-$MOD_VERSION"
moddir=./target/exploded/$MOD_NAME
extension=""
case "$OSTYPE" in
linux*) system="lin"
;;
darwin*)
system="mac"
;;
*) system="win"
extension=".exe"
;;
esac
if [[ "$PROCESSOR_ARCHITECTURE" == "AMD64" && -f "./main/bin/weidu-$system-amd64$extnesion" ]]; then
system="$system-amd64"
else
system="$system-x86"
fi
case "$#" in
0)
eval "$0 package"
exit $?
;;
*)
case "$1" in
package)
echo "Copying files..."
rm -rf ./target
mkdir -p ./target/exploded
cp -a ./main/src/ "$moddir"
sed -e "s:BACKUP ~$name/backup~:BACKUP ~$MOD_NAME/backup~:g" \
-e "s:VERSION ~SNAPSHOT~:VERSION ~$MOD_VERSION~:g" \
-e "s?AUTHOR ~polymorphedsquirrel~?AUTHOR ~$MOD_AUTHORS~?g" \
./main/src/$name.tp2 > $moddir/$MOD_NAME.tp2
if [ ! "$MOD_NAME" == "$name" ]; then
rm $moddir/$name.tp2
fi
case "$#" in
1)
echo "Packaging $system..."
cp "./main/bin/weidu-$system$extension" "./target/exploded/setup-$MOD_NAME$extension"
tar -czf "./target/$targetname-$system.tgz" -C "./target/exploded" .
;;
*)
skip=1
for arch in $@; do
if [[ $skip == 0 ]]; then
rm -f ./target/exploded/setup-*
case $arch in
win*)
cp ./main/bin/weidu-$arch.exe "./target/exploded/setup-$MOD_NAME.exe"
;;
*)
cp ./main/bin/weidu-$arch "./target/exploded/setup-$MOD_NAME"
;;
esac
echo "Packaging $arch..."
tar -czf "./target/$targetname-$arch.tgz" -C ./target/exploded .
fi
skip=0
done
esac
;;
testinstall)
if [ ! -d "target/exploded" ]; then
./do package
if [ ! $? -eq 0 ]; then
exit $?
fi
fi
for GAMEDIR in "test/Baldur's Gate" "test/Baldur's Gate EE" "test/Siege of Dragonspear" "test/Baldur's Gate 2" "test/Baldur's Gate 2 EE" "test/Icewind Dale" "test/Icewind Dale EE"; do
if [ -d "$GAMEDIR" ]; then
echo "Installing in $GAMEDIR"
if [ -d "$GAMEDIR/$MOD_NAME" ]; then
rm -rf "$GAMEDIR/$MOD_NAME.bak"
if [ -f "$GAMEDIR/setup-$MOD_NAME$extension" ]; then
cd "$GAMEDIR"
"./setup-$MOD_NAME$extension" --uninstall
cd -
fi
mv "$GAMEDIR/$MOD_NAME" "$GAMEDIR/$MOD_NAME.bak"
fi
cp -a "$moddir" "$GAMEDIR"
cp -a "./main/bin/weidu-$system$extension" "$GAMEDIR/setup-$MOD_NAME$xtension"
fi
done
;;
test)
for GAMEDIR in "test/Baldur's Gate" "test/Baldur's Gate EE" "test/Siege of Dragonspear" "test/Baldur's Gate 2" "test/Baldur's Gate 2 EE" "test/Icewind Dale" "test/Icewind Dale EE"; do
if [[ tested!=1 && -d "$GAMEDIR" ]]; then
if [[ -f "$GAMEDIR/setup-json.tp2" ]]; then
cd "$GAMEDIR"
"./setup-json$extension" --uninstall
cd -
fi
mkdir "$GAMEDIR/json"
cp test/src/setup-json.tp2 "$GAMEDIR"
cp test/src/json-input.tpa "$GAMEDIR"
cp main/src/json.tpa main/src/stringutil.tpa "$GAMEDIR/json"
cp main/bin/weidu-$system$extnesion "$GAMEDIR/setup-json$extension"
cd "$GAMEDIR"
"./setup-json$extension" --yes
if [[ "$?" != 0 ]]; then
cd -
exit $?
fi
"./setup-json$extension" --uninstall
cd -
break
fi
done
;;
clean)
rm -rf ./target
;;
*)
echo "Usage: $0 [-h|clean|package|testinstall]"
esac
;;
esac