Created
August 12, 2010 10:09
-
-
Save jnwhiteh/520676 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
die() { | |
echo "$1"; | |
exit 1; | |
} | |
# Fetch and install Lua/LuaRocks into the local directory | |
ROOT=`pwd` | |
SANDBOX="${ROOT}/sandbox" | |
TMP_DIR="${ROOT}/sandbox/src" | |
if [ ! -d "${TMP_DIR}" ]; then mkdir -p "${TMP_DIR}"; fi | |
pushd "${TMP_DIR}" | |
PREFIX="${ROOT}" | |
rm -fr "lua-5.1.4" | |
wget http://www.lua.org/ftp/lua-5.1.4.tar.gz; | |
tar -zxf "lua-5.1.4.tar.gz" | |
pushd lua-5.1.4 | |
# Patch the LUA install to allow LUA_ROOT to be overridden by variable | |
patch -p0 << ENDPATCH | |
diff -Naur src.orig/luaconf.h src/luaconf.h | |
--- src.orig/luaconf.h 2008-03-23 11:58:49.000000000 +0000 | |
+++ src/luaconf.h 2008-03-23 11:59:30.000000000 +0000 | |
@@ -94,9 +94,15 @@ | |
".\\\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" | |
#else | |
+#ifndef LUA_ROOT | |
#define LUA_ROOT "/usr/local/" | |
+#endif | |
+#ifndef LUA_LDIR | |
#define LUA_LDIR LUA_ROOT "share/lua/5.1/" | |
+#endif | |
+#ifndef LUA_CDIR | |
#define LUA_CDIR LUA_ROOT "lib/lua/5.1/" | |
+#endif | |
#define LUA_PATH_DEFAULT \\ | |
"./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \\ | |
LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua" | |
ENDPATCH | |
patch -p0 << ENDPATCH | |
diff -Naur src.orig/Makefile src/Makefile | |
--- src.orig/Makefile 2008-03-23 12:28:40.000000000 +0000 | |
+++ src/Makefile 2008-03-23 12:29:07.000000000 +0000 | |
@@ -8,7 +8,7 @@ | |
PLAT= none | |
CC= gcc | |
-CFLAGS= -O2 -Wall \$(MYCFLAGS) | |
+CFLAGS= -O2 -DLUA_ROOT=\"${SANDBOX}/\" -Wall \$(MYCFLAGS) | |
AR= ar rcu | |
RANLIB= ranlib | |
RM= rm -f | |
ENDPATCH | |
# Compile and install Lua | |
case `uname` in | |
'Linux') | |
LUA_TARGET="linux" | |
;; | |
'Darwin') | |
LUA_TARGET="macosx" | |
;; | |
esac | |
make ${LUA_TARGET} INSTALL_TOP="${SANDBOX}" | |
make install INSTALL_TOP="${SANDBOX}" | |
make clean | |
# Download and install Luarocks | |
popd | |
wget http://luarocks.org/releases/luarocks-2.0.2.tar.gz | |
if [ -d "luarocks-2.0.2" ]; then rm -fr luarocks-2.0.2; fi | |
tar -zxf "luarocks-2.0.2.tar.gz" | |
pushd luarocks-2.0.2 | |
./configure --with-lua="${SANDBOX}" --prefix="${SANDBOX}" --force-config | |
make && make install && make clean | |
popd # Back to tmp | |
popd # Back to the original directory |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment