How to install luarocks packages without internet?

2019-07-30 09:44发布

I used torch distro repository on github and installed LuaJIT and luarocks.

I want to install luarocks packages , from source, that is downloading the packages(.zip files) and building them from source .

I tried doing it by downloading the packages from github and then running luarocks install modulename.rockspec . But here it again starts cloning from github.

Can anyone tell me the exact procedure to do this ?

1条回答
做个烂人
2楼-- · 2019-07-30 10:45

You can use either source rocks or binary rocks.

Using source rocks

A source rock is a package with .src.rock extension containing the sources. You create it packing a rockspec:

luarocks pack bla-1.0-1.rockspec     # uses the network

This produces bla-1.0-1.src.rock. Running luarocks build bla-1.0-1.src.rock does not use the network to build bla, but it will hit the network to fetch dependencies if needed. So you need to pack and install all dependencies beforehand.

Using binary rocks

A binary rock is a compiled package with .PLATFORM.rock extension containing the .lua or .so/.dll modules. You create it building a module and then packing the code you built:

luarocks build bla-1.0-1.rockspec     # uses the network
luarocks pack bla                     # doesn't use the network

This produces a binary rock, say bla-1.0-1.linux-x86.rock. Note however that to install this in another machine, the target machine needs to be fully ABI-compatible, that is, all installed libraries in the source and destination machine need to be compatible (e.g. same OS/distro version). For this reason, this is useful for deploying rocks to multiple machines in a farm, but not for distributing binary packages for end-users in general.

Grouping packed rocks into a local server

Once you pack all rocks you need (and their dependencies) using one of the methods above, you can put them all in a directory, then turn it into a "local server":

mkdir my_rocks
mv *.rock my_rocks     # suppose we have some packed .rock files here
cd my_rocks
luarocks-admin make-manifest my_rocks

This works with both source and binary rocks. You'll then be able to build rocks from there without fetching the network.

luarocks install bla --only-server=/home/YOURNAME/my_rocks
查看更多
登录 后发表回答