Avançar para o conteúdo principal
Prosody's plugin installer is making use of Luarocks to work underneath the hood. Therefore, it makes sense that we look a bit into Luarocks to see how it works.

Concepts

Here is what you need to know. From the perspective of Luarocks, Lua Libraries are files called Rocks. Rock files are like a zip file, in the sense that inside there are many files. Most of those files are the sources, which means those are the files that have all the code itself. And then there is a rockspec file. This is like an instruction file, written in Lua, which contains the important information that Luarocks needs to do its job. Things like the location of sources, dependencies and build instructions. The code is then installed in what is called a rock tree. A normal folder, in other words. But this folder is referenced on luarocks documentation, for example, so that things know where to look for when they need to use a particular library.

Installing, removing as list

If you are working on debian you can just use:
  • sudo apt-get install luarocks
Now, there might be some trouble here and there, depending on your machine, or if you are in a different OS, but the guys at luarocks have tips for almost every possible situation, just check here:
Worst case scenario head over to their support section and surely you'll find a someone to help you.

Now, with that out of the way, lets (The attentive reader will notice I misspelled "lets" at the beginning of the next video 😅) check how it works! Topics we are covering here:
  • luarocks help
  • configuration section
  • using the global and local trees
  • using install, remove and list

Other flags

--tree

We can use this flag to specify a custom path for a rock tree, without changing anything at the configuration file.

--server

We can use this flag to specify the place from which we are getting our rocks. We can reference a rock tree, a repository or a server. These terms are used somehow interchangeably, which might be confusing. Lets go by parts! Here I'll show you how to use a remote source being served to us.

Lets take it slow

Okay, so things might get a bit confusing now. Lets keep it simple. There is a number of things to take into account, but all of them lead to the same place. We want to have rocks, which consist of rockspecs and lua libraries packed together. Therefore, we need to write rockspecs related to these sources, if we want to have a rock. We can do this with the write_rockspecs command:

Luarocks provides a command that allows us to automatically create rockspecs. It will only fill some fields by default though. Most of them have to be filled by hand. Notably, the source.url source has to be filled. It is a mandatory field, without it you wont make it with luarocks install or remove commands, for example.
You can make it work with the "make" command though. The make command is your answer, in the cases where you have everything in your local machine. It is meant for use to install things, when we dont have to fetch them from somewhere in the web. Here is out it works:

Luarocks-admin is another command line tool that comes with the Luarocks. This one is intended to deal with repository management. Repository management! It is not a tool to actually run a true server. We can create a local or remote folder, and make use of this tool to create manifests and add/remove rocks. But it doesn't make that folder into a server! That has to be done with other tools, and it is not the point or the responsibility of luarocks to set up a private or custom server for us. That is up to the user.

We'll talk a bit about these "servers" but for now, lets consider this. We can make a local folder into a luarocks compliant repository. For that we need to create a file, called a manifest. This file tracks down which files are currently available at that location. Luarocks fetches things from its official remote repository, but we are given the option to run our very own, very secretive and special thing 😎
We will give it a look about how it works and how to use the --server and --tree flags to work around.

Comentários

Mensagens populares deste blogue

Sailing!

After some fusion dance, we have some stuff working neatly! Last week was all about the lua environment and improvements aimed at user-friendliness, which you can check down below with latest changesets and demos. Events prosodyctl Removed most development / experimental commands Created a script that is automatically setting up a ready to be served repository will rockspecs for all of prosody's plugins ( demo ) Various improvements/updates to the main commands: list - demo install demos: installing a prosody plugin installing a luarocks library Installation also prints configuration help   remove - demo prosody uses a separate folder to deal with non-standard plugins - demo Users can configure their own path, and override it at any time from the command line if needed - demo Updated the startup utility script regarding management of default/custom installer directories and lua environment Difficulties The greatest obstacles this past week were ...
Prosody's plugin installer is making use of Luarocks to get things working. Therefore, it makes sense that we look a bit into Luarocks to see how it works. Concepts Here is what you need to know. Luarocks uses files, called rockspecs, to get things installed around. These are basically instruction files and they tell the program how to do the work. We can pack the sources and the rockspecs into a single file, called a rock. We can install libraries from both rocks and rockspec files. The code is installed in what is called a rock tree, which is a folder with a specific structure inside, organized in a way to help with the required management of libraries and servers. Installing, removing and list If you are working on debian you can just use: sudo apt-get install luarocks Now, there might be some trouble here and there, depending on your machine, or if you are in a different OS, but the guys at luarocks have tips for almost every possible situation, just che...