CentOS: how to install LuaRocks


luarocks logo

LuaRocks is the package manager for the Lua programming language.

Main website: luarocks.org https://github.com/luarocks/luarocks

Step 1: download source code

cd /usr/local/src
LUAROCKS_URL='http://luarocks.org/releases/luarocks-2.4.2.tar.gz'
mkdir -p luarocks
wget -qO - "$LUAROCKS_URL"     | tar xzv --strip-components 1 -C luarocks/

Result:

[root@tutorialspots ~]# cd /usr/local/src
[root@tutorialspots src]# LUAROCKS_URL='http://luarocks.org/releases/luarocks-2.4.2.tar.gz'
[root@tutorialspots src]# mkdir -p luarocks
[root@tutorialspots src]# wget -qO - "$LUAROCKS_URL"     | tar xzv --strip-components 1 -C luarocks/
luarocks-2.4.2/configure
luarocks-2.4.2/rockspec
luarocks-2.4.2/src/
luarocks-2.4.2/src/luarocks/
luarocks-2.4.2/src/luarocks/make_manifest.lua
luarocks-2.4.2/src/luarocks/fs.lua
luarocks-2.4.2/src/luarocks/manif_core.lua
luarocks-2.4.2/src/luarocks/dir.lua
luarocks-2.4.2/src/luarocks/validate.lua
luarocks-2.4.2/src/luarocks/help.lua
luarocks-2.4.2/src/luarocks/repos.lua
luarocks-2.4.2/src/luarocks/command_line.lua
luarocks-2.4.2/src/luarocks/cache.lua
luarocks-2.4.2/src/luarocks/upload/
luarocks-2.4.2/src/luarocks/upload/api.lua
luarocks-2.4.2/src/luarocks/upload/multipart.lua
luarocks-2.4.2/src/luarocks/unpack.lua
luarocks-2.4.2/src/luarocks/index.lua
luarocks-2.4.2/src/luarocks/upload.lua
luarocks-2.4.2/src/luarocks/lint.lua
luarocks-2.4.2/src/luarocks/path_cmd.lua
luarocks-2.4.2/src/luarocks/purge.lua
luarocks-2.4.2/src/luarocks/install.lua
luarocks-2.4.2/src/luarocks/write_rockspec.lua
luarocks-2.4.2/src/luarocks/build.lua
luarocks-2.4.2/src/luarocks/search.lua
luarocks-2.4.2/src/luarocks/make.lua
luarocks-2.4.2/src/luarocks/list.lua
luarocks-2.4.2/src/luarocks/fs/
luarocks-2.4.2/src/luarocks/fs/win32.lua
luarocks-2.4.2/src/luarocks/fs/win32/
luarocks-2.4.2/src/luarocks/fs/win32/tools.lua
luarocks-2.4.2/src/luarocks/fs/unix/
luarocks-2.4.2/src/luarocks/fs/unix/tools.lua
luarocks-2.4.2/src/luarocks/fs/lua.lua
luarocks-2.4.2/src/luarocks/fs/tools.lua
luarocks-2.4.2/src/luarocks/fs/unix.lua
luarocks-2.4.2/src/luarocks/loader.lua
luarocks-2.4.2/src/luarocks/tools/
luarocks-2.4.2/src/luarocks/tools/patch.lua
luarocks-2.4.2/src/luarocks/tools/zip.lua
luarocks-2.4.2/src/luarocks/tools/tar.lua
luarocks-2.4.2/src/luarocks/add.lua
luarocks-2.4.2/src/luarocks/build/
luarocks-2.4.2/src/luarocks/build/cmake.lua
luarocks-2.4.2/src/luarocks/build/make.lua
luarocks-2.4.2/src/luarocks/build/command.lua
luarocks-2.4.2/src/luarocks/build/builtin.lua
luarocks-2.4.2/src/luarocks/config_cmd.lua
luarocks-2.4.2/src/luarocks/show.lua
luarocks-2.4.2/src/luarocks/fetch.lua
luarocks-2.4.2/src/luarocks/path.lua
luarocks-2.4.2/src/luarocks/util.lua
luarocks-2.4.2/src/luarocks/deps.lua
luarocks-2.4.2/src/luarocks/admin_remove.lua
luarocks-2.4.2/src/luarocks/new_version.lua
luarocks-2.4.2/src/luarocks/pack.lua
luarocks-2.4.2/src/luarocks/download.lua
luarocks-2.4.2/src/luarocks/doc.lua
luarocks-2.4.2/src/luarocks/cfg.lua
luarocks-2.4.2/src/luarocks/type_check.lua
luarocks-2.4.2/src/luarocks/persist.lua
luarocks-2.4.2/src/luarocks/require.lua
luarocks-2.4.2/src/luarocks/manif.lua
luarocks-2.4.2/src/luarocks/remove.lua
luarocks-2.4.2/src/luarocks/refresh_cache.lua
luarocks-2.4.2/src/luarocks/fetch/
luarocks-2.4.2/src/luarocks/fetch/git_file.lua
luarocks-2.4.2/src/luarocks/fetch/sscm.lua
luarocks-2.4.2/src/luarocks/fetch/cvs.lua
luarocks-2.4.2/src/luarocks/fetch/git_https.lua
luarocks-2.4.2/src/luarocks/fetch/git_ssh.lua
luarocks-2.4.2/src/luarocks/fetch/hg_http.lua
luarocks-2.4.2/src/luarocks/fetch/git_http.lua
luarocks-2.4.2/src/luarocks/fetch/svn.lua
luarocks-2.4.2/src/luarocks/fetch/git.lua
luarocks-2.4.2/src/luarocks/fetch/hg_ssh.lua
luarocks-2.4.2/src/luarocks/fetch/hg_https.lua
luarocks-2.4.2/src/luarocks/fetch/hg.lua
luarocks-2.4.2/src/bin/
luarocks-2.4.2/src/bin/luarocks
luarocks-2.4.2/src/bin/luarocks-admin
luarocks-2.4.2/.busted
luarocks-2.4.2/COPYING
luarocks-2.4.2/Makefile.luarocks
luarocks-2.4.2/README.md
luarocks-2.4.2/Makefile
luarocks-2.4.2/config.ld
luarocks-2.4.2/Makefile.install.inc
luarocks-2.4.2/Makefile.setup.inc
luarocks-2.4.2/spec/
luarocks-2.4.2/spec/unpack_spec.lua
luarocks-2.4.2/spec/fs_spec.lua
luarocks-2.4.2/spec/config_spec.lua
luarocks-2.4.2/spec/search_spec.lua
luarocks-2.4.2/spec/make_manifest_spec.lua
luarocks-2.4.2/spec/make_spec.lua
luarocks-2.4.2/spec/new_version_spec.lua
luarocks-2.4.2/spec/deps_spec.lua
luarocks-2.4.2/spec/doc_spec.lua
luarocks-2.4.2/spec/purge_spec.lua
luarocks-2.4.2/spec/fetch_spec.lua
luarocks-2.4.2/spec/refresh_cache_spec.lua
luarocks-2.4.2/spec/install_spec.lua
luarocks-2.4.2/spec/build_spec.lua
luarocks-2.4.2/spec/download_spec.lua
luarocks-2.4.2/spec/add_spec.lua
luarocks-2.4.2/spec/remove_spec.lua
luarocks-2.4.2/spec/pack_spec.lua
luarocks-2.4.2/spec/util_spec.lua
luarocks-2.4.2/spec/persist.lua
luarocks-2.4.2/spec/show_spec.lua
luarocks-2.4.2/spec/path_spec.lua
luarocks-2.4.2/spec/lint_spec.lua
luarocks-2.4.2/spec/list_spec.lua
luarocks-2.4.2/spec/upload_spec.lua
luarocks-2.4.2/spec/write_rockspec_spec.lua
luarocks-2.4.2/spec/help_spec.lua
luarocks-2.4.2/test/
luarocks-2.4.2/test/mock-server.lua
luarocks-2.4.2/test/test_environment.lua
luarocks-2.4.2/test/README.md
luarocks-2.4.2/test/luarocks_site.lua
luarocks-2.4.2/test/testfiles/
luarocks-2.4.2/test/testfiles/not_a_zipfile-1.0-1.src.rock
luarocks-2.4.2/test/testfiles/type_mismatch_version-1.0-1.rockspec
luarocks-2.4.2/test/testfiles/missing_external-0.1-1.rockspec
luarocks-2.4.2/test/testfiles/invalid_validate-args-1.5.4-1.rockspec
luarocks-2.4.2/test/testfiles/no_build_table-0.1-1.rockspec
luarocks-2.4.2/test/testfiles/type_mismatch_table-1.0-1.rockspec
luarocks-2.4.2/test/testfiles/invalid_patch-0.1-1.rockspec
luarocks-2.4.2/test/testfiles/mixed_deploy_type/
luarocks-2.4.2/test/testfiles/mixed_deploy_type/mdt_file
luarocks-2.4.2/test/testfiles/mixed_deploy_type/mdt.c
luarocks-2.4.2/test/testfiles/mixed_deploy_type/mdt.lua
luarocks-2.4.2/test/testfiles/mixed_deploy_type/mixed_deploy_type-0.2.0-1.rockspec
luarocks-2.4.2/test/testfiles/mixed_deploy_type/mixed_deploy_type-0.1.0-1.rockspec
luarocks-2.4.2/test/testfiles/type_mismatch_string-1.0-1.rockspec

Step 2: Build Luarocks

pushd luarocks
./configure --prefix=/usr/local \
    --with-lua=/usr/local \
    --lua-suffix=jit \
    --with-lua-include=/usr/local/include/luajit-2.1         
make build install
popd

Result:

[root@tutorialspots src]# pushd luarocks
/usr/local/src/luarocks /usr/local/src ~
[root@tutorialspots luarocks]# ./configure --prefix=/usr/local \
>     --with-lua=/usr/local \
>     --lua-suffix=jit \
>     --with-lua-include=/usr/local/include/luajit-2.1
Lua version detected: 5.1
Lua interpreter found: /usr/local/bin/luajit...
Checking Lua includes... lua.h found in /usr/local/include/luajit-2.1/lua.h
Checking if Lua header version matches that of the interpreter... yes
curl found at /usr/bin
md5sum found at /usr/bin
unzip found at /usr/bin
Configuring for system... Linux
Configuring for architecture... x86_64
Using unversioned rocks dir: /usr/local/lib/luarocks/rocks
Writing configuration...

Installation prefix: /usr/local
LuaRocks configuration directory: /usr/local/etc/luarocks
Using Lua from: /usr/local

Done configuring.
- Type 'make build' and 'make install':
  to install to /usr/local as usual.
- Type 'make bootstrap':
  to install LuaRocks in /usr/local as a rock.
[root@tutorialspots  luarocks]# make build install
rm -f src/luarocks/site_config.lua
echo 'local site_config = {}' >> src/luarocks/site_config.lua
if [ -n "/usr/local" ] ;\
then \
   echo "site_config.LUAROCKS_PREFIX=[[/usr/local]]" >> src/luarocks/site_config.lua ;\
fi
if [ -n "/usr/local/include/luajit-2.1" ] ;\
then \
   echo "site_config.LUA_INCDIR=[[/usr/local/include/luajit-2.1]]" >> src/luarocks/site_config.lua ;\
fi
if [ -n "/usr/local/lib" ] ;\
then \
   echo "site_config.LUA_LIBDIR=[[/usr/local/lib]]" >> src/luarocks/site_config.lua ;\
fi
if [ -n "/usr/local/bin" ] ;\
then \
   echo "site_config.LUA_BINDIR=[[/usr/local/bin]]" >> src/luarocks/site_config.lua ;\
fi
if [ -n "jit" ] ;\
then \
   echo "site_config.LUA_INTERPRETER=[[luajit]]" >> src/luarocks/site_config.lua ;\
fi
if [ -n "/usr/local/etc/luarocks" ] ;\
then \
   echo "site_config.LUAROCKS_SYSCONFDIR=[[/usr/local/etc/luarocks]]" >> src/luarocks/site_config.lua ;\
fi
if [ -n "/usr/local" ] ;\
then \
   echo "site_config.LUAROCKS_ROCKS_TREE=[[/usr/local]]" >> src/luarocks/site_config.lua ;\
fi
if [ -n "" ] ;\
then \
   echo "site_config.LUAROCKS_FORCE_CONFIG=true" >> src/luarocks/site_config.lua ;\
fi
if [ -n "/lib/luarocks/rocks" ] ;\
then \
   echo "site_config.LUAROCKS_ROCKS_SUBDIR=[[/lib/luarocks/rocks]]" >> src/luarocks/site_config.lua ;\
fi
if [ "yes" = "yes" ] ;\
then \
   echo "site_config.LUA_DIR_SET=true" >> src/luarocks/site_config.lua ;\
