aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominyk Tiller2015-04-20 13:39:05 +0100
committerMike McQuaid2015-04-24 10:36:31 +0100
commit06e2a38236544d74eb672d6dd7ba40a03da72ef3 (patch)
treed7a0834ec925e335f462f534c0e08497b6f9298d
parenta03796a453fa3f6e6059d632302bad6e8c1b2bfc (diff)
downloadhomebrew-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.
-rw-r--r--Library/Formula/lua.rb80
-rw-r--r--Library/Formula/lua51.rb78
2 files changed, 133 insertions, 25 deletions
diff --git a/Library/Formula/lua.rb b/Library/Formula/lua.rb
index ba3fbfd39..671f4553e 100644
--- a/Library/Formula/lua.rb
+++ b/Library/Formula/lua.rb
@@ -1,18 +1,16 @@
-require "formula"
-
class Lua < Formula
homepage "http://www.lua.org/"
url "http://www.lua.org/ftp/lua-5.2.3.tar.gz"
mirror "https://mirrors.kernel.org/debian/pool/main/l/lua5.2/lua5.2_5.2.3.orig.tar.gz"
- sha1 "926b7907bc8d274e063d42804666b40a3f3c124c"
+ sha256 "13c2fb97961381f7d06d5b5cea55b743c163800896fd5c5e2356201d3619002d"
+ revision 2
+
bottle do
sha1 "febde5bb25ed1a6d7cdf2b1a9ed798f29587f7f4" => :yosemite
sha1 "10d2bc30697656e6deb6fde98a8fafbd1385681c" => :mavericks
sha1 "ced438f2c14b0c7e26b356e4e13fb5a47c3c60fc" => :mountain_lion
end
- revision 1
-
fails_with :llvm do
build 2326
cause "Lua itself compiles with LLVM, but may fail when other software tries to link."
@@ -21,6 +19,7 @@ class Lua < 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
@@ -28,16 +27,25 @@ class Lua < Formula
# completion provided by advanced readline power patch
# See http://lua-users.org/wiki/LuaPowerPatches
- patch do
- url "http://luajit.org/patches/lua-5.2.0-advanced_readline.patch"
- sha1 "ca405dbd126bc018980a26c2c766dfb0f82e919e"
- end if build.with? "completion"
+ if build.with? "completion"
+ patch do
+ url "http://luajit.org/patches/lua-5.2.0-advanced_readline.patch"
+ sha256 "33d32d11fce4f85b88ce8f9bd54e6a6cbea376dfee3dbf8cdda3640e056bc29d"
+ end
+ end
# sigaction provided by posix signalling power patch
- patch do
- url "http://lua-users.org/files/wiki_insecure/power_patches/5.2/lua-5.2.3-sig_catch.patch"
- sha1 "b9a0044eb3c422f8405798c900ce31587156c7dd"
- end if build.with? "sigaction"
+ if build.with? "sigaction"
+ patch do
+ url "http://lua-users.org/files/wiki_insecure/power_patches/5.2/lua-5.2.3-sig_catch.patch"
+ sha256 "f2e77f73791c08169573658caa3c97ba8b574c870a0a165972ddfbddb948c164"
+ 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?
@@ -65,6 +73,33 @@ class Lua < Formula
ln_s "#{include}", "#{include}/lua5.2"
ln_s "#{lib}/pkgconfig/lua.pc", "#{lib}/pkgconfig/lua5.2.pc"
ln_s "#{lib}/pkgconfig/lua.pc", "#{lib}/pkgconfig/lua-5.2.pc"
+
+ # 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}/luarocks52", "--with-lua=#{lua_prefix}",
+ "--lua-version=5.2", "--versioned-rocks-dir", "--force-config=#{etc}/luarocks52"
+ system "make", "build"
+ system "make", "install"
+
+ (share+"lua/5.2/luarocks").install_symlink Dir["#{libexec}/share/lua/5.2/luarocks/*"]
+ bin.install_symlink libexec/"bin/luarocks-5.2"
+ bin.install_symlink libexec/"bin/luarocks-admin-5.2"
+
+ # This block ensures luarock exec scripts don't break across updates.
+ inreplace libexec/"share/lua/5.2/luarocks/site_config.lua" do |s|
+ s.gsub! "#{HOMEBREW_CELLAR}/lua/#{pkg_version}/libexec", "#{Formula["lua"].opt_libexec}"
+ s.gsub! "#{HOMEBREW_CELLAR}/lua/#{pkg_version}/include", "#{HOMEBREW_PREFIX}/include"
+ s.gsub! "#{HOMEBREW_CELLAR}/lua/#{pkg_version}/lib", "#{HOMEBREW_PREFIX}/lib"
+ s.gsub! "#{HOMEBREW_CELLAR}/lua/#{pkg_version}/bin", "#{HOMEBREW_PREFIX}/bin"
+ end
+ end
+ end
end
def pc_file; <<-EOS.undent
@@ -90,8 +125,27 @@ class Lua < Formula
EOS
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}/lua", "-e", "print ('Ducks are cool')"
+
+ if File.exist?(bin/"luarocks-5.2")
+ mkdir testpath/"luarocks"
+ system bin/"luarocks-5.2", "install", "moonscript", "--tree=#{testpath}/luarocks"
+ assert File.exist? testpath/"luarocks/bin/moon"
+ end
end
end
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