|
Igor Gnatenko |
5460ad |
From dd6c65044c41922193f520ace668e2c5e55f1004 Mon Sep 17 00:00:00 2001
|
|
Igor Gnatenko |
5460ad |
From: Panu Matilainen <pmatilai@redhat.com>
|
|
Igor Gnatenko |
5460ad |
Date: Tue, 16 Oct 2018 11:26:46 +0300
|
|
Igor Gnatenko |
5460ad |
Subject: [PATCH] Resurrect long since broken Lua library path
|
|
Igor Gnatenko |
5460ad |
|
|
Igor Gnatenko |
5460ad |
LUA_PATH global variable is not consulted when loading libraries in
|
|
Igor Gnatenko |
5460ad |
Lua >= 5.1, package.path has replaced it. Rpm's Lua library path
|
|
Igor Gnatenko |
5460ad |
was always supposed to be /usr/lib/rpm/lua/ but this has been broken
|
|
Igor Gnatenko |
5460ad |
for the last ten years or so, oops. Make the directory a first-class
|
|
Igor Gnatenko |
5460ad |
citizen: create it on install, add a macro for it, make it actually
|
|
Igor Gnatenko |
5460ad |
work and ensure it stays that way by adding a test for it.
|
|
Igor Gnatenko |
5460ad |
---
|
|
Igor Gnatenko |
5460ad |
Makefile.am | 2 ++
|
|
Igor Gnatenko |
5460ad |
macros.in | 2 ++
|
|
Igor Gnatenko |
5460ad |
rpmio/rpmlua.c | 13 ++++++-------
|
|
Igor Gnatenko |
5460ad |
tests/rpmmacro.at | 17 ++++++++++++++++-
|
|
Igor Gnatenko |
5460ad |
4 files changed, 26 insertions(+), 8 deletions(-)
|
|
Igor Gnatenko |
5460ad |
|
|
Igor Gnatenko |
5460ad |
diff --git a/Makefile.am b/Makefile.am
|
|
Igor Gnatenko |
5460ad |
index ff40ffbd1..813bdb834 100644
|
|
Igor Gnatenko |
5460ad |
--- a/Makefile.am
|
|
Igor Gnatenko |
5460ad |
+++ b/Makefile.am
|
|
Igor Gnatenko |
5460ad |
@@ -249,6 +249,7 @@ install-data-local:
|
|
Igor Gnatenko |
5460ad |
$(RPMCANONVENDOR) $(RPMCANONOS) $(RPMCANONGNU)
|
|
Igor Gnatenko |
5460ad |
@$(MKDIR_P) $(DESTDIR)$(localstatedir)/tmp
|
|
Igor Gnatenko |
5460ad |
@$(MKDIR_P) $(DESTDIR)$(rpmconfigdir)/macros.d
|
|
Igor Gnatenko |
5460ad |
+ @$(MKDIR_P) $(DESTDIR)$(rpmconfigdir)/lua
|
|
Igor Gnatenko |
5460ad |
|
|
Igor Gnatenko |
5460ad |
# XXX to appease distcheck we need to remove "stuff" here...
|
|
Igor Gnatenko |
5460ad |
uninstall-local:
|
|
Igor Gnatenko |
5460ad |
@@ -257,6 +258,7 @@ uninstall-local:
|
|
Igor Gnatenko |
5460ad |
@rm -rf $(DESTDIR)$(rpmconfigdir)/platform/
|
|
Igor Gnatenko |
5460ad |
@rm -f $(DESTDIR)$(rpmconfigdir)/macros
|
|
Igor Gnatenko |
5460ad |
@rm -rf $(DESTDIR)$(rpmconfigdir)/macros.d
|
|
Igor Gnatenko |
5460ad |
+ @rm -rf $(DESTDIR)$(rpmconfigdir)/lua
|
|
Igor Gnatenko |
5460ad |
|
|
Igor Gnatenko |
5460ad |
MAINTAINERCLEANFILES = ChangeLog
|
|
Igor Gnatenko |
5460ad |
|
|
Igor Gnatenko |
5460ad |
diff --git a/macros.in b/macros.in
|
|
Igor Gnatenko |
5460ad |
index 00f382da1..e0a1aea4e 100644
|
|
Igor Gnatenko |
5460ad |
--- a/macros.in
|
|
Igor Gnatenko |
5460ad |
+++ b/macros.in
|
|
Igor Gnatenko |
5460ad |
@@ -149,6 +149,8 @@
|
|
Igor Gnatenko |
5460ad |
%_rpmconfigdir %{getconfdir}
|
|
Igor Gnatenko |
5460ad |
# The directory where rpm's macro files live
|
|
Igor Gnatenko |
5460ad |
%_rpmmacrodir %{_rpmconfigdir}/macros.d
|
|
Igor Gnatenko |
5460ad |
+# The directory where rpm's addon lua libraries live
|
|
Igor Gnatenko |
5460ad |
+%_rpmluadir %{_rpmconfigdir}/lua
|
|
Igor Gnatenko |
5460ad |
|
|
Igor Gnatenko |
5460ad |
# The directory where sources/patches will be unpacked and built.
|
|
Igor Gnatenko |
5460ad |
%_builddir %{_topdir}/BUILD
|
|
Igor Gnatenko |
5460ad |
diff --git a/rpmio/rpmlua.c b/rpmio/rpmlua.c
|
|
Igor Gnatenko |
5460ad |
index 8a1fa73e4..e67d2fb52 100644
|
|
Igor Gnatenko |
5460ad |
--- a/rpmio/rpmlua.c
|
|
Igor Gnatenko |
5460ad |
+++ b/rpmio/rpmlua.c
|
|
Igor Gnatenko |
5460ad |
@@ -124,13 +124,6 @@ rpmlua rpmluaNew()
|
|
Igor Gnatenko |
5460ad |
}
|
|
Igor Gnatenko |
5460ad |
#ifndef LUA_GLOBALSINDEX
|
|
Igor Gnatenko |
5460ad |
lua_pushglobaltable(L);
|
|
Igor Gnatenko |
5460ad |
-#endif
|
|
Igor Gnatenko |
5460ad |
- lua_pushliteral(L, "LUA_PATH");
|
|
Igor Gnatenko |
5460ad |
- lua_pushfstring(L, "%s/%s", rpmConfigDir(), "/lua/?.lua");
|
|
Igor Gnatenko |
5460ad |
-#ifdef LUA_GLOBALSINDEX
|
|
Igor Gnatenko |
5460ad |
- lua_rawset(L, LUA_GLOBALSINDEX);
|
|
Igor Gnatenko |
5460ad |
-#else
|
|
Igor Gnatenko |
5460ad |
- lua_settable(L, -3);
|
|
Igor Gnatenko |
5460ad |
#endif
|
|
Igor Gnatenko |
5460ad |
lua_pushliteral(L, "print");
|
|
Igor Gnatenko |
5460ad |
lua_pushcfunction(L, rpm_print);
|
|
Igor Gnatenko |
5460ad |
@@ -142,6 +135,12 @@ rpmlua rpmluaNew()
|
|
Igor Gnatenko |
5460ad |
#ifndef LUA_GLOBALSINDEX
|
|
Igor Gnatenko |
5460ad |
lua_pop(L, 1);
|
|
Igor Gnatenko |
5460ad |
#endif
|
|
Igor Gnatenko |
5460ad |
+
|
|
Igor Gnatenko |
5460ad |
+ lua_getglobal(L, "package");
|
|
Igor Gnatenko |
5460ad |
+ lua_pushfstring(L, "%s/%s", rpmConfigDir(), "/lua/?.lua");
|
|
Igor Gnatenko |
5460ad |
+ lua_setfield(L, -2, "path");
|
|
Igor Gnatenko |
5460ad |
+ lua_pop(L, 1);
|
|
Igor Gnatenko |
5460ad |
+
|
|
Igor Gnatenko |
5460ad |
rpmluaSetData(lua, "lua", lua);
|
|
Igor Gnatenko |
5460ad |
if (stat(initlua, &st) != -1)
|
|
Igor Gnatenko |
5460ad |
(void)rpmluaRunScriptFile(lua, initlua);
|
|
Igor Gnatenko |
5460ad |
diff --git a/tests/rpmmacro.at b/tests/rpmmacro.at
|
|
Igor Gnatenko |
5460ad |
index 88d2a0519..8875490db 100644
|
|
Igor Gnatenko |
5460ad |
--- a/tests/rpmmacro.at
|
|
Igor Gnatenko |
5460ad |
+++ b/tests/rpmmacro.at
|
|
Igor Gnatenko |
5460ad |
@@ -303,6 +303,21 @@ runroot rpm \
|
|
Igor Gnatenko |
5460ad |
)
|
|
Igor Gnatenko |
5460ad |
AT_CLEANUP
|
|
Igor Gnatenko |
5460ad |
|
|
Igor Gnatenko |
5460ad |
+AT_SETUP([lua library path])
|
|
Igor Gnatenko |
5460ad |
+AT_KEYWORDS([macros lua])
|
|
Igor Gnatenko |
5460ad |
+AT_CHECK([
|
|
Igor Gnatenko |
5460ad |
+AT_SKIP_IF([$LUA_DISABLED])
|
|
Igor Gnatenko |
5460ad |
+f=$(rpm --eval "%{_rpmconfigdir}/lua/foo.lua")
|
|
Igor Gnatenko |
5460ad |
+echo "bar = 'graak'" > ${f}
|
|
Igor Gnatenko |
5460ad |
+runroot rpm \
|
|
Igor Gnatenko |
5460ad |
+ --eval '%{lua:require "foo"; print(bar)}'
|
|
Igor Gnatenko |
5460ad |
+rm -f ${f}
|
|
Igor Gnatenko |
5460ad |
+],
|
|
Igor Gnatenko |
5460ad |
+[0],
|
|
Igor Gnatenko |
5460ad |
+[graak
|
|
Igor Gnatenko |
5460ad |
+])
|
|
Igor Gnatenko |
5460ad |
+AT_CLEANUP
|
|
Igor Gnatenko |
5460ad |
+
|
|
Igor Gnatenko |
5460ad |
AT_SETUP([%define + %undefine in nested levels 1])
|
|
Igor Gnatenko |
5460ad |
AT_KEYWORDS([macros define undefine])
|
|
Igor Gnatenko |
5460ad |
AT_CHECK([
|
|
Igor Gnatenko |
5460ad |
@@ -438,4 +453,4 @@ runroot rpm --macros "/data/macros.testfile" \
|
|
Igor Gnatenko |
5460ad |
|
|
Igor Gnatenko |
5460ad |
macro_2
|
|
Igor Gnatenko |
5460ad |
])
|
|
Igor Gnatenko |
5460ad |
-AT_CLEANUP
|
|
Igor Gnatenko |
5460ad |
\ No newline at end of file
|
|
Igor Gnatenko |
5460ad |
+AT_CLEANUP
|
|
Igor Gnatenko |
5460ad |
--
|
|
Igor Gnatenko |
5460ad |
2.19.1
|
|
Igor Gnatenko |
5460ad |
|