2009-10-15 08:07:12 +00:00
|
|
|
require 'formula'
|
2009-09-15 09:23:45 +00:00
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Luarocks < Formula
|
2010-06-23 19:30:26 +00:00
|
|
|
homepage 'http://luarocks.org'
|
2013-08-09 16:04:41 +00:00
|
|
|
head 'https://github.com/keplerproject/luarocks.git'
|
2014-01-13 01:50:52 +00:00
|
|
|
url 'http://luarocks.org/releases/luarocks-2.1.2.tar.gz'
|
|
|
|
sha1 '406253d15c9d50bb0d09efa9807fb2ddd31cba9d'
|
2013-06-20 04:48:39 +00:00
|
|
|
|
2012-09-02 18:53:18 +00:00
|
|
|
option 'with-luajit', 'Use LuaJIT instead of the stock Lua'
|
2012-10-22 15:09:50 +00:00
|
|
|
option 'with-lua52', 'Use Lua 5.2 instead of the stock Lua'
|
2012-09-02 18:53:18 +00:00
|
|
|
|
2014-03-06 20:40:26 +00:00
|
|
|
if build.with? "luajit"
|
2012-09-02 18:53:18 +00:00
|
|
|
depends_on 'luajit'
|
2014-01-17 22:56:08 +00:00
|
|
|
# luajit depends internally on lua being installed
|
|
|
|
# and is only 5.1 compatible, see #25954
|
|
|
|
depends_on 'lua'
|
2014-03-06 20:40:26 +00:00
|
|
|
elsif build.with? "lua52"
|
2012-10-22 15:09:50 +00:00
|
|
|
depends_on 'lua52'
|
2012-09-02 18:53:18 +00:00
|
|
|
else
|
|
|
|
depends_on 'lua'
|
|
|
|
end
|
2009-09-15 09:23:45 +00:00
|
|
|
|
2012-03-18 20:33:24 +00:00
|
|
|
fails_with :llvm do
|
|
|
|
cause "Lua itself compiles with llvm, but may fail when other software tries to link."
|
|
|
|
end
|
2011-04-01 03:23:19 +00:00
|
|
|
|
2013-08-09 16:04:41 +00:00
|
|
|
# Remove writability checks in the install script.
|
|
|
|
# Homebrew checks that its install targets are writable, or fails with
|
|
|
|
# appropriate messaging if not. The check that luarocks does has been
|
|
|
|
# seen to have false positives, so remove it.
|
|
|
|
# TODO: better document the false positive cases, or remove this patch.
|
2014-03-19 17:07:57 +00:00
|
|
|
patch :DATA
|
2011-08-04 11:47:53 +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"]
|
|
|
|
|
2014-03-06 20:40:26 +00:00
|
|
|
if build.with? "luajit"
|
2011-04-01 03:23:19 +00:00
|
|
|
args << "--with-lua-include=#{HOMEBREW_PREFIX}/include/luajit-2.0"
|
|
|
|
args << "--lua-suffix=jit"
|
2014-01-14 02:30:32 +00:00
|
|
|
args << "--with-lua=luajit"
|
2011-04-01 03:23:19 +00:00
|
|
|
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
|
|
|
|
2013-04-09 17:58:14 +00:00
|
|
|
def caveats; <<-EOS.undent
|
|
|
|
Rocks install to: #{HOMEBREW_PREFIX}/lib/luarocks/rocks
|
|
|
|
|
|
|
|
You may need to run `luarocks install` inside the Homebrew build
|
|
|
|
environment for rocks to successfully build. To do this, first run `brew sh`.
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
2014-02-23 21:31:41 +00:00
|
|
|
test do
|
2010-06-30 17:03:22 +00:00
|
|
|
opoo "Luarocks test script installs 'lpeg'"
|
2012-05-15 21:36:45 +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
|
|
|
|
|
|
|
__END__
|
|
|
|
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua
|
2012-07-10 00:36:48 +00:00
|
|
|
index 67c3ce0..2d149c7 100644
|
2011-08-04 11:47:53 +00:00
|
|
|
--- a/src/luarocks/fs/lua.lua
|
|
|
|
+++ b/src/luarocks/fs/lua.lua
|
2012-10-22 15:09:50 +00:00
|
|
|
@@ -669,29 +669,5 @@ end
|
2011-08-04 11:47:53 +00:00
|
|
|
-- @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)
|
2012-07-10 00:36:48 +00:00
|
|
|
- local ok = true
|
|
|
|
- local err = ""
|
2012-10-22 15:09:50 +00:00
|
|
|
- for _, dir in ipairs { cfg.rocks_dir, root_dir } do
|
2012-07-10 00:36:48 +00:00
|
|
|
- if fs.exists(dir) and not fs.is_writable(dir) then
|
|
|
|
- ok = false
|
|
|
|
- err = "Your user does not have write permissions in " .. dir
|
|
|
|
- break
|
|
|
|
- end
|
2011-08-04 11:47:53 +00:00
|
|
|
- end
|
2012-10-22 15:09:50 +00:00
|
|
|
- local root_parent = dir.dir_name(root_dir)
|
|
|
|
- if ok and not fs.exists(root_dir) and not fs.is_writable(root_parent) then
|
|
|
|
- ok = false
|
|
|
|
- err = root_dir.." does not exist and your user does not have write permissions in " .. root_parent
|
|
|
|
- end
|
2012-07-10 00:36:48 +00:00
|
|
|
- if ok then
|
|
|
|
- return true
|
|
|
|
- else
|
|
|
|
- if flags["local"] then
|
|
|
|
- err = err .. " \n-- please check your permissions."
|
|
|
|
- else
|
|
|
|
- err = err .. " \n-- you may want to run as a privileged user or use your local tree with --local."
|
|
|
|
- end
|
|
|
|
- return nil, err
|
|
|
|
- end
|
|
|
|
+ return true
|
2011-08-04 11:47:53 +00:00
|
|
|
end
|