Blob Blame History Raw
%{!?luaver: %global luaver %(lua -e "print(string.sub(_VERSION, 5))" || echo 0)}
%global lualibdir %{_libdir}/lua/%{luaver}
%global luapkgdir %{_datadir}/lua/%{luaver}

%global luacompatver 5.1
%global luacompatlibdir %{_libdir}/lua/%{luacompatver}
%global luacompatpkgdir %{_datadir}/lua/%{luacompatver}

Name:           lua-cqueues
Version:        20171014
Release:        5%{?dist}
Summary:        Stackable Continuation Queues for the Lua Programming Language

License:        MIT
URL:            https://25thandclement.com/~william/projects/cqueues.html
Source0:        https://25thandclement.com/~william/projects/releases/cqueues-%{version}.tgz

Patch1:         0001-GCC9-compatibility.patch

BuildRequires:  gcc
BuildRequires:  m4
BuildRequires:  make
BuildRequires:  openssl-devel
BuildRequires:  lua
BuildRequires:  lua-devel >= %{luaver}

%if 0%{?fedora} || 0%{?rhel} > 7
BuildRequires:  compat-lua
BuildRequires:  compat-lua-devel
%endif

Requires:       lua(abi) = %{luaver}

%description
cqueues is a type of event loop for Lua. It doesn't use callbacks but instead
you communicate with an event controller by the yielding and resumption of
Lua coroutines using objects.

cqueues are stackable. Each instantiated cqueue is a poll-able object which
can be polled from another cqueue, or another event loop system entirely.
The design is meant to be non-intrusive, composable, and embeddable within
existing applications.

cqueues includes a sockets library with DNS, buffering, end-of-line
translation, SSL/TLS, and descriptor passing support builtin.
Domain querying, connection establishment, and SSL negotiation are handled
transparently as part of a state machine entered with every I/O operation,
so users can read and write immediately upon instantiating the object,
as if opening a regular file.

cqueues also includes modules for handling signals, threads, and file change
notifications using native kernel facilities and accessible through easy
to use interfaces which abstract the different kernel facilities.

%if 0%{?fedora}
%package -n compat-%{name}
Summary:        Stackable Continuation Queues for the Lua Programming Language %{luacompatver}
Provides:       lua-cqueues-compat
Requires:       compat-lua-libs

%description -n compat-%{name}
Compatibility package for Lua %{luacompatver}
%endif

%package doc
Summary:        Documentation for the Stackable Continuation Queues library
BuildArch:      noarch
# Conflicts: {name} != {version} + compat-{name} != {version} would have been better
# but I'm trying to avoid Conflicts
Requires:       %{name} == %{version}

%description doc
Documentation for the Stackable Continuation Queues library
for the Lua Programming Language

%prep
%setup -q -n cqueues-%{version}
%patch1 -p1

%build
%set_build_flags
export CFLAGS="$CFLAGS -fPIC"
make LUA_APIS="%{luaver}" %{?_smp_mflags} prefix=%{_prefix} libdir=%{_libdir}

%if 0%{?fedora}
make LUA_APIS="%{luacompatver}" %{?_smp_mflags} prefix=%{_prefix} libdir=%{_libdir} CFLAGS="$CFLAGS -I%{_includedir}/lua-%{luacompatver}"
%endif

%install
make install LUA_APIS="%{luaver}" DESTDIR=%{buildroot} prefix=%{_prefix} libdir=%{_libdir}

%if 0%{?fedora}
make install LUA_APIS="%{luacompatver}" DESTDIR=%{buildroot} prefix=%{_prefix} libdir=%{_libdir}
%endif

# documentation
mkdir -p %{buildroot}%{_pkgdocdir}
cp -r -t %{buildroot}%{_pkgdocdir} doc/cqueues.pdf examples
sed -i '1 s|^#!/.*$|#!/usr/bin/lua|' %{buildroot}%{_pkgdocdir}/examples/*

#% check
## Lua openssl package is missing
#make check -j1

%files
%{luapkgdir}/*
%{lualibdir}/*
%license LICENSE

%if 0%{?fedora}
%files -n compat-%{name}
%{luacompatpkgdir}/*
%{luacompatlibdir}/*
%license LICENSE
%endif

%files doc
# force examples to be non-executable to avoid potential mess in autogenerated deps
%defattr(644,root,root,755)
%doc %{_pkgdocdir}/*
%license LICENSE

%changelog
* Wed Apr 10 2019 Tomas Krizek <tomas.krizek@nic.cz> - 20171014-5
- Re-add compat-lua-devel needed for 5.1 build

* Thu Apr 04 2019 Tomas Krizek <tomas.krizek@nic.cz> - 20171014-4
- Compatibility patch for GCC 9, fixes BZ#1675333
- Clean up BuildRequires/Requires

* Thu Apr 04 2019 Tomas Krizek <tomas.krizek@nic.cz> - 20171014-3
- Change compat package name to compat-lua-cqueues

* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 20171014-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Fri Jan 11 2019 Petr Špaček <petr.spacek@nic.cz> - 20171014-1
- Rebuild for released Fedora/CentOS versions (fedpkg update was missing)

* Thu Sep 13 2018 Petr Špaček <petr.spacek@nic.cz> - 20171014-0
- Initial package for Fedora 28+ and EPEL 7