[celestia] lua 5.2

Tom Callaway spot at fedoraproject.org
Tue May 14 15:40:19 UTC 2013


commit 7249ce0a6050fee9c8b27e96728fc6ec411e7588
Author: Tom Callaway <spot at fedoraproject.org>
Date:   Tue May 14 11:39:54 2013 -0400

    lua 5.2

 celestia-1.6.1-lua-5.2.patch |  262 ++++++++++++++++++++++++++++++++++++++++++
 celestia.spec                |    9 ++-
 2 files changed, 270 insertions(+), 1 deletions(-)
---
diff --git a/celestia-1.6.1-lua-5.2.patch b/celestia-1.6.1-lua-5.2.patch
new file mode 100644
index 0000000..4d631cb
--- /dev/null
+++ b/celestia-1.6.1-lua-5.2.patch
@@ -0,0 +1,262 @@
+diff -up celestia-1.6.1/configure.in.lua-52 celestia-1.6.1/configure.in
+--- celestia-1.6.1/configure.in.lua-52	2011-06-05 12:11:45.000000000 -0400
++++ celestia-1.6.1/configure.in	2013-05-14 11:11:34.358327867 -0400
+@@ -375,13 +375,17 @@ AC_ARG_WITH([lua],
+ 
+ if (test "$enable_lua" != "no"); then
+ 	LUA_VER=0
+-	PKG_CHECK_MODULES(LUA, lua5.1 >= 5.1.0, LUA_VER=0x050100, 
+-		[ PKG_CHECK_MODULES(LUA, lua >= 5.1.0, LUA_VER=0x050100, 
+-		  [ PKG_CHECK_MODULES(LUA, lua50 >= 5.0.0 lua50 < 5.1.0, LUA_VER=0x050000,
+-		    [ PKG_CHECK_MODULES(LUA, lua >= 5.0.0 lua < 5.1.0, LUA_VER=0x050000, AC_MSG_RESULT([no])) ] 
+-		    ) ] 
++	PKG_CHECK_MODULES(LUA, lua5.2 >= 5.2.0, LUA_VER=0x050200,
++		[ PKG_CHECK_MODULES(LUA, lua >= 5.2.0, LUA_VER=0x050200,
++		  [ PKG_CHECK_MODULES(LUA, lua5.1 >= 5.1.0, LUA_VER=0x050100, 
++		    [ PKG_CHECK_MODULES(LUA, lua >= 5.1.0, LUA_VER=0x050100, 
++		      [ PKG_CHECK_MODULES(LUA, lua50 >= 5.0.0 lua50 < 5.1.0, LUA_VER=0x050000,
++		        [ PKG_CHECK_MODULES(LUA, lua >= 5.0.0 lua < 5.1.0, LUA_VER=0x050000, AC_MSG_RESULT([no])) ] 
++		        ) ] 
++		      ) ]
++                    ) ]
+ 		) ]
+-	)
++	) 
+ 	if (test "$LUA_VER" = "0x050000"); then
+ 		PKG_CHECK_MODULES(LUALIB, lualib50 >= 5.0.0 lualib50 < 5.1.0, ,
+ 			[ PKG_CHECK_MODULES(LUALIB, lualib >= 5.0.0 lualib < 5.1.0, , AC_MSG_RESULT([no])) ]
+diff -up celestia-1.6.1/src/celengine/scriptorbit.cpp.lua-52 celestia-1.6.1/src/celengine/scriptorbit.cpp
+--- celestia-1.6.1/src/celengine/scriptorbit.cpp.lua-52	2011-06-05 12:11:09.000000000 -0400
++++ celestia-1.6.1/src/celengine/scriptorbit.cpp	2013-05-14 11:11:34.359327867 -0400
+@@ -73,8 +73,7 @@ ScriptedOrbit::initialize(const std::str
+ 
+     if (!moduleName.empty())
+     {
+-        lua_pushstring(luaState, "require");
+-        lua_gettable(luaState, LUA_GLOBALSINDEX);
++        lua_getglobal(luaState, "require");
+         if (!lua_isfunction(luaState, -1))
+         {
+             clog << "Cannot load ScriptedOrbit package: 'require' function is unavailable\n";
+@@ -92,8 +91,7 @@ ScriptedOrbit::initialize(const std::str
+     }
+ 
+     // Get the orbit generator function
+-    lua_pushstring(luaState, funcName.c_str());
+-    lua_gettable(luaState, LUA_GLOBALSINDEX);
++    lua_getglobal(luaState, funcName.c_str());
+ 
+     if (lua_isfunction(luaState, -1) == 0)
+     {
+@@ -157,9 +155,8 @@ ScriptedOrbit::initialize(const std::str
+     luaOrbitObjectName = GenerateScriptObjectName();
+ 
+     // Attach the name to the script orbit
+-    lua_pushstring(luaState, luaOrbitObjectName.c_str());
+     lua_pushvalue(luaState, -2); // dup the orbit object on top of stack
+-    lua_settable(luaState, LUA_GLOBALSINDEX);
++    lua_setglobal(luaState, luaOrbitObjectName.c_str());
+ 
+     // Now, call orbit object methods to get the bounding radius
+     // and valid time range.
+@@ -206,8 +203,7 @@ ScriptedOrbit::computePosition(double tj
+ {
+     Point3d pos(0.0, 0.0, 0.0);
+ 
+-    lua_pushstring(luaState, luaOrbitObjectName.c_str());
+-    lua_gettable(luaState, LUA_GLOBALSINDEX);
++    lua_getglobal(luaState, luaOrbitObjectName.c_str());
+     if (lua_istable(luaState, -1))
+     {
+         lua_pushstring(luaState, "position");
+diff -up celestia-1.6.1/src/celengine/scriptrotation.cpp.lua-52 celestia-1.6.1/src/celengine/scriptrotation.cpp
+--- celestia-1.6.1/src/celengine/scriptrotation.cpp.lua-52	2011-06-05 12:11:09.000000000 -0400
++++ celestia-1.6.1/src/celengine/scriptrotation.cpp	2013-05-14 11:11:34.359327867 -0400
+@@ -74,8 +74,7 @@ ScriptedRotation::initialize(const std::
+ 
+     if (!moduleName.empty())
+     {
+-        lua_pushstring(luaState, "require");
+-        lua_gettable(luaState, LUA_GLOBALSINDEX);
++        lua_getglobal(luaState, "require");
+         if (!lua_isfunction(luaState, -1))
+         {
+             clog << "Cannot load ScriptedRotation package: 'require' function is unavailable\n";
+@@ -93,8 +92,7 @@ ScriptedRotation::initialize(const std::
+     }
+ 
+     // Get the rotation generator function
+-    lua_pushstring(luaState, funcName.c_str());
+-    lua_gettable(luaState, LUA_GLOBALSINDEX);
++    lua_getglobal(luaState, funcName.c_str());
+ 
+     if (lua_isfunction(luaState, -1) == 0)
+     {
+@@ -131,9 +129,8 @@ ScriptedRotation::initialize(const std::
+     luaRotationObjectName = GenerateScriptObjectName();
+ 
+     // Attach the name to the script rotation
+-    lua_pushstring(luaState, luaRotationObjectName.c_str());
+     lua_pushvalue(luaState, -2); // dup the rotation object on top of stack
+-    lua_settable(luaState, LUA_GLOBALSINDEX);
++    lua_setglobal(luaState, luaRotationObjectName.c_str());
+ 
+     // Get the rest of the rotation parameters; they are all optional.
+     period          = SafeGetLuaNumber(luaState, -1, "period", 0.0);
+@@ -160,8 +157,7 @@ ScriptedRotation::spin(double tjd) const
+ {
+     if (tjd != lastTime || !cacheable)
+     {
+-        lua_pushstring(luaState, luaRotationObjectName.c_str());
+-        lua_gettable(luaState, LUA_GLOBALSINDEX);
++        lua_getglobal(luaState, luaRotationObjectName.c_str());
+         if (lua_istable(luaState, -1))
+         {
+             lua_pushstring(luaState, "orientation");
+diff -up celestia-1.6.1/src/celestia/celx.cpp.lua-52 celestia-1.6.1/src/celestia/celx.cpp
+--- celestia-1.6.1/src/celestia/celx.cpp.lua-52	2011-06-05 12:11:13.000000000 -0400
++++ celestia-1.6.1/src/celestia/celx.cpp	2013-05-14 11:17:34.953333278 -0400
+@@ -51,6 +51,10 @@
+ #include "celx.h"
+ #include "celestiacore.h"
+ 
++#ifndef lua_open
++#define lua_open()     luaL_newstate()
++#endif
++
+ using namespace std;
+ 
+ const char* CelxLua::ClassNames[] =
+@@ -294,14 +298,7 @@ void CelxLua::initMaps()
+ 
+ static void getField(lua_State* l, int index, const char* key)
+ {
+-    // When we move to Lua 5.1, this will be replaced by:
+-    // lua_getfield(l, index, key);
+-    lua_pushstring(l, key);
+-
+-    if (index != LUA_GLOBALSINDEX && index != LUA_REGISTRYINDEX)
+-        lua_gettable(l, index - 1);
+-    else
+-        lua_gettable(l, index);
++    lua_getfield(l, index, key);
+ }
+ 
+ 
+@@ -583,8 +580,7 @@ void LuaState::cleanup()
+             lua_pop(state,1);
+         }
+     }
+-    lua_pushstring(costate, CleanupCallback);
+-    lua_gettable(costate, LUA_GLOBALSINDEX);
++    lua_getglobal(costate, CleanupCallback);
+     if (lua_isnil(costate, -1))
+     {
+         return;
+@@ -654,7 +650,11 @@ static int resumeLuaThread(lua_State *L,
+     //   luaL_error(L, "too many arguments to resume");
+     lua_xmove(L, co, narg);
+ 
++#if LUA_VER >= 0x050200
++    status = lua_resume(co, NULL, narg);
++#else
+     status = lua_resume(co, narg);
++#endif
+ #if LUA_VER >= 0x050100
+     if (status == 0 || status == LUA_YIELD)
+ #else
+@@ -768,8 +768,7 @@ bool LuaState::charEntered(const char* c
+     int stack_top = lua_gettop(costate);
+ #endif
+     bool result = true;
+-    lua_pushstring(costate, KbdCallback);
+-    lua_gettable(costate, LUA_GLOBALSINDEX);
++    lua_getglobal(costate, KbdCallback);
+     lua_pushstring(costate, c_p);
+     timeout = getTime() + 1.0;
+     if (lua_pcall(costate, 1, 1, 0) != 0)
+@@ -961,8 +960,11 @@ int LuaState::loadScript(istream& in, co
+         lua_pushstring(state, streamname.c_str());
+         lua_settable(state, LUA_REGISTRYINDEX);
+     }
+-
++#if LUA_VER >= 0x050200
++    int status = lua_load(state, readStreamChunk, &info, streamname.c_str(), NULL);
++#else
+     int status = lua_load(state, readStreamChunk, &info, streamname.c_str());
++#endif
+     if (status != 0)
+         cout << "Error loading script: " << lua_tostring(state, -1) << '\n';
+ 
+@@ -3157,8 +3159,7 @@ static int celestia_requestkeyboard(lua_
+     if (lua_toboolean(l, 2))
+     {
+         // Check for existence of charEntered:
+-        lua_pushstring(l, KbdCallback);
+-        lua_gettable(l, LUA_GLOBALSINDEX);
++        lua_getglobal(l, KbdCallback);
+         if (lua_isnil(l, -1))
+         {
+             Celx_DoError(l, "script requested keyboard, but did not provide callback");
+@@ -3559,16 +3560,14 @@ bool LuaState::init(CelestiaCore* appCor
+         return false;
+     }
+ 
+-    lua_pushstring(state, "KM_PER_MICROLY");
+     lua_pushnumber(state, (lua_Number)KM_PER_LY/1e6);
+-    lua_settable(state, LUA_GLOBALSINDEX);
++    lua_setglobal(state, "KM_PER_MICROLY");
+ 
+     loadLuaLibs(state);
+ 
+     // Create the celestia object
+-    lua_pushstring(state, "celestia");
+     celestia_new(state, appCore);
+-    lua_settable(state, LUA_GLOBALSINDEX);
++    lua_setglobal(state, "celestia");
+     // add reference to appCore in the registry
+     lua_pushstring(state, "celestia-appcore");
+     lua_pushlightuserdata(state, static_cast<void*>(appCore));
+@@ -3604,7 +3603,7 @@ bool LuaState::init(CelestiaCore* appCor
+ void LuaState::setLuaPath(const string& s)
+ {
+ #if LUA_VER >= 0x050100
+-    lua_getfield(state, LUA_GLOBALSINDEX, "package");
++    lua_getglobal(state, "package");
+     lua_pushstring(state, s.c_str());
+     lua_setfield(state, -2, "path");
+     lua_pop(state, 1);
+@@ -4118,7 +4117,7 @@ void LuaState::allowLuaPackageAccess()
+     openLuaLibrary(state, LUA_LOADLIBNAME, luaopen_package);
+ 
+     // Disallow loadlib
+-    lua_getfield(state, LUA_GLOBALSINDEX, "package");
++    lua_getglobal(state, "package");
+     lua_pushnil(state);
+     lua_setfield(state, -2, "loadlib");
+     lua_pop(state, 1);
+diff -up celestia-1.6.1/src/celestia/celx_gl.cpp.lua-52 celestia-1.6.1/src/celestia/celx_gl.cpp
+--- celestia-1.6.1/src/celestia/celx_gl.cpp.lua-52	2011-06-05 12:11:13.000000000 -0400
++++ celestia-1.6.1/src/celestia/celx_gl.cpp	2013-05-14 11:11:34.362327867 -0400
+@@ -221,7 +221,6 @@ static int gl_PushMatrix(lua_State* l)
+ void LoadLuaGraphicsLibrary(lua_State* l)
+ {
+     CelxLua celx(l);
+-    lua_pushstring(l, "gl");
+     lua_newtable(l);
+     
+     celx.registerMethod("Frustum", gl_Frustum);
+@@ -259,11 +258,10 @@ void LoadLuaGraphicsLibrary(lua_State* l
+     celx.registerValue("NEAREST", GL_NEAREST);
+     celx.registerValue("SRC_ALPHA", GL_SRC_ALPHA);
+     celx.registerValue("ONE_MINUS_SRC_ALPHA", GL_ONE_MINUS_SRC_ALPHA);
+-    lua_settable(l, LUA_GLOBALSINDEX);
++    lua_setglobal(l, "gl");
+     
+-    lua_pushstring(l, "glu");
+     lua_newtable(l);
+     celx.registerMethod("LookAt", glu_LookAt);
+     celx.registerMethod("Ortho2D", glu_Ortho2D);
+-    lua_settable(l, LUA_GLOBALSINDEX);
++    lua_setglobal(l, "glu");
+ }
diff --git a/celestia.spec b/celestia.spec
index 4365f83..7139299 100644
--- a/celestia.spec
+++ b/celestia.spec
@@ -1,6 +1,6 @@
 Name:           celestia
 Version:        1.6.1
-Release:        11%{?dist}
+Release:        12%{?dist}
 Summary:        OpenGL real-time visual space simulation
 Group:          Applications/Emulators
 License:        GPLv2+
@@ -38,6 +38,7 @@ Source3:        celestia.desktop
 URL:            http://www.shatters.net/celestia/
 Patch0:         celestia-1.6.1-gcc47.patch
 Patch1:         celestia-1.6.1-zlib.patch
+Patch2:		celestia-1.6.1-lua-5.2.patch
 BuildRequires:  zlib-devel
 BuildRequires:  gtkglext-devel
 BuildRequires:  libgnomeui-devel
@@ -50,6 +51,7 @@ BuildRequires:  libXt-devel
 BuildRequires:  libXmu-devel
 BuildRequires:  lua-devel
 BuildRequires:  gettext-devel
+BuildRequires:	libtool, autoconf
 Requires(pre):  GConf2
 Requires(post): GConf2
 Requires(preun): GConf2
@@ -70,6 +72,8 @@ object you want to visit.
 %setup -q
 %patch0 -p1 -b .gcc47
 %patch1 -p1 -b .zlib
+%patch2 -p1 -b .lua-52
+autoconf
 
 # Make sure we compile with the right CFLAGS/CXXFLAGS (from Hans de Goede).
 sed -i 's/CFLAGS="\$CFLAGS \$CELESTIAFLAGS \$CELESTIA_CFLAGS"/CFLAGS="\$CFLAGS \$CELESTIAFLAGS"/' configure
@@ -134,6 +138,9 @@ fi
 
 
 %changelog
+* Tue May 14 2013 Tom Callaway <spot at fedoraproject.org> - 1.6.1-12
+- rebuild for lua 5.2
+
 * Thu Feb 14 2013 Rahul Sundaram <sundaram at fedoraproject.org> - 1.6.1-11
 - remove vendor tag from desktop file. https://fedorahosted.org/fpc/ticket/247
 - clean up spec to follow current guidelines


More information about the scm-commits mailing list