Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lua@5.1 & lua: update luarocks to 2.4.4 #21282

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions Formula/lua.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Lua < Formula
homepage "https://www.lua.org/"
url "https://www.lua.org/ftp/lua-5.3.4.tar.gz"
sha256 "f681aa518233bc407e23acf0f5887c884f17436f000d453b2491a9f11a52400c"
revision 2
revision 3

bottle do
cellar :any
Expand All @@ -19,11 +19,9 @@ class Lua < Formula
# ***Update me with each version bump!***
patch :DATA

# Don't use the https://luarocks.org/releases/luarocks-x.y.z.tar.gz URL
# directly as it redirects to the HTTP version of the below URL.
resource "luarocks" do
url "https://luarocks.github.io/luarocks/releases/luarocks-2.4.3.tar.gz"
sha256 "4d414d32fed5bb121c72d3ff1280b7f2dc9027a9bc012e41dfbffd5b519b362e"
url "https://luarocks.org/releases/luarocks-2.4.4.tar.gz"
sha256 "3938df33de33752ff2c526e604410af3dceb4b7ff06a770bc4a240de80a1f934"
end

def install
Expand Down Expand Up @@ -73,10 +71,10 @@ def install

# This block ensures luarock exec scripts don't break across updates.
inreplace libexec/"share/lua/5.3/luarocks/site_config.lua" do |s|
s.gsub! libexec.to_s, opt_libexec
s.gsub! include.to_s, "#{HOMEBREW_PREFIX}/include"
s.gsub! lib.to_s, "#{HOMEBREW_PREFIX}/lib"
s.gsub! bin.to_s, "#{HOMEBREW_PREFIX}/bin"
s.gsub! libexec, opt_libexec
s.gsub! include, HOMEBREW_PREFIX/"include"
s.gsub! lib, HOMEBREW_PREFIX/"lib"
s.gsub! bin, HOMEBREW_PREFIX/"bin"
end
end
end
Expand Down
28 changes: 15 additions & 13 deletions Formula/lua@5.1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class LuaAT51 < Formula
url "https://www.lua.org/ftp/lua-5.1.5.tar.gz"
mirror "https://mirrors.ocf.berkeley.edu/debian/pool/main/l/lua5.1/lua5.1_5.1.5.orig.tar.gz"
sha256 "2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333"
revision 5
revision 6

bottle do
cellar :any
Expand Down Expand Up @@ -41,13 +41,14 @@ class LuaAT51 < Formula
end

resource "luarocks" do
url "https://keplerproject.github.io/luarocks/releases/luarocks-2.3.0.tar.gz"
sha256 "68e38feeb66052e29ad1935a71b875194ed8b9c67c2223af5f4d4e3e2464ed97"
url "https://luarocks.org/releases/luarocks-2.4.4.tar.gz"
sha256 "3938df33de33752ff2c526e604410af3dceb4b7ff06a770bc4a240de80a1f934"
end

def install
# Use our CC/CFLAGS to compile.
inreplace "src/Makefile" do |s|
s.gsub! HOMEBREW_PREFIX, prefix
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this actually work for a non-standard prefix?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should do, theoretically. It is just a slight variation of what we've been doing in the lua formula for ages, without anyone complaining about it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does the replacement not fail if the prefix isn't in the file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why wouldn't the prefix be in the file? We're the ones adding that line in the inline patch. Maybe I'm misunderstanding you? I've slept for about 4 hours over the last day 🙃.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, OK. That's what I get for looking at this on my iPhone.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+	$(CC) -dynamiclib -install_name HOMEBREW_PREFIX/lib/liblua.5.1.dylib \
+		-compatibility_version 5.1 -current_version 5.1.5 \
+		-o liblua.5.1.5.dylib $^

compared to:

+	$(CC) -dynamiclib -install_name @LUA_PREFIX@/lib/liblua.5.3.dylib \
+		-compatibility_version 5.3 -current_version 5.3.4 \
+		-o liblua.5.3.4.dylib $^

in the lua formula. Same principle, just a slight divergence at some point for some reason. Possibly my fault given how much I've touched these formulae over the years.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not look right. If I am not mistaking, this should be

s.gsub! "HOMEBREW_PREFIX", prefix

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think so? brew unpack --patch lua@5.1 shows the blob as I expected it to be:

$(LUA_A): $(CORE_O) $(LIB_O)
	$(CC) -dynamiclib -install_name /usr/local/lib/liblua.5.1.dylib \
		-compatibility_version 5.1 -current_version 5.1.5 \
		-o liblua.5.1.5.dylib $^

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get this for non-standard homebrew prefix.

brew upgrade lua@5.1
==> Upgrading 1 outdated package, with result:
lua@5.1 5.1.5_6
==> Upgrading lua@5.1 
==> Downloading https://www.lua.org/ftp/lua-5.1.5.tar.gz
######################################################################## 100.0%
Error: inreplace failed
src/Makefile:
  expected replacement of #<Pathname:/home/comp/chengxu/usr> with #<Pathname:/home/comp/chengxu/usr/Cellar/lua@5.1/5.1.5_6>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure I tried a string replacement in the default prefix and hit issues with it, which is why I didn't go down that route. Maybe we should just save ourselves some hassle & change it to @LUA_PREFIX@ to match the lua formula.

s.remove_make_var! "CC"
s.change_make_var! "CFLAGS", "#{ENV.cflags} $(MYCFLAGS)"
s.change_make_var! "MYLDFLAGS", ENV.ldflags
Expand All @@ -74,11 +75,11 @@ def install
# 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"
mv "#{man1}/luac.1", "#{man1}/luac-5.1.1"
mv "#{lib}/pkgconfig/lua.pc", "#{lib}/pkgconfig/lua-5.1.pc"
mv bin/"lua", bin/"lua-5.1"
mv bin/"luac", bin/"luac-5.1"
mv man1/"lua.1", man1/"lua-5.1.1"
mv man1/"luac.1", man1/"luac-5.1.1"
mv lib/"pkgconfig/lua.pc", lib/"pkgconfig/lua-5.1.pc"
bin.install_symlink "lua-5.1" => "lua5.1"
bin.install_symlink "luac-5.1" => "luac5.1"
include.install_symlink "lua-5.1" => "lua5.1"
Expand All @@ -93,7 +94,8 @@ def install

system "./configure", "--prefix=#{libexec}", "--rocks-tree=#{HOMEBREW_PREFIX}",
"--sysconfdir=#{etc}/luarocks51", "--with-lua=#{prefix}",
"--lua-version=5.1", "--versioned-rocks-dir"
"--with-lua-include=#{include}/lua-5.1", "--lua-version=5.1",
"--versioned-rocks-dir"
system "make", "build"
system "make", "install"

Expand All @@ -103,10 +105,10 @@ def install

# 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! libexec.to_s, opt_libexec.to_s
s.gsub! include.to_s, "#{HOMEBREW_PREFIX}/include"
s.gsub! lib.to_s, "#{HOMEBREW_PREFIX}/lib"
s.gsub! bin.to_s, "#{HOMEBREW_PREFIX}/bin"
s.gsub! libexec, opt_libexec
s.gsub! include, HOMEBREW_PREFIX/"include"
s.gsub! lib, HOMEBREW_PREFIX/"lib"
s.gsub! bin, HOMEBREW_PREFIX/"bin"
end
end
end
Expand Down