Monday, February 25, 2013
Something you never want to hear from an airline pilot
Ladies and gentlemen, this is your captain speaking. We have a small problem. All four engines have stopped. We are doing our damnedest to get them going again. I trust you are not in too much distress.
And this reminds me of the following quote: “Superior pilots will use their superior judgement to avoid sitations that require their superior skills.”
Some impressions about LuaRocks
I've gone off against “control panels” (and “package managers”) a few times so it's odd that I find myself playing around with LuaRocks, a package manager for installing Lua-based software (Perl has CPAN, Ruby has RubyGems, so it's not uncommon for package management to exist for languages).
So far, it hasn't been that horrible. One neat aspect of LuaRocks is that the specification for a “rock” can exist outside the source code that comprises a “rock.” For instance, the following “rockspec:”
package = "OrgConman" version = "1.0.0-1" source = { url = "git://github.com/spc476/lua-conmanorg.git", branch = "master", } description = { homepage = "https://github.com/spc476/lua-conmanorg", maintainer = "Sean Conner", license = "LGPL", summary = "Useful modules. A lot of useful modules", detailed = [[ A lot of useful routines to manipulate tables. Yes, I should write more text here. But I'm still playing aorund with this stuff. ]], } supported_platforms = { "linux", "macosx", "freebsd", "unix" } dependencies = { "lua ~> 5.1" } external_dependencies = { TCC = { header = "libtcc.h" }, OPENSSH = { library = "crypto" }, MAGIC = { header = "magic.h" }, RT = { library = "rt" }, } build = { type = "make", copy_directories = {}, variables = { CC = "$(CC) -std=c99", CFLAGS = "$(CFLAGS)", LFLAGS = "$(LIBFLAG)", LUALUA = "$(LUADIR)", LUALIB = "$(LIBDIR)", }, }
can be used, as is, to install the package, even though no existing
“rock” exists, nor has it been published anywhere. All
it takes is saving it in a file called
orgconman-1.0.0-1.rockspec
, and running luarocks build
orgconman-1.0.0-1.rockspec
—it will then download the code from github,
build it and install it (assuming you meet the dependencies listed).
And once published, it will be a simple luarocks install
orgconman
to install the code (this will check the “rock servers”
listed in the configuration file for the named “rock”, download the
“rockspec” and then build and install it).
Even nicer, you can specify different locations to install the resulting
“rocks” beside the default /usr/local/lib/lua/
(such
locations can be specified in the configuration file, or on the command
line).
So far, the only problematic aspect of LuaRocks I've encountered is
actually making a “rock.” luarocks pack
rockspec
doesn't quite work out of the box:
[spc]lucy:/tmp>luarocks pack orgconman-1.0.0-1.rockspec Initialized empty Git repository in /tmp/luarocks_orgconman-1.0.0-1-7168/lua-conmanorg/.git/ remote: Counting objects: 41, done. remote: Compressing objects: 100% (37/37), done. remote: Total 41 (delta 11), reused 11 (delta 2) Receiving objects: 100% (41/41), 60.55 KiB, done. Resolving deltas: 100% (11/11), done. sh: line 0: cd: lua-conmanorg: No such file or directory Packed: /tmp/orgconman-1.0.0-1.src.rock
It seems like it's not switching into the temporary build directory when trying to make the “rock.” I can work around it (by checking out the code at the same level as the “rockspec”), but I still find that bug annoying.
Another issue—there is no easy way to specify the language level (C89
or C99) in a platform independent way. Here, I have to assume the given
platforms I do support use gcc
, but not all platforms I
currently use Lua on have gcc
(Solaris
comes to mind). Again, I'm working around the issue, but I feel it is
something that should be addressed somehow.
This is also having me rethink how I develop the modules I have
developed. Right now, they all exist in a single repository, but all the
modules are mostly independent. But there isn't a simple way to checkout
specific files using git
, so I may have to make sepearate
repositories for each module (so far, 22 existing modules, two additional
ones I could add).