Blob Blame History Raw
%bcond_without test

%ifarch %{arm} %{ix86} x86_64 %{mips} aarch64
%bcond_without luajit
%else
%bcond_with luajit
%endif

%global lua_incdir %{_includedir}/lua-%{lua_version}
%global lua_builddir obj-lua%{lua_version}

%global lua_51_version 5.1
%global lua_51_incdir %{_includedir}/lua-%{lua_51_version}
%global lua_51_libdir %{_libdir}/lua/%{lua_51_version}
%global lua_51_pkgdir %{_datadir}/lua/%{lua_51_version}
%global lua_51_builddir obj-lua%{lua_51_version}

%global luajit_version 2.1
%global luajit_incdir %{_includedir}/luajit-%{luajit_version}
%global luajit_libdir %{_libdir}/luajit/%{luajit_version}
%global luajit_builddir obj-luajit

%global real_version 1.42.0
%global extra_version 1

%if 0%{?rhel} && 0%{?rhel} < 9
# EPEL8's cmake macros have _vpath_builddir defined
# ... but its cmake does not support -B
# see https://fedoraproject.org/wiki/Changes/CMake_to_do_out-of-source_builds
%global _vpath_builddir .
%endif

BuildRequires:  cmake
BuildRequires:  gcc
BuildRequires:  libuv-devel >= 1.42.0
BuildRequires:  lua-devel
BuildRequires:  compat-lua >= %{lua_51_version}
BuildRequires:  compat-lua-devel >= %{lua_51_version}
%if %{with luajit}
BuildRequires:  luajit-devel
# /with luajit
%endif
BuildRequires:  lua5.1-compat53

Name:           lua-luv
Version:        %{real_version}.%{extra_version}
Release:        3%{?dist}

License:        ASL 2.0
Summary:        Bare libuv bindings for lua
Url:            https://github.com/luvit/luv

%if 0%{?fedora} < 33 && 0%{?rhel} < 9
Requires:       lua(abi) = %{lua_version}
%endif

Source0:        https://github.com/luvit/luv/archive/%{real_version}-%{extra_version}/luv-%{version}.tar.gz

Patch100:       lua-luv-disable-udp-test.patch

%description
This library makes libuv available to lua scripts. It was made
for the luvit project but should usable from nearly any lua
project.

The library can be used by multiple threads at once. Each thread
is assumed to load the library from a different lua_State. Luv
will create a unique uv_loop_t for each state. You can't share uv
handles between states/loops.

The best docs currently are the libuv docs themselves. Hopefully
soon we'll have a copy locally tailored for lua.

%package devel
Summary:        Development files for lua-luv
Requires:       lua-luv%{?_isa} = %{version}-%{release}

%description devel
Files required for lua-luv development

%package -n lua5.1-luv
Summary:        Bare libuv bindings for lua 5.1
Requires:       lua(abi) = %{lua_51_version}

%description -n lua5.1-luv
This library makes libuv available to lua scripts. It was made
for the luvit project but should usable from nearly any lua
project.

The library can be used by multiple threads at once. Each thread
is assumed to load the library from a different lua_State. Luv
will create a unique uv_loop_t for each state. You can't share uv
handles between states/loops.

The best docs currently are the libuv docs themselves. Hopefully
soon we'll have a copy locally tailored for lua.

%package -n lua5.1-luv-devel
Summary:        Development files for lua5.1-luv
Requires:       lua5.1-luv%{?_isa} = %{version}-%{release}

%description -n lua5.1-luv-devel
Files required for lua5.1-luv development

%if %{with luajit}
%package -n luajit%{luajit_version}-luv
Summary:        Bare libuv bindings for lua 5.1
Requires:       lua(abi) = %{lua_51_version}

%description -n luajit%{luajit_version}-luv
This library makes libuv available to lua scripts. It was made
for the luvit project but should usable from nearly any lua
project.

The library can be used by multiple threads at once. Each thread
is assumed to load the library from a different lua_State. Luv
will create a unique uv_loop_t for each state. You can't share uv
handles between states/loops.

The best docs currently are the libuv docs themselves. Hopefully
soon we'll have a copy locally tailored for lua.

%package -n luajit%{luajit_version}-luv-devel
Summary:        Development files for luajit%{luajit_version}-luv
Requires:       luajit%{luajit_version}-luv%{?_isa} = %{version}-%{release}

%description -n luajit%{luajit_version}-luv-devel
Files required for luajit%{luajit_version}-luv development
# /with luajit
%endif

%prep
%setup -n luv-%{real_version}-%{extra_version}

%patch100 -p1

# Remove bundled dependencies
rm -rf deps

# Remove network sensitive tests gh#luvit/luv#340
rm -f tests/test-dns.lua

