File liquidwar.spec of Package liquidwar

#
# spec file for package liquidwar
#
# Copyright (c) 2013 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/
#

%if ! %{defined _fillupdir}
%define _fillupdir /var/adm/fillup-templates
%endif
Name:           liquidwar
Version:        5.6.4
Release:        0
Summary:        Multiplayer wargame with liquid armies
License:        GPL-2.0+
Group:          Amusements/Games/Action/Arcade
Url:            http://www.ufoot.org/liquidwar/v5
Source0:        http://download.savannah.nongnu.org/releases/%{name}/%{name}-%{version}.tar.bz2
Source1:        liquidwar.init
Source2:        liquidwar.sysconfig
Source3:        liquidwar.logrotate
# PATCH-MISSING-TAG -- See http://wiki.opensuse.org/openSUSE:Packaging_Patches_guidelines
Patch0:         %{name}-overflow.patch
# PATCH-MISSING-TAG -- See http://wiki.opensuse.org/openSUSE:Packaging_Patches_guidelines
Patch1:         %{name}-libs.patch
# PATCH-MISSING-TAG -- See http://wiki.opensuse.org/openSUSE:Packaging_Patches_guidelines
Patch2:         %{name}-desktop.patch
BuildRequires:  liballeg44-devel
BuildRequires:  allegro44-tools
BuildRequires:  pwdutils
BuildRequires:  python
BuildRequires:  python-xml
BuildRequires:  texinfo
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} >= 1230
BuildRequires:  texlive-dvips
%else
BuildRequires:  texlive-bin
%endif
BuildRequires:  texlive-latex
BuildRequires:  update-desktop-files
Requires(post):   /sbin/install-info
Requires(post): %insserv_prereq 
Requires(post): %fillup_prereq
Requires(preun):  /sbin/install-info

%description
Liquid War is a unique multiplayer wargame. You control an army of liquid
and have to try and eat your opponents. A single player mode is available,
but the game is definitely designed to be multiplayer, and has network
support.

%package doc
Summary:        Documentation for the LiquidWar game in additional formats
Group:          Documentation/Other
Requires:       %{name} = %{version}

%description doc
This package contains the documentation of LiquidWar in html, pdf, ps and txt
format.

%package server
Summary:        Network game server for the LiquidWar game
Group:          Amusements/Games/Action/Arcade
Requires:       %{name} = %{version}
Requires:       logrotate
Requires(pre):    pwdutils
Requires(post):   /sbin/chkconfig
Requires(preun):  /sbin/chkconfig /sbin/service
Requires(postun): /sbin/service

%description server
This package contains the server for hosting network LiquidWar games.

%prep
%setup -q
%patch0
%patch1
%patch2
# don't strip the binaries please
sed -i 's/install\(\s\+-c\)\?\s\+-s/install/g' Makefile.in
# fix manpage doc reference
sed -i \
  -e 's:^\.B /usr/share/doc/liquidwar $:\.B %{_docdir}/%{name}-doc-%{version}:' \
  -e 's:^or $:directory (from :' \
  -e 's:^\.B /usr/local/share/doc/liquidwar$:the %{name}-doc :' \
  -e 's:^directories, :package), :' \
  doc/man/begin.man.in
# fix README.* encoding
for i in de dk fr; do
  iconv -f ISO-8859-1 -t UTF8 README.$i > $i
  mv $i README.$i
done
FAKE_BUILDDATE=$(LC_ALL=C date -r %{_sourcedir}/%{name}.changes '+%b %e %Y')
sed -i "s/__DATE__/\"$FAKE_BUILDDATE\"/" src/langfr.c src/langdk.c src/langen.c src/langde.c src/basicopt.c
FAKE_BUILDTIME=$(LC_ALL=C date -r %{_sourcedir}/%{name}.changes '+%H:%M:%S')
sed -i "s/__TIME__/\"$FAKE_BUILDTIME\"/" src/langfr.c src/langdk.c src/langen.c src/langde.c src/basicopt.c

%build
%configure --disable-target-opt \
%ifnarch %{ix86}
  --disable-asm
%endif

MAKE_FLAGS="DEBUG_FLAGS= GAMEDIR=%{_bindir} DATADIR=%{_datadir}/%{name}"
# to show to compile flags with out MAKE_FLAGS
make config $MAKE_FLAGS
make %{?_smp_mflags} $MAKE_FLAGS

# make docs utf-8
iconv -f ISO-8859-1 -t UTF8 doc/man/%{name}.6 | gzip > doc/man/%{name}.6.gz
gzip -cd doc/info/%{name}.info.gz | \
  iconv -f ISO-8859-1 -t UTF8 > doc/info/%{name}.info
gzip -f doc/info/%{name}.info

%install
make install_nolink DESTDIR=%{buildroot} GAMEDIR=%{_bindir} \
  DATADIR=%{_datadir}/%{name}
mv %{buildroot}%{_datadir}/doc/%{name} liquidwardocs
rm %{buildroot}%{_datadir}/pixmaps/%{name}.xpm

# below is the desktop file and icon stuff.

%suse_update_desktop_file -i %{name} Game ArcadeGame

mkdir -p %{buildroot}%{_datadir}/icons/hicolor/{32x32,48x48}/apps
install -p -m 644 misc/%{name}_32x32.xpm \
  %{buildroot}%{_datadir}/icons/hicolor/32x32/apps/%{name}.xpm
install -p -m 644 misc/%{name}.xpm \
  %{buildroot}%{_datadir}/icons/hicolor/48x48/apps/%{name}.xpm

install -p -D -m 755 %{SOURCE1} \
        %{buildroot}/%{_initddir}/%{name}-server
install -p -D -m 644 %{SOURCE2} \
        %{buildroot}%{_fillupdir}/sysconfig.%{name}-server
install -p -D -m 644 %{SOURCE3} \
        %{buildroot}/%{_sysconfdir}/logrotate.d/%{name}-server

mkdir -p %{buildroot}%{_prefix}/sbin
ln -s /etc/init.d/liquidwar-server %{buildroot}%{_sbindir}/rcliquidwar-server

%pre server
if ! getent passwd "%{name}" >/dev/null 2>/dev/null; then
    /usr/sbin/useradd -r -s /sbin/nologin -d %{_datadir}/%{name} -M \
            -c 'LiquidWar Server' \
            %{name} >/dev/null || :
fi

%post server
%{fillup_and_insserv liquidwar-server}

%preun server
%stop_on_removal liquidwar-server

%postun server
%restart_on_update liquidwar-server
%insserv_cleanup

%post
/sbin/install-info %{_infodir}/%{name}.info.gz %{_infodir}/dir

%preun
if [ $1 = 0 ] ; then
  /sbin/install-info --delete %{_infodir}/%{name}.info.gz %{_infodir}/dir
fi

%files
%defattr(-,root,root,-)
%doc COPYING README
%{_bindir}/%{name}
%{_bindir}/%{name}-mapgen
%{_datadir}/%{name}
%{_infodir}/%{name}.*
%{_mandir}/man6/%{name}.6.gz
%{_mandir}/man6/%{name}-mapgen.6.gz
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor

%files doc
%defattr(-,root,root,-)
%doc liquidwardocs/*

%files server
%defattr(-,root,root,-)
%{_bindir}/%{name}-server
%{_mandir}/man6/%{name}-server.6.gz
%{_initddir}/%{name}-server
%{_sbindir}/rc%{name}-server
%{_fillupdir}/sysconfig.%{name}-server
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}-server

%changelog
openSUSE Build Service is sponsored by