File veloren.spec of Package veloren
# Note: requires internet access during build procces because of Rust nightly and git-lfs
# Optimize for build time or performance
%bcond_without release_build
%global debug_package %{nil}
%global commit 7940ced71e793aac4b96877df32f430e24e613c3
%global shortcommit %(c=%{commit}; echo ${c:0:7})
%global date 20200201
%global uuid net.%{name}.%{name}
Name: veloren
Version: 0.5.0
Release: 0
Summary: Multiplayer voxel RPG written in Rust
License: GPLv3+
URL: https://veloren.net/
Source: %{name}-%{version}.tar.xz
# Install desktop file, icon and appdata manifest
# * https://gitlab.com/veloren/veloren/merge_requests/654
#Source10: %{uuid}.appdata.xml
#Source11: %{uuid}.desktop
#Source12: %{uuid}.png
BuildRequires: cargo >= 1.40
BuildRequires: rust >= 1.40
BuildRequires: gcc
#a#BuildRequires: git-lfs
%if 0%{?el7}
BuildRequires: python3
%endif
BuildRequires: desktop-file-utils
#a#BuildRequires: libappstream-glib
BuildRequires: pkgconfig(alsa)
BuildRequires: pkgconfig(atk)
BuildRequires: pkgconfig(cairo)
BuildRequires: pkgconfig(gdk-3.0)
BuildRequires: pkgconfig(gdk-pixbuf-2.0)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(pango)
Requires: %{name}-data = %{version}-%{release}
Requires: hicolor-icon-theme
%if 0%{?fedora} || 0%{?rhel} >= 8
Recommends: %{name}-chat-cli%{?_isa} = %{version}-%{release}
Recommends: %{name}-server-cli%{?_isa} = %{version}-%{release}
%endif
%description
Veloren is a multiplayer voxel RPG written in Rust. It is inspired by games such
as Cube World, Legend of Zelda: Breath of the Wild, Dwarf Fortress and
Minecraft.
# Data package
%package data
Summary: Data files for %{name}
BuildArch: noarch
Requires: %{name} = %{version}-%{release}
%description data
Data files for %{name}.
# Server CLI package
%package server-cli
Summary: Standalone server for %{name}
%if 0%{?fedora} || 0%{?rhel} >= 8
Recommends: %{name}-chat-cli%{?_isa} = %{version}-%{release}
%endif
%description server-cli
Standalone server for %{name}.
# Chat CLI package
%package chat-cli
Summary: Standalone chat for %{name}
%if 0%{?fedora} || 0%{?rhel} >= 8
Recommends: %{name}-server-cli%{?_isa} = %{version}-%{release}
%endif
%description chat-cli
Standalone chat for %{name}.
%prep
%autosetup
# Unoptimize dev/debug builds
sed -i 's/opt-level = 2/opt-level = 0/' Cargo.toml
%build
pushd voxygen
#VELOREN_ASSETS=assets
%if %{with release_build}
cargo build --release
%else
cargo build
%endif
popd
%if %{with release_build}
# Standalone server
pushd server-cli
cargo build --release
popd
# Standalone chat
pushd chat-cli
cargo build --release
popd
%endif
%install
# Disable cargo install until bug will been fixed in upstream
#$HOME/.cargo/bin/cargo install --root=%{buildroot}%{_prefix} --path=.
%if %{with release_build}
install -m 0755 -Dp target/release/%{name}-voxygen %{buildroot}%{_bindir}/%{name}-voxygen
%else
install -m 0755 -Dp target/debug/%{name}-voxygen %{buildroot}%{_bindir}/%{name}-voxygen
%endif
mkdir -p %{buildroot}%{_datadir}/%{name}
cp -ap assets %{buildroot}%{_datadir}/%{name}/
%if %{with release_build}
# Standalone server
install -m 0755 -Dp target/release/%{name}-server-cli %{buildroot}%{_bindir}/%{name}-server-cli
# Standalone chat
install -m 0755 -Dp target/release/%{name}-chat-cli %{buildroot}%{_bindir}/%{name}-chat-cli
%endif
# Install desktop file, icon and appdata manifest
install -m 0644 -Dp %{SOURCE10} %{buildroot}%{_metainfodir}/%{uuid}.appdata.xml
install -m 0644 -Dp %{SOURCE11} %{buildroot}%{_datadir}/applications/%{uuid}.desktop
install -m 0644 -Dp %{SOURCE12} %{buildroot}%{_datadir}/icons/hicolor/256x256/apps/%{uuid}.png
%check
appstream-util validate-relax --nonet %{buildroot}%{_metainfodir}/*.xml
desktop-file-validate %{buildroot}%{_datadir}/applications/*.desktop
%files
%license LICENSE
%doc README.md CONTRIBUTING.md
%{_bindir}/%{name}-voxygen
%files data
%{_datadir}/%{name}/
%{_datadir}/applications/*.desktop
%{_datadir}/icons/hicolor/*/*/*.png
%{_metainfodir}/*.xml
%if %{with release_build}
%files server-cli
%license LICENSE
%doc README.md
%{_bindir}/%{name}-server-cli
%files chat-cli
%license LICENSE
%doc README.md
%{_bindir}/%{name}-chat-cli
%endif
%changelog