2009-10-15 08:07:12 +00:00
|
|
|
require 'formula'
|
2009-09-15 09:23:45 +00:00
|
|
|
|
2011-04-01 03:23:19 +00:00
|
|
|
def use_luajit?; ARGV.include? '--with-luajit'; end
|
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Luarocks < Formula
|
2011-04-01 03:23:19 +00:00
|
|
|
url 'http://luarocks.org/releases/luarocks-2.0.4.1.tar.gz'
|
2010-06-23 19:30:26 +00:00
|
|
|
homepage 'http://luarocks.org'
|
2011-04-01 03:23:19 +00:00
|
|
|
md5 '2c7caccce3cdf236e6f9aca7bec9bdea'
|
2009-09-15 09:23:45 +00:00
|
|
|
|
2011-04-01 03:23:19 +00:00
|
|
|
depends_on use_luajit? ? 'luajit' : 'lua'
|
2009-09-15 09:23:45 +00:00
|
|
|
|
2011-12-18 23:28:16 +00:00
|
|
|
fails_with_llvm "Lua itself compiles with llvm, but may fail when other software tries to link."
|
2011-04-01 03:23:19 +00:00
|
|
|
|
2011-08-04 11:47:53 +00:00
|
|
|
def patches
|
|
|
|
DATA if HOMEBREW_PREFIX.to_s == '/usr/local'
|
|
|
|
end
|
|
|
|
|
2011-04-01 03:23:19 +00:00
|
|
|
def options
|
|
|
|
[['--with-luajit', 'Use LuaJIT instead of the stock Lua.']]
|
|
|
|
end
|
2011-03-19 21:20:02 +00:00
|
|
|
|
2011-04-01 03:23:19 +00:00
|
|
|
def install
|
2010-06-23 19:30:23 +00:00
|
|
|
# Install to the Cellar, but direct modules to HOMEBREW_PREFIX
|
2011-04-01 03:23:19 +00:00
|
|
|
args = ["--prefix=#{prefix}",
|
2011-08-04 11:47:53 +00:00
|
|
|
"--rocks-tree=#{HOMEBREW_PREFIX}",
|
2011-04-01 03:23:19 +00:00
|
|
|
"--sysconfdir=#{etc}/luarocks"]
|
|
|
|
|
|
|
|
if use_luajit?
|
|
|
|
args << "--with-lua-include=#{HOMEBREW_PREFIX}/include/luajit-2.0"
|
|
|
|
args << "--lua-suffix=jit"
|
|
|
|
end
|
|
|
|
|
|
|
|
system "./configure", *args
|
2009-09-15 09:23:45 +00:00
|
|
|
system "make"
|
|
|
|
system "make install"
|
|
|
|
end
|
2010-06-30 17:03:22 +00:00
|
|
|
|
2011-08-04 11:47:53 +00:00
|
|
|
def caveats; <<-EOS.undent
|
|
|
|
Luarocks now "just works" but this means any rocks you installed previously
|
|
|
|
will need to be moved from `lib/luarocks/lib/luarocks` to `lib/luarocks`.
|
|
|
|
You'll probably have a better time of it all if you just reinstall them.
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
2010-06-30 17:03:22 +00:00
|
|
|
def test
|
|
|
|
opoo "Luarocks test script installs 'lpeg'"
|
2011-09-01 20:00:28 +00:00
|
|
|
system "#{bin}/luarocks install lpeg"
|
2011-08-04 11:47:53 +00:00
|
|
|
system "lua", "-llpeg", "-e", 'print ("Hello World!")'
|
2010-06-30 17:03:22 +00:00
|
|
|
end
|
2009-09-15 09:23:45 +00:00
|
|
|
end
|
2011-08-04 11:47:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
# this patch because we set the permissions of /usr/local to root owned
|
|
|
|
# not user writable to be "good" citizens of /usr/local. Actually LUA is being
|
|
|
|
# pedantic since all the directories it wants under /usr/local are writable
|
|
|
|
# so we just return true. Naughty, but I don't know LUA and don't want to
|
|
|
|
# write a better patch.
|
|
|
|
__END__
|
|
|
|
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua
|
|
|
|
index 3a547fe..ca4ddc5 100644
|
|
|
|
--- a/src/luarocks/fs/lua.lua
|
|
|
|
+++ b/src/luarocks/fs/lua.lua
|
|
|
|
@@ -619,10 +619,5 @@ end
|
|
|
|
-- @return boolean or (boolean, string): true on success, false on failure,
|
|
|
|
-- plus an error message.
|
|
|
|
function check_command_permissions(flags)
|
|
|
|
- local root_dir = path.root_dir(cfg.rocks_dir)
|
|
|
|
- if not flags["local"] and not fs.is_writable(root_dir) then
|
|
|
|
- return nil, "Your user does not have write permissions in " .. root_dir ..
|
|
|
|
- " \n-- you may want to run as a privileged user or use your local tree with --local."
|
|
|
|
- end
|
|
|
|
return true
|
|
|
|
end
|