File minetest.spec of Package minetest
#
# spec file for package minetest
#
# Copyright (c) 2016 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 http://bugs.opensuse.org/
#
%define minetestuser %{name}
%define minetestgroup %{name}
%if 0%{?is_opensuse}
%if 0%{?suse_version} >= 1315
%bcond_without leveldb
%else
%bcond_with leveldb
%endif
%bcond_without redis
%else
%bcond_with redis
%bcond_with leveldb
%endif
Name: minetest
Version: 0.4.15
Release: 0
Summary: A InfiniMiner/Minecraft inspired game
License: LGPL-2.1+ and CC-BY-SA-3.0
Group: Amusements/Games/3D/Simulation
Url: http://minetest.net/
Source: https://github.com/minetest/%{name}/archive/%{version}/%{name}-%{version}.tar.gz
Source1: minetest-rpmlintrc
Source2: minetest@.service
# PATCH-FEATURE-OPENSUSE shared_mods.patch -- Search also /usr/share/minetest for mods
Patch0: shared_mods.patch
# PATCH-FIX-FEDORA https://github.com/minetest/minetest/issues/4483
Patch1: use-pkg-config-to-find-luajit.patch
BuildRequires: cmake
BuildRequires: desktop-file-utils
BuildRequires: doxygen
BuildRequires: fdupes
BuildRequires: gcc-c++
BuildRequires: gettext-tools
BuildRequires: gmp-devel
BuildRequires: google-droid-fonts
BuildRequires: hicolor-icon-theme
BuildRequires: irrlicht-devel
BuildRequires: liberation-fonts
BuildRequires: libjpeg-devel
BuildRequires: ncurses-devel
BuildRequires: pkg-config
BuildRequires: systemd-rpm-macros
BuildRequires: update-desktop-files
BuildRequires: pkgconfig(bzip2)
BuildRequires: pkgconfig(freetype2)
BuildRequires: pkgconfig(gl)
BuildRequires: pkgconfig(jsoncpp)
BuildRequires: pkgconfig(libcurl)
BuildRequires: pkgconfig(libpng12)
BuildRequires: pkgconfig(luajit)
BuildRequires: pkgconfig(openal)
BuildRequires: pkgconfig(sqlite3)
BuildRequires: pkgconfig(vorbis)
BuildRequires: pkgconfig(x11)
BuildRequires: pkgconfig(zlib)
%if %{with leveldb}
BuildRequires: leveldb-devel
%endif
%if %{with redis}
%if 0%{?suse_version} > 1320
BuildRequires: pkg-config
BuildRequires: pkgconfig(hiredis)
%else
# workarund a bug in hiredis dependencies
BuildRequires: hiredis-devel
%if 0%{?suse_version} <= 1310 || 0%{?suse_version} == 1320
BuildRequires: libhiredis0_10
%endif
%endif
%endif
Requires: %{name}-data = %{version}
Requires: opengl-games-utils
Requires(pre): /usr/sbin/groupadd
Requires(pre): /usr/sbin/useradd
Recommends: %{name}-lang
Recommends: minetest-game
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
An infinite-world block sandbox game and a game engine, inspired by InfiniMiner, Minecraft and the like.
%package -n %{name}server
Summary: Minetest server
License: LGPL-2.1+
Group: Amusements/Games/3D/Simulation
Requires: %{name}-data = %{version}
%{?systemd_requires}
%description -n %{name}server
An infinite-world block sandbox game and a game engine, inspired by InfiniMiner, Minecraft and the like.
This package contains a minetest server.
%package data
Summary: Minetest shared data
License: LGPL-2.1+ and CC-BY-SA-3.0
Group: Amusements/Games/3D/Simulation
Requires: google-droid-fonts
Requires: liberation-fonts
BuildArch: noarch
%description data
An infinite-world block sandbox game and a game engine, inspired by InfiniMiner, Minecraft and the like.
This package contains data for %{name} and %{name}server.
%lang_package
%prep
%setup -q
%patch0 -p1
%patch1 -p1
# purge bundled jsoncpp and lua
rm -rf src/json src/lua src/gmp
%build
%cmake \
-DCUSTOM_DOCDIR="%{_docdir}/%{name}" \
-DCUSTOM_LOCALEDIR="%{_datadir}/locale" \
-DCUSTOM_SHAREDIR="%{_datadir}/%{name}" \
-DBUILD_SERVER=ON \
-DRUN_IN_PLACE=OFF \
-DENABLE_GETTEXT=ON \
-DENABLE_FREETYPE=ON \
-DENABLE_SYSTEM_JSONCPP=ON \
%if %{with leveldb}
-DENABLE_LEVELDB=ON \
%else
-DENABLE_LEVELDB=OFF \
%endif
%if %{with redis}
-DENABLE_REDIS=ON
%else
-DENABLE_REDIS=OFF
%endif
make %{?_smp_mflags} VERBOSE=1
%install
%cmake_install
# Install wrapper and desktop file
desktop-file-install --dir=%{buildroot}%{_datadir}/applications misc/%{name}.desktop
ln -s opengl-game-wrapper.sh %{buildroot}%{_bindir}/%{name}-wrapper
sed -i 's/Exec=%{name}/Exec=%{name}-wrapper/' %{buildroot}%{_datadir}/applications/%{name}.desktop
%suse_update_desktop_file -r %{name} Game Simulation
# Replace fonts with symlinks (we use the system ones)
rm %{buildroot}%{_datadir}/%{name}/fonts/DroidSansFallbackFull.ttf
ln -s %{_datadir}/fonts/truetype/DroidSansFallbackFull.ttf %{buildroot}%{_datadir}/%{name}/fonts/DroidSansFallbackFull.ttf
rm %{buildroot}%{_datadir}/%{name}/fonts/liberationsans.ttf
rm %{buildroot}%{_datadir}/%{name}/fonts/liberationmono.ttf
ln -s %{_datadir}/fonts/truetype/LiberationSans-Regular.ttf %{buildroot}%{_datadir}/%{name}/fonts/liberationsans.ttf
ln -s %{_datadir}/fonts/truetype/LiberationMono-Regular.ttf %{buildroot}%{_datadir}/%{name}/fonts/liberationmono.ttf
# Clean up
rm -rf %{buildroot}%{_datadir}/minetest/client/serverlist/.gitignore
%fdupes %{buildroot}%{_datadir}
install -m 0644 -D %{SOURCE2} %{buildroot}%{_unitdir}/%{name}@.service
install -m 0644 -D minetest.conf.example %{buildroot}%{_sysconfdir}/%{name}/minetest.conf.example
install -d -m 755 %{buildroot}%{_localstatedir}/lib/%{name}
%find_lang %{name}
%post
desktop-file-validate %{_datadir}/applications/%{name}.desktop
%desktop_database_post
%icon_theme_cache_post
%postun
%desktop_database_postun
%icon_theme_cache_postun
%pre -n %{name}server
getent group %{name} >/dev/null || %{_sbindir}/groupadd -r %{minetestgroup}
getent passwd %{name} >/dev/null || %{_sbindir}/useradd -r -g %{minetestgroup} -d %{_localstatedir}/lib/%{name} -s /sbin/nologin -c "user for %{name}server" %{minetestuser}
%service_add_pre %{name}@.service
%post -n %{name}server
%service_add_post %{name}@.service
%preun -n %{name}server
%service_del_preun %{name}@.service
%postun -n %{name}server
%service_del_postun %{name}@.service
%files lang -f %{name}.lang
%defattr(-,root,root,-)
%files
%defattr(-,root,root,-)
%{_bindir}/%{name}
%{_bindir}/%{name}-wrapper
%dir %{_datadir}/appdata/
%{_datadir}/appdata/%{name}.appdata.xml
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/scalable/apps/%{name}.svg
%{_datadir}/icons/hicolor/128x128/apps/minetest.png
%{_mandir}/man6/%{name}.6*
%files -n %{name}server
%defattr(-,root,root,-)
%{_bindir}/%{name}server
%attr(0755,%{minetestuser},%{minetestgroup}) %{_localstatedir}/lib/%{name}/
%{_mandir}/man6/%{name}server.6*
%dir %{_sysconfdir}/%{name}
%config %{_sysconfdir}/%{name}/minetest.conf.example
%{_unitdir}/%{name}@.service
%files data
%defattr(-,root,root,-)
%{_datadir}/%{name}/
%doc %{_docdir}/%{name}/
%changelog