%build
# lua
mkdir %{lua_builddir}

pushd %{lua_builddir}
%cmake -S .. \
    -DWITH_SHARED_LIBUV=ON \
    -DBUILD_MODULE=ON \
    -DBUILD_SHARED_LIBS=ON \
    -DWITH_LUA_ENGINE=Lua \
    -DLUA_BUILD_TYPE=System \
    -DINSTALL_LIB_DIR=%{_libdir} \
    -DLUA_INCLUDE_DIR=%{lua_incdir}

%cmake_build
popd

# lua-compat
mkdir %{lua_51_builddir}

pushd %{lua_51_builddir}
%cmake -S .. \
    -DWITH_SHARED_LIBUV=ON \
    -DBUILD_MODULE=ON \
    -DBUILD_SHARED_LIBS=ON \
    -DWITH_LUA_ENGINE=Lua \
    -DLUA_BUILD_TYPE=System \
    -DINSTALL_LIB_DIR=%{_libdir} \
    -DLUA_COMPAT53_DIR=%{lua_51_incdir} \
    -DLUA_INCLUDE_DIR=%{lua_51_incdir} \
    -DLUA_LIBRARY=%{_libdir}/liblua-%{lua_51_version}.so

%cmake_build
popd

%if %{with luajit}
# luajit
mkdir %{luajit_builddir}

pushd %{luajit_builddir}
%cmake -S .. \
    -DWITH_SHARED_LIBUV=ON \
    -DBUILD_MODULE=ON \
    -DBUILD_SHARED_LIBS=ON \
    -DWITH_LUA_ENGINE=LuaJit \
    -DLUA_BUILD_TYPE=System \
    -DINSTALL_LIB_DIR=%{_libdir} \
    -DLUA_COMPAT53_DIR=%{lua_51_incdir}

%cmake_build
popd
# /with luajit
%endif

%install
# lua
install -d -m 0755 %{buildroot}%{lua_libdir}
install -m 0755 -p %{lua_builddir}/%{_vpath_builddir}/luv.so %{buildroot}%{lua_libdir}/luv.so

install -d -m 0755 %{buildroot}%{lua_incdir}/luv
for f in lhandle.h lreq.h luv.h util.h; do
    install -m 0644 -p src/$f %{buildroot}%{lua_incdir}/luv/$f
done

# lua-5.1
install -d -m 0755 %{buildroot}%{lua_51_libdir}
install -m 0755 -p %{lua_51_builddir}/%{_vpath_builddir}/luv.so %{buildroot}%{lua_51_libdir}/luv.so

install -d -m 0755 %{buildroot}%{lua_51_incdir}/luv
for f in lhandle.h lreq.h luv.h util.h; do
    install -m 0644 -p src/$f %{buildroot}%{lua_51_incdir}/luv/$f
done

%if %{with luajit}
# luajit
install -d -m 0755 %{buildroot}%{luajit_libdir}
install -m 0755 -p %{luajit_builddir}/%{_vpath_builddir}/luv.so %{buildroot}%{luajit_libdir}/luv.so

install -d -m 0755 %{buildroot}%{luajit_incdir}/luv
for f in lhandle.h lreq.h luv.h util.h; do
    install -m 0644 -p src/$f %{buildroot}%{luajit_incdir}/luv/$f
done
# /with luajit
%endif

%if %{with test}
%check
# lua-5.1
ln -sf %{lua_51_builddir}/%{_vpath_builddir}/luv.so luv.so
lua-5.1 tests/run.lua
rm luv.so
# lua
ln -sf %{lua_builddir}/%{_vpath_builddir}/luv.so luv.so
lua tests/run.lua
rm luv.so

%if %{with luajit}
# luajit
ln -sf %{luajit_builddir}/%{_vpath_builddir}/luv.so luv.so
%if 0%{?el8}
%ifarch aarch64
# luajit test consistently failing with:
# ok 105 udp - udp recvmmsg
# PANIC: unprotected error in call to Lua API (bad light userdata pointer)
# /var/tmp/rpm-tmp.8I3N1v: line 45:   553 Aborted                 (core dumped) luajit tests/run.lua
rm tests/test-work.lua
%endif
%endif
luajit tests/run.lua
rm luv.so
# /with luajit
%endif

# /with test
%endif

%files
%doc README.md
%license LICENSE.txt
%{lua_libdir}/luv.so

%files devel
%dir %{lua_incdir}
%dir %{lua_incdir}/luv/
%{lua_incdir}/luv/lhandle.h
%{lua_incdir}/luv/lreq.h
%{lua_incdir}/luv/luv.h
%{lua_incdir}/luv/util.h

%files -n lua5.1-luv
%doc README.md
%license LICENSE.txt
%{lua_51_libdir}/luv.so

