diff options
| author | Dominyk Tiller | 2015-04-20 13:39:05 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2015-04-24 10:36:31 +0100 |
| commit | 06e2a38236544d74eb672d6dd7ba40a03da72ef3 (patch) | |
| tree | d7a0834ec925e335f462f534c0e08497b6f9298d /Library/Formula/lua51.rb | |
| parent | a03796a453fa3f6e6059d632302bad6e8c1b2bfc (diff) | |
| download | homebrew-06e2a38236544d74eb672d6dd7ba40a03da72ef3.tar.bz2 | |
luarocks: migrate into lua formulae
This PR ‘pythonises’ the Lua setup. There have been requests for us to
do this for a while, and it’s a good idea - It’s just taken me a while
to finish ironing out.
The individual luarocks formula dies entirely, in favour of luarocks
being vendored into the two Lua formulae in Homebrew/homebrew with
versioned trees.
This provides roughly the same experience we deliver with pip
and co from Python.
Luajit is not yet supported, because it’s being a pain, but Luajit
support will land in the semi-near future, as will support for Lua53
in Versions. All 4 installations can sit side-by-side with no non-binary
conflict. Binary conflict is handled roughly the same way Python
handles it sadly, which is regrettable but presently unavoidable.
Diffstat (limited to 'Library/Formula/lua51.rb')
| -rw-r--r-- | Library/Formula/lua51.rb | 78 |
1 files changed, 66 insertions, 12 deletions
diff --git a/Library/Formula/lua51.rb b/Library/Formula/lua51.rb index 109605e5a..09c1fe89b 100644 --- a/Library/Formula/lua51.rb +++ b/Library/Formula/lua51.rb @@ -1,12 +1,11 @@ -require "formula" - class Lua51 < Formula # 5.2 is not fully backwards compatible so we must retain 2 Luas for now. # The transition has begun. Lua will now become Lua51, and Lua52 will become Lua. homepage "http://www.lua.org/" url "http://www.lua.org/ftp/lua-5.1.5.tar.gz" mirror "https://mirrors.kernel.org/debian/pool/main/l/lua5.1/lua5.1_5.1.5.orig.tar.gz" - sha1 "b3882111ad02ecc6b972f8c1241647905cb2e3fc" + sha256 "2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333" + revision 1 bottle do revision 1 @@ -23,6 +22,7 @@ class Lua51 < Formula option :universal option "with-completion", "Enables advanced readline support" option "without-sigaction", "Revert to ANSI signal instead of improved POSIX sigaction" + option "without-luarocks", "Don't build with Luarocks support embedded" # Be sure to build a dylib, or else runtime modules will pull in another static copy of liblua = crashy # See: https://github.com/Homebrew/homebrew/pull/5043 @@ -30,17 +30,26 @@ class Lua51 < Formula # sigaction provided by posix signalling power patch from # http://lua-users.org/wiki/LuaPowerPatches - patch do - url "http://lua-users.org/files/wiki_insecure/power_patches/5.1/sig_catch.patch" - sha1 "19f361f0c590f80fccd033486cbee6c9dc8616c8" - end if build.with? "sigaction" + if build.with? "completion" + patch do + url "http://lua-users.org/files/wiki_insecure/power_patches/5.1/sig_catch.patch" + sha256 "221435dedd84a386e2d40454e6260a678286bfb7128afa18a4339e5fdda9c8f2" + end + end # completion provided by advanced readline power patch from # http://lua-users.org/wiki/LuaPowerPatches - patch do - url "http://luajit.org/patches/lua-5.1.4-advanced_readline.patch" - sha1 "3cfe2eb027b51202923d20042ae37f3249508664" - end if build.with? "completion" + if build.with? "completion" + patch do + url "http://luajit.org/patches/lua-5.1.4-advanced_readline.patch" + sha256 "dfd17e720d1079dcb64529af3e4fea4a4abc0115c934f365282a489d134cceb4" + end + end + + resource "luarocks" do + url "https://github.com/keplerproject/luarocks/archive/v2.2.1.tar.gz" + sha256 "30e5bd99f82f5e3ea174572c1831f9ff83dfe37727f9fcfc89168b4572193571" + end def install ENV.universal_binary if build.universal? @@ -73,7 +82,6 @@ class Lua51 < Formula # Renaming from Lua to Lua51. # Note that the naming must be both lua-version & lua.version. # Software can't find the libraries without supporting both the hyphen or full stop. - mv "#{bin}/lua", "#{bin}/lua-5.1" mv "#{bin}/luac", "#{bin}/luac-5.1" mv "#{man1}/lua.1", "#{man1}/lua-5.1.1" @@ -83,10 +91,56 @@ class Lua51 < Formula ln_s "#{include}/lua-5.1", "#{include}/lua5.1" ln_s "#{bin}/lua-5.1", "#{bin}/lua5.1" ln_s "#{bin}/luac-5.1", "#{bin}/luac5.1" + + # This resource must be handled after the main install, since there's a lua dep. + # Keeping it in install rather than postinstall means we can bottle. + if build.with? "luarocks" + resource("luarocks").stage do + ENV.prepend_path "PATH", bin + lua_prefix = prefix + + system "./configure", "--prefix=#{libexec}", "--rocks-tree=#{HOMEBREW_PREFIX}", + "--sysconfdir=#{etc}/luarocks51", "--with-lua=#{lua_prefix}", + "--lua-version=5.1", "--versioned-rocks-dir", "--force-config=#{etc}/luarocks51" + system "make", "build" + system "make", "install" + + (share+"lua/5.1/luarocks").install_symlink Dir["#{libexec}/share/lua/5.1/luarocks/*"] + bin.install_symlink libexec/"bin/luarocks-5.1" + bin.install_symlink libexec/"bin/luarocks-admin-5.1" + + # This block ensures luarock exec scripts don't break across updates. + inreplace libexec/"share/lua/5.1/luarocks/site_config.lua" do |s| + s.gsub! "#{HOMEBREW_CELLAR}/lua51/#{pkg_version}/libexec", "#{Formula["lua51"].opt_libexec}" + s.gsub! "#{HOMEBREW_CELLAR}/lua51/#{pkg_version}/include", "#{HOMEBREW_PREFIX}/include" + s.gsub! "#{HOMEBREW_CELLAR}/lua51/#{pkg_version}/lib", "#{HOMEBREW_PREFIX}/lib" + s.gsub! "#{HOMEBREW_CELLAR}/lua51/#{pkg_version}/bin", "#{HOMEBREW_PREFIX}/bin" + end + end + end + end + + def caveats; <<-EOS.undent + Please be aware due to the way Luarocks is designed any binaries installed + via Luarocks-5.2 AND 5.1 will overwrite each other in #{HOMEBREW_PREFIX}/bin. + + This is, for now, unavoidable. If this is troublesome for you, you can build + rocks with the `--tree=` command to a special, non-conflicting location and + then add that to your `$PATH`. + + If you have existing Rocks trees in $HOME, you will need to migrate them to the new + location manually. You will only have to do this once. + EOS end test do system "#{bin}/lua5.1", "-e", "print ('Ducks are cool')" + + if File.exist?(bin/"luarocks-5.1") + mkdir testpath/"luarocks" + system bin/"luarocks-5.1", "install", "moonscript", "--tree=#{testpath}/luarocks" + assert File.exist? testpath/"luarocks/bin/moon" + end end end |
