File conquest.spec of Package conquest

#
# spec file for package conquest
#
# Copyright (c) 2019, Martin Hauke <mardnh@gmx.de>
#
# 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 https://bugs.opensuse.org/
#

%define home_dir    %{_localstatedir}/lib/%{name}

Name:           conquest
Version:        9.1
Release:        0
Summary:        A real-time multi-player space warfare game
License:        MIT
Group:          Amusements/Games/Strategy/Real Time
URL:            https://github.com/jtrulson/conquest
Source:         https://github.com/jtrulson/conquest/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        https://github.com/jtrulson/conquest/releases/download/%{version}/conquest-musicpak.tar.gz
Patch0:         conquest-fix-build.patch
Patch1:         conquest-server-systemd.patch
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  bison
BuildRequires:  flex
BuildRequires:  freeglut-devel
BuildRequires:  gcc-c++
BuildRequires:  libtool
BuildRequires:  ncurses-devel
BuildRequires:  pkgconfig
BuildRequires:  update-desktop-files
BuildRequires:  pkgconfig(SDL2_mixer)
BuildRequires:  pkgconfig(gl)
BuildRequires:  pkgconfig(glu)
BuildRequires:  pkgconfig(sdl2)
BuildRequires:  pkgconfig(xi)
BuildRequires:  pkgconfig(xmu)
BuildRequires:  pkgconfig(xt)

%description
Conquest is a top-down, real time space warfare game. It was originally written
in RATFOR for the VAX/VMS system in 1983 by Jef Poskanzer and Craig Leres.

%prep
%setup -q
tar xzvf %{SOURCE1}
%patch -P 0 -p1
%patch -P 1 -p1

%build
autoreconf -fiv
%configure
make %{?_smp_mflags}

%install
%make_install
install -Dm0644 icon/conquest-icon-48.png %{buildroot}%{_datadir}/pixmaps/conquest.png
install -Dm0644 00_music.src %{buildroot}%{_sysconfdir}/conquest/00_music.src
rm -rf %{buildroot}%{_datadir}/doc/conquest/
%suse_update_desktop_file -c %{name} %{name} "A real-time multi-player space warfare game" %{name} %{name} Game StrategyGame

# To start server (via systemd), root has to execute once before:
# conqoper -C
# conqoper -Ie
install -D -m 0644 systemd/%{name}.service %{buildroot}%{_unitdir}/%{name}.service
mkdir -v -m 0755 %{buildroot}%{_sbindir}
ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
install -D -d -m 0750 %{buildroot}%{home_dir}

%pre
# group "conquest" seems to be needed to start server
# user is set to "conquest" in systemd unit
getent group %{name} >/dev/null || %{_sbindir}/groupadd -r %{name}
getent passwd %{name} >/dev/null || %{_sbindir}/useradd -r -g %{name} \
  -d %{home_dir} -s /bin/false -c "conquest game server" %{name}

%service_add_pre %{name}.service

%post
%service_add_post %{name}.service

%preun
%service_del_preun %{name}.service

%postun
%service_del_postun %{name}.service

%files
%license LICENSE.txt
%doc README.md
%doc docs/*
%{_bindir}/conqai
%{_bindir}/conqinit
%{_bindir}/conqmetad
%{_bindir}/conqoper
%{_bindir}/conqstrat
%{_bindir}/conquest
%{_bindir}/conquestd
%{_libexecdir}/conqdriv
%dir %{_sysconfdir}/conquest
%config(noreplace) %{_sysconfdir}/conquest/*
%{_datadir}/conquest
%{_mandir}/man6/*.6%{?ext_man}
%{_datadir}/applications/conquest.desktop
%{_datadir}/pixmaps/conquest.png
%{_unitdir}/%{name}.service
%{_sbindir}/rc%{name}
%dir %attr(0750,%{name},%{name}) %{home_dir}

%changelog
openSUSE Build Service is sponsored by