diff --git a/_aggregate b/_aggregate
deleted file mode 100644
index 6d268a7..0000000
--- a/_aggregate
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- lua51
-
-
-
diff --git a/baselibs.conf b/baselibs.conf
new file mode 100644
index 0000000..3a1066c
--- /dev/null
+++ b/baselibs.conf
@@ -0,0 +1 @@
+liblua5_1
diff --git a/lua51-5.1.4-libdir.diff b/lua51-5.1.4-libdir.diff
new file mode 100644
index 0000000..3f94fbd
--- /dev/null
+++ b/lua51-5.1.4-libdir.diff
@@ -0,0 +1,13 @@
+Index: lua-5.1.4/etc/lua.pc
+===================================================================
+--- lua-5.1.4.orig/etc/lua.pc
++++ lua-5.1.4/etc/lua.pc
+@@ -25,7 +25,7 @@ Name: Lua
+ Description: An Extensible Extension Language
+ Version: ${R}
+ Requires:
+-Libs: -L${libdir} -llua -lm
++Libs: -llua -lm
+ Cflags: -I${includedir}
+
+ # (end of lua.pc)
diff --git a/lua51-5.1.4-module-path.diff b/lua51-5.1.4-module-path.diff
new file mode 100644
index 0000000..ef5faec
--- /dev/null
+++ b/lua51-5.1.4-module-path.diff
@@ -0,0 +1,21 @@
+diff -urNad trunk~/src/luaconf.h trunk/src/luaconf.h
+--- trunk~/src/luaconf.h 2006-02-10 12:44:06.000000000 -0500
++++ trunk/src/luaconf.h 2006-02-17 21:32:55.000000000 -0500
+@@ -83,13 +83,17 @@
+
+ #else
+ #define LUA_ROOT "/usr/local/"
++#define LUA_ROOT2 "/usr/"
+ #define LUA_LDIR LUA_ROOT "share/lua/5.1/"
++#define LUA_LDIR2 LUA_ROOT2 "share/lua/5.1/"
+ #define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
++#define LUA_CDIR2 LUA_ROOT2 "LIBDIR/lua/5.1/"
+ #define LUA_PATH_DEFAULT \
+ "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
+- LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua"
++ LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \
++ LUA_LDIR2"?.lua;" LUA_LDIR2"?/init.lua"
+ #define LUA_CPATH_DEFAULT \
+- "./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so"
++ "./?.so;" LUA_CDIR"?.so;" LUA_CDIR2"?.so;" LUA_CDIR"loadall.so"
+ #endif
diff --git a/lua51-5.1.4-shared.diff b/lua51-5.1.4-shared.diff
new file mode 100644
index 0000000..dcb5f27
--- /dev/null
+++ b/lua51-5.1.4-shared.diff
@@ -0,0 +1,91 @@
+Index: etc/lua.pc
+===================================================================
+--- etc/lua.pc.orig
++++ etc/lua.pc
+@@ -8,7 +8,7 @@ V= 5.1
+ R= 5.1.4
+
+ # grep '^INSTALL_.*=' ../Makefile | sed 's/INSTALL_TOP/prefix/'
+-prefix= /usr/local
++prefix= /usr
+ INSTALL_BIN= ${prefix}/bin
+ INSTALL_INC= ${prefix}/include
+ INSTALL_LIB= ${prefix}/lib
+Index: src/luaconf.h
+===================================================================
+--- src/luaconf.h.orig
++++ src/luaconf.h
+@@ -184,7 +184,7 @@
+
+ #elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
+ defined(__ELF__)
+-#define LUAI_FUNC __attribute__((visibility("hidden"))) extern
++#define LUAI_FUNC extern
+ #define LUAI_DATA LUAI_FUNC
+
+ #else
+Index: src/Makefile
+===================================================================
+--- src/Makefile.orig
++++ src/Makefile
+@@ -23,6 +23,7 @@ MYLIBS=
+ PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
+
+ LUA_A= liblua.a
++LUA_SO= liblua.so
+ CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
+ lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \
+ lundump.o lvm.o lzio.o
+@@ -36,7 +37,7 @@ LUAC_T= luac
+ LUAC_O= luac.o print.o
+
+ ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O)
+-ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
++ALL_T= $(LUA_SO) $(LUA_A) $(LUA_T) $(LUAC_T)
+ ALL_A= $(LUA_A)
+
+ default: $(PLAT)
+@@ -47,15 +48,20 @@ o: $(ALL_O)
+
+ a: $(ALL_A)
+
++# shared libraries (for Linux)
++$(LUA_SO): $(CORE_O) $(LIB_O)
++ $(CC) -o $(LUA_SO).$V -shared -Wl,-soname,$(LUA_SO).$V $(CORE_O) $(LIB_O) -lm -ldl
++ ln -fs $(LUA_SO).$(V) $(LUA_SO)
++
+ $(LUA_A): $(CORE_O) $(LIB_O)
+ $(AR) $@ $?
+ $(RANLIB) $@
+
+ $(LUA_T): $(LUA_O) $(LUA_A)
+- $(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
++ $(CC) -o $@ $(MYLDFLAGS) $(LUA_O) -L. -llua $(LIBS)
+
+ $(LUAC_T): $(LUAC_O) $(LUA_A)
+- $(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
++ $(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) -L. -llua $(LIBS)
+
+ clean:
+ $(RM) $(ALL_T) $(ALL_O)
+Index: Makefile
+===================================================================
+--- Makefile.orig
++++ Makefile
+@@ -43,7 +43,7 @@ PLATS= aix ansi bsd freebsd generic linu
+ # What to install.
+ TO_BIN= lua luac
+ TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp
+-TO_LIB= liblua.a
++TO_LIB= liblua.a liblua.so.$(V)
+ TO_MAN= lua.1 luac.1
+
+ # Lua version and release.
+@@ -62,6 +62,7 @@ install: dummy
+ cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
+ cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)
+ cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
++ ln -s liblua.so.$(V) $(INSTALL_LIB)/liblua.so
+ cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
+ cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
+
diff --git a/lua51-5.1.4-upstream-bugfix.diff b/lua51-5.1.4-upstream-bugfix.diff
new file mode 100644
index 0000000..f026737
--- /dev/null
+++ b/lua51-5.1.4-upstream-bugfix.diff
@@ -0,0 +1,196 @@
+# patch-lua-5.1.4-2 created 2010-05-14T21:02:40-0300
+# apply to a pristine copy of Lua 5.1.4 with:
+# wget http://www.lua.org/ftp/lua-5.1.4.tar.gz
+# tar zxf lua-5.1.4.tar.gz
+# cd lua-5.1.4/src
+# wget http://www.lua.org/ftp/patch-lua-5.1.4-2
+# patch < patch-lua-5.1.4-2
+# use curl -O -R if you don't have wget
+
+--- src/lcode.c 2007/12/28 15:32:23 2.25.1.3
++++ src/lcode.c 2009/06/15 14:12:25 2.25.1.4
+@@ -1,5 +1,5 @@
+ /*
+-** $Id: lcode.c,v 2.25.1.3 2007/12/28 15:32:23 roberto Exp $
++** $Id: lcode.c,v 2.25.1.4 2009/06/15 14:12:25 roberto Exp $
+ ** Code generator for Lua
+ ** See Copyright Notice in lua.h
+ */
+@@ -544,15 +544,18 @@
+ pc = NO_JUMP; /* always true; do nothing */
+ break;
+ }
+- case VFALSE: {
+- pc = luaK_jump(fs); /* always jump */
+- break;
+- }
+ case VJMP: {
+ invertjump(fs, e);
+ pc = e->u.s.info;
+ break;
+ }
++ case VFALSE: {
++ if (!hasjumps(e)) {
++ pc = luaK_jump(fs); /* always jump */
++ break;
++ }
++ /* else go through */
++ }
+ default: {
+ pc = jumponcond(fs, e, 0);
+ break;
+@@ -572,14 +575,17 @@
+ pc = NO_JUMP; /* always false; do nothing */
+ break;
+ }
+- case VTRUE: {
+- pc = luaK_jump(fs); /* always jump */
+- break;
+- }
+ case VJMP: {
+ pc = e->u.s.info;
+ break;
+ }
++ case VTRUE: {
++ if (!hasjumps(e)) {
++ pc = luaK_jump(fs); /* always jump */
++ break;
++ }
++ /* else go through */
++ }
+ default: {
+ pc = jumponcond(fs, e, 1);
+ break;
+--- src/ldblib.c 2008/01/21 13:11:21 1.104.1.3
++++ src/ldblib.c 2009/08/04 18:50:18 1.104.1.4
+@@ -1,5 +1,5 @@
+ /*
+-** $Id: ldblib.c,v 1.104.1.3 2008/01/21 13:11:21 roberto Exp $
++** $Id: ldblib.c,v 1.104.1.4 2009/08/04 18:50:18 roberto Exp $
+ ** Interface from Lua to its debug API
+ ** See Copyright Notice in lua.h
+ */
+@@ -45,6 +45,7 @@
+
+
+ static int db_getfenv (lua_State *L) {
++ luaL_checkany(L, 1);
+ lua_getfenv(L, 1);
+ return 1;
+ }
+--- src/liolib.c 2008/01/18 17:47:43 2.73.1.3
++++ src/liolib.c 2010/05/14 15:33:51 2.73.1.4
+@@ -1,5 +1,5 @@
+ /*
+-** $Id: liolib.c,v 2.73.1.3 2008/01/18 17:47:43 roberto Exp $
++** $Id: liolib.c,v 2.73.1.4 2010/05/14 15:33:51 roberto Exp $
+ ** Standard I/O (and system) library
+ ** See Copyright Notice in lua.h
+ */
+@@ -276,7 +276,10 @@
+ lua_pushnumber(L, d);
+ return 1;
+ }
+- else return 0; /* read fails */
++ else {
++ lua_pushnil(L); /* "result" to be removed */
++ return 0; /* read fails */
++ }
+ }
+
+
+--- src/llex.c 2007/12/27 13:02:25 2.20.1.1
++++ src/llex.c 2009/11/23 14:58:22 2.20.1.2
+@@ -1,5 +1,5 @@
+ /*
+-** $Id: llex.c,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $
++** $Id: llex.c,v 2.20.1.2 2009/11/23 14:58:22 roberto Exp $
+ ** Lexical Analyzer
+ ** See Copyright Notice in lua.h
+ */
+@@ -118,8 +118,10 @@
+ lua_State *L = ls->L;
+ TString *ts = luaS_newlstr(L, str, l);
+ TValue *o = luaH_setstr(L, ls->fs->h, ts); /* entry for `str' */
+- if (ttisnil(o))
++ if (ttisnil(o)) {
+ setbvalue(o, 1); /* make sure `str' will not be collected */
++ luaC_checkGC(L);
++ }
+ return ts;
+ }
+
+--- src/loadlib.c 2008/08/06 13:29:28 1.52.1.3
++++ src/loadlib.c 2009/09/09 13:17:16 1.52.1.4
+@@ -1,5 +1,5 @@
+ /*
+-** $Id: loadlib.c,v 1.52.1.3 2008/08/06 13:29:28 roberto Exp $
++** $Id: loadlib.c,v 1.52.1.4 2009/09/09 13:17:16 roberto Exp $
+ ** Dynamic library loader for Lua
+ ** See Copyright Notice in lua.h
+ **
+@@ -639,7 +639,7 @@
+ lua_pushvalue(L, -1);
+ lua_replace(L, LUA_ENVIRONINDEX);
+ /* create `loaders' table */
+- lua_createtable(L, 0, sizeof(loaders)/sizeof(loaders[0]) - 1);
++ lua_createtable(L, sizeof(loaders)/sizeof(loaders[0]) - 1, 0);
+ /* fill it with pre-defined loaders */
+ for (i=0; loaders[i] != NULL; i++) {
+ lua_pushcfunction(L, loaders[i]);
+--- src/lstrlib.c 2008/07/11 17:27:21 1.132.1.4
++++ src/lstrlib.c 2010/05/14 15:34:19 1.132.1.5
+@@ -1,5 +1,5 @@
+ /*
+-** $Id: lstrlib.c,v 1.132.1.4 2008/07/11 17:27:21 roberto Exp $
++** $Id: lstrlib.c,v 1.132.1.5 2010/05/14 15:34:19 roberto Exp $
+ ** Standard library for string operations and pattern-matching
+ ** See Copyright Notice in lua.h
+ */
+@@ -754,6 +754,7 @@
+
+
+ static int str_format (lua_State *L) {
++ int top = lua_gettop(L);
+ int arg = 1;
+ size_t sfl;
+ const char *strfrmt = luaL_checklstring(L, arg, &sfl);
+@@ -768,7 +769,8 @@
+ else { /* format item */
+ char form[MAX_FORMAT]; /* to store the format (`%...') */
+ char buff[MAX_ITEM]; /* to store the formatted item */
+- arg++;
++ if (++arg > top)
++ luaL_argerror(L, arg, "no value");
+ strfrmt = scanformat(L, strfrmt, form);
+ switch (*strfrmt++) {
+ case 'c': {
+--- src/lvm.c 2007/12/28 15:32:23 2.63.1.3
++++ src/lvm.c 2009/07/01 21:10:33 2.63.1.4
+@@ -1,5 +1,5 @@
+ /*
+-** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $
++** $Id: lvm.c,v 2.63.1.4 2009/07/01 21:10:33 roberto Exp $
+ ** Lua virtual machine
+ ** See Copyright Notice in lua.h
+ */
+@@ -133,6 +133,7 @@
+
+ void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
+ int loop;
++ TValue temp;
+ for (loop = 0; loop < MAXTAGLOOP; loop++) {
+ const TValue *tm;
+ if (ttistable(t)) { /* `t' is a table? */
+@@ -152,7 +153,9 @@
+ callTM(L, tm, t, key, val);
+ return;
+ }
+- t = tm; /* else repeat with `tm' */
++ /* else repeat with `tm' */
++ setobj(L, &temp, tm); /* avoid pointing inside table (may rehash) */
++ t = &temp;
+ }
+ luaG_runerror(L, "loop in settable");
+ }
+
diff --git a/lua51-5.1.4.tar.bz2 b/lua51-5.1.4.tar.bz2
new file mode 100644
index 0000000..82a46bc
--- /dev/null
+++ b/lua51-5.1.4.tar.bz2
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:48b0a8f52e7ea8015689cf9837fbcfb7440260117df4a2aca243e1e74b623e7f
+size 176571
diff --git a/lua51.changes b/lua51.changes
new file mode 100644
index 0000000..d1a89f0
--- /dev/null
+++ b/lua51.changes
@@ -0,0 +1,199 @@
+-------------------------------------------------------------------
+Wed Dec 21 13:48:10 UTC 2011 - pgajdos@suse.com
+
+- lua51 branched from lua package
+
+-------------------------------------------------------------------
+Tue Oct 4 11:44:08 UTC 2011 - uli@suse.com
+
+- cross-build fix: use %__cc macro
+
+-------------------------------------------------------------------
+Mon Jun 28 06:38:35 UTC 2010 - jengelh@medozas.de
+
+- use %_smp_mflags
+
+-------------------------------------------------------------------
+Mon Jun 14 15:55:32 CEST 2010 - pgajdos@suse.cz
+
+- removed -L/usr/lib from Libs: in etc/lua.pc [bnc#613497]
+- used upstream bugfix patch from http://www.lua.org/download.html
+
+-------------------------------------------------------------------
+Sat Apr 24 11:38:23 UTC 2010 - coolo@novell.com
+
+- buildrequire pkg-config to fix provides
+
+-------------------------------------------------------------------
+Tue Mar 23 11:16:23 CET 2010 - pgajdos@suse.cz
+
+- modified LUA_PATH_DEFAULT [bnc#589441]: search modules under
+ /usr/%{_lib}/lua/%{major_version} too
+
+-------------------------------------------------------------------
+Sat Dec 12 18:28:44 CET 2009 - jengelh@medozas.de
+
+- add baselibs.conf as a source
+- package documentation as noarch
+
+-------------------------------------------------------------------
+Sun Dec 6 16:02:17 CET 2009 - jengelh@medozas.de
+
+- enable parallel building
+
+-------------------------------------------------------------------
+Tue Nov 3 19:09:29 UTC 2009 - coolo@novell.com
+
+- updated patches to apply with fuzz=0
+
+-------------------------------------------------------------------
+Wed Sep 16 23:25:13 CEST 2009 - dmueller@suse.de
+
+- add baselibs.conf
+
+-------------------------------------------------------------------
+Mon Jun 8 15:57:11 CEST 2009 - pgajdos@suse.cz
+
+- package owns /usr/{lib,share}/lua directories from now
+- emoved unneeded root.patch
+
+-------------------------------------------------------------------
+Thu Sep 11 16:00:41 CEST 2008 - pgajdos@suse.cz
+
+- updated to 5.1.4: bugfix release
+
+-------------------------------------------------------------------
+Wed Jun 11 10:56:51 ADT 2008 - jfunk@funktronics.ca
+
+- Set LUA_ROOT to /usr and fix INSTALL_CMOD for lib64
+- Add RPM macros file
+- Allows for lua- packages like python, perl, and ruby
+
+-------------------------------------------------------------------
+Fri Mar 28 07:57:37 CET 2008 - coolo@suse.de
+
+- hint the solver about the package rename
+
+-------------------------------------------------------------------
+Wed Mar 26 21:29:35 CET 2008 - coolo@suse.de
+
+- do not package/provide the shared lib twice / follow shared lib
+ policy
+
+-------------------------------------------------------------------
+Tue Feb 19 10:37:22 CET 2008 - pgajdos@suse.cz
+
+- created -doc package
+- updated to version 5.1.3, bug fix release. Fixed bugs:
+ * wrong error message in some concatenations
+ * too many variables in an assignment may cause a C stack
+ overflow
+ * an error in a module loaded through the '-l' option shows no
+ traceback
+ * gsub may go wild when wrongly called without its third
+ argument and with a large subject
+ * table.remove removes last element of a table when given
+ an out-of-bound index
+ * lua_setfenv may crash if called over an invalid object
+ * stand-alone interpreter shows incorrect error message when
+ the "message" is a coroutine.
+ * debug.sethook/gethook may overflow the thread's stack
+
+-------------------------------------------------------------------
+Tue Jul 24 14:31:30 CEST 2007 - pgajdos@suse.cz
+
+- using /sbin/ldconfig in specfile
+- updated to version 5.1.2, fixes some bugs:
+ * count hook may be called without being set
+ * code generated for "-nil", "-true", and "-false" is wrong
+ * recursive coroutines may overflow C stack
+ * wrong error message in some concatenations
+ * very small numbers all collide in the hash function
+
+-------------------------------------------------------------------
+Mon Nov 27 17:42:31 CET 2006 - mrueckert@suse.de
+
+- package liblua.so as symlink.
+
+-------------------------------------------------------------------
+Thu Nov 16 21:29:32 CET 2006 - mrueckert@suse.de
+
+- the core package now uses update alternatives to allow installation
+ of 5.0.x and 5.1.x
+- devel packages will conflict now
+
+-------------------------------------------------------------------
+Tue Nov 14 21:29:31 CET 2006 - mrueckert@suse.de
+
+- ARGH dont copy and paste!:
+ lua-libs should not depend on lua. another run on (#217875)
+
+-------------------------------------------------------------------
+Tue Nov 14 11:42:44 CET 2006 - mrueckert@suse.de
+
+- really fix the file pattern (#217875)
+
+-------------------------------------------------------------------
+Thu Nov 9 15:08:50 CET 2006 - mrueckert@suse.de
+
+- splitted out lua-libs so we can install at least both libs
+ in parallel. (#217875)
+
+-------------------------------------------------------------------
+Thu Oct 19 22:44:09 CEST 2006 - dmueller@suse.de
+
+- fix wrong prefix in lua.pc
+- link liblua with -lm to satisfy unresolved symbols
+
+-------------------------------------------------------------------
+Thu Oct 19 16:44:39 CEST 2006 - mjancar@suse.cz
+
+- include lua.pc
+
+-------------------------------------------------------------------
+Wed Oct 18 19:17:00 CEST 2006 - mjancar@suse.cz
+
+- update to 5.1.1
+ Language:
+ * new module system.
+ * new semantics for control variables of fors.
+ * new semantics for setn/getn.
+ * new syntax/semantics for varargs.
+ * new long strings and comments.
+ * new `mod' operator (`%')
+ * new length operator #t
+ * metatables for all types
+ API:
+ * new functions: lua_createtable, lua_get(set)field, lua_push(to)integer.
+ * user supplies memory allocator (lua_open becomes lua_newstate).
+ * luaopen_* functionst must be called through Lua.
+ Implementation:
+ * new configuration scheme via luaconf.h.
+ * incremental garbage collection.
+ * better handling of end-of-line in the lexer.
+ * fully reentrant parser (new Lua function `load')
+ * better support for 64-bit machines.
+ * native loadlib support for Mac OS X.
+ * standard distribution in only one library (lualib.a merged into lua.a)
+
+-------------------------------------------------------------------
+Wed Jan 25 21:38:05 CET 2006 - mls@suse.de
+
+- converted neededforbuild to BuildRequires
+
+-------------------------------------------------------------------
+Sat Jan 14 01:36:17 CET 2006 - schwab@suse.de
+
+- Don't strip binaries.
+- Fix shared library linking.
+
+-------------------------------------------------------------------
+Thu Sep 8 15:17:49 CEST 2005 - anicka@suse.cz
+
+- enable dynamic loading capability (#106845)
+
+-------------------------------------------------------------------
+Fri Apr 23 16:17:31 CEST 2004 - mcihar@suse.cz
+
+- initial packaging
+
diff --git a/lua51.spec b/lua51.spec
new file mode 100644
index 0000000..ce13c65
--- /dev/null
+++ b/lua51.spec
@@ -0,0 +1,184 @@
+#
+# spec file for package lua51
+#
+# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
+#
+# All modifications and additions to the file contributed by third parties
+# remain the property of their copyright owners, unless otherwise agreed
+# upon. The license for this file, and modifications and additions to the
+# file, is the same license as for the pristine package itself (unless the
+# license for the pristine package is not an Open Source License, in which
+# case the license is the MIT License). An "Open Source License" is a
+# license that conforms to the Open Source Definition (Version 1.9)
+# published by the Open Source Initiative.
+
+# Please submit bugfixes or comments via http://bugs.opensuse.org/
+#
+
+# norootforbuild
+
+
+Name: lua51
+Version: 5.1.4
+Release: 17
+%define major_version 5.1
+License: MIT License (or similar)
+Group: System/Libraries
+AutoReqProv: on
+BuildRequires: pkg-config readline-devel update-alternatives
+PreReq: update-alternatives
+Summary: Small Embeddable Language with Simple Procedural Syntax
+Url: http://www.lua.org
+Source: %{name}-%{version}.tar.bz2
+Source1: macros.lua
+Source2: baselibs.conf
+Patch0: %{name}-%{version}-shared.diff
+Patch1: %{name}-%{version}-module-path.diff
+Patch2: %{name}-%{version}-upstream-bugfix.diff
+Patch3: %{name}-%{version}-libdir.diff
+BuildRoot: %{_tmppath}/%{name}-%{version}-build
+
+%description
+Lua is a programming language originally designed for extending
+applications, but also frequently used as a general-purpose,
+stand-alone language.
+
+Lua combines simple procedural syntax (similar to Pascal) with powerful
+data description constructs based on associative arrays and extensible
+semantics. Lua is dynamically typed, interpreted from byte codes, and
+has automatic memory management, making it ideal for configuration,
+scripting, and rapid prototyping. Lua is implemented as a small library
+of C functions, written in ANSI C, and the implementation goals are
+simplicity, efficiency, portability, and low embedding cost.
+
+%package devel
+License: MIT License (or similar)
+Summary: Development files for lua
+Group: Development/Libraries/C and C++
+Requires: %{name} = %{version}
+Conflicts: lua50-devel
+Conflicts: lua-devel
+
+%description devel
+Lua is a programming language originally designed for extending
+applications, but also frequently used as a general-purpose,
+stand-alone language.
+
+This package contains files needed for embedding lua into your
+application.
+
+%package -n liblua5_1
+License: MIT License (or similar)
+Summary: Small Embeddable Language with Simple Procedural Syntax
+Group: System/Libraries
+Provides: %{name}-libs = 5.1.3
+Obsoletes: %{name}-libs <= 5.1.3
+
+%description -n liblua5_1
+Lua is a programming language originally designed for extending
+applications, but also frequently used as a general-purpose,
+stand-alone language.
+
+Lua combines simple procedural syntax (similar to Pascal) with powerful
+data description constructs based on associative arrays and extensible
+semantics. Lua is dynamically typed, interpreted from byte codes, and
+has automatic memory management, making it ideal for configuration,
+scripting, and rapid prototyping. Lua is implemented as a small library
+of C functions, written in ANSI C, and the implementation goals are
+simplicity, efficiency, portability, and low embedding cost.
+
+%package doc
+License: MIT License (or similar)
+Summary: Small Embeddable Language with Simple Procedural Syntax
+Group: System/Libraries
+%if 0%{?suse_version} >= 1120
+BuildArch: noarch
+%endif
+
+%description doc
+Lua is a programming language originally designed for extending
+applications, but also frequently used as a general-purpose,
+stand-alone language.
+
+Lua combines simple procedural syntax (similar to Pascal) with powerful
+data description constructs based on associative arrays and extensible
+semantics. Lua is dynamically typed, interpreted from byte codes, and
+has automatic memory management, making it ideal for configuration,
+scripting, and rapid prototyping. Lua is implemented as a small library
+of C functions, written in ANSI C, and the implementation goals are
+simplicity, efficiency, portability, and low embedding cost.
+
+%prep
+%setup -q -n lua-%{version}
+%patch0 -b .shared
+%patch1 -p1
+%patch2
+%patch3 -p1
+
+%build
+sed -i 's:LUA_ROOT2 "LIBDIR/lua/%{major_version}/":LUA_ROOT2 \"%{_lib}/lua/%{major_version}/":' src/luaconf.h
+make %{?_smp_mflags} -C src CC="%{__cc}" MYCFLAGS="$RPM_OPT_FLAGS -fPIC -DLUA_USE_LINUX" MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses" V=%{major_version} all
+
+%install
+make install INSTALL_TOP="$RPM_BUILD_ROOT%{_prefix}" INSTALL_LIB="$RPM_BUILD_ROOT%{_libdir}" INSTALL_CMOD=$RPM_BUILD_ROOT%{_libdir}/lua/%{major_version} INSTALL_MAN="$RPM_BUILD_ROOT%{_mandir}/man1"
+install -D -m644 etc/lua.pc $RPM_BUILD_ROOT%{_libdir}/pkgconfig/lua.pc
+for file in lua luac ; do
+ mv "%{buildroot}%{_bindir}/${file}" "%{buildroot}%{_bindir}/${file}%{major_version}"
+ mv "%{buildroot}%{_mandir}/man1/${file}.1" "%{buildroot}%{_mandir}/man1/${file}%{major_version}.1"
+done
+install -d -m 0755 $RPM_BUILD_ROOT%{_libdir}/lua/%{major_version}
+install -d -m 0755 $RPM_BUILD_ROOT%{_datadir}/lua/%{major_version}
+install -D %{SOURCE1} %buildroot/etc/rpm/macros.lua
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%post
+/usr/sbin/update-alternatives --install \
+ %{_bindir}/lua lua %{_bindir}/lua%{major_version} 10 \
+ --slave %{_bindir}/luac luac %{_bindir}/luac%{major_version} \
+ --slave %{_mandir}/man1/lua.1.gz lua.1.gz %{_mandir}/man1/lua%{major_version}.1.gz \
+ --slave %{_mandir}/man1/luac.1.gz luac.1.gz %{_mandir}/man1/luac%{major_version}.1.gz
+
+%preun
+if [ "$1" = 0 ] ; then
+ /usr/sbin/update-alternatives --remove lua %{_bindir}/lua%{major_version}
+fi
+
+%post -n liblua5_1 -p /sbin/ldconfig
+
+%postun -n liblua5_1 -p /sbin/ldconfig
+
+%files
+%defattr(-,root,root)
+%doc COPYRIGHT HISTORY README
+%{_mandir}/man1/lua%{major_version}.1*
+%{_mandir}/man1/luac%{major_version}.1*
+%{_prefix}/bin/lua%{major_version}
+%{_prefix}/bin/luac%{major_version}
+%dir %{_libdir}/lua
+%dir %{_libdir}/lua/%{major_version}
+%dir %{_datadir}/lua
+%dir %{_datadir}/lua/%{major_version}
+/etc/rpm/macros.lua
+
+%files -n liblua5_1
+%defattr(-,root,root)
+%{_libdir}/liblua.so.%{major_version}
+
+%files devel
+%defattr(-,root,root)
+%{_includedir}/lauxlib.h
+%{_includedir}/lua.h
+%{_includedir}/lua.hpp
+%{_includedir}/luaconf.h
+%{_includedir}/lualib.h
+%{_libdir}/pkgconfig/lua.pc
+%{_libdir}/liblua.a
+%{_libdir}/liblua.so
+
+%files doc
+%defattr(-,root,root)
+%doc doc/*
+
+%changelog
diff --git a/macros.lua b/macros.lua
new file mode 100644
index 0000000..612a78f
--- /dev/null
+++ b/macros.lua
@@ -0,0 +1,10 @@
+# RPM macros for Lua
+
+# The major.minor version of Lua
+%lua_version %(lua -e 'print(_VERSION)' | cut -d ' ' -f 2)
+
+# compiled modules should go here
+%lua_archdir %{_libdir}/lua/%{lua_version}
+
+# pure Lua modules should go here
+%lua_noarchdir %{_datadir}/lua/%{lua_version}