File unvanquished.spec of Package unvanquished
#
# spec file for package unvanquished
#
# Copyright (c) 2014 SUSE LINUX Products 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/
#
#Compat macro for new _fillupdir macro introduced in Nov 2017
%if ! %{defined _fillupdir}
%define _fillupdir /var/adm/fillup-templates
%endif
Name: unvanquished
Version: 0.41.0
Release: 0
Summary: Sci-fi RTS and FPS game
License: GPL-3.0
Group: Amusements/Games/Action/Shoot
Url: http://unvanquished.net/
#Source: http://dl.unvanquished.net/sources/stripped/%{name}-%{version}.tar.xz
# Github download will become Unvanquished-%{version}.tar.gz, i.e. note the 'Unv' not 'unv'
Source: https://github.com/Unvanquished/Unvanquished/archive/v%{version}.tar.gz
Source1: http://dl.unvanquished.net/deps/linux32-3.tar.bz2
Source2: http://dl.unvanquished.net/deps/linux64-3.tar.bz2
Source3: http://dl.unvanquished.net/deps/pnacl-2.zip
Source10: %{name}-service.sh
Source11: server.cfg
#Source12: https://github.com/Unvanquished/Unvanquished/raw/master/archlinux/configs/maprotation.cfg
Source12: maprotation.cfg
Source20: NOTES.txt
BuildRequires: cmake
BuildRequires: desktop-file-utils
BuildRequires: xz
BuildRequires: gcc-c++
BuildRequires: gmp-devel
BuildRequires: hicolor-icon-theme
BuildRequires: libGeoIP-devel
BuildRequires: libjpeg-devel
BuildRequires: libtinyxml-devel
BuildRequires: ncurses-devel
BuildRequires: pkgconfig(bzip2)
BuildRequires: unzip
BuildRequires: pkgconfig(freetype2)
BuildRequires: pkgconfig(glew)
BuildRequires: pkgconfig(libcurl)
%if 0%{?suse_version}
BuildRequires: pkgconfig(libpng)
%endif
%if 0%{?fedora}
BuildRequires: pkgconfig(libpng15)
%endif
BuildRequires: pkgconfig(libwebp)
BuildRequires: pkgconfig(nettle)
BuildRequires: pkgconfig(openal)
BuildRequires: pkgconfig(opus)
BuildRequires: pkgconfig(opusfile)
BuildRequires: pkgconfig(sdl2)
BuildRequires: pkgconfig(speex)
BuildRequires: pkgconfig(theora)
BuildRequires: pkgconfig(vorbis)
%if 0%{?suse_version} >= 1210
BuildRequires: systemd-rpm-macros
%endif
Requires: opengl-games-utils
Requires: %{name}-data = %{version}
%if 0%{?suse_version} > 1020
Recommends: %{name}-maps
Recommends: %{name}-service
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-build
# Service setup
%{define} _service %{name}-server
%{define} _service_user %{name}
%{define} _service_home /var/lib/%{_service}
%description
Players fight online in team based combat in a war of aliens against humans.
While the humans are equipped with weapons that they use to exterminate the alien presence, the aliens have only their pincers and a few special attacks, such as poison gas, and ranged electrical and projectile attacks. Players do not spawn at random points in the map; instead, each map has default spawn points and both teams are capable of moving them wherever they please. Both teams have other buildings that round out their base, such as machinegun turrets for the humans and barricades for the aliens. Either team wins by destroying the opposing team's spawn points and killing any remaining members of that team before they are able to build any more spawn points or the game timer ends.
This package only contains the game engine.
# As a Service
%package service
Summary: Sci-fi RTS and FPS game - Run game server as a service
Group: Amusements/Games/Action/Shoot
Requires: %{name} >= %{version}
PreReq: %fillup_prereq
PreReq: shadow
%{?systemd_requires}
#
%description service
Players fight online in team based combat in a war of aliens against humans.
This package installs the files and config to run a unvanquished server as a systemd service.
** THIS IS A WORK IN PROGRESS - EXPERIMENTAL**
- Service control and monitoring still experimental.
- Connection to server instance's console not telnet'esque yet.
%prep
# Capital 'U' inside of Github downloaded tarball
%setup -q -n Unvanquished-%{version}
# Google Native Client (NaCl)
pushd external_deps
%ifarch i586
tar -xjvf %{SOURCE1}
%endif
%ifarch x86_64
tar -xjvf %{SOURCE2}
%endif
unzip -o %{SOURCE3}
popd
mkdir build
%build
cd build
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_SKIP_RPATH=ON \
-DBUILD_GAME_NATIVE_DLL=OFF \
-DBUILD_GAME_NATIVE_EXE=OFF \
-DBUILD_GAME_NACL=OFF
#-DCMAKE_BUILD_TYPE=RelWithDebInfo \
#-USE_OPENAL_DLOPEN=OFF \
make %{?_smp_mflags}
%install
# Docs + Notes
cp -a %{SOURCE20} ./
# Icons
install -Dm644 debian/%{name}.png %{buildroot}%{_datadir}/icons/hicolor/128x128/apps/%{name}.png
# == Command Interface ==
mkdir command-ui
pushd command-ui
# Run a game client
# ----------------------
cat >> %{name} <<EOF
#!/bin/sh
app_args=''
uri=''
while [ \$# -gt 0 ]; do
case "\$1" in
# handle URI unv:// passed in
unv://*)
uri=\$(echo "\$1" | grep -o '^unv://[^[:space:]+;]*')
app_args="\${app_args} +connect \${uri}"
;;
*)
app_args="\${app_args} \$1"
;;
esac
shift
done
# Note: argument stucture changed in alpha 37:
# -set <variable> <value> is now the preferred way to set a configuration variable.
# +set <variable> <value> and +<command> are only applied after engine initialization.
exec %{_libdir}/%{name}/daemon -libpath %{_libdir}/%{name} -pakpath %{_datadir}/%{name}/pkg \${app_args}
EOF
# ----------------------
# Run a game server
# ----------------------
cat >> %{name}-server <<EOF
#!/bin/sh
# Note: argument stucture changed in alpha 37:
# -set <variable> <value> is now the preferred way to set a configuration variable.
# +set <variable> <value> and +<command> are only applied after engine initialization.
exec %{_libdir}/%{name}/daemonded -libpath %{_libdir}/%{name}/ -pakpath %{_datadir}/%{name}/pkg -curses "\$@"
EOF
# ----------------------
mkdir -p %{buildroot}%{_bindir}/
install -m 755 %{name} %{name}-server %{buildroot}%{_bindir}/
# Desktop launcher
# Don't use a suse-macro to support other distributions
# ----------------------
cat >> %{name}.desktop <<EOF
[Desktop Entry]
Categories=Game;ActionGame;
Name=Unvanquished
GenericName=sci-fi RTS and FPS mashup
Type=Application
Exec=%{name}
Icon=%{name}
MimeType=x-scheme-handler/unv;
EOF
# ----------------------
install -Dm 644 %{name}.desktop %{buildroot}%{_datadir}/applications/%{name}.desktop
# Server as service
# sysconfig
# ----------------------
cat >> %{_service}.conf <<EOF
# Unvanquished Dedicated Server - Environment Config
# Daemonded lib directory
LIBPATH=%{_libdir}/%{name}
# Server Store
HOMEPATH=%{_service_home}
# .pk3 Package Store - for installed game data and maps
PAKPATH=%{_datadir}/%{name}/pkg
# Startup Server Configuration
EXEC=server.cfg
EOF
# ----------------------
# For /etc/sysconfig/
install -Dm 644 %{_service}.conf %{buildroot}%{_fillupdir}/sysconfig.%{_service}
install -Dm 750 %{SOURCE10} %{buildroot}%{_service_home}/%{name}-service.sh
# Systemd service file
# ----------------------
cat >> %{_service}.service <<EOF
[Unit]
Description=Unvanquished Dedicated Server
After=network.target
[Service]
EnvironmentFile=/etc/sysconfig/%{_service}
User=%{_service_user}
Group=%{_service_user}
ExecStart=%{_service_home}/%{name}-service.sh +exec \$EXEC
ExecStop=%{_service_home}/%{name}-service.sh stop
[Install]
WantedBy=multi-user.target
EOF
# ----------------------
install -Dm 644 %{_service}.service %{buildroot}%{_unitdir}/%{_service}.service
# Administer the running service instance
# ----------------------
cat >> %{_service}-cmd <<EOF
#!/bin/sh
# Send command(s) to running daemonded instance started as a service
#
test -s /etc/sysconfig/%{_service} && . /etc/sysconfig/%{_service}
service_state=\$(systemctl is-active %{_service}.service)
if [ "\${service_state}" != "active" ]; then
echo "No active instance of %{_service}, Exiting."
exit 1
fi
# Administer running service instance - To send it commands.
# -homepath must be same as running instance
exec %{_libdir}/%{name}/daemonded -libpath \$LIBPATH -pakpath \$PAKPATH -homepath \$HOMEPATH "\$@"
EOF
# ----------------------
install -Dm 750 %{_service}-cmd %{buildroot}%{_service_home}/%{_service}-cmd
#
popd # command-ui
# Service Home
install -Dm 640 %{SOURCE11} %{buildroot}%{_service_home}/config/server.cfg
install -Dm 640 %{SOURCE12} %{buildroot}%{_service_home}/game/maprotation.cfg
install -d %{buildroot}%{_service_home}/pkg
# == Binary Assets ==
mkdir -p %{buildroot}%{_libdir}/%{name}/
cd build
# Application
install -m 755 daemon daemonded daemon-tty %{buildroot}%{_libdir}/%{name}/
# Helpers
install -m 755 nacl_helper_bootstrap nacl_loader %{buildroot}%{_libdir}/%{name}/
%ifarch i586
install -m 755 irt_core-x86.nexe %{buildroot}%{_libdir}/%{name}/
%endif
%ifarch x86_64
install -m 755 irt_core-x86_64.nexe %{buildroot}%{_libdir}/%{name}/
%endif
# NOTE: 'irt_core-x86.nexe' is getting stripped or tweaked after build
# in packaging, and causes failure at runtime with an IPC error.
# Protect 'irt_core-x86[_64].nexe from getting 'stripped'.
export NO_BRP_STRIP_DEBUG='true'
%pre service
# Server Setup of User / Group
getent group %{_service_user} >/dev/null || groupadd -r %{_service_user}
getent passwd %{_service_user} >/dev/null || useradd -r -g %{_service_user} \
-d %{_service_home} -s /bin/false -c "Unvanquished Dedicated Server" %{_service_user}
%service_add_pre %{_service}.service
%post service
%icon_theme_cache_post
%desktop_database_post
%{fillup_only -n %{_service}}
%service_add_post %{_service}.service
# TODO?: (how to symlink file not created by this spec)
#ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rc%{_service}
%preun service
%service_del_preun %{_service}.service
%postun service
%icon_theme_cache_postun
%desktop_database_postun
%service_del_postun %{_service}.service
%files
%defattr(-,root,root,-)
%doc GPL.txt COPYING.txt NOTES.txt
%{_bindir}/*
%{_libdir}/%{name}/
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/128x128/apps/%{name}.png
%files service
%defattr(-,root,root,-)
%doc NOTES.txt
%config %{_fillupdir}/sysconfig.%{_service}
%{_unitdir}/%{_service}.service
%attr(750,%{_service_user},%{_service_user}) %dir %{_service_home}/
%attr(750,%{_service_user},%{_service_user}) %dir %{_service_home}/config/
%attr(750,%{_service_user},%{_service_user}) %dir %{_service_home}/game/
%attr(750,%{_service_user},%{_service_user}) %dir %{_service_home}/pkg/
%attr(0750,%{_service_user},%{_service_user}) %{_service_home}/%{name}-service.sh
%attr(0750,%{_service_user},%{_service_user}) %{_service_home}/%{_service}-cmd
%attr(0640,%{_service_user},%{_service_user}) %config(noreplace) %{_service_home}/config/server.cfg
%attr(0640,%{_service_user},%{_service_user}) %config(noreplace) %{_service_home}/game/maprotation.cfg
%changelog