[apt] fix for lua 5.2
Tom Callaway
spot at fedoraproject.org
Fri May 10 15:06:04 UTC 2013
commit eb7f7a86e9c0eb03847fd9c9b20e102d26f89725
Author: Tom Callaway <spot at fedoraproject.org>
Date: Fri May 10 11:05:32 2013 -0400
fix for lua 5.2
apt-0.5.15lorg3.95-lua-5.2.patch | 460 ++++++++++++++++++++++++++++++++++++++
apt.spec | 8 +-
2 files changed, 467 insertions(+), 1 deletions(-)
---
diff --git a/apt-0.5.15lorg3.95-lua-5.2.patch b/apt-0.5.15lorg3.95-lua-5.2.patch
new file mode 100644
index 0000000..20e032e
--- /dev/null
+++ b/apt-0.5.15lorg3.95-lua-5.2.patch
@@ -0,0 +1,460 @@
+diff -up apt-0.5.15lorg3.95.git522/apt-pkg/luaiface.cc.lua-52 apt-0.5.15lorg3.95.git522/apt-pkg/luaiface.cc
+--- apt-0.5.15lorg3.95.git522/apt-pkg/luaiface.cc.lua-52 2013-05-10 10:34:53.794097260 -0400
++++ apt-0.5.15lorg3.95.git522/apt-pkg/luaiface.cc 2013-05-10 10:56:59.914049857 -0400
+@@ -41,6 +41,18 @@ extern "C" {
+
+ using namespace std;
+
++#ifndef lua_pushglobaltable
++#define lua_pushglobaltable(L) lua_pushvalue(L, LUA_GLOBALSINDEX)
++#endif
++
++#ifndef lua_open
++#define lua_open() luaL_newstate()
++#endif
++
++#ifndef lua_strlen
++#define lua_strlen(L,i) lua_rawlen(L, (i))
++#endif
++
+ #define pushudata(ctype, value) \
+ do { \
+ ctype *_tmp = (ctype *) lua_newuserdata(L, sizeof(ctype)); \
+@@ -107,14 +119,14 @@ Lua::Lua()
+ lua_settop(L, 0); /* discard any results */
+ }
+ #else
+- const luaL_reg lualibs[] = {
++ const luaL_Reg lualibs[] = {
+ {"posix", luaopen_posix},
+ {"rex", luaopen_rex},
+ {"apt", luaopen_apt},
+ {NULL, NULL}
+ };
+ luaL_openlibs(L);
+- const luaL_reg *lib = lualibs;
++ const luaL_Reg *lib = lualibs;
+ for (; lib->name; lib++) {
+ lua_pushcfunction(L, lib->func);
+ lua_pushstring(L, lib->name);
+@@ -175,13 +187,21 @@ bool Lua::RunScripts(const char *ConfLis
+ if (Value == "interactive") {
+ lua_pushstring(L, "script_slot");
+ lua_pushstring(L, ConfListKey);
++#ifdef LUA_GLOBALSINDEX
+ lua_rawset(L, LUA_GLOBALSINDEX);
++#else
++ lua_settable(L, -3);
++#endif
+
+ RunInteractive(ConfListKey);
+
+ lua_pushstring(L, "script_slot");
+ lua_pushnil(L);
++#ifdef LUA_GLOBALSINDEX
+ lua_rawset(L, LUA_GLOBALSINDEX);
++#else
++ lua_settable(L, -3);
++#endif
+ continue;
+ }
+ if (Value[0] == '.' || Value[0] == '/') {
+@@ -214,14 +234,21 @@ bool Lua::RunScripts(const char *ConfLis
+
+ lua_pushstring(L, "script_slot");
+ lua_pushstring(L, ConfListKey);
++#ifdef LUA_GLOBALSINDEX
+ lua_rawset(L, LUA_GLOBALSINDEX);
++#else
++ lua_settable(L, -3);
++#endif
+
+ InternalRunScript();
+
+ lua_pushstring(L, "script_slot");
+ lua_pushnil(L);
++#ifdef LUA_GLOBALSINDEX
+ lua_rawset(L, LUA_GLOBALSINDEX);
+-
++#else
++ lua_settable(L, -3);
++#endif
+ lua_pop(L, 1);
+
+ return true;
+@@ -359,7 +386,11 @@ void Lua::SetGlobal(const char *Name)
+ {
+ lua_pushstring(L, Name);
+ lua_pushnil(L);
++#ifdef LUA_GLOBALSINDEX
+ lua_rawset(L, LUA_GLOBALSINDEX);
++#else
++ lua_settable(L, -3);
++#endif
+ Globals.push_back(Name);
+ }
+
+@@ -368,7 +399,11 @@ void Lua::SetGlobal(const char *Name, co
+ if (Value != NULL) {
+ lua_pushstring(L, Name);
+ lua_pushstring(L, Value);
++#ifdef LUA_GLOBALSINDEX
+ lua_rawset(L, LUA_GLOBALSINDEX);
++#else
++ lua_settable(L, -3);
++#endif
+ }
+ Globals.push_back(Name);
+ }
+@@ -378,7 +413,11 @@ void Lua::SetGlobal(const char *Name, pk
+ if (Value != NULL) {
+ lua_pushstring(L, Name);
+ pushudata(pkgCache::Package*, Value);
++#ifdef LUA_GLOBALSINDEX
+ lua_rawset(L, LUA_GLOBALSINDEX);
++#else
++ lua_settable(L, -3);
++#endif
+ }
+ Globals.push_back(Name);
+ }
+@@ -393,7 +432,11 @@ void Lua::SetGlobal(const char *Name, co
+ lua_pushstring(L, Value[i]);
+ lua_rawseti(L, -2, i+1);
+ }
++#ifdef LUA_GLOBALSINDEX
+ lua_rawset(L, LUA_GLOBALSINDEX);
++#else
++ lua_settable(L, -3);
++#endif
+ Globals.push_back(Name);
+ }
+
+@@ -408,7 +451,11 @@ void Lua::SetGlobal(const char *Name, ve
+ lua_pushstring(L, Value[i]);
+ lua_rawseti(L, -2, i+1);
+ }
++#ifdef LUA_GLOBALSINDEX
+ lua_rawset(L, LUA_GLOBALSINDEX);
++#else
++ lua_settable(L, -3);
++#endif
+ Globals.push_back(Name);
+ }
+
+@@ -423,7 +470,11 @@ void Lua::SetGlobal(const char *Name, ve
+ lua_pushstring(L, Value[i].c_str());
+ lua_rawseti(L, -2, i+1);
+ }
++#ifdef LUA_GLOBALSINDEX
+ lua_rawset(L, LUA_GLOBALSINDEX);
++#else
++ lua_settable(L, -3);
++#endif
+ Globals.push_back(Name);
+ }
+
+@@ -438,7 +489,11 @@ void Lua::SetGlobal(const char *Name, ve
+ pushudata(pkgCache::Package*, Value[i]);
+ lua_rawseti(L, -2, i+1);
+ }
++#ifdef LUA_GLOBALSINDEX
+ lua_rawset(L, LUA_GLOBALSINDEX);
++#else
++ lua_settable(L, -3);
++#endif
+ Globals.push_back(Name);
+ }
+
+@@ -446,7 +501,11 @@ void Lua::SetGlobal(const char *Name, bo
+ {
+ lua_pushstring(L, Name);
+ lua_pushboolean(L, Value);
++#ifdef LUA_GLOBALSINDEX
+ lua_rawset(L, LUA_GLOBALSINDEX);
++#else
++ lua_settable(L, -3);
++#endif
+ Globals.push_back(Name);
+ }
+
+@@ -454,7 +513,11 @@ void Lua::SetGlobal(const char *Name, do
+ {
+ lua_pushstring(L, Name);
+ lua_pushnumber(L, Value);
++#ifdef LUA_GLOBALSINDEX
+ lua_rawset(L, LUA_GLOBALSINDEX);
++#else
++ lua_settable(L, -3);
++#endif
+ Globals.push_back(Name);
+ }
+
+@@ -463,7 +526,11 @@ void Lua::SetGlobal(const char *Name, vo
+ if (Value != NULL) {
+ lua_pushstring(L, Name);
+ lua_pushlightuserdata(L, Value);
++#ifdef LUA_GLOBALSINDEX
+ lua_rawset(L, LUA_GLOBALSINDEX);
++#else
++ lua_settable(L, -3);
++#endif
+ }
+ Globals.push_back(Name);
+ }
+@@ -472,7 +539,11 @@ void Lua::SetGlobal(const char *Name, lu
+ {
+ lua_pushstring(L, Name);
+ lua_pushcfunction(L, Value);
++#ifdef LUA_GLOBALSINDEX
+ lua_rawset(L, LUA_GLOBALSINDEX);
++#else
++ lua_settable(L, -3);
++#endif
+ Globals.push_back(Name);
+ }
+
+@@ -483,7 +554,11 @@ void Lua::ResetGlobals()
+ I != Globals.end(); I++) {
+ lua_pushstring(L, I->c_str());
+ lua_pushnil(L);
+- lua_rawset(L, LUA_GLOBALSINDEX);
++#ifdef LUA_GLOBALSINDEX
++ lua_rawset(L, LUA_GLOBALSINDEX);
++#else
++ lua_settable(L, -3);
++#endif
+ }
+ Globals.clear();
+ }
+@@ -492,7 +567,11 @@ void Lua::ResetGlobals()
+ const char *Lua::GetGlobalStr(const char *Name)
+ {
+ lua_pushstring(L, Name);
+- lua_rawget(L, LUA_GLOBALSINDEX);
++#ifdef LUA_GLOBALSINDEX
++ lua_rawset(L, LUA_GLOBALSINDEX);
++#else
++ lua_settable(L, -3);
++#endif
+ const char *Ret = NULL;
+ if (lua_isstring(L, -1))
+ Ret = lua_tostring(L, -1);
+@@ -504,7 +583,11 @@ vector<string> Lua::GetGlobalStrList(con
+ {
+ vector<string> Ret;
+ lua_pushstring(L, Name);
+- lua_rawget(L, LUA_GLOBALSINDEX);
++#ifdef LUA_GLOBALSINDEX
++ lua_rawset(L, LUA_GLOBALSINDEX);
++#else
++ lua_settable(L, -3);
++#endif
+ int t = lua_gettop(L);
+ if (lua_istable(L, t)) {
+ lua_pushnil(L);
+@@ -520,8 +603,13 @@ vector<string> Lua::GetGlobalStrList(con
+
+ double Lua::GetGlobalNum(const char *Name)
+ {
++
+ lua_pushstring(L, Name);
+- lua_rawget(L, LUA_GLOBALSINDEX);
++#ifdef LUA_GLOBALSINDEX
++ lua_rawset(L, LUA_GLOBALSINDEX);
++#else
++ lua_settable(L, -3);
++#endif
+ double Ret = 0;
+ if (lua_isnumber(L, -1))
+ Ret = lua_tonumber(L, -1);
+@@ -532,7 +620,11 @@ double Lua::GetGlobalNum(const char *Nam
+ bool Lua::GetGlobalBool(const char *Name)
+ {
+ lua_pushstring(L, Name);
+- lua_rawget(L, LUA_GLOBALSINDEX);
++#ifdef LUA_GLOBALSINDEX
++ lua_rawset(L, LUA_GLOBALSINDEX);
++#else
++ lua_settable(L, -3);
++#endif
+ bool Ret = lua_toboolean(L, -1);
+ lua_remove(L, -1);
+ return Ret;
+@@ -541,7 +633,11 @@ bool Lua::GetGlobalBool(const char *Name
+ void *Lua::GetGlobalPtr(const char *Name)
+ {
+ lua_pushstring(L, Name);
+- lua_rawget(L, LUA_GLOBALSINDEX);
++#ifdef LUA_GLOBALSINDEX
++ lua_rawset(L, LUA_GLOBALSINDEX);
++#else
++ lua_settable(L, -3);
++#endif
+ void *Ret = NULL;
+ if (lua_isuserdata(L, -1))
+ Ret = lua_touserdata(L, -1);
+@@ -552,7 +648,11 @@ void *Lua::GetGlobalPtr(const char *Name
+ pkgCache::Package *Lua::GetGlobalPkg(const char *Name)
+ {
+ lua_pushstring(L, Name);
+- lua_rawget(L, LUA_GLOBALSINDEX);
++#ifdef LUA_GLOBALSINDEX
++ lua_rawset(L, LUA_GLOBALSINDEX);
++#else
++ lua_settable(L, -3);
++#endif
+ pkgCache::Package *Ret;
+ checkudata(pkgCache::Package*, Ret, -1);
+ lua_remove(L, -1);
+@@ -563,7 +663,11 @@ vector<pkgCache::Package*> Lua::GetGloba
+ {
+ vector<pkgCache::Package*> Ret;
+ lua_pushstring(L, Name);
+- lua_rawget(L, LUA_GLOBALSINDEX);
++#ifdef LUA_GLOBALSINDEX
++ lua_rawset(L, LUA_GLOBALSINDEX);
++#else
++ lua_settable(L, -3);
++#endif
+ int t = lua_gettop(L);
+ if (lua_istable(L, t)) {
+ lua_pushnil(L);
+@@ -1467,7 +1571,11 @@ static int AptLua_gettext(lua_State *L)
+ const char *str = luaL_checkstring(L, 1);
+ if (str != NULL) {
+ lua_pushliteral(L, "TEXTDOMAIN");
+- lua_rawget(L, LUA_GLOBALSINDEX);
++#ifdef LUA_GLOBALSINDEX
++ lua_rawset(L, LUA_GLOBALSINDEX);
++#else
++ lua_settable(L, -3);
++#endif
+ if (lua_isstring(L, -1))
+ lua_pushstring(L, dgettext(lua_tostring(L, -1), str));
+ else
+@@ -1478,7 +1586,7 @@ static int AptLua_gettext(lua_State *L)
+ return 0;
+ }
+
+-static const luaL_reg aptlib[] = {
++static const luaL_Reg aptlib[] = {
+ {"confget", AptLua_confget},
+ {"confgetlist", AptLua_confgetlist},
+ {"confset", AptLua_confset},
+@@ -1552,7 +1660,7 @@ static int AptLua_pkgcomp(lua_State *L)
+
+ static int luaopen_apt(lua_State *L)
+ {
+- lua_pushvalue(L, LUA_GLOBALSINDEX);
++ lua_pushglobaltable(L);
+ luaL_openlib(L, NULL, aptlib, 0);
+ return 0;
+ }
+diff -up apt-0.5.15lorg3.95.git522/luaext/lposix.c.lua-52 apt-0.5.15lorg3.95.git522/luaext/lposix.c
+--- apt-0.5.15lorg3.95.git522/luaext/lposix.c.lua-52 2013-05-10 10:40:39.678084896 -0400
++++ apt-0.5.15lorg3.95.git522/luaext/lposix.c 2013-05-10 11:01:24.318040405 -0400
+@@ -49,6 +49,15 @@ static const char *filetype(mode_t m)
+
+ typedef int (*Selector)(lua_State *L, int i, const void *data);
+
++/* implemented as luaL_typerror until lua 5.1, dropped in 5.2
++ * (C) 1994-2012 Lua.org, PUC-Rio. MIT license
++ */
++static int typerror (lua_State *L, int narg, const char *tname) {
++ const char *msg = lua_pushfstring(L, "%s expected, got %s",
++ tname, luaL_typename(L, narg));
++ return luaL_argerror(L, narg, msg);
++}
++
+ static int doselection(lua_State *L, int i, const char *const S[], Selector F, const void *data)
+ {
+ if (lua_isnone(L, i))
+@@ -135,7 +144,7 @@ static uid_t mygetuid(lua_State *L, int
+ return (p==NULL) ? -1 : p->pw_uid;
+ }
+ else
+- return luaL_typerror(L, i, "string or number");
++ return typerror(L, i, "string or number");
+ }
+
+ static gid_t mygetgid(lua_State *L, int i)
+@@ -150,7 +159,7 @@ static gid_t mygetgid(lua_State *L, int
+ return (g==NULL) ? -1 : g->gr_gid;
+ }
+ else
+- return luaL_typerror(L, i, "string or number");
++ return typerror(L, i, "string or number");
+ }
+
+
+@@ -554,7 +563,7 @@ static int Pgetpasswd(lua_State *L) /**
+ else if (lua_isstring(L, 1))
+ p = getpwnam(lua_tostring(L, 1));
+ else
+- luaL_typerror(L, 1, "string or number");
++ typerror(L, 1, "string or number");
+ if (p==NULL)
+ lua_pushnil(L);
+ else
+@@ -571,7 +580,7 @@ static int Pgetgroup(lua_State *L) /**
+ else if (lua_isstring(L, 1))
+ g = getgrnam(lua_tostring(L, 1));
+ else
+- luaL_typerror(L, 1, "string or number");
++ typerror(L, 1, "string or number");
+ if (g==NULL)
+ lua_pushnil(L);
+ else
+@@ -690,10 +699,10 @@ static int Puname(lua_State *L) /** un
+ luaL_buffinit(L, &b);
+ for (s=luaL_optstring(L, 1, "%s %n %r %v %m"); *s; s++)
+ if (*s!='%')
+- luaL_putchar(&b, *s);
++ luaL_addchar(&b, *s);
+ else switch (*++s)
+ {
+- case '%': luaL_putchar(&b, *s); break;
++ case '%': luaL_addchar(&b, *s); break;
+ case 'm': luaL_addstring(&b,u.machine); break;
+ case 'n': luaL_addstring(&b,u.nodename); break;
+ case 'r': luaL_addstring(&b,u.release); break;
+@@ -792,7 +801,7 @@ static int Pmkstemp(lua_State *L)
+ }
+
+
+-static const luaL_reg R[] =
++static const luaL_Reg R[] =
+ {
+ {"access", Paccess},
+ {"chdir", Pchdir},
+diff -up apt-0.5.15lorg3.95.git522/luaext/lrexlib.c.lua-52 apt-0.5.15lorg3.95.git522/luaext/lrexlib.c
+--- apt-0.5.15lorg3.95.git522/luaext/lrexlib.c.lua-52 2013-05-10 10:40:07.837086034 -0400
++++ apt-0.5.15lorg3.95.git522/luaext/lrexlib.c 2013-05-10 10:40:24.532085437 -0400
+@@ -161,7 +161,7 @@ static int posix_gc (lua_State *L) {
+ return 0;
+ }
+
+-static const luaL_reg posixmeta[] = {
++static const luaL_Reg posixmeta[] = {
+ {"match", posix_match},
+ {"gmatch", posix_gmatch},
+ {"__gc", posix_gc},
+@@ -285,7 +285,7 @@ static int pcre_gc (lua_State *L)
+ return 0;
+ }
+
+-static const luaL_reg pcremeta[] = {
++static const luaL_Reg pcremeta[] = {
+ {"match", pcre_match},
+ {"gmatch", pcre_gmatch},
+ {"__gc", pcre_gc},
+@@ -297,7 +297,7 @@ static const luaL_reg pcremeta[] = {
+
+ /* Open the library */
+
+-static const luaL_reg rexlib[] = {
++static const luaL_Reg rexlib[] = {
+ #ifdef WITH_POSIX
+ {"newPOSIX", posix_comp},
+ #endif
diff --git a/apt.spec b/apt.spec
index 19b0498..4b18edd 100644
--- a/apt.spec
+++ b/apt.spec
@@ -10,7 +10,7 @@
Summary: Debian's Advanced Packaging Tool with RPM support
Name: apt
Version: %{aptver}
-Release: 7.%{snapver}.1%{?dist}
+Release: 8.%{snapver}.1%{?dist}
Group: System Environment/Base
URL: http://apt-rpm.org/
# SourceLicense: GPLv2+ except lua/ which is MIT
@@ -45,6 +45,8 @@ Patch0: apt-0.5.15lorg3.2-ppc.patch
Patch1: apt-0.5.15lorg3.x-cache-corruption.patch
# fix build with gcc 4.7
Patch2: apt-0.5.15lorg3.95-gcc47.patch
+# fix build with lua 5.2
+Patch3: apt-0.5.15lorg3.95-lua-5.2.patch
# TODO: verify the required minimum Python version
BuildRequires: python-devel >= 2.2
@@ -163,6 +165,7 @@ about it in /var/log/apt.log, or in the configured file.
%patch0 -p1 -b .ppc
%patch1 -p0 -b .mmap
%patch2 -p1 -b .gcc47
+%patch3 -p1 -b .lua-52
install -pm 644 %{SOURCE19} comps2prio.xsl
@@ -358,6 +361,9 @@ fi
%changelog
+* Fri May 10 2013 Tom Callaway <spot at fedoraproject.org> - 0.5.14lorg3.95-8.git522.1
+- fix for new lua
+
* Wed Feb 13 2013 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.5.15lorg3.95-7.git522.1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
More information about the scm-commits
mailing list