%files -n lua5.1-luv-devel
%dir %{lua_51_incdir}
%dir %{lua_51_incdir}/luv/
%{lua_51_incdir}/luv/lhandle.h
%{lua_51_incdir}/luv/lreq.h
%{lua_51_incdir}/luv/luv.h
%{lua_51_incdir}/luv/util.h

%if %{with luajit}
%files -n luajit%{luajit_version}-luv
%doc README.md
%license LICENSE.txt
%{luajit_libdir}/luv.so

%files -n luajit%{luajit_version}-luv-devel
%dir %{luajit_incdir}
%dir %{luajit_incdir}/luv/
%{luajit_incdir}/luv/lhandle.h
%{luajit_incdir}/luv/lreq.h
%{luajit_incdir}/luv/luv.h
%{luajit_incdir}/luv/util.h
# /with luajit
%endif

%changelog
* Fri Mar 11 2022 Michel Alexandre Salim <salimma@fedoraproject.org> - 1.42.0.1-3
- Adjust for cmake 3.23.0, where -S (passed by %%cmake) overrides the positional argument
- Disable UDP multicast tests unconditionally, seems flaky
- Disable luajit threadpool tests on EPEL 8 aarch64

* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.42.0.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Thu Sep 23 2021 Andreas Schneider <asn@redhat.com> - 1.42.0.0-1
- Update to version 1.42.0.1
  * https://github.com/luvit/luv/releases/tag/1.42.0-1
  * https://github.com/luvit/luv/releases/tag/1.42.0-0
- Do not build luajit on s390x and ppc64

* Fri Jul 23 2021 Andreas Schneider <asn@redhat.com> - 1.41.1.0-3
- Build a luajit2.1 flavor

* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.41.1.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Mon Jul 19 2021 Andreas Schneider <asn@redhat.com> - 1.41.1.0-1
- Update to version 1.41.1
  * https://github.com/luvit/luv/releases/tag/1.41.1-0

* Mon Jul 12 2021 Michel Alexandre Salim <salimma@fedoraproject.org> - 1.41.0.0-3
- use macros from lua-{s,}rpm-macros; spec now portable across Lua versions
- reenable s390x build on epel8 (#1829151)

* Sat Jul 03 2021 Andreas Schneider <asn@redhat.com> - 1.41.0.0-2
- Fixed tests with lua >= 5.4.3

* Mon Apr 19 2021 Andreas Schneider <asn@redhat.com> - 1.41.0.0-1
- Update to version 1.41.0
  * https://github.com/luvit/luv/releases/tag/1.41.0-0
  * https://github.com/luvit/luv/releases/tag/1.40.0-0

* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.36.0.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.36.0.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Tue Jun 30 2020 Tom Callaway <spot@fedoraproject.org> - 1.36.0.0-3
- fix for lua 5.4
- adjust logic for new cmake weirdness (f33+)

* Tue Jun 30 2020 Björn Esser <besser82@fedoraproject.org> - 1.36.0.0-2
- Rebuilt for Lua 5.4

* Tue Apr 28 2020 Michel Alexandre Salim <salimma@fedoraproject.org> - 1.36.0.0-1
- Update to version 1.36.0-0
- Support building on EPEL 8

* Sat Feb 29 2020 Andreas Schneider <asn@redhat.com> - 1.34.2.1-1
-  Update to version 1.34.2-1
  - https://github.com/luvit/luv/releases/tag/1.34.2-0
  - https://github.com/luvit/luv/releases/tag/1.34.2-1

* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.34.1.1-1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Tue Jan 21 2020 Andreas Schneider <asn@redhat.com> - 1.34.1.1-0
- Update to version 1.34.1-1

* Tue Oct 29 2019 Andreas Schneider <asn@redhat.com> - 1.32.0.0-0
- Update to version 1.32.0-0

* Tue Oct 01 2019 Andreas Schneider <asn@redhat.com> - 1.30.1.1-5
- Fixed versioning

* Tue Oct 01 2019 Andreas Schneider <asn@redhat.com> - 1.30.1-4.1
- Update to version 1.30.1-1
- Removed luv-1.30-include_lua_header.patch
- Added missing Requires for devel packages
- Fixed source URL
- Fixed license
- Preserved timestamps

* Mon Sep 30 2019 Andreas Schneider <asn@redhat.com> - 1.30.1-3
- Fixed BR for lua 5.3

* Mon Sep 30 2019 Andreas Schneider <asn@redhat.com> - 1.30.1-2
- Added BR for gcc
- Renamed lua globals

* Tue Sep 24 2019 Andreas Schneider <asn@redhat.com> - 1.30.1-1
- Initial version 1.30.1-0