File minetest.spec of Package minetest

# spec file for package minetest
# Copyright (c) 2023 SUSE LLC
# 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 minetestuser %{name}
%define minetestgroup %{name}
%define irrlichtmt_version 1.9.0mt10
%bcond_without leveldb
%bcond_without redis
%bcond_without postgresql
Name:           minetest
Version:        5.7.0
Release:        0
Summary:        A InfiniMiner/Minecraft inspired game
License:        CC-BY-SA-3.0 AND LGPL-2.1-or-later
Group:          Amusements/Games/3D/Simulation
Source1:        minetest-rpmlintrc
Source2:        minetest@.service
# PATCH-FIX-UPSTREAM - minetest-fix-luajit-include-path.diff -- Fixes the FindLuaJIT CMake module so it also looks for moonjit’s include path
Patch0:         minetest-fix-luajit-include-path.patch
# PATCH-FIX-OPENSUSE old-desktopfile-standard.patch -- build without 'PrefersNonDefaultGPU' option in desktopfile on Leap 15.3 and below
Patch1:         old-desktopfile-standard.patch
BuildRequires:  cmake
BuildRequires:  doxygen
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  gettext-tools
BuildRequires:  gmp-devel
BuildRequires:  google-arimo-fonts
BuildRequires:  google-cousine-fonts
BuildRequires:  google-droid-fonts
BuildRequires:  hicolor-icon-theme
BuildRequires:  irrlicht-devel
BuildRequires:  libXxf86vm-devel
BuildRequires:  libjpeg-devel
BuildRequires:  libzstd-devel
BuildRequires:  ncurses-devel
# Needed for symlink checking
BuildRequires:  opengl-games-utils
BuildRequires:  pkgconfig
BuildRequires:  spatialindex-devel
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(libpng)
BuildRequires:  pkgconfig(luajit)
BuildRequires:  pkgconfig(openal)
BuildRequires:  pkgconfig(sqlite3)
BuildRequires:  pkgconfig(vorbis)
BuildRequires:  pkgconfig(x11)
BuildRequires:  pkgconfig(xi)
BuildRequires:  pkgconfig(zlib)
%if 0%{?sle_version} > 0 && 0%{?sle_version} <= 150400
BuildRequires:  desktop-file-utils
BuildRequires:  desktop-file-utils >= 0.25
%if %{with leveldb}
BuildRequires:  leveldb-devel
%if %{with redis}
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(hiredis)
%if %{with postgresql}
BuildRequires:  postgresql-devel
# Workaround for CMake's FindPostgreSQL.cmake depending on internal
# server headers even if just building a client application.
BuildRequires:  postgresql-server-devel
Requires:       %{name}-data = %{version}
Requires:       opengl-games-utils
Recommends:     %{name}-lang
Recommends:     minetest-game
Provides:       minetest-runtime = %{version}
Provides:       bundled(irrlicht) = %{irrlichtmt_version}

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-or-later
Group:          Amusements/Games/3D/Simulation
Requires:       %{name}-data = %{version}
Requires(pre):  shadow
Recommends:     minetest-game
Provides:       minetest-runtime = %{version}

%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:        CC-BY-SA-3.0 AND LGPL-2.1-or-later
Group:          Amusements/Games/3D/Simulation
Requires:       google-arimo-fonts
Requires:       google-cousine-fonts
Requires:       google-droid-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 minetest and minetestserver.

%setup -q
%if 0%{?sle_version} > 0 && 0%{?sle_version} <= 150400
%patch0 -p1
%patch1 -p1

cd lib
tar -xzf %{SOURCE3}
mv irrlicht-%{irrlichtmt_version} irrlichtmt
cd ..

# Purge bundled jsoncpp, lua and gmp libraries.
rm -rf lib/jsoncpp lib/lua lib/gmp

%cmake \
%ifarch aarch64
%if 0%{suse_version} > 1550
  -DCMAKE_CXX_FLAGS="%{optflags} -mbranch-protection=none" \
  -DCUSTOM_DOCDIR="%{_docdir}/%{name}" \
  -DCUSTOM_LOCALEDIR="%{_datadir}/locale" \
  -DCUSTOM_SHAREDIR="%{_datadir}/%{name}" \
  -DPNG_PNG_INCLUDE_DIR=$(pkg-config libpng --variable=includedir) \
%if %{with leveldb}
%if %{with redis}
%if %{with postgresql}


# Install the wrapper.
ln -s %{buildroot}%{_bindir}/%{name}-wrapper
sed -i 's/^Exec=.*$/Exec=%{name}-wrapper/' \
%suse_update_desktop_file -r net.minetest.minetest Game Simulation

# Replace fonts with symlinks (we use the system ones).
for font in Arimo-Regular Cousine-Regular DroidSansFallbackFull; do
    rm %{buildroot}%{_datadir}/%{name}/fonts/$font.ttf
    ln -s %{_datadir}/fonts/truetype/$font.ttf \

# Clean up.
%fdupes %{buildroot}%{_datadir}/

install -Dpm 0644 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}@.service
install -Dpm 0644 minetest.conf.example \

mkdir -p %{buildroot}%{_localstatedir}/lib/%{name}/

%find_lang %{name}

desktop-file-validate %{_datadir}/applications/net.minetest.minetest.desktop

%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

%license LICENSE.txt
%dir %{_datadir}/metainfo/

%files lang -f %{name}.lang

%files -n %{name}server
%license LICENSE.txt
%attr(0755,%{minetestuser},%{minetestgroup}) %{_localstatedir}/lib/%{name}/
%dir %{_sysconfdir}/%{name}
%config %{_sysconfdir}/%{name}/minetest.conf.example

%files data
%license LICENSE.txt
%doc .github/
%doc .github/
%doc %{_docdir}/%{name}/

openSUSE Build Service is sponsored by