File prosody.spec of Package prosody

# spec file for package prosody
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

%define _piddir /run
Name:           prosody
Version:        0.10.3
Release:        0
Summary:        Communications server for Jabber/XMPP
License:        MIT
Group:          Productivity/Networking/Other
Source3:        %{name}.keyring
Source4:        %{name}.service
Source5:        prosody.tmpfile
# Make prosody work on systems that have lua 5.1 AND 5.2 installed
Patch0:         prosody-lua51coexist.patch
Patch1:         prosody-configure.patch
Patch2:         prosody-makefile.patch
# PATCH-FIX-OPENSUSE - enable Unix features
Patch3:         prosody-cfg.patch
BuildRequires:  libidn-devel
BuildRequires:  libopenssl-devel
BuildRequires:  lua51-devel
Requires:       lua51
Requires:       lua51-BitOp
Requires:       lua51-luaexpat
Requires:       lua51-luafilesystem
Requires:       lua51-luasec
Requires:       lua51-luasocket
Requires(pre):  permissions
Requires(pre):  pwdutils
Recommends:     lua51-luadbi
Recommends:     lua51-luaevent
Recommends:     lua51-zlib
BuildRequires:  systemd-rpm-macros

Prosody is a communications server for Jabber/XMPP written in Lua.

Prosody can link up with other Prosody installations and other
XMPP-compatible services to form an open communication network,
whilst allowing control over who they connect to, and who they share
data with.

%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1

sed -i 's|@@LIBDIR@@|%{_libdir}|g;s|@@INCLUDEDIR@@|%{_includedir}|g;' configure
sed -i 's|@@LIBDIR@@|%{_libdir}|g;s|@@INCLUDEDIR@@|%{_includedir}|g;' Makefile
sed -i 's|@@PIDDIR@@|%{_piddir}|g;' prosody.cfg.lua.dist

# CFLAGS need to keep -fPIC for shared modules
./configure \
    --lua-suffix="5.1" \
    --with-lua-include=%{lua_incdir} \
    --cflags="%{optflags} -fPIC" \

make %{?_smp_mflags}


install -D -m 0644 %{SOURCE4} %{buildroot}%{_unitdir}/%{name}.service
# tmpfiles.d
install -D -m 0644 %{SOURCE5} %{buildroot}%{_tmpfilesdir}/%{name}.conf
mkdir -p %{buildroot}%{_sbindir}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcprosody

# mkdir read/write by prosody
mkdir -p %{buildroot}%{_piddir}/prosody
mkdir -p %{buildroot}%{_localstatedir}/log/prosody

# clean up for rpmlint
chmod 644 %{buildroot}/%{_libdir}/prosody/prosody.version
chmod -R g+rX,o= %{buildroot}%{_sysconfdir}/prosody

getent group %{name} > /dev/null || groupadd -r %{name}
getent passwd %{name} > /dev/null || useradd -r -g %{name} -d %{_localstatedir}/lib/%{name} -s/sbin/nologin -c "user for %{name}" %{name}
%service_add_pre %{name}.service

%service_add_post %{name}.service
systemd-tmpfiles --create %{_tmpfilesdir}/%{name}.conf ||:

%service_del_preun %{name}.service

%service_del_postun %{name}.service

%config %attr(-,root,prosody) %{_sysconfdir}/prosody/
%dir %{_libdir}/prosody
%dir %attr(-,prosody,prosody) %{_localstatedir}/lib/prosody
%dir %attr(-,prosody,prosody) %{_localstatedir}/log/prosody
%dir %attr(0755,prosody,prosody) %ghost %{_piddir}/prosody