ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/util/gatherer
Revision: 1.1
Committed: Fri Dec 30 04:17:19 2011 UTC (12 years, 4 months ago) by root
Branch: MAIN
Log Message:
*** empty log message ***

File Contents

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