2017-06-22 09:06:37 -06:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2017-06-22 09:24:37 -06:00
|
|
|
LUA_ROOT="$HOME/lua53"
|
2017-06-22 09:13:22 -06:00
|
|
|
LUA_URL="http://www.lua.org/ftp/lua-5.3.3.tar.gz"
|
2017-06-22 09:06:37 -06:00
|
|
|
LUA_TAR=$(basename "$LUA_URL")
|
2017-06-22 09:24:37 -06:00
|
|
|
LUA_DIR="$LUA_ROOT/${LUA_TAR%.tar.*}"
|
2017-06-22 09:06:37 -06:00
|
|
|
LUA_SHA1="a0341bc3d1415b814cc738b2ec01ae56045d64ef"
|
|
|
|
|
|
|
|
echo $LUA_TAR
|
|
|
|
echo $LUA_DIR
|
|
|
|
|
|
|
|
sha1() {
|
|
|
|
python -c 'import hashlib, sys; print(hashlib.sha1(open(sys.argv[1],"rb").read()).hexdigest())' "$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
download() {
|
|
|
|
echo "Downloading $LUA_URL"
|
2017-06-22 09:24:37 -06:00
|
|
|
wget -O "$LUA_ROOT/$LUA_TAR" "$LUA_URL"
|
|
|
|
tar xvf "$LUA_ROOT/$LUA_TAR"
|
2017-06-22 09:06:37 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
build() {
|
|
|
|
cd "$LUA_DIR/src"
|
|
|
|
make generic
|
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
2017-06-22 09:24:37 -06:00
|
|
|
mkdir -p "$LUA_ROOT"
|
|
|
|
cd "$LUA_ROOT"
|
2017-06-22 09:06:37 -06:00
|
|
|
mkdir -p bin
|
|
|
|
|
2017-06-22 09:24:37 -06:00
|
|
|
if [ "$(sha1 "$LUA_ROOT/$LUA_TAR" 2>/dev/null)" != "$LUA_SHA1" ]; then
|
2017-06-22 09:06:37 -06:00
|
|
|
download
|
|
|
|
build
|
|
|
|
else
|
|
|
|
echo "Already downloaded"
|
|
|
|
|
2017-06-22 09:24:37 -06:00
|
|
|
if [ -x "$LUA_DIR/src/luac" ]; then
|
|
|
|
echo "Already built"
|
|
|
|
else
|
|
|
|
build
|
|
|
|
fi
|
2017-06-22 09:06:37 -06:00
|
|
|
fi
|
|
|
|
|
2017-06-22 09:24:37 -06:00
|
|
|
echo "Linking"
|
|
|
|
ln -sf "$LUA_DIR/src/lua" "$LUA_ROOT/bin/lua5.3"
|
|
|
|
ln -sf "$LUA_DIR/src/luac" "$LUA_ROOT/bin/luac5.3"
|
|
|
|
echo "Done"
|
2017-06-22 09:06:37 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
main
|