aboutsummaryrefslogtreecommitdiff
path: root/GNUmakefile
diff options
context:
space:
mode:
authortobil4sk <tobil4sk@outlook.com>2026-02-03 22:47:50 +0000
committerGitHub <noreply@github.com>2026-02-03 19:47:50 -0300
commit47301d83aba58925e1b9594023621ebb27070cdb (patch)
tree73021b5366687ec1683b9e66505e74f22f71d31b /GNUmakefile
parentacf1f47e7f1b1ecbc147e41cae51ddfd06ad898d (diff)
downloadluarocks-main.tar.gz
luarocks-main.tar.bz2
luarocks-main.zip
Improve flexibility around vendored librariesmain
compat53 is vendored since #1757 as it is required to run luarocks with lua 5.1 or 5.2. However, this introduced some issues as the GNUmakefile install rule places these in the same place where `luarocks install compat53` would install them. This means you get conflicts if you install the actual package: ``` Warning: /.../prefix/share/lua/5.1/compat53/init.lua is not tracked by this installation of LuaRocks. Moving it to /.../prefix/share/lua/5.1/compat53/init.lua~ Warning: /.../prefix/share/lua/5.1/compat53/module.lua is not tracked by this installation of LuaRocks. Moving it to /.../prefix/share/lua/5.1/compat53/module.lua~ Warning: /.../prefix/share/lua/5.1/compat53/file_mt.lua is not tracked by this installation of LuaRocks. Moving it to /.../prefix/share/lua/5.1/compat53/file_mt.lua~ ``` It is also not ideal for linux package maintainers to include a vendored package, see: https://github.com/luarocks/luarocks/pull/1757#issuecomment-3409873412. To solve these issues, this patchset makes the following changes: - GNUmakefile now places the compat53 files under `luarocks/vendor/compat53` (which is added internally to the luarocks script's `package.path`). This way a user's installation of compat53 does not interfere at all with luarocks one. - Added `--with-system-compat53` option to configure script for external packaging systems. - Fixed install.bat's logic for deciding whether to vendor compat53, as the current script includes it for every version. install.bat already places luarocks sources outside of LUAPATH, so that part can stay as is. I've also inverted the version check to avoid the need for future patches like: #1850.
Diffstat (limited to '')
-rw-r--r--GNUmakefile38
1 files changed, 29 insertions, 9 deletions
diff --git a/GNUmakefile b/GNUmakefile
index c938756d..0e28818b 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -18,6 +18,16 @@ LUAROCKS_FILES = $(shell find src/luarocks/ -type f -name '*.lua')
18 18
19LUA_ENV_VARS = LUA_PATH LUA_PATH_5_2 LUA_PATH_5_3 LUA_PATH_5_4 LUA_PATH_5_5 LUA_CPATH LUA_CPATH_5_2 LUA_CPATH_5_3 LUA_CPATH_5_4 LUA_CPATH_5_5 19LUA_ENV_VARS = LUA_PATH LUA_PATH_5_2 LUA_PATH_5_3 LUA_PATH_5_4 LUA_PATH_5_5 LUA_CPATH LUA_CPATH_5_2 LUA_CPATH_5_3 LUA_CPATH_5_4 LUA_CPATH_5_5
20 20
21luarockspackagepath := $(luadir)/?.lua
22
23ifndef WITH_SYSTEM_ROCKS
24luarockspackagepath := $(luarockspackagepath);$(luadir)/luarocks/vendor/?.lua
25vendored_rocks = 1
26ifneq ($(filter $(LUA_VERSION),5.1 5.2),)
27vendored_compat53 = 1
28endif
29endif
30
21all: build 31all: build
22 32
23# ---------------------------------------- 33# ----------------------------------------
@@ -54,7 +64,7 @@ luarocks: config.unix $(builddir)/config-$(LUA_VERSION).lua
54 rm -f src/luarocks/core/hardcoded.lua 64 rm -f src/luarocks/core/hardcoded.lua
55 echo "#!/bin/sh" > luarocks 65 echo "#!/bin/sh" > luarocks
56 echo "unset $(LUA_ENV_VARS)" >> luarocks 66 echo "unset $(LUA_ENV_VARS)" >> luarocks
57 echo 'LUAROCKS_SYSCONFDIR="$(luarocksconfdir)" LUA_PATH="$(CURDIR)/src/?.lua;;" exec "$(LUA)" "$(CURDIR)/src/bin/luarocks" --project-tree="$(CURDIR)/lua_modules" "$$@"' >> luarocks 67 echo 'LUAROCKS_SYSCONFDIR="$(luarocksconfdir)" LUA_PATH="$(CURDIR)/src/?.lua;$(CURDIR)/vendor/?.lua;;" exec "$(LUA)" "$(CURDIR)/src/bin/luarocks" --project-tree="$(CURDIR)/lua_modules" "$$@"' >> luarocks
58 chmod +rx ./luarocks 68 chmod +rx ./luarocks
59 ./luarocks init 69 ./luarocks init
60 70
@@ -62,7 +72,7 @@ luarocks-admin: config.unix
62 rm -f src/luarocks/core/hardcoded.lua 72 rm -f src/luarocks/core/hardcoded.lua
63 echo "#!/bin/sh" > luarocks-admin 73 echo "#!/bin/sh" > luarocks-admin
64 echo "unset $(LUA_ENV_VARS)" >> luarocks-admin 74 echo "unset $(LUA_ENV_VARS)" >> luarocks-admin
65 echo 'LUAROCKS_SYSCONFDIR="$(luarocksconfdir)" LUA_PATH="$(CURDIR)/src/?.lua;;" exec "$(LUA)" "$(CURDIR)/src/bin/luarocks-admin" --project-tree="$(CURDIR)/lua_modules" "$$@"' >> luarocks-admin 75 echo 'LUAROCKS_SYSCONFDIR="$(luarocksconfdir)" LUA_PATH="$(CURDIR)/src/?.lua;$(CURDIR)/vendor/?.lua;;" exec "$(LUA)" "$(CURDIR)/src/bin/luarocks-admin" --project-tree="$(CURDIR)/lua_modules" "$$@"' >> luarocks-admin
66 chmod +rx ./luarocks-admin 76 chmod +rx ./luarocks-admin
67 77
68$(builddir)/luarocks: src/bin/luarocks config.unix 78$(builddir)/luarocks: src/bin/luarocks config.unix
@@ -71,7 +81,7 @@ $(builddir)/luarocks: src/bin/luarocks config.unix
71 'package.loaded["luarocks.core.hardcoded"] = { '\ 81 'package.loaded["luarocks.core.hardcoded"] = { '\
72 "$$([ -n "$(FORCE_CONFIG)" ] && printf 'FORCE_CONFIG = true, ')"\ 82 "$$([ -n "$(FORCE_CONFIG)" ] && printf 'FORCE_CONFIG = true, ')"\
73 'SYSCONFDIR = [[$(luarocksconfdir)]] }\n'\ 83 'SYSCONFDIR = [[$(luarocksconfdir)]] }\n'\
74 'package.path=[[$(luadir)/?.lua;]] .. package.path\n'\ 84 'package.path=[[$(luarockspackagepath);]] .. package.path\n'\
75 'local list = package.searchers or package.loaders; table.insert(list, 1, function(name) if name:match("^luarocks%%.") then return loadfile([[$(luadir)/]] .. name:gsub([[%%.]], [[/]]) .. [[.lua]]) end end)\n'; \ 85 'local list = package.searchers or package.loaders; table.insert(list, 1, function(name) if name:match("^luarocks%%.") then return loadfile([[$(luadir)/]] .. name:gsub([[%%.]], [[/]]) .. [[.lua]]) end end)\n'; \
76 tail -n +2 src/bin/luarocks \ 86 tail -n +2 src/bin/luarocks \
77 )> "$@" 87 )> "$@"
@@ -82,7 +92,7 @@ $(builddir)/luarocks-admin: src/bin/luarocks-admin config.unix
82 'package.loaded["luarocks.core.hardcoded"] = { '\ 92 'package.loaded["luarocks.core.hardcoded"] = { '\
83 "$$([ -n "$(FORCE_CONFIG)" ] && printf 'FORCE_CONFIG = true, ')"\ 93 "$$([ -n "$(FORCE_CONFIG)" ] && printf 'FORCE_CONFIG = true, ')"\
84 'SYSCONFDIR = [[$(luarocksconfdir)]] }\n'\ 94 'SYSCONFDIR = [[$(luarocksconfdir)]] }\n'\
85 'package.path=[[$(luadir)/?.lua;]] .. package.path\n'\ 95 'package.path=[[$(luarockspackagepath);]] .. package.path\n'\
86 'local list = package.searchers or package.loaders; table.insert(list, 1, function(name) if name:match("^luarocks%%.") then return loadfile([[$(luadir)/]] .. name:gsub([[%%.]], [[/]]) .. [[.lua]]) end end)\n'; \ 96 'local list = package.searchers or package.loaders; table.insert(list, 1, function(name) if name:match("^luarocks%%.") then return loadfile([[$(luadir)/]] .. name:gsub([[%%.]], [[/]]) .. [[.lua]]) end end)\n'; \
87 tail -n +2 src/bin/luarocks-admin \ 97 tail -n +2 src/bin/luarocks-admin \
88 )> "$@" 98 )> "$@"
@@ -119,15 +129,25 @@ install: all install-config
119 do \ 129 do \
120 $(INSTALL_DATA) "$$f" '$(DESTDIR)$(luadir)'/`echo $$f | sed 's,^src/,,'`; \ 130 $(INSTALL_DATA) "$$f" '$(DESTDIR)$(luadir)'/`echo $$f | sed 's,^src/,,'`; \
121 done 131 done
122ifeq (,$(findstring $(LUA_VERSION),"5.3" "5.4" "5.5")) 132ifdef vendored_rocks
123 find src/compat53/ -type d | while read f; \ 133 find vendor/ -type d | while read f; \
124 do \ 134 do \
125 mkdir -p '$(DESTDIR)$(luadir)'/`echo $$f | sed 's,^src/,,'`; \ 135 mkdir -p '$(DESTDIR)$(luadir)/luarocks'/`echo $$f`; \
126 done 136 done
127 find src/compat53/ -type f -name '*.lua' | while read f; \ 137 find vendor/ -maxdepth 1 -type f -name '*.lua' | while read f; \
128 do \ 138 do \
129 $(INSTALL_DATA) "$$f" '$(DESTDIR)$(luadir)'/`echo $$f | sed 's,^src/,,'`; \ 139 $(INSTALL_DATA) "$$f" '$(DESTDIR)$(luadir)/luarocks'/`echo $$f`; \
130 done 140 done
141ifdef vendored_compat53
142 find vendor/compat53/ -type d | while read f; \
143 do \
144 mkdir -p '$(DESTDIR)$(luadir)/luarocks'/`echo $$f`; \
145 done
146 find vendor/compat53/ -type f -name '*.lua' | while read f; \
147 do \
148 $(INSTALL_DATA) "$$f" '$(DESTDIR)$(luadir)/luarocks'/`echo $$f`; \
149 done
150endif
131endif 151endif
132 152
133install-config: 153install-config: