I was anxious to test Tir on my Mac and had to hack some lua rocks to get them to install and let me get going.
I must admit it’s a horrible hack but it works. Maybe someone (meaning not me ;) should ask the luaposix and luuid authors to get them working on Mac.
I first stumbled on an install problem with luaposix.
sudo luarocks install luaposix
Installing http://luarocks.org/repositories/rocks/luaposix-5.1.7-2.src.rock…
Archive: /private/tmp/luarocks_luarocks-rock-luaposix-5.1.7-2-8760/luaposix-5.1.7-2.src.rock
inflating: luaposix-5.1.7-2.rockspec
inflating: luaposix-5.1.7.tar.bz2
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 -I/usr/local/include -c lposix.c -o lposix.o
lposix.c: In function ‘get_clk_id_const’:
lposix.c:1214: error: ‘CLOCK_REALTIME’ undeclared (first use in this function)
lposix.c:1214: error: (Each undeclared identifier is reported only once
lposix.c:1214: error: for each function it appears in.)
lposix.c:1216: error: ‘CLOCK_MONOTONIC’ undeclared (first use in this function)
lposix.c:1218: error: ‘CLOCK_PROCESS_CPUTIME_ID’ undeclared (first use in this function)
lposix.c:1220: error: ‘CLOCK_THREAD_CPUTIME_ID’ undeclared (first use in this function)
Error: Build error: Failed compiling object lposix.o
I pointed luarocks to the previous rockspec of luaposix and the installation worked:
sudo luarocks install http://luarocks.org/repositories/rocks/luaposix-5.1.2-1.rockspec
luarocks list
Installed rocks:
————————
luaposix
5.1.2-1 (installed) - /usr/local/lib/luarocks/rocks
Is something else missing?
sudo luarocks install http://tir.mongrel2.org/downloads/tir-0.7-1.rockspec
Missing dependencies for tir:
luuid
The regular install did not work:
sudo luarocks install luuid
Installing http://luarocks.org/repositories/rocks/luuid-20100303-1.src.rock…
Archive: /private/tmp/luarocks_luarocks-rock-luuid-20100303-1-4564/luuid-20100303-1.src.rock
inflating: luuid-20100303-1.rockspec
extracting: luuid.tar.gz
Error: Could not find expected file libuuid.dylib for LIBUUID — you may have to install LIBUUID in your system and/or set the LIBUUID_DIR variable
Mmm… luuid expects libuuid.dylib to be installed through e2fsprogs. I do have e2fsprogs installed with MacPorts.
port list | grep e2fsprogs
e2fsprogs @1.41.10 sysutils/e2fsprogs
libuuid.dylib is also there:
ls /opt/local/lib/libuuid.dylib
/opt/local/lib/libuuid.dylib
I tried setting the LIBUUID_DIR to /opt/local/lib (also tried /opt/local) but luuid kept complaining about the missing dylib.
As a last resort I downloaded e2fsprogs from:
http://prdownloads.sourceforge.net/e2fsprogs/e2fsprogs-1.41.12.tar.gz
and luuid from:
http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/5.1/luuid.tar.gz
untared both and compiled luuid directly against e2fsprogs’ uuid source:
cd e2fsprogs-1.41.12
./configure
cd lib/uuid
make
./tst_uuid
cp luuid.c . (copy luuid.c from luuid.tar.gz)
gcc -O2 -fno-common -c -o luuid.o luuid.c
gcc -bundle -undefined dynamic_lookup -o uuid.so clear.o compare.o copy.o gen_uuid.o isnull.o luuid.o pack.o parse.o unpack.o unparse.o uuid_time.o
lua uuid/test.lua
uuid library for Lua 5.1 / Mar 2010
uuid generation type time os.time
ef1f2001-c8ea-4c5e-b929-4c3fe418619b default -391635366
c47e5ec0-6108-434d-8fa1-ee32858e73b8 default -1308890128
891c5fe2-0083-42bd-b436-598178d347f3 random -1077775031
5ab31b64-f6f4-11df-af44-1f6e50cf2f04 time 1290511519 1290511519
5be57e5a-f6f4-11df-af44-1f6e50cf2f04 time 1290511521 1290511521
uuid validation isvalid expect
84949cc5-4701-4a84-895b-354c584a981b true true pass
84949CC5-4701-4A84-895B-354C584A981B true true pass
84949cc5-4701-4a84-895b-354c584a981bc false false pass
84949cc5-4701-4a84-895b-354c584a981 false false pass
84949cc5x4701-4a84-895b-354c584a981b false false pass
84949cc504701-4a84-895b-354c584a981b false false pass
84949cc5-470104a84-895b-354c584a981b false false pass
84949cc5-4701-4a840895b-354c584a981b false false pass
84949cc5-4701-4a84-895b0354c584a981b false false pass
g4949cc5-4701-4a84-895b-354c584a981b false false pass
84949cc5-4701-4a84-895b-354c584a981g false false pass
uuid library for Lua 5.1 / Mar 2010
Because I was not able to rebundle the luuid rock, I took the manual road and just copied uuid.so to /usr/local/lib/lua/5.1/
The following works now:
lua
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> require ‘uuid’
> u=uuid.new()
> print(u,”default”,uuid.time(u))
03801c06-d0a3-4a8e-aec1-bf6c7bbbbc01 default -566323678
You can either remove luuid from tir’s rockspec dependencies or create a luuid/ directory with a 20100303-1/ directory inside it containing the luuid-20100303-1.rockspec and a rock_manifest file with the following content (generate your own md5 signature for uuid.so):
rock_manifest = {
lib={
[‘uuid.so’]=’aa17da86ed0e5664b65da672ad9a1684’
},
[‘luuid-20100303-1.rockspec’]=’fdd4e2f6845cdde78b5773d84280bb3c’
}
then copy it to /usr/local/lib/luarocks/rocks/ and force luarocks-admin to rebuild its manifest with:
sudo luarocks-admin make_manifest
Good luck!