forked from OpenKore/openkore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makedist.sh
executable file
·238 lines (213 loc) · 5.81 KB
/
makedist.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
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#!/bin/bash
# This script creates a source tarball for OpenKore.
PACKAGE=openkore
VERSION=`date +"%Y-%m-%d"`
DIRS=(.
src
src/Actor
src/Actor/Slave
src/AI
src/AI/Slave
src/auto/XSTools
src/auto/XSTools/darwin/include
src/auto/XSTools/misc
src/auto/XSTools/OSL
src/auto/XSTools/OSL/doc
src/auto/XSTools/OSL/IO
src/auto/XSTools/OSL/Net
src/auto/XSTools/OSL/Net/Unix
src/auto/XSTools/OSL/Net/Win32
src/auto/XSTools/OSL/test/unit
src/auto/XSTools/OSL/Threading
src/auto/XSTools/OSL/Threading/Unix
src/auto/XSTools/OSL/Threading/Win32
src/auto/XSTools/PaddedPackets
src/auto/XSTools/PaddedPackets/Algorithms
src/auto/XSTools/PathFinding
src/auto/XSTools/Translation
src/auto/XSTools/unix
src/auto/XSTools/utils
src/auto/XSTools/utils/c-bindings
src/auto/XSTools/utils/perl
src/auto/XSTools/utils/unix
src/auto/XSTools/utils/win32
src/auto/XSTools/win32
src/Base
src/Base/Ragnarok
src/Base/Server
src/Base/WebServer
src/build
src/Bus
src/Bus/Server
src/deps
src/deps/Carp
src/deps/Class
src/deps/Class/Accessor
src/deps/Class/Data
src/deps/Data/YAML
src/deps/Devel
src/deps/Devel/StackTrace
src/deps/Exception
src/deps/Exception/Class
src/deps/File
src/deps/JSON
src/deps/List
src/deps/Text
src/deps/Tie
src/doc
src/doc/data
src/doc/srcdoc
src/Interface
src/Interface/Console
src/Interface/Win32
src/Interface/Wx
src/Interface/Wx/DockNotebook
src/Interface/Wx/List
src/Interface/Wx/List/ItemList
src/Interface/Wx/StatView
src/InventoryList
src/MediaServer
src/Network
src/Network/Receive
src/Network/Receive/idRO
src/Network/Receive/iRO
src/Network/Receive/kRO
src/Network/Send
src/Network/Send/idRO
src/Network/Send/iRO
src/Network/Send/kRO
src/Network/XKore2
src/po
src/Poseidon
src/scons-local-3.1.2
src/scons-local-3.1.2/scons-local-3.1.2
src/scons-local-3.1.2/scons-local-3.1.2/SCons
src/scons-local-3.1.2/scons-local-3.1.2/SCons/compat
src/scons-local-3.1.2/scons-local-3.1.2/SCons/Node
src/scons-local-3.1.2/scons-local-3.1.2/SCons/Platform
src/scons-local-3.1.2/scons-local-3.1.2/SCons/Scanner
src/scons-local-3.1.2/scons-local-3.1.2/SCons/Script
src/scons-local-3.1.2/scons-local-3.1.2/SCons/Tool
src/scons-local-3.1.2/scons-local-3.1.2/SCons/Tool/clangCommon
src/scons-local-3.1.2/scons-local-3.1.2/SCons/Tool/docbook
src/scons-local-3.1.2/scons-local-3.1.2/SCons/Tool/MSCommon
src/scons-local-3.1.2/scons-local-3.1.2/SCons/Tool/packaging
src/scons-local-3.1.2/scons-local-3.1.2/SCons/Variables
src/Task
src/test
src/test/data
src/test/data/child
src/test/Utils
src/Utils
src/Utils/StartupNotification
)
PACKAGEDIR=$PACKAGE-$VERSION
if [[ "$1" == "--bin" ]]; then
BINDIST=1
if [[ "$2" == "-o" ]]; then
PACKAGEDIR="$3"
fi
elif [[ "$1" == "--semibin" ]]; then
SEMIBINDIST=1
PACKAGEDIR="$2"
if [[ "$PACKAGEDIR" = "" ]]; then
echo "No output folder given. See --help"
exit 1
elif [[ ! -d "$PACKAGEDIR" ]]; then
echo "The output folder does not exist. See --help"
exit 1
fi
elif [[ "$1" == "--help" ]]; then
echo "makedist.sh [ --bin | --semibin DIR ]"
echo " --bin [ -o DIR ] Create a binary distribution archive, including the binaries,"
echo " confpack and tablepack."
echo " --semibin DIR Create a binary distribution, excluding binaries, confpack and"
echo " tablepack. Files will be copied to DIR."
exit 1
else
echo "unknown option '$1'"
echo "Try 'makedist.sh --help' for more information."
exit 1
fi
if [[ "$BINDIST" == "1" ]]; then
for F in start.exe wxstart.exe NetRedirect.dll XSTools.dll start-poseidon.exe; do
if [[ ! -f "$F" ]]; then
echo "Please put $F in the current folder."
exit 1
fi
done
fi
ADDITIONAL=()
if [[ "$BINDIST" != "1" ]]; then
ADDITIONAL[${#ADDITIONAL[@]}]=SConstruct
ADDITIONAL[${#ADDITIONAL[@]}]=SConscript
ADDITIONAL[${#ADDITIONAL[@]}]=Distfiles
ADDITIONAL[${#ADDITIONAL[@]}]=makedist.sh
fi
export GZIP=--best
export BZIP2=-9
# Bail out on error
err() {
if [ "x$1" != "x" ]; then
echo "*** Error: $1"
else
echo "*** Error"
fi
exit 1
}
# Preparation: create the dist folder
rm -rf "$PACKAGEDIR" || err
mkdir "$PACKAGEDIR" || err
mkdir "$PACKAGEDIR/control" || err
mkdir "$PACKAGEDIR/fields" || err
# Copy the files to the dist folder
process() {
local TARGET="$PACKAGEDIR/$1/"
local IFS=$'\n'
local FILES=`cat "$1/Distfiles" 2>/dev/null | sed 's/\r//g'`
echo "# Processing $1 :"
if ! [ -d "$TARGET" ]; then
mkdir -p "$TARGET" || err
fi
for F in "${ADDITIONAL[@]}"; do
if [ -f "$1/$F" ]; then
echo " copying $1/$F"
cp "$1/$F" "$TARGET" || err
fi
done
for F in ${FILES[@]}; do
echo " copying $1/$F"
cp "$1/$F" "$TARGET" || err
done
}
for D in ${DIRS[@]}; do
process "$D"
done
#######################################
# Copy the confpack and tablepack files to the distribution's folder
cp -v control/*.txt "$PACKAGEDIR/control/" || err
cp -v fields/*.gz "$PACKAGEDIR/fields/" || err
cp -vr fields/tools "$PACKAGEDIR/fields/" || err
cp -vr tables "$PACKAGEDIR/" || err
# Convert openkore.pl to Unix line format, otherwise Unix users can't execute it directly.
perl src/build/dos2unix.pl "$PACKAGEDIR/openkore.pl" || err
perl src/build/unix2dos.pl "$PACKAGEDIR/README.md" || err
if [[ "$BINDIST" == "1" ]]; then
# Create binary zipfile
cp -v XSTools.dll NetRedirect.dll start-poseidon.exe "$PACKAGEDIR/" || err
# Win32 binary
cp -v start.exe "$PACKAGEDIR/" || err
zip -9r "$PACKAGE-$VERSION-win32.zip" "$PACKAGEDIR" || err
echo "$PACKAGE-$VERSION-win32.zip created"
# Win32 Wx binary
cp -v wxstart.exe "$PACKAGEDIR/" || err
rm -vf "$PACKAGEDIR/start.exe"
zip -9r "$PACKAGE-$VERSION-win32_WX.zip" "$PACKAGEDIR" || err
echo "$PACKAGE-$VERSION-win32_wx.zip created"
elif [[ "$SEMIBINDIST" == "1" ]]; then
# Create tarball
echo "Creating distribution archive..."
tar --bzip2 -cf "$PACKAGEDIR.tar.bz2" "$PACKAGEDIR" || err
echo "$PACKAGEDIR.tar.bz2"
fi
rm -rf "$PACKAGEDIR"