%global commit      7e6fbda34a6e956710002972f9872b61d171b774
%global shortcommit %(c=%{commit}; echo ${c:0:7})
%global date        20190916

Name:           veloren
Version:        0.3.0
Release:        6.%{date}git%{shortcommit}%{?dist}
Summary:        Multiplayer voxel RPG written in Rust

License:        GPLv3+
URL:            https://gitlab.com/veloren/veloren
Source0:        %{url}/-/archive/%{commit}/%{name}-%{version}.%{date}git%{shortcommit}.tar.gz

#BuildRequires:  cargo >= 1.39
#BuildRequires:  desktop-file-utils
BuildRequires:  gcc
BuildRequires:  git
BuildRequires:  git-lfs
#BuildRequires:  rust >= 1.39
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:       hicolor-icon-theme
Recommends:     %{name}-server-cli

%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.


%package        server-cli

Summary:        Standalone server for %{name}
Recommends:     %{name} = %{version}-%{release}

%description    server-cli
Standalone server for %{name}.


%prep
%autosetup -p1 -n %{name}-%{commit}
git clone https://gitlab.com/veloren/veloren.git
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly -y
cd veloren
git reset --hard %{commit}
#sed -i '/default-run = "veloren-voxygen"/d' voxygen/Cargo.toml


%build
#git lfs install
#git lfs fetch
#git lfs checkout
cd veloren/voxygen
$HOME/.cargo/bin/cargo +nightly install --root=%{buildroot}%{_prefix} --path=.
cd ..
# Standalone server
cd server-cli
$HOME/.cargo/bin/cargo +nightly install --root=%{buildroot}%{_prefix} --path=.
cd ..

%install
install -Dpm0755    %{name}/target/release/%{name}-voxygen      %{buildroot}%{_bindir}/%{name}-voxygen
mkdir -p                                                        %{buildroot}%{_datadir}/%{name}
cp -a               %{name}/assets                              %{buildroot}%{_datadir}/%{name}/
# Standalone server
install -Dpm0755    %{name}/target/release/%{name}-server-cli   %{buildroot}%{_bindir}/%{name}-server-cli


%files
%license LICENSE
%doc README.md
%{_bindir}/%{name}-voxygen
%{_datadir}/%{name}

%files server-cli
%license LICENSE
%doc README.md
%{_bindir}/%{name}-server-cli


%changelog
* Sat Sep 07 2019 Artem Polishchuk <ego.cordatus@gmail.com> - 0.3.0-2.20190907git92c0edc
- Update to latest git snapshot

* Fri Mar 29 2019 Artem Polishchuk <ego.cordatus@gmail.com> - 0.3.0-1.20190906gitd41d020
- Initial package