From e9970e0769f8618ed92c22dba4731d88c82690ae Mon Sep 17 00:00:00 2001
From: leso-kn <info@lesosoftware.com>
Date: Sat, 17 Feb 2024 10:36:13 +0100
Subject: [PATCH] community/luarocks: add patch for luarocks#1549 (rocks --tree
 on musl)

Fixed in luarocks!1550 (merged) but not included in the latest release yet (luarocks v3.9.2 from 2022-12-08).

See https://github.com/luarocks/luarocks/pull/1550
---
 community/luarocks/APKBUILD                   |  4 ++-
 .../luarocks/fix-1549-rocks-tree-musl.patch   | 27 +++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)
 create mode 100644 community/luarocks/fix-1549-rocks-tree-musl.patch

diff --git a/community/luarocks/APKBUILD b/community/luarocks/APKBUILD
index 7c983a6a299a..274bdeb0a191 100644
--- a/community/luarocks/APKBUILD
+++ b/community/luarocks/APKBUILD
@@ -2,7 +2,7 @@
 # Maintainer: Jakub Jirutka <jakub@jirutka.cz>
 pkgname=luarocks
 pkgver=3.9.2
-pkgrel=1
+pkgrel=2
 pkgdesc="Deployment and management system for Lua modules"
 url="https://luarocks.org/"
 arch="noarch"
@@ -11,6 +11,7 @@ depends="curl"
 source="https://luarocks.org/releases/$pkgname-$pkgver.tar.gz
 	prefer-curl-to-wget.patch
 	config.lua
+	fix-1549-rocks-tree-musl.patch
 	"
 
 _lua_versions="5.1 5.2 5.3 5.4"
@@ -77,4 +78,5 @@ sha512sums="
 7e93164bdcf35338e993822931a8e59957ab69c6e23236a7a075649c2f7cd173305c4ca6e9d115fc5e282cb76c21754d7adac92b21885006e5ee3bc06a9d0059  luarocks-3.9.2.tar.gz
 e8ea793df118bd9b871d44706d9b51b95e0ae437dd4262df405c2ac45529f34cf88e06f1ba857abb4ce37b7df0e15777aba104c740709d2485d6579eadf3c032  prefer-curl-to-wget.patch
 5845d5643c3eeb6d4af6d919a588c5253c91e6a0b278116b4cd855437fc48ac64970fd3ef758c135bc0536ddc1aaa16b01c50e33c864f59aeef1ccced0d01d82  config.lua
+72e8ebdc92250d775a5fd6fc593c4a2c7f5d1ba6107c71340f95fc1d03fd339a04fccf848bfc9464232cc2269448cfab0501de00c67b8e6e2843bbafdb06fb88  fix-1549-rocks-tree-musl.patch
 "
diff --git a/community/luarocks/fix-1549-rocks-tree-musl.patch b/community/luarocks/fix-1549-rocks-tree-musl.patch
new file mode 100644
index 000000000000..e300fc972ff7
--- /dev/null
+++ b/community/luarocks/fix-1549-rocks-tree-musl.patch
@@ -0,0 +1,27 @@
+Fixed in luarocks!1550 (merged) but not included in a release yet (latest is v3.9.2).
+Patch can be removed once a new luarocks version is released.
+
+See https://github.com/luarocks/luarocks/pull/1550
+
+commit f4b1deab270a94778e1bd8903ff48387b0ed9fbc
+Author: leso-kn <info@lesosoftware.com>
+Date:   Tue Dec 5 22:05:55 2023 +0100
+
+    fix: Add value specified via --tree to cfg.rocks_trees (#1549)
+    
+    * Fixes a crash in `fulfill_dependency()` on musl
+
+diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua
+index f1446df..ca79c31 100644
+--- a/src/luarocks/cmd.lua
++++ b/src/luarocks/cmd.lua
+@@ -83,6 +83,9 @@ do
+          if not named then
+             local root_dir = fs.absolute_name(args.tree)
+             replace_tree(args, root_dir)
++            if (args.deps_mode or cfg.deps_mode) ~= "order" then
++               table.insert(cfg.rocks_trees, 1, { name = "arg", root = root_dir } )
++            end
+          end
+       elseif args["local"] then
+          if fs.is_superuser() then
-- 
GitLab