setup_lua.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #! /bin/bash
  2. set -ev
  3. # this script installs a lua / luarocks environment in .travis/lua
  4. # this is necessary because travis docker architecture (the fast way)
  5. # does not permit sudo, and does not contain a useful lua installation
  6. # After this script is finished, you can configure your environment to
  7. # use it by sourcing lua_env.sh
  8. source ci/travis/platform.sh
  9. # The current versions when this script was written
  10. LUA_VERSION=5.2.4
  11. LUAROCKS_VERSION=2.2.2
  12. # directory where this script is located
  13. SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
  14. # civetweb base dir
  15. PROJECT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../.. && pwd )
  16. # fetch and unpack lua src
  17. cd $SCRIPT_DIR
  18. LUA_BASE=lua-$LUA_VERSION
  19. rm -rf $LUA_BASE
  20. curl http://www.lua.org/ftp/$LUA_BASE.tar.gz | tar zx
  21. # build lua
  22. cd $LUA_BASE
  23. make $PLATFORM
  24. make local
  25. # mv built lua install to target Lua dir
  26. LUA_DIR=$PROJECT_DIR/ci/lua
  27. rm -rf $LUA_DIR
  28. mv $SCRIPT_DIR/$LUA_BASE/install $LUA_DIR
  29. # add to path required by luarocks installer
  30. export PATH=$LUA_DIR/bin:$PATH
  31. # fetch and unpack luarocks
  32. cd $SCRIPT_DIR
  33. LUAROCKS_BASE=luarocks-$LUAROCKS_VERSION
  34. rm -rf ${LUAROCKS_BASE}
  35. LUAROCKS_URL=http://luarocks.org/releases/${LUAROCKS_BASE}.tar.gz
  36. # -L because it's a 302 redirect
  37. curl -L $LUAROCKS_URL | tar xzp
  38. cd $LUAROCKS_BASE
  39. # build luarocks
  40. ./configure --prefix=$LUA_DIR
  41. make build
  42. make install
  43. # cleanup source dirs
  44. cd $SCRIPT_DIR
  45. rm -rf $LUAROCKS_BASE
  46. rm -rf $LUA_BASE