Blob Blame History Raw
%if 0%{?fedora} >= 22
%define luaver 5.3
%else
%if 0%{?fedora} >= 20 || 0%{?rhel} > 7
%define luaver 5.2
%else
%define luaver 5.1
%endif
%endif

%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:        19%{?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:         lua-dbi-0.5-sync-hg-47382fea7a9c.patch
Patch3:         lua-dbi-0.5-pgsql-include-flags.patch

BuildRequires:  lua-devel, sqlite-devel, postgresql-devel
%if 0%{?fedora} >= 28 || 0%{?rhel} >= 8
BuildRequires:  mariadb-connector-c-devel
%else
BuildRequires:  mysql-devel
%endif
%if 0%{?fedora} >= 16 || 0%{?rhel} >= 7
Requires:       lua(abi) = %{luaver}
%else
Requires:       lua >= %{luaver}
%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
BuildRequires:  compat-lua >= %{luacompatver}, compat-lua-devel >= %{luacompatver}

%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 .47382fea7a9c
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
%patch3 -p1 -b .pgsqlflags

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

%if 0%{?fedora} >= 20
pushd %{lua51dir}
export CFLAGS="$RPM_OPT_FLAGS -fPIC -DLUA_COMPAT_APIINTCASTS"
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
%{!?_licensedir:%global license %%doc}
%license COPYING
%doc README
%{lualibdir}/*.so
%{luapkgdir}/*.lua

%if 0%{?fedora} >= 20
%files compat
%{!?_licensedir:%global license %%doc}
%license COPYING
%doc README 
%{luacompatlibdir}/*.so
%{luacompatpkgdir}/*.lua
%endif


%changelog
* Thu Feb 08 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.5-19
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Thu Sep 21 2017 Robert Scheck <robert@fedoraproject.org> 0.5-18
- Build against mariadb-connector-c-devel rather mysql-devel for
  Fedora >= 28 (#1493634, thanks to Michal Schorm)

* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.5-17
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild

* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.5-16
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.5-15
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.5-14
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Sun Jun 21 2015 Robert Scheck <robert@fedoraproject.org> 0.5-13
- Really build -compat subpackage against compat-lua (#1232688)

* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.5-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Thu Jan 15 2015 Tom Callaway <spot@fedoraproject.org> - 0.5-11
- add all new upstream fixes
- rebuild for lua 5.3
- fix compile against modern pgsql

* Sun Aug 17 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.5-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild

* 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