fi
echo "site_config.LUAROCKS_UNAME_S=[[Linux]]" >> src/luarocks/site_config.lua
echo "site_config.LUAROCKS_UNAME_M=[[x86_64]]" >> src/luarocks/site_config.lua
echo "site_config.LUAROCKS_DOWNLOADER=[[curl]]" >> src/luarocks/site_config.lua
echo "site_config.LUAROCKS_MD5CHECKER=[[md5sum]]" >> src/luarocks/site_config.lua
if [ -n "lib64" ] ;\
then \
   echo 'site_config.LUAROCKS_EXTERNAL_DEPS_SUBDIRS={ bin="bin", lib={ "lib", [[lib64]] }, include="include" }' >> src/luarocks/site_config.lua ;\
   echo 'site_config.LUAROCKS_RUNTIME_EXTERNAL_DEPS_SUBDIRS={ bin="bin", lib={ "lib", [[lib64]] }, include="include" }' >> src/luarocks/site_config.lua ;\
fi
echo "return site_config" >> src/luarocks/site_config.lua
for f in luarocks luarocks-admin ;\
do \
   mv src/bin/$f src/bin/$f.bak ;\
   sed "s,^#!.*lua.*,#!/usr/bin/env lua,;/^package.path/d" < src/bin/$f.bak > src/bin/$f ;\
   chmod +rx src/bin/$f ;\
   rm -f src/bin/$f.bak ;\
done
for f in luarocks luarocks-admin ;\
do \
   sed "1d" src/bin/$f > src/bin/$f.bak ;\
   echo "#!/usr/local/bin/luajit" > src/bin/$f ;\
   echo "package.path = [[/usr/local/share/lua/5.1//?.lua;]]..package.path" | sed "s,//,/,g" >> src/bin/$f ;\
   cat src/bin/$f.bak >> src/bin/$f ;\
   chmod +rx src/bin/$f ;\
   rm -f src/bin/$f.bak ;\
done

Done. Type 'make install' to install into /usr/local.

mkdir -p "/usr/local/bin"
cd src/bin && \
luaver="5.1" && [ -n "$luaver" ] || luaver=` -e 'print(_VERSION:sub(5))'`; \
for f in luarocks luarocks-admin; \
do \
   cp "$f" "/usr/local/bin/$f-$luaver"; \
   chmod +rx "/usr/local/bin/$f-$luaver"; \
   ln -nfs "$f-$luaver" "/usr/local/bin/$f"; \
done
mkdir -p "/usr/local/share/lua/5.1//luarocks"
cd src/luarocks && for f in fs/tools.lua fs/unix/tools.lua fs/unix.lua fs/win32/tools.lua fs/win32.lua fs/lua.lua persist.lua list.lua require.lua repos.lua dir.lua make_manifest.lua command_line.lua config_cmd.lua install.lua build/command.lua build/cmake.lua build/make.lua build/builtin.lua fetch/cvs.lua fetch/git.lua fetch/sscm.lua tools/patch.lua fetch/svn.lua tools/zip.lua tools/tar.lua pack.lua type_check.lua make.lua remove.lua fs.lua manif.lua add.lua deps.lua build.lua search.lua show.lua manif_core.lua fetch.lua unpack.lua validate.lua cfg.lua download.lua help.lua util.lua index.lua cache.lua refresh_cache.lua loader.lua admin_remove.lua fetch/hg.lua fetch/git_file.lua new_version.lua lint.lua purge.lua path.lua path_cmd.lua write_rockspec.lua doc.lua upload.lua upload/api.lua upload/multipart.lua fetch/git_http.lua fetch/hg_http.lua fetch/hg_https.lua fetch/hg_ssh.lua fetch/git_https.lua fetch/git_ssh.lua; \
do \
   d="/usr/local/share/lua/5.1//luarocks"/`dirname "$f"` && \
   mkdir -p "$d" && \
   cp "$f" "$d" || exit 1; \
done
mkdir -p "/usr/local/share/lua/5.1//luarocks"
cp src/luarocks/site_config.lua "/usr/local/share/lua/5.1//luarocks"
mkdir -p "/usr/local"
if [ ! -f "/usr/local/etc/luarocks/config-5.1.lua" ] ;\
then \
   mkdir -p `dirname "/usr/local/etc/luarocks/config-5.1.lua"` ;\
   echo 'rocks_trees = {' >> "/usr/local/etc/luarocks/config-5.1.lua" ;\
   if  [ ! -n "" ] ;\
   then \
      echo '   { name = [[user]], root = home..[[/.luarocks]] },' >> "/usr/local/etc/luarocks/config-5.1.lua" ;\
   fi ;\
   echo '   { name = [[system]], root = [[/usr/local]] }' >> "/usr/local/etc/luarocks/config-5.1.lua" ;\
   echo '}' >> "/usr/local/etc/luarocks/config-5.1.lua" ;\
fi
[root@tutorialspots luarocks]# popd
/usr/local/src ~
[root@tutorialspots src]#

Leave a Reply