-
Notifications
You must be signed in to change notification settings - Fork 33
/
wsapi-install-1.6
executable file
·584 lines (481 loc) · 14.4 KB
/
wsapi-install-1.6
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
#!/bin/bash
# Generic AIO installation script.
# Platform
pushd `dirname $0`
WGET="wget -c -t0"
if [ "`echo ${OSTYPE%%[0-9]*}`" = "darwin" ]
then
WGET="curl -O --retry 10"
fi
SOURCE_DIR=`pwd`
# Defaults
PREFIX="/usr/local"
TMP="/tmp"
LUA_SUFFIX=""
BUILD_LUA="yes"
INSTALL_LUA="yes"
USE_READLINE="yes"
NCURSES_DIR="/usr"
READLINE_DIR="/usr"
LUA_DIR="/usr"
LUA_INCDIR="/usr/include"
LUA_LIBDIR="/usr/lib"
LUA_BINDIR="/usr/bin"
SKIP_PACKAGE=no
SKIP_LR=no
BOOTSTRAP=no
UNAME="`uname`"
if ! [ "$UNAME" = "Linux" -o "$UNAME" = "Darwin" -o "$UNAME" = "FreeBSD" ]
then
USE_READLINE=no
fi
# Installer parameters
LUA_VERSION=5.2.1
PACKAGE=WSAPI
PACKAGE_OPT=wsapi
PACKAGE_ROCK=wsapi-xavante
INSTALLER_VERSION=0.7
PACKAGE_VERSION=1.6
LUAROCKS_REPO=http://luarocks.org/repositories/rocks
LUAROCKS_URL=http://www.luarocks.org/releases/luarocks-2.0.12.tar.gz
LUAROCKS_VERSION=2.0.12
# Help
show_help() {
cat <<EOF
$PACKAGE Installer version $INSTALLER_VERSION.
Installs Lua $LUA_VERSION, LuaRocks $LUAROCKS_VERSION and $PACKAGE $PACKAGE_VERSION.
--help This help.
--prefix=DIR Prefix where Lua should be installed.
Default is $PREFIX. Creates \$PREFIX/bin,
\$PREFIX/include, \$PREFIX/lib, \$PREFIX/share,
and \$PREFIX/man.
--include-dir=DIR Prefix where C header files should be installed.
Default is \$(PREFIX)/include
--lua-suffix=SUFFIX Versioning suffix to use in Lua filenames.
(lua vs. lua5.1, liblua.a vs. liblua5.1.a...)
--with-readline=DIR Prefix where Readline is installed.
Used by Lua.
Default is $READLINE_DIR
--with-ncurses=DIR Prefix where NCurses is installed.
Used by Lua when Readline is enabled.
Default is $NCURSES_DIR
--without-readline Disable Readline support when building Lua.
--from=URL Install from LuaRocks repository URL
--with-$PACKAGE_OPT=VERSION
Installs the provided $PACKAGE version instead
of $PACKAGE $PACKAGE_VERSION
--without-$PACKAGE_OPT
Does not install $PACKAGE, just Lua and LuaRocks
--without-rocks Does not install LuaRocks and $PACKAGE, just Lua
--bootstrap Also downloads Lua, LuaRocks, and the rocks for
$PACKAGE in the current path
EOF
}
# Parse options
while [ "$1" ]
do
value="`echo $1 | sed 's/.*=\(.*\)/\1/'`"
if echo "$value" | grep -q "~"
then
echo
echo '*WARNING*: the "~" sign is not expanded in flags.'
echo 'If you mean the home directory, use $HOME instead.'
echo
exit 1
fi
case "$1" in
--help)
show_help
exit 0
;;
--prefix=*)
PREFIX="$value"
PREFIX_SET=yes
;;
--include-dir=*)
INCLUDEDIR="$value"
INCLUDEDIR_SET=yes
;;
--lua-suffix=*)
LUA_SUFFIX="$value"
LUA_SUFFIX_SET=yes
;;
--with-readline=*)
READLINE_DIR="$value"
USE_READLINE=yes
;;
--from=*)
LUAROCKS_REPO="$value"
;;
--with-ncurses=*)
NCURSES_DIR="$value"
;;
--with-$PACKAGE_OPT=*)
PACKAGE_VERSION="$value"
;;
--without-$PACKAGE_OPT*)
SKIP_PACKAGE=yes
;;
--without-rocks*)
SKIP_PACKAGE=yes
SKIP_LR=yes
;;
--bootstrap*)
BOOTSTRAP=yes
;;
--without-readline)
USE_READLINE=no
;;
*)
echo "Error: Unknown flag: $1"
exit 1
;;
esac
shift
done
echo "$PACKAGE Installer version $PACKAGE_VERSION."
if ! [ "$INCLUDEDIR_SET" = "yes" ]
then
INCLUDEDIR="$PREFIX/include"
fi
LUA_DIR="$PREFIX"
LUA_INCDIR="$INCLUDEDIR"
LUA_LIBDIR="$LUA_DIR/lib"
LUA_BINDIR="$LUA_DIR/bin"
echo
echo "The name of the Lua executable is lua$LUA_SUFFIX"
echo "Lua installation prefix: $PREFIX"
echo "Include files: $PREFIX/include"
echo
echo "Will create bin, etc, lib, share, and man"
echo "directories in $PREFIX"
echo
echo "Proceed with setup? [Y/n] "
read YESNO
if [ "$YESNO" = "n" ]
then
echo "Setup aborted"
exit 1
fi
if [ "$YESNO" = "N" ]
then
echo "Setup aborted"
exit 1
fi
# External dependencies
test_package() {
package_keyword="$1"
package_name="$2"
with_flag="$3"
shift 3
if echo "$OPTIONAL_PACKAGES" | grep -q "$package_keyword"
then
echo -n "Checking $package_name... "
tried=""
while [ "$1" ]
do
test_file="$1"
if [ -e "$test_file" ]
then
echo "found: $test_file"
return 0
fi
tried="$tried $1"
shift
done
echo "not found:$tried"
echo
echo "Error: Could not verify the presence of $package_name."
echo "You may need to install development packages for $package_name."
if [ "$with_flag" ]
then
echo "If you are sure they are installed,"
echo "you can supply their location with $with_flag."
fi
echo "See --help for details."
exit 1
fi
}
if [ "$USE_READLINE" = "yes" ]
then
test_package "" "Readline" --with-readline $READLINE_DIR/include/readline/readline.h
if [ "$UNAME" = "Linux" ]
then
test_package "" "NCurses" --with-ncurses $NCURSES_DIR/include/ncurses.h
fi
fi
if [[ -f lua-$LUA_VERSION.tar.gz && -f luarocks-$LUAROCKS_VERSION.tar.gz && -d rocks ]]; then
echo "Installing from current directory..."
else
echo "Installing from the Net..."
mkdir -p /tmp/$PACKAGE_OPT-$PACKAGE_VERSION && pushd /tmp/$PACKAGE_OPT-$PACKAGE_VERSION
fi
cat <<EOF > Makefile
# This file was automatically generated by the configure script.
# Run "./configure --help" for details.
BUILD_LUA=$BUILD_LUA
INSTALL_LUA=$INSTALL_LUA
USE_READLINE=$USE_READLINE
PREFIX=$PREFIX
INCLUDEDIR=$INCLUDEDIR
LUA_SUFFIX=$LUA_SUFFIX
READLINE_DIR=$READLINE_DIR
NCURSES_DIR=$NCURSES_DIR
LUA_DIR=$LUA_DIR
LUA_INCDIR=$LUA_INCDIR
LUA_LIBDIR=$LUA_LIBDIR
LUA_BINDIR=$LUA_BINDIR
LUA_URL=http://www.lua.org/ftp
READLINE_LIBDIR=\$(READLINE_DIR)/lib
READLINE_INCLUDEDIR=\$(READLINE_DIR)/include
NCURSES_LIBDIR=\$(NCURSES_DIR)/lib
NCURSES_INCLUDEDIR=\$(NCURSES_DIR)/include
LUA_VERSION=$LUA_VERSION
PLATFORM_CFLAGS=-Wl,-E
PLATFORM_LDFLAGS=-lm -ldl
LIB_FLAG=-shared
ifeq (\$(shell uname -m | sed 's/i.86/i386/'),i386)
FPIC=
else
FPIC=-fpic
endif
LUA_LIB=\$(LUA_LIBDIR)/liblua\$(LUA_SUFFIX).a
LUA_DEFPATH=-DLUA_ROOT=\\\\\\"\$(LUA_DIR)\\\\\\"
ifeq (\$(USE_READLINE), yes)
LUA_READLINE_CFLAGS=-DLUA_USE_READLINE -I\$(READLINE_INCLUDEDIR)
LUA_READLINE_LIBS=-lreadline -lhistory -lncurses -L\$(READLINE_LIBDIR) -L\$(NCURSES_LIBDIR)
else
LUA_READLINE_CFLAGS=
LUA_READLINE_LIBS=
endif
LUA_MYCFLAGS=-DLUA_USE_POSIX -DLUA_USE_DLOPEN \$(LUA_READLINE_CFLAGS)
LUA_MYLIBS=\$(PLATFORM_CFLAGS) -ldl \$(LUA_READLINE_LIBS)
WGET=wget -c -t0
PLATFORM_BUILD=build
ifeq (\$(shell bash -c 'echo ${OSTYPE%%[0-9]*}'),darwin)
WGET=curl -O --retry 10
PLATFORM_BUILD=OSX-build
ifneq (\$(LUA_READLINE_LIBS),)
LUA_READLINE_LIBS=-lreadline -L\$(READLINE_LIBDIR)
endif
endif
ifeq (\$(shell uname -s),FreeBSD)
PLATFORM_BUILD=FreeBSD-build
endif
platform: \$(PLATFORM_BUILD)
OSX-build:
MACOSX_DEPLOYMENT_TARGET=10.3 \$(MAKE) \\
LUA_MYCFLAGS="-DLUA_USE_MACOSX \$(LUA_READLINE_CFLAGS)" \\
LUA_MYLIBS="\$(LUA_READLINE_LIBS)" \\
PLATFORM_CFLAGS="-dynamic" \\
PLATFORM_LDFLAGS="-lm -ldl" \\
LIB_FLAG="-bundle -undefined dynamic_lookup -all_load" \\
build
FreeBSD-build:
\$(MAKE) \\
LUA_MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" \\
LUA_MYLIBS="-Wl,-E" \\
PLATFORM_LDFLAGS="-lm" \\
build
LUA_TESTFILE=lua-\$(LUA_VERSION)/src/lua\$(LUA_SUFFIX)
fetch: lua-\$(LUA_VERSION)
lua-\$(LUA_VERSION).tar.gz:
\$(WGET) \$(LUA_URL)/\$@
lua-\$(LUA_VERSION):
\$(MAKE) lua-\$(LUA_VERSION).tar.gz
test -d \$@ || tar zxvpf lua-\$(LUA_VERSION).tar.gz
cd lua-\$(LUA_VERSION) && patch -p1 < ../lua-\$(LUA_VERSION)-easylua.diff
build: \$(LUA_TESTFILE)
\$(LUA_TESTFILE): lua-\$(LUA_VERSION)
cd lua-\$(LUA_VERSION) && \$(MAKE) \\
LUA_SUFFIX="\$(LUA_SUFFIX)" \\
INSTALL_INC="\$(LUA_INCDIR)" \\
MYCFLAGS="\$(LUA_DEFPATH) \$(LUA_MYCFLAGS)" \\
MYLIBS="\$(LUA_MYLIBS)" \\
CC="\$(CC)" \\
generic
install: build
cd lua-\$(LUA_VERSION) && \$(MAKE) \\
LUA_SUFFIX="\$(LUA_SUFFIX)" \\
INSTALL_INC="\$(LUA_INCDIR)" \\
INSTALL_TOP="\$(LUA_DIR)" \\
MYCFLAGS="\$(LUA_MYCFLAGS)" \\
MYLIBS="\$(LUA_MYLIBS)" \\
INSTALL_EXEC="install -p -m 0755" \\
INSTALL_DATA="install -p -m 0644" \\
STRIP="true" \\
install
clean:
if [ -d lua-\$(LUA_VERSION) ]; then \\
cd lua-\$(LUA_VERSION) && \$(MAKE) \\
LUA_SUFFIX="\$(LUA_SUFFIX)" \\
clean; \\
fi
klean:
rm -f lua-\$(LUA_VERSION).tar.gz
rm -rf lua-\$(LUA_VERSION)
rm -f Makefile
rm -f lua-\$(LUA_VERSION)-easylua.diff
EOF
cat <<EOF > lua-5.1.4-easylua.diff
diff -Naur lua-5.1.4-orig/Makefile lua-5.1.4/Makefile
--- lua-5.1.4-orig/Makefile 2007-03-25 11:44:39.000000000 -0300
+++ lua-5.1.4/Makefile 2007-05-11 16:08:02.000000000 -0300
@@ -41,10 +41,10 @@
PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
# What to install.
-TO_BIN= lua luac
+TO_BIN= lua\$(LUA_SUFFIX) luac\$(LUA_SUFFIX)
TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp
-TO_LIB= liblua.a
-TO_MAN= lua.1 luac.1
+TO_LIB= liblua\$(LUA_SUFFIX).a
+TO_MAN= lua\$(LUA_SUFFIX).1 luac\$(LUA_SUFFIX).1
# Lua version and release.
V= 5.1
@@ -56,11 +56,15 @@
cd src && \$(MAKE) \$@
test: dummy
- src/lua test/hello.lua
+ src/lua\$(LUA_SUFFIX) test/hello.lua
install: dummy
- cd src && \$(MKDIR) \$(INSTALL_BIN) \$(INSTALL_INC) \$(INSTALL_LIB) \$(INSTALL_MAN) \$(INSTALL_LMOD) \$(INSTALL_CMOD)
+ cd src && \$(MKDIR) -p \$(INSTALL_BIN) \$(INSTALL_INC) \$(INSTALL_LIB) \$(INSTALL_MAN) \$(INSTALL_LMOD) \$(INSTALL_CMOD)
cd src && \$(INSTALL_EXEC) \$(TO_BIN) \$(INSTALL_BIN)
cd src && \$(INSTALL_DATA) \$(TO_INC) \$(INSTALL_INC)
cd src && \$(INSTALL_DATA) \$(TO_LIB) \$(INSTALL_LIB)
+ cp doc/lua.1 doc/t_lua.1
+ cp doc/luac.1 doc/t_luac.1
+ mv doc/t_lua.1 doc/lua\$(LUA_SUFFIX).1
+ mv doc/t_luac.1 doc/luac\$(LUA_SUFFIX).1
cd doc && \$(INSTALL_DATA) \$(TO_MAN) \$(INSTALL_MAN)
diff -Naur lua-5.1.4-orig/src/luaconf.h lua-5.1.4/src/luaconf.h
--- lua-5.1.4-orig/src/luaconf.h 2007-03-24 00:01:55.000000000 -0300
+++ lua-5.1.4/src/luaconf.h 2007-05-11 16:12:55.000000000 -0300
@@ -94,9 +94,11 @@
".\\\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
#else
-#define LUA_ROOT "/usr/local/"
-#define LUA_LDIR LUA_ROOT "share/lua/5.1/"
-#define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
+#ifndef LUA_ROOT
+#define LUA_ROOT "/usr/local"
+#endif
+#define LUA_LDIR LUA_ROOT "/share/lua/5.1/"
+#define LUA_CDIR LUA_ROOT "/lib/lua/5.1/"
#define LUA_PATH_DEFAULT \\
"./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \\
LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua"
diff -Naur lua-5.1.4-orig/src/Makefile lua-5.1.4/src/Makefile
--- lua-5.1.4-orig/src/Makefile 2007-03-25 11:49:23.000000000 -0300
+++ lua-5.1.4/src/Makefile 2007-05-11 16:08:02.000000000 -0300
@@ -22,17 +22,17 @@
PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
-LUA_A= liblua.a
+LUA_A= liblua\$(LUA_SUFFIX).a
CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \\
lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \\
lundump.o lvm.o lzio.o
LIB_O= lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o \\
lstrlib.o loadlib.o linit.o
-LUA_T= lua
+LUA_T= lua\$(LUA_SUFFIX)
LUA_O= lua.o
-LUAC_T= luac
+LUAC_T= luac\$(LUA_SUFFIX)
LUAC_O= luac.o print.o
ALL_O= \$(CORE_O) \$(LIB_O) \$(LUA_O) \$(LUAC_O)
@@ -93,7 +93,7 @@
\$(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline"
generic:
- \$(MAKE) all MYCFLAGS=
+ \$(MAKE) all
linux:
\$(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
EOF
echo
echo
echo "========================================================="
echo "Installing Lua $LUA_VERSION on $PREFIX"
echo "========================================================="
echo
echo
if [ "`uname -s`" = "FreeBSD" ]
then
MAKE=gmake
else
MAKE=make
fi
cleanup() {
echo
echo "Cleaning up..."
echo
if [ -d /tmp/$PACKAGE_OPT-$PACKAGE_VERSION ]; then
popd && rm -rf /tmp/$PACKAGE_OPT-$PACKAGE_VERSION
fi
}
$MAKE clean > /dev/null 2> /dev/null
$MAKE || (echo "Failed compiling Lua. Exiting..."; cleanup; exit 1)
$MAKE install || (echo "Failed installing Lua. Exiting..."; cleanup; exit 1)
echo
echo "Done. Lua is installed on $PREFIX."
echo
if ! [ $SKIP_LR = "yes" ]
then
echo
echo
echo "========================================================="
echo "Now installing LuaRocks $LUAROCKS_VERSION in $PREFIX."
echo "========================================================="
echo
echo
if [ $LUAROCKS_URL != "" ]
then
if [ ! -f luarocks-$LUAROCKS_VERSION.tar.gz ]; then
$WGET $LUAROCKS_URL
fi
tar zxvf luarocks-$LUAROCKS_VERSION.tar.gz
cd luarocks-$LUAROCKS_VERSION
else
cvs -d:pserver:[email protected]:/cvsroot/luarocks export -r HEAD luarocks
cd luarocks
fi
sh configure --prefix=$PREFIX --with-lua=$PREFIX \
--with-lua-include=$LUA_INCDIR && make && make install || (echo "Failed installing LuaRocks. Exiting..."; cleanup; exit 1)
cd ..
fi
if ! [ $SKIP_PACKAGE = "yes" ]
then
echo
echo
echo "========================================================="
echo "Now installing $PACKAGE in $PREFIX."
echo "========================================================="
echo
if [ -d rocks ]; then
$PREFIX/bin/luarocks install $PACKAGE_ROCK --only-from=`pwd`/rocks $PACKAGE_VERSION
else
$PREFIX/bin/luarocks install --from=$LUAROCKS_REPO $PACKAGE_ROCK $PACKAGE_VERSION
fi
fi
if [ $BOOTSTRAP = "yes" ]
then
cat <<EOF > /tmp/$PACKAGE_OPT-$PACKAGE_VERSION/pack_tree.lua
#!/usr/bin/env lua
local lfs = require "lfs"
local prefix, tree, target = ...
rockspecs = io.popen('find "' .. tree .. '" -name "*.rockspec"')
if lfs.attributes(target, "mode") ~= "d" then
lfs.mkdir(target)
end
lfs.chdir(target)
for rockspec in rockspecs:lines() do
os.execute('"' .. prefix .. '/bin/luarocks" pack "' .. rockspec .. '"')
end
os.execute('"' .. prefix .. '/bin/luarocks-admin" make_manifest "' .. target .. '"')
EOF
cp /tmp/$PACKAGE_OPT-$PACKAGE_VERSION/lua-$LUA_VERSION.tar.gz "$SOURCE_DIR/"
cp /tmp/$PACKAGE_OPT-$PACKAGE_VERSION/luarocks-$LUAROCKS_VERSION.tar.gz "$SOURCE_DIR/"
"$PREFIX/bin/lua" /tmp/$PACKAGE_OPT-$PACKAGE_VERSION/pack_tree.lua "$PREFIX" "$PREFIX/lib/luarocks/rocks" "$SOURCE_DIR/rocks"
fi
cleanup