Blob Blame History Raw
%define luaver 5.2
%define lualibdir %{_libdir}/lua/%{luaver}
%define luapkgdir %{_datadir}/lua/%{luaver}
%define luacompatver 5.1
%define luacompatlibdir %{_libdir}/lua/%{luacompatver}
%define luacompatpkgdir %{_datadir}/lua/%{luacompatver}
%define lua51dir %{_builddir}/lua51-%{name}-%{version}-%{release}

%define real_name luadbi

Name:           lua-dbi
Version:        0.5
Release:        9%{?dist}
Summary:        Database interface library for Lua

Group:          Development/Libraries
License:        MIT
URL:             http://code.google.com/p/%{real_name}
Source0:        http://%{real_name}.googlecode.com/files/%{real_name}.%{version}.tar.gz
Patch0:         %{name}-RH-build.patch
Patch1:         %{name}-RH-build52.patch
Patch2:         %{name}-0.5-pgsql_transaction.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildRequires:  lua-devel, mysql-devel, sqlite-devel, postgresql-devel
%if 0%{?fedora} >= 16 || 0%{?rhel} >= 7
Requires: lua(abi) = %{luaver}
%else
Requires: lua >= %{luaver}
%endif

%if 0%{?fedora} >= 20
BuildRequires:  compat-lua >= %{luacompatver}, compat-lua-devel >= %{luacompatver}
%endif


%description
LuaDBI is a database interface library for Lua. It is designed to provide a
RDBMS agnostic API for handling database operations. LuaDBI also provides
support for prepared statement handles, placeholders and bind parameters for all
database operations.

Currently LuaDBI supports DB2, Oracle, MySQL, PostgreSQL and SQLite databases
with native database drivers.

%if 0%{?fedora} >= 20
%package compat
Summary:        Database interface library for Lua 5.1
Group:          Development/Libraries

%description compat
LuaDBI is a database interface library for Lua 5.1. It is designed to provide a
RDBMS agnostic API for handling database operations. LuaDBI also provides
support for prepared statement handles, placeholders and bind parameters for all
database operations.

Currently LuaDBI supports DB2, Oracle, MySQL, PostgreSQL and SQLite databases
with native database drivers.
%endif

%prep
%setup -q -c
%patch2 -p1 -b .pgsql_transaction
find . -name \*.[ch] -print -exec chmod -x '{}' \;

%if 0%{?fedora} >= 20
rm -rf %{lua51dir}
cp -a . %{lua51dir}
pushd %{lua51dir}
%patch0 -p1 -b .RH-build
popd
%endif

%patch1 -p1 -b .RH-build52

%build
export CFLAGS="$RPM_OPT_FLAGS -fPIC"
make %{?_smp_mflags} LIBDIR="%{_libdir}"

%if 0%{?fedora} >= 20
pushd %{lua51dir}
export CFLAGS="$RPM_OPT_FLAGS -fPIC"
make %{?_smp_mflags} LIBDIR="%{_libdir}"
popd
%endif

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{luapkgdir}
mkdir -p $RPM_BUILD_ROOT%{lualibdir}

cp -p *.so $RPM_BUILD_ROOT%{lualibdir}
cp -p *.lua $RPM_BUILD_ROOT%{luapkgdir}
%if 0%{?fedora} >= 20
pushd %{lua51dir}
mkdir -p $RPM_BUILD_ROOT%{luacompatpkgdir}
mkdir -p $RPM_BUILD_ROOT%{luacompatlibdir}

cp -p *.so $RPM_BUILD_ROOT%{luacompatlibdir}
cp -p *.lua $RPM_BUILD_ROOT%{luacompatpkgdir}
popd
%endif


%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root,-)
%doc README COPYING
%{lualibdir}/*.so
%{luapkgdir}/*.lua

%if 0%{?fedora} >= 20
%files compat
%defattr(-,root,root,-)
%doc README COPYING
%{luacompatlibdir}/*.so
%{luacompatpkgdir}/*.lua
%endif


%changelog
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.5-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Thu May 22 2014 Jan Kaluza <jkaluza@redhat.com> - 0.5-8
- build -compat subpackage against compat-lua

* Sat Aug 03 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.5-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild

* Fri May 10 2013 Tom Callaway <spot@fedoraproject.org> - 0.5-6
- rebuild for lua 5.2

* Fri Apr 26 2013 Robert Scheck <robert@fedoraproject.org> - 0.5-5
- Added upstream patch to avoid PostgreSQL transaction warnings

* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.5-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild

* Thu Jul 19 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.5-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

* Sat Jun 23 2012 Matej Cepl <mcepl@redhat.com> - 0.5-2
- Couple of fixes to satisfy packaging review.

* Mon May 23 2011 Matěj Cepl <mcepl@redhat.com> - 0.5-1
- Initial packaging