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:        1%{?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

BuildRequires:  lua-devel >= %{luaver}
%if 0%{?fedora}
Requires:       lua(abi) = %{luaver}
%else
Requires:       lua >= %{luaver}
%endif

%if 0%{?fedora}
BuildRequires:  compat-lua >= %{luacompatver}, compat-lua-devel >= %{luacompatver}
%endif
BuildRequires:  gcc, m4, make, openssl-devel

%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 compat
Summary:        Stackable Continuation Queues for the Lua Programming Language %{luacompatver}
# owner of /usr/lib64/lua/5.1, for some reason this depedency is not auto-generated
Requires:       compat-lua-libs

%description compat
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}
# owner of /usr/share/doc
Requires:       filesystem

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

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

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

%if 0%{?fedora}
make LUA_APIS="%{luacompatver}" %{?_smp_mflags} prefix=%{_prefix} libdir=%{_libdir} CFLAGS="-I%{_includedir}/lua-%{luacompatver} %{optflags} -fPIC"
%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 compat
%{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
* 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