From 1cad9b9a7f46f5cf5e09ed8dd73202598ab9c197 Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: Thu, 5 Jun 2014 17:39:12 +1000 Subject: [PATCH] initial version --- .gitignore | 1 + destdir.patch | 16 ++++++++ lua-ldap.spec | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++ lua52.patch | 34 ++++++++++++++++ sources | 1 + 5 files changed, 159 insertions(+) create mode 100644 destdir.patch create mode 100644 lua-ldap.spec create mode 100644 lua52.patch diff --git a/.gitignore b/.gitignore index e69de29..9b40795 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/lualdap-1.1.0.tar.gz diff --git a/destdir.patch b/destdir.patch new file mode 100644 index 0000000..09a8310 --- /dev/null +++ b/destdir.patch @@ -0,0 +1,16 @@ +diff -ur lualdap-1.1.0.orig/Makefile lualdap-1.1.0/Makefile +--- lualdap-1.1.0.orig/Makefile 2007-03-14 08:07:33.000000000 +1000 ++++ lualdap-1.1.0/Makefile 2014-06-05 15:33:23.377297238 +1000 +@@ -20,9 +20,9 @@ + $(CC) -c $(CFLAGS) -o $@ $(COMPAT_DIR)/compat-5.1.c + + install: src/$(LIBNAME) +- mkdir -p $(LUA_LIBDIR) +- cp src/$(LIBNAME) $(LUA_LIBDIR) +- cd $(LUA_LIBDIR); ln -f -s $(LIBNAME) $T.so ++ mkdir -p $(DESTDIR)$(LUA_LIBDIR) ++ cp src/$(LIBNAME) $(DESTDIR)$(LUA_LIBDIR) ++ ln -s $(LIBNAME) $(DESTDIR)$(LUA_LIBDIR)/$T.so + + clean: + rm -f $(OBJS) src/$(LIBNAME) diff --git a/lua-ldap.spec b/lua-ldap.spec new file mode 100644 index 0000000..6b83685 --- /dev/null +++ b/lua-ldap.spec @@ -0,0 +1,107 @@ +%if 0%{?fedora} >= 20 || 0%{?rhel} > 7 +%global luaver 5.2 +%global luacompatver 5.1 +%global luacompatlibdir %{_libdir}/lua/%{luacompatver} +%global luacompatpkgdir %{_datadir}/lua/%{luacompatver} +%global compatbuilddir %{_builddir}/lua51-%{name}-%{version}-%{release} +%else +%global luaver 5.1 +%endif + +%global lualibdir %{_libdir}/lua/%{luaver} +%global luapkgdir %{_datadir}/lua/%{luaver} + +Name: lua-ldap +Version: 1.1.0 +Release: 1%{?dist} +Summary: LDAP client library for Lua, using OpenLDAP +License: MIT +URL: http://www.keplerproject.org/lualdap/ +Source0: http://files.luaforge.net/releases/lualdap/lualdap/LuaLDAP%{version}/lualdap-%{version}.tar.gz +# obey DESTDIR in the Makefile +Patch0: destdir.patch +# fixes for Lua 5.2 compatibility +Patch1: lua52.patch +BuildRequires: lua-devel +BuildRequires: openldap-devel +%if 0%{?fedora} >= 16 || 0%{?rhel} >= 7 +Requires: lua(abi) = %{luaver} +%else +Requires: lua >= %{luaver} +%endif + +%description +LuaLDAP is a simple interface from Lua to an LDAP client. It enables a Lua +program to: +* Connect to an LDAP server; +* Execute any operation (search, add, compare, delete, modify and rename); +* Retrieve entries and references of the search result. + +%if "%{?luacompatver}" +%package compat +Summary: LDAP client library for Lua 5.1, using OpenLDAP +BuildRequires: compat-lua-devel >= %{luacompatver} +%if 0%{?fedora} >= 16 || 0%{?rhel} >= 7 +Requires: lua(abi) = %{luacompatver} +%else +Requires: lua >= %{luacompatver} +%endif + +%description compat +LuaLDAP is a simple interface from Lua to an LDAP client. It enables a Lua 5.1 +program to: +* Connect to an LDAP server; +* Execute any operation (search, add, compare, delete, modify and rename); +* Retrieve entries and references of the search result. +%endif + +%prep +%setup -q -n lualdap-%{version} +%patch0 -p1 +%patch1 -p1 +%if "%{?luacompatver}" +rm -rf %{compatbuilddir} +cp -a . %{compatbuilddir} +%endif + +echo "CFLAGS = $RPM_OPT_FLAGS -fPIC -I%{_includedir} -DLDAP_DEPRECATED" >>config +echo "LUA_VERSION_NUM = $(subst .,,%{luaver})0" >>config +echo "LUA_LIBDIR = %{lualibdir}" >>config + +%if "%{?luacompatver}" +echo "CFLAGS = $RPM_OPT_FLAGS -fPIC -I%{_includedir}/lua-%{luacompatver} -DLDAP_DEPRECATED" >>%{compatbuilddir}/config +echo "LUA_VERSION_NUM = $(subst .,,%{luacompatver})0" >>%{compatbuilddir}/config +echo "LUA_LIBDIR = %{luacompatlibdir}" >>%{compatbuilddir}/config +%endif + +%build +make %{?_smp_mflags} + +%if "%{?luacompatver}" +pushd %{compatbuilddir} +make %{?_smp_mflags} +popd +%endif + +%install +make install DESTDIR=%{buildroot} + +%if "%{?luacompatver}" +pushd %{compatbuilddir} +make install DESTDIR=%{buildroot} +popd +%endif + +%files +%doc README doc/ +%{lualibdir}/lualdap.so* + +%if "%{?luacompatver}" +%files compat +%doc README doc/ +%{luacompatlibdir}/lualdap.so* +%endif + +%changelog +* Thu Jun 05 2014 Dan Callaghan - 1.1.0-1 +- initial version diff --git a/lua52.patch b/lua52.patch new file mode 100644 index 0000000..820ec4b --- /dev/null +++ b/lua52.patch @@ -0,0 +1,34 @@ +diff -ur lualdap-1.1.0.orig/src/lualdap.c lualdap-1.1.0/src/lualdap.c +--- lualdap-1.1.0.orig/src/lualdap.c 2007-12-15 01:11:22.000000000 +1000 ++++ lualdap-1.1.0/src/lualdap.c 2014-06-05 15:34:22.657478715 +1000 +@@ -25,6 +25,12 @@ + #include "compat-5.1.h" + #endif + ++#ifndef luaL_getn ++// Lua 5.1 converted this to a macro, 5.2 dropped it entirely... ++// This is the definition from 5.1 ++#define luaL_getn(L,i) ((int)lua_objlen(L, i)) ++#endif ++ + #ifdef WINLDAPAPI + #define timeval l_timeval + typedef ULONG ldap_int_t; +@@ -872,7 +878,7 @@ + ** Create a metatable. + */ + static int lualdap_createmeta (lua_State *L) { +- const luaL_reg methods[] = { ++ const luaL_Reg methods[] = { + {"close", lualdap_close}, + {"add", lualdap_add}, + {"compare", lualdap_compare}, +@@ -987,7 +993,7 @@ + ** Create ldap table and register the open method. + */ + int luaopen_lualdap (lua_State *L) { +- struct luaL_reg lualdap[] = { ++ struct luaL_Reg lualdap[] = { + {"open_simple", lualdap_open_simple}, + {NULL, NULL}, + }; diff --git a/sources b/sources index e69de29..08ccbba 100644 --- a/sources +++ b/sources @@ -0,0 +1 @@ +5e104520c3f1333f38817a9fa1e76681 lualdap-1.1.0.tar.gz