From 5460ad1e1770f3ba64828f340fe8b1479fd051dd Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Tue, 16 Oct 2018 11:24:03 +0200 Subject: [PATCH] Resurrect long since broken Lua library path Signed-off-by: Igor Gnatenko --- ...t-long-since-broken-Lua-library-path.patch | 118 ++++++++++++++++++ rpm.spec | 7 +- 2 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 0001-Resurrect-long-since-broken-Lua-library-path.patch diff --git a/0001-Resurrect-long-since-broken-Lua-library-path.patch b/0001-Resurrect-long-since-broken-Lua-library-path.patch new file mode 100644 index 0000000..e81fe39 --- /dev/null +++ b/0001-Resurrect-long-since-broken-Lua-library-path.patch @@ -0,0 +1,118 @@ +From dd6c65044c41922193f520ace668e2c5e55f1004 Mon Sep 17 00:00:00 2001 +From: Panu Matilainen +Date: Tue, 16 Oct 2018 11:26:46 +0300 +Subject: [PATCH] Resurrect long since broken Lua library path + +LUA_PATH global variable is not consulted when loading libraries in +Lua >= 5.1, package.path has replaced it. Rpm's Lua library path +was always supposed to be /usr/lib/rpm/lua/ but this has been broken +for the last ten years or so, oops. Make the directory a first-class +citizen: create it on install, add a macro for it, make it actually +work and ensure it stays that way by adding a test for it. +--- + Makefile.am | 2 ++ + macros.in | 2 ++ + rpmio/rpmlua.c | 13 ++++++------- + tests/rpmmacro.at | 17 ++++++++++++++++- + 4 files changed, 26 insertions(+), 8 deletions(-) + +diff --git a/Makefile.am b/Makefile.am +index ff40ffbd1..813bdb834 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -249,6 +249,7 @@ install-data-local: + $(RPMCANONVENDOR) $(RPMCANONOS) $(RPMCANONGNU) + @$(MKDIR_P) $(DESTDIR)$(localstatedir)/tmp + @$(MKDIR_P) $(DESTDIR)$(rpmconfigdir)/macros.d ++ @$(MKDIR_P) $(DESTDIR)$(rpmconfigdir)/lua + + # XXX to appease distcheck we need to remove "stuff" here... + uninstall-local: +@@ -257,6 +258,7 @@ uninstall-local: + @rm -rf $(DESTDIR)$(rpmconfigdir)/platform/ + @rm -f $(DESTDIR)$(rpmconfigdir)/macros + @rm -rf $(DESTDIR)$(rpmconfigdir)/macros.d ++ @rm -rf $(DESTDIR)$(rpmconfigdir)/lua + + MAINTAINERCLEANFILES = ChangeLog + +diff --git a/macros.in b/macros.in +index 00f382da1..e0a1aea4e 100644 +--- a/macros.in ++++ b/macros.in +@@ -149,6 +149,8 @@ + %_rpmconfigdir %{getconfdir} + # The directory where rpm's macro files live + %_rpmmacrodir %{_rpmconfigdir}/macros.d ++# The directory where rpm's addon lua libraries live ++%_rpmluadir %{_rpmconfigdir}/lua + + # The directory where sources/patches will be unpacked and built. + %_builddir %{_topdir}/BUILD +diff --git a/rpmio/rpmlua.c b/rpmio/rpmlua.c +index 8a1fa73e4..e67d2fb52 100644 +--- a/rpmio/rpmlua.c ++++ b/rpmio/rpmlua.c +@@ -124,13 +124,6 @@ rpmlua rpmluaNew() + } + #ifndef LUA_GLOBALSINDEX + lua_pushglobaltable(L); +-#endif +- lua_pushliteral(L, "LUA_PATH"); +- lua_pushfstring(L, "%s/%s", rpmConfigDir(), "/lua/?.lua"); +-#ifdef LUA_GLOBALSINDEX +- lua_rawset(L, LUA_GLOBALSINDEX); +-#else +- lua_settable(L, -3); + #endif + lua_pushliteral(L, "print"); + lua_pushcfunction(L, rpm_print); +@@ -142,6 +135,12 @@ rpmlua rpmluaNew() + #ifndef LUA_GLOBALSINDEX + lua_pop(L, 1); + #endif ++ ++ lua_getglobal(L, "package"); ++ lua_pushfstring(L, "%s/%s", rpmConfigDir(), "/lua/?.lua"); ++ lua_setfield(L, -2, "path"); ++ lua_pop(L, 1); ++ + rpmluaSetData(lua, "lua", lua); + if (stat(initlua, &st) != -1) + (void)rpmluaRunScriptFile(lua, initlua); +diff --git a/tests/rpmmacro.at b/tests/rpmmacro.at +index 88d2a0519..8875490db 100644 +--- a/tests/rpmmacro.at ++++ b/tests/rpmmacro.at +@@ -303,6 +303,21 @@ runroot rpm \ + ) + AT_CLEANUP + ++AT_SETUP([lua library path]) ++AT_KEYWORDS([macros lua]) ++AT_CHECK([ ++AT_SKIP_IF([$LUA_DISABLED]) ++f=$(rpm --eval "%{_rpmconfigdir}/lua/foo.lua") ++echo "bar = 'graak'" > ${f} ++runroot rpm \ ++ --eval '%{lua:require "foo"; print(bar)}' ++rm -f ${f} ++], ++[0], ++[graak ++]) ++AT_CLEANUP ++ + AT_SETUP([%define + %undefine in nested levels 1]) + AT_KEYWORDS([macros define undefine]) + AT_CHECK([ +@@ -438,4 +453,4 @@ runroot rpm --macros "/data/macros.testfile" \ + + macro_2 + ]) +-AT_CLEANUP +\ No newline at end of file ++AT_CLEANUP +-- +2.19.1 + diff --git a/rpm.spec b/rpm.spec index bccbd11..c217620 100644 --- a/rpm.spec +++ b/rpm.spec @@ -23,7 +23,7 @@ %global rpmver 4.14.2 #global snapver rc2 -%global rel 7 +%global rel 8 %global srcver %{version}%{?snapver:-%{snapver}} %global srcdir %{?snapver:testing}%{!?snapver:%{name}-%(echo %{version} | cut -d'.' -f1-2).x} @@ -60,6 +60,7 @@ Patch6: 0001-find-debuginfo.sh-decompress-DWARF-compressed-ELF-se.patch # Patches already upstream: Patch101: 0001-Fix-ancient-python-GIL-locking-bug-on-callback-RhBug.patch +Patch102: 0001-Resurrect-long-since-broken-Lua-library-path.patch # These are not yet upstream Patch906: rpm-4.7.1-geode-i686.patch @@ -482,6 +483,7 @@ make check || (cat tests/rpmtests.log; exit 1) %attr(0755, root, root) %dir %{rpmhome} %{rpmhome}/macros %{rpmhome}/macros.d +%{rpmhome}/lua %{rpmhome}/rpmpopt* %{rpmhome}/rpmrc @@ -580,6 +582,9 @@ make check || (cat tests/rpmtests.log; exit 1) %doc doc/librpm/html/* %changelog +* Tue Oct 16 2018 Igor Gnatenko - 4.14.2-8 +- Resurrect long since broken Lua library path + * Fri Oct 12 2018 Panu Matilainen - 4.14.2-7 - Actually fail build on test-suite failures again - Invoke python2 explicitly from test-suite to unbreak build, part II