1 |
root |
1.1 |
#!/bin/bash |
2 |
|
|
|
3 |
root |
1.8 |
# this gem of a hack gathers all files required by the client for the platform |
4 |
root |
1.4 |
# by deep magic, it works on osx, linux and windows. on MY osx, linux |
5 |
|
|
# and windows, that is. |
6 |
|
|
|
7 |
root |
1.1 |
STRIP="strip" |
8 |
|
|
LIBEXT=so |
9 |
|
|
LIB0=so.? |
10 |
|
|
SO=so |
11 |
|
|
SYSLIB=/usr/lib |
12 |
|
|
MAKE=make |
13 |
|
|
ARCHNAME=x86 |
14 |
root |
1.4 |
GENPACK_ENVVARS="LD_LIBRARY_PATH=." |
15 |
root |
1.1 |
|
16 |
|
|
umask 022 |
17 |
|
|
|
18 |
|
|
if [ "$(uname -s)" = CYGWIN_NT-5.0 ]; then |
19 |
|
|
. ~/.setenv |
20 |
|
|
|
21 |
|
|
OS=windows |
22 |
root |
1.7 |
URLADER=windows-x86 |
23 |
root |
1.1 |
unset PANGO |
24 |
|
|
PERL=/c/perl/bin/perl |
25 |
|
|
MAKE=nmake |
26 |
|
|
SYSLIB=/c/gtk/bin |
27 |
|
|
LIBEXT=dll |
28 |
|
|
LIB0=dll |
29 |
|
|
SO=dll |
30 |
|
|
STRIP=":" # stripping the perl library kills it, and apparently, everythignis always stripped |
31 |
|
|
|
32 |
|
|
# fontconfig apparently ignores env vars and always looks at ./etc/fonts/fonts.conf, |
33 |
|
|
# but only if . isn't actually called bin or lib. hope for the best. |
34 |
|
|
GENPACK_ENVVARS="FONTCONFIG_PATH=pm/Deliantra/Client/private/resources/fonts FONTCONFIG_FILE=fonts.conf" |
35 |
|
|
|
36 |
|
|
pango-querymodules() { |
37 |
|
|
/c/gtk/bin/pango-querymodules # empty output usually |
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
elif [ "$(uname -s)" = Darwin ]; then |
41 |
|
|
OS=darwin |
42 |
root |
1.6 |
URLADER=darwin-x86 |
43 |
root |
1.1 |
PANGO=1.6.0 |
44 |
|
|
PERL=/opt/local/bin/perl |
45 |
root |
1.4 |
GENPACK_ENVVARS="DYLD_LIBRARY_PATH=." |
46 |
root |
1.1 |
|
47 |
|
|
SYSLIB=/opt/local/lib |
48 |
|
|
LIB0=dylib |
49 |
|
|
SO=bundle |
50 |
|
|
STRIP="strip -x" |
51 |
|
|
elif [ $(arch) = i686 ]; then |
52 |
|
|
OS=linux |
53 |
root |
1.6 |
URLADER=linux-x86 |
54 |
root |
1.1 |
PANGO=1.5.0 |
55 |
|
|
PERL=/usr/bin/perl |
56 |
|
|
else |
57 |
|
|
OS=linux |
58 |
root |
1.6 |
URLADER=linux-amd64 |
59 |
root |
1.1 |
PANGO=1.5.0 |
60 |
|
|
PERL=/usr/bin/perl |
61 |
|
|
ARCHNAME=amd64 |
62 |
|
|
fi |
63 |
|
|
|
64 |
|
|
export DIST="$(pwd)/dist/$OS-$ARCHNAME" |
65 |
|
|
|
66 |
|
|
rm -rf "$DIST" |
67 |
|
|
mkdir -p "$DIST" |
68 |
|
|
|
69 |
|
|
#PERL=/opt/perl |
70 |
|
|
#PANGO=1.6.0 |
71 |
|
|
|
72 |
|
|
export EV_EVENTFD=0 |
73 |
|
|
export EV_INOTIFY=0 |
74 |
|
|
export EV_SIGNALFD=0 |
75 |
|
|
|
76 |
|
|
cat <<EOF >"$DIST"/pango.rc |
77 |
|
|
[Pango] |
78 |
|
|
ModuleFiles = pango.modules |
79 |
|
|
EOF |
80 |
|
|
|
81 |
|
|
( |
82 |
|
|
exec 5>"$DIST"/pango.modules |
83 |
|
|
pango-querymodules | grep ^/ | while read lib rest; do |
84 |
|
|
base=$(basename "$lib") |
85 |
|
|
[ "$base" = pango-basic-x.$LIBEXT ] && continue |
86 |
|
|
cp -p "$lib" "$DIST"/. |
87 |
root |
1.7 |
echo "./$base $rest" >&5 # using ./ seems to help pango not to rummage around in /usr/lib etc. |
88 |
root |
1.1 |
done |
89 |
|
|
) |
90 |
|
|
|
91 |
|
|
############################################################################# |
92 |
|
|
|
93 |
|
|
IFS=" |
94 |
|
|
" # space tab nl cr - cr for windows |
95 |
|
|
eval $($PERL -V:sitebinexp -V:sitearchexp -V:sitelib -V:vendorarchexp -V:vendorlibexp -V:archlibexp -V:privlibexp) |
96 |
|
|
|
97 |
|
|
mkdir -p "$DIST"/pm/bin |
98 |
|
|
cp "$sitebinexp"/deliantra "$DIST"/pm/bin/ |
99 |
|
|
cp -p util/run "$DIST" |
100 |
|
|
|
101 |
|
|
( |
102 |
|
|
exec <util/modules.dep |
103 |
|
|
|
104 |
|
|
# while read type name; do |
105 |
|
|
# if [ "$type" = d ]; then |
106 |
|
|
# # not implemented |
107 |
|
|
# dir=$(echo "$name" | sed -e s%::%/%g) |
108 |
|
|
# for lib in "$sitearchexp" "$sitelib" "$vendorarchexp" "$vendorlibexp" "$archlibexp" "$privlibexp"; do |
109 |
|
|
# if [ -e "$lib/auto/$dir/.packlist" ]; then |
110 |
|
|
# cat "$lib/auto/$dir/.packlist" |
111 |
|
|
# fi |
112 |
|
|
# echo "x $lib $dir" |
113 |
|
|
# done |
114 |
|
|
# elif [ $type = m ]; then |
115 |
|
|
# : |
116 |
|
|
# else |
117 |
|
|
# echo "unknown type $type ($name)" |
118 |
|
|
# exit 1 |
119 |
|
|
# fi |
120 |
|
|
# done |
121 |
|
|
mkdir -p "$DIST"/pm |
122 |
|
|
|
123 |
|
|
export OSDIST="$DIST" |
124 |
|
|
[ "$OS" = windows ] && OSDIST=$(cygpath -w "$OSDIST") |
125 |
|
|
|
126 |
|
|
$PERL -e ' |
127 |
|
|
use Config; |
128 |
|
|
use File::Glob qw(:glob); |
129 |
|
|
use File::Copy; |
130 |
|
|
use File::Path; |
131 |
|
|
use File::Basename; |
132 |
|
|
|
133 |
|
|
my @path = do { |
134 |
|
|
my %seen; |
135 |
|
|
grep !$seen{$_}++, grep length, map $Config{$_}, qw( |
136 |
|
|
sitearchexp |
137 |
|
|
sitelib |
138 |
|
|
vendorarchexp |
139 |
|
|
vendorlibexp |
140 |
|
|
archlibexp |
141 |
|
|
privlibexp |
142 |
|
|
) |
143 |
|
|
}; |
144 |
|
|
|
145 |
|
|
while (<>) { |
146 |
|
|
s/\015?\012$//; |
147 |
|
|
next if /^(#|$)/; |
148 |
|
|
s/\.dynob$/.'$SO'/; |
149 |
|
|
|
150 |
|
|
my $found; |
151 |
|
|
for my $lib (@path) { |
152 |
|
|
chdir $lib || next; |
153 |
|
|
|
154 |
|
|
my @glob = File::Glob::bsd_glob $_, 0; # explicit 0 needed |
155 |
|
|
|
156 |
|
|
if (@glob) { |
157 |
|
|
++$found; |
158 |
|
|
|
159 |
|
|
for (@glob) { |
160 |
|
|
if (-d $_) { |
161 |
|
|
system "rsync", "-aR", $_, "$ENV{DIST}/pm/."; |
162 |
|
|
} else { |
163 |
root |
1.2 |
File::Path::mkpath "$ENV{OSDIST}/pm/" . dirname $_; |
164 |
root |
1.1 |
File::Copy::syscopy "$_", "$ENV{OSDIST}/pm/$_" |
165 |
|
|
or die "$ENV{OSDIST}/pm/$_: $!"; |
166 |
|
|
|
167 |
|
|
if (s/\.pm$//) { |
168 |
|
|
$auto = "auto/$_"; |
169 |
|
|
|
170 |
|
|
for my $glob ("*.'$SO'", "autosplit.ix", "*.al") { |
171 |
|
|
for (bsd_glob "$auto/$glob", 0) { |
172 |
root |
1.2 |
File::Path::mkpath "$ENV{OSDIST}/pm/" . dirname $_; |
173 |
root |
1.1 |
File::Copy::syscopy "$_", "$ENV{OSDIST}/pm/$_"; |
174 |
|
|
} |
175 |
|
|
} |
176 |
|
|
} |
177 |
|
|
} |
178 |
|
|
} |
179 |
|
|
|
180 |
|
|
last; |
181 |
|
|
} |
182 |
|
|
} |
183 |
|
|
|
184 |
|
|
warn "$_: not found\n" |
185 |
|
|
unless $found; |
186 |
|
|
} |
187 |
|
|
' |
188 |
|
|
) || exit |
189 |
|
|
|
190 |
|
|
############################################################################# |
191 |
|
|
|
192 |
|
|
if [ "$OS" = windows ]; then |
193 |
|
|
libdeps() { |
194 |
|
|
objdump -p "$1" | awk '/\tDLL Name:/ { print $3 }' | while read lib; do |
195 |
|
|
set -- $(type "$lib") |
196 |
|
|
case "$3" in |
197 |
|
|
/c/WINNT/* | /c/sdk/* ) |
198 |
|
|
;; |
199 |
|
|
* ) |
200 |
|
|
echo "$3" |
201 |
|
|
;; |
202 |
|
|
esac |
203 |
|
|
done |
204 |
|
|
} |
205 |
|
|
elif [ "$OS" = darwin ]; then |
206 |
|
|
libdeps() { |
207 |
|
|
otool -L "$1" | perl -ne 'print "$1\n" if m%^\s+(/opt\S+)%' |
208 |
|
|
} |
209 |
|
|
else |
210 |
|
|
libdeps() { |
211 |
|
|
ldd "$1" | perl -ne 'print "$1\n" if / => (\S+)/' |
212 |
|
|
} |
213 |
|
|
fi |
214 |
|
|
|
215 |
|
|
add_deps() { |
216 |
|
|
local so="$1" |
217 |
|
|
libdeps "$so" | while read path; do |
218 |
|
|
base="$(basename "$path")" |
219 |
|
|
if ! [ -e "$base" ]; then |
220 |
|
|
cp -p "$path" . |
221 |
|
|
chmod 755 "$base" |
222 |
|
|
add_deps "$base" |
223 |
|
|
fi |
224 |
|
|
done |
225 |
|
|
} |
226 |
|
|
|
227 |
|
|
( |
228 |
|
|
cd "$DIST" |
229 |
|
|
|
230 |
root |
1.2 |
cp -p "$PERL" . |
231 |
root |
1.1 |
|
232 |
|
|
if [ "$OS" = windows ]; then |
233 |
|
|
cp -p $SYSLIB/libvorbisfile-3.dll $SYSLIB/mikmod.dll $SYSLIB/libpng12-0.dll . |
234 |
|
|
cp /root/src/CFPlus/util/splash.bmp . |
235 |
|
|
chmod -R u+rwX pm/auto |
236 |
root |
1.2 |
|
237 |
|
|
# convert perl to a non-console-app |
238 |
|
|
$PERL -MWin32::Exe -e '$e = new Win32::Exe"perl.exe"; $e->set_subsystem_windows; $e->write' |
239 |
|
|
|
240 |
root |
1.1 |
else |
241 |
|
|
for lib in mikmod vorbisfile; do |
242 |
|
|
cp -p $SYSLIB/lib$lib.$LIB0 . |
243 |
|
|
chmod 755 lib$lib.$LIB0 |
244 |
|
|
done |
245 |
|
|
fi |
246 |
|
|
|
247 |
|
|
for so in $(find . -name "*.$SO" -o -name "*.$LIBEXT" -o -name "*.$LIB0") perl; do |
248 |
|
|
add_deps "$so" |
249 |
|
|
done |
250 |
|
|
|
251 |
|
|
rm -f pm/auto/POSIX/*.al |
252 |
|
|
|
253 |
|
|
for lib in \ |
254 |
|
|
dl c m rt pthread nsl crypt \ |
255 |
|
|
X11 Xext Xau Xdmcp ICE SM Xrandr Xrender Xxf86vm drm GL \ |
256 |
|
|
z |
257 |
|
|
do |
258 |
root |
1.5 |
rm -f lib"$lib".$LIB0 |
259 |
root |
1.1 |
done |
260 |
|
|
|
261 |
root |
1.5 |
if [ "$OS" != windows ]; then |
262 |
|
|
# patch braindamaged pango |
263 |
root |
1.8 |
|
264 |
|
|
if [ "$OS" = darwin ]; then |
265 |
|
|
set libdeliantra-pango-1.0.0.dylib |
266 |
|
|
perl -pe 's{/o(?opt/local/.../pango)}{.\x00}g; s{\Q'$PANGO'\E\x00}{y.t.u\x00}g' <"$1" >"$1~" && mv "$1~" "$1" |
267 |
|
|
else |
268 |
|
|
set libpango-1.0.$LIB0 |
269 |
|
|
perl -pe 's{/u(?=sr/lib(32)?/pango)}{.\x00}g; s{\Q'$PANGO'\E\x00}{y.t.u\x00}g' <"$1" >"$1~" && mv "$1~" "$1" |
270 |
|
|
fi |
271 |
root |
1.5 |
chmod 755 "$1" |
272 |
|
|
fi |
273 |
|
|
|
274 |
root |
1.1 |
if [ "$OS" = darwin ]; then |
275 |
|
|
# "dll hell" is most severe on os x, because apple |
276 |
|
|
# does not generally give a shit for backwards compatibility, |
277 |
|
|
# alwayss ships outdated libraries and often provides libraries |
278 |
|
|
# of the same name as well-known libs (such as libjpeg), that |
279 |
|
|
# of course do something completely different |
280 |
|
|
patchlibs() { |
281 |
|
|
<"$1" \ |
282 |
|
|
perl -0777 -pe ' |
283 |
|
|
s%('"/opt/local/lib[^\x00]*/lib"'([^\x00/]+)\.dylib\x00)% |
284 |
|
|
my $s = $1; |
285 |
|
|
my $r = "libdeliantra-$2.dylib\x00"; |
286 |
|
|
(length $r) <= (length $s) |
287 |
|
|
or die "lib replacement <$r> larger than <$s>\n"; |
288 |
|
|
substr $s, 0, length $r, $r; |
289 |
|
|
$s |
290 |
|
|
%ge |
291 |
|
|
' \ |
292 |
|
|
>"$1~" && mv "$1~" "$1" || exit 67 |
293 |
|
|
} |
294 |
|
|
|
295 |
|
|
# patch bundles and pango modules with external dependencies, |
296 |
|
|
# should be few, so hardcode(tm) |
297 |
|
|
for so in \ |
298 |
|
|
pm/auto/BDB/BDB.bundle \ |
299 |
|
|
pm/auto/Deliantra/Client/Client.bundle \ |
300 |
|
|
*.$LIBEXT |
301 |
|
|
do |
302 |
|
|
patchlibs "$so" |
303 |
|
|
done |
304 |
|
|
|
305 |
|
|
# now patch and rename all .dylibs |
306 |
|
|
for lib in *.$LIB0; do |
307 |
|
|
stem="${lib#lib}" |
308 |
|
|
stem="${stem%.$LIB0}" |
309 |
|
|
patchlibs "$lib" |
310 |
|
|
mv "$lib" "libdeliantra-$stem.dylib" |
311 |
|
|
done |
312 |
|
|
fi |
313 |
|
|
|
314 |
root |
1.7 |
[ "$OS" = linux ] && chrpath -d perl $(find pm -name "*.so") # debian perls have an rpath, many modules too |
315 |
root |
1.1 |
$STRIP $(find . -name "*.$SO" -o -name "*.$LIBEXT" -o -name "*.$LIB0") perl |
316 |
root |
1.7 |
|
317 |
|
|
: >timidity.cfg |
318 |
root |
1.1 |
) |
319 |
|
|
|
320 |
root |
1.6 |
cat >"$DIST".vars <<EOF |
321 |
|
|
G_URLADER="$URLADER" |
322 |
|
|
G_OS="$OS" |
323 |
|
|
G_ARCHNAME="$ARCHNAME" |
324 |
|
|
G_ENVVARS="$GENPACK_ENVVARS" |
325 |
root |
1.7 |
G_COMMAND="./perl run" |
326 |
root |
1.6 |
EOF |
327 |
root |
1.1 |
|