aperezdc / luabot

An XMPP (Jabber) bot written in Lua using the protocol implementation from Verse/Prosody

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not able to use luabot as a service : luarock spec file coud help ?

mathdesc opened this issue · comments

aka luabot rocks but with luarocks luabot would rock on luarocks... and harder

Before realizing that a rock spec file was lacking to produce a installable package,

I tried using luarocks to produce a rock that could be installed in a way that enable to create an LSBInitScript service started as a system service (with a prosody requiere dependency)

I lack the lua knowledge for that but I guess my issue is worth mentioning for any other watchers whom enjoy luabot but lack the luarock support to proper deploy it as a dedicated service .

Why not using it or a similar packaging ?

@mathdesc For the moment the recommended way of installing is using the luafilesystem, luasocket and luasec packages from your distribution, cloning the Git repository, and running the bot from there. The repository includes all the other needed modules for the bot. In particular, it is not neccessary to have all of Prosody installed, and that is why the bot repository includes the needed modules.

Would some documentation on how to run the bot be enough for you, or would you prefer to have the possibility of installing it using LuaRocks?

@aperezdc Prosody fully fledged is not a must have, I understood. As for me I already have it full to run muc XMPP service, so... It managed to start it on the command line no issue there.

"Running the bot from there" is not a proper distro way of running luabot as a service like Prosody does for instance. And I tend to run software I like as a service (reloadable, autorestartable, etc..) LSB is at least a common ground on various unix based distributions.

Yes some doc to start (the README.md seem pruned on how to start the bot) and package & deploy luabot would definitely be a plus.

Yes it could be so nice to be able to package your sources with rules and generate an installable package.

I find LuaRocks on the fly after my unsuccessful attempt to have a dedicated service from the source, trying to hack the "relative path" but didn't get an "install path".

I don't even really know if it's the way to go, I'm not competent in packaging lua, but if you feel like
that servicing the purpose and the target, I'll follow your advice. Now whether you think it by luarocks or another packaging system, or even have the source to be runnable "position independent", it's up to your better judgement (and time I guess)

Thanks for your concern, best regards

A scm version is now available in LuaRocks. It should be possible to do something like the following:

luarocks install --server=https://luarocks.org/dev luabot
$EDITOR config.lua  # See the example config from the repo
luabot config.lua

@mathdesc: Would you mind trying the steps above? If it doesn't work, please let me know and I'll try to fix the LuaRocks packaging.

@aperezdc I did not manage to get luabot installed.
I also tried installing rock dependencies luaexpat-1.3.0 by itself with
the same :
Could not find expected file expat.h for EXPAT.

Here are some information and traces to point this out

sudo luarocks install --server=http://luarocks.org/dev luabot
Installing http://luarocks.org/dev/luabot-scm-0.rockspec...
Using http://luarocks.org/dev/luabot-scm-0.rockspec... switching to 'build' mode

Missing dependencies for luabot:
luaexpat >= 1.2
luafilesystem >= 1.6
luasec >= 0.6
lua >= 5.2

Using http://luarocks.org/repositories/rocks/luaexpat-1.3.0-1.src.rock... switching to 'build' mode
Archive:  /tmp/luarocks_luarocks-rock-luaexpat-1.3.0-1-7493/luaexpat-1.3.0-1.src.rock
  inflating: luaexpat-1.3.0-1.rockspec  
 extracting: luaexpat-1.3.0.tar.gz   

Error: Failed installing dependency: http://luarocks.org/repositories/rocks/luaexpat-1.3.0-1.src.rock 
 Could not find expected file expat.h for EXPAT -- you may have to install EXPAT in your system and/or pass EXPAT_DIR or EXPAT_INCDIR to the luarocks command. Example: luarocks install luaexpat EXPAT_DIR=/usr/local

Strange while the deps are installed with apt

 dpkg --get-selections | grep lua
liblua5.1-0:amd64               install
liblua5.1-0-dev:amd64               install
lua-event:amd64                 install
lua-expat:amd64                 install
lua-filesystem:amd64                install
lua-sec:amd64                   install
lua-socket:amd64                install
lua5.1                      install
lua5.2                      install
luarocks                    install

Maybe I miss an export of a path LUA_CPATH ?
Because below I can see lua environnement is pointing to
the correct lua-expat lib system-wide installation.

dpkg --listfiles lua-expat
/.
/usr
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/lua
/usr/lib/x86_64-linux-gnu/lua/5.1
/usr/lib/x86_64-linux-gnu/lua/5.2
/usr/lib/x86_64-linux-gnu/liblua5.1-expat.so.0.0.0
/usr/lib/x86_64-linux-gnu/liblua5.2-expat.so.0.0.0
/usr/share
/usr/share/doc
/usr/share/doc/lua-expat
/usr/share/doc/lua-expat/changelog.Debian.gz
/usr/share/doc/lua-expat/copyright
/usr/share/lua
/usr/share/lua/5.1
/usr/share/lua/5.1/lxp
/usr/share/lua/5.1/lxp/lom.lua
/usr/share/lua/5.2
/usr/share/lua/5.2/lxp
/usr/lib/x86_64-linux-gnu/liblua5.2-expat.so.0
/usr/lib/x86_64-linux-gnu/liblua5.1-expat.so.0
/usr/lib/x86_64-linux-gnu/lua/5.1/lxp.so
/usr/lib/x86_64-linux-gnu/lua/5.2/lxp.so
/usr/share/lua/5.2/lxp/lom.lua

dpkg -s lua-expat:amd64 | grep 'Version'
Version: 1.2.0-6
Lua-Versions: 5.1 5.2

luarocks path --bin | grep /usr/lib/x86_64-linux-gnu/lua/5.1
export LUA_CPATH='/usr/local/lib/lua/5.1/?.so;
/home/mathdesc/.luarocks/lib/lua/5.1/?.so;
./?.so;
/usr/local/lib/lua/5.1/?.so;
/usr/lib/x86_64-linux-gnu/lua/5.1/?.so;
/usr/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so'

@mathdesc: From the output of dpkg --listfiles it looks like the Debian packages do not install the rock_manifest files, so of course LuaRocks thinks that the packages are not installed, and it tries to build them. In order to build them, the Expat headers provided by the libexpat1-dev package are needed. If you install that package, then LuaRocks will be able to compile and install LuaExpat.

Maybe it would be a good idea to suggest to the distribution developers to have also the manifest files which would make LuaRocks aware that the packages are installed and available; but at the same time LuaRocks might try to update versions of a package, and delete the version installed from the distro packages... Dunno. There does not seem to be a reasonable way of telling LuaRocks that a pacakge is already installed in a way that it should not remove the old version when it install an update.

At any rate, please do try installing libexpat1-dev and try the suggested command again. Ah, as a hint, you may want to tell LuaRocks to install Lua modules in your user directory with luarocks install --user, so you don't need to use sudo.