Blob Blame History Raw
%global develdocdir %{_docdir}/%{name}-devel/html

Name:           openclonk
Summary:        Multiplayer action, tactics and skill game
Version:        7.0
Release:        5%{?dist}
URL:            http://www.openclonk.org/
Source0:        https://github.com/openclonk/openclonk/archive/v7.0.tar.gz#/%{name}-%{version}.tar.gz
License:        ISC and CC-BY-SA
Group:          Amusements/Games

Source1:        %{name}-html-de.desktop
Source2:        %{name}-html-en.desktop
Source3:        %{name}-docs.png

BuildRequires:  boost-devel
BuildRequires:  cmake
BuildRequires:  gtest-devel
BuildRequires:  libjpeg-devel
BuildRequires:  tinyxml-devel
BuildRequires:  pkgconfig(SDL_mixer)
BuildRequires:  pkgconfig(dri)
BuildRequires:  pkgconfig(freealut)
BuildRequires:  pkgconfig(freetype2)
BuildRequires:  pkgconfig(gl)
BuildRequires:  pkgconfig(glew)
BuildRequires:  pkgconfig(gtk+-2.0)
BuildRequires:  pkgconfig(gtksourceview-2.0)
BuildRequires:  pkgconfig(libpng12)
BuildRequires:  pkgconfig(libupnp)
BuildRequires:  pkgconfig(ogg)
BuildRequires:  pkgconfig(sdl)
BuildRequires:  pkgconfig(vorbis)
BuildRequires:  pkgconfig(x11)
BuildRequires:  pkgconfig(xpm)
BuildRequires:  pkgconfig(xrandr)
BuildRequires:  pkgconfig(xxf86vm)
BuildRequires:  pkgconfig(zlib)
BuildRequires:  pkgconfig(xml2po)
BuildRequires:  ImageMagick
BuildRequires:  desktop-file-utils
BuildRequires:  libappstream-glib
BuildRequires:  libxslt
BuildRequires:  gettext
BuildRequires:  libxml2-devel
BuildRequires:  gtk3-devel

Requires:       %{name}-data = %{version}-%{release}
Requires:       hicolor-icon-theme
Provides:       bundled(timsort)

%description
Clonk is a multiplayer-action-tactics-skill game.
It is often referred to as a mixture of The Settlers and Worms.
In a simple 2D antfarm-style landscape, the player controls
his crew of Clonks, small but robust humanoid beings.
The game encourages free play but the normal goal is to
either exploit valuable resources from the earth
by building a mine or fight each other on an arena-like map.

%package     data
Summary:     %{summary}
Requires:    %{name} = %{version}
BuildArch:   noarch

%description data
This package contains the data files for openclonk.

%package     devel-docs
Summary:     Documentation for developing programs that will use %{name}
Group:       Documentation
BuildArch:   noarch
Requires:    xdg-utils

%description devel-docs
This package contains documentation needed for developing with %{name}.

%prep
%autosetup

# remove bundled tinyxml
rm -rf thirdparty/tinyxml
# remove bundled getopt
rm -rf thirdparty/getopt
# remove bundled natupnp
rm -rf thirdparty/natupnp
rm -rf planet/Tests.c4f
# change permission in src and docs folder
find src -type f | xargs chmod -v 644
find docs -type f | xargs chmod -v 644
find docs -type d | xargs chmod -v 755

# change permission due rpmlint W: spurious-executable-perm
chmod a-x README Credits.txt thirdparty/timsort/sort.h \
          COPYING TRADEMARK licenses/*

# Set directory for datafiles
sed -e 's|share/games/openclonk|share/openclonk|g' -i CMakeLists.txt

cp -p planet/COPYING COPYING-planet

## Strip all .png files 
## 'iCCP: known incorrect sRGB profile' warnings
find . -type f -name "*.png" -exec convert {} -strip {} \;

%build
mkdir -p build && cd build
%cmake -Wno-cpp -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_CXX_FLAGS:STRING="$RPM_OPT_FLAGS" \
 -DCMAKE_EXE_LINKER_FLAGS:STRING="$RPM_LD_FLAGS" \
 -DCMAKE_VERBOSE_MAKEFILE:BOOL=TRUE \
 -DCMAKE_SKIP_RPATH:BOOL=YES -DWITH_AUTOMATIC_UPDATE:BOOL=OFF \
 -DUSE_X11:BOOL=ON -DUSE_GTK:BOOL=ON -DBUILD_SHARED_LIBS:BOOL=OFF \
 -DUSE_STATIC_BOOST=OFF -DUSE_SYSTEM_TINYXML=ON ..

%make_build

# build the German and English HTML-documentation from the English \
# XML-source files and the translation file
pushd ../docs
mkdir -p sdk-de/{definition,folder,material,particle,scenario,script/fn}
make %{?_smp_mflags} chm/de/Entwickler.chm
make %{?_smp_mflags} chm/en/Developer.chm
popd

%install
make -C build DESTDIR=$RPM_BUILD_ROOT install
mv $RPM_BUILD_ROOT%{_prefix}/games/openclonk $RPM_BUILD_ROOT%{_bindir}
desktop-file-validate $RPM_BUILD_ROOT%{_datadir}/applications/%{name}.desktop

# Make an appdata file
mkdir -p $RPM_BUILD_ROOT%{_datadir}/appdata
cat > $RPM_BUILD_ROOT%{_datadir}/appdata/%{name}.appdata.xml <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2014 Richard Hughes <richard@hughsie.com> -->
<component type="desktop">
  <id type="desktop">%{name}.desktop</id>
  <metadata_license>CC0-1.0</metadata_license>
  <summary>Multiplayer action, tactics and skill game</summary>
  <name>%{name}</name>
  <project_license>ISC and CC-BY-SA</project_license>
  <categories>
   <category>Games</category>
   <category>Web Browser</category>
  </categories>
  <description>
    <p>
      Clonk is a multiplayer-action-tactics-skill game.
      It is often referred to as a mixture of The Settlers and Worms.
      In a simple 2D antfarm-style landscape, the player controls
      his crew of Clonks, small but robust humanoid beings.
      The game encourages free play but the normal goal is to
      either exploit valuable resources from the earth
      by building a mine or fight each other on an arena-like map.
    </p>
  </description>
  <url type="homepage">http://www.openclonk.org/</url>
  <screenshots>
    <screenshot type="default">https://sagitter.fedorapeople.org/%{name}-screenshots/%{name}1.png</screenshot>
    <screenshot>https://sagitter.fedorapeople.org/%{name}-screenshots/%{name}6.png</screenshot>
    <screenshot>https://sagitter.fedorapeople.org/%{name}-screenshots/%{name}3.png</screenshot>
    <screenshot>https://sagitter.fedorapeople.org/%{name}-screenshots/%{name}4.png</screenshot>
    <screenshot>https://sagitter.fedorapeople.org/%{name}-screenshots/%{name}5.png</screenshot>
  </screenshots>
  <updatecontact>forum.openclonk.org</updatecontact>
</component>
EOF

appstream-util validate-relax --nonet $RPM_BUILD_ROOT%{_datadir}/appdata/*.appdata.xml

# install html docs to %%{_docdir}/%%{name}-devel/html
mkdir -p $RPM_BUILD_ROOT%{develdocdir}/{de,en}
cp -pr docs/chm/de $RPM_BUILD_ROOT%{develdocdir}/
cp -pr docs/chm/en $RPM_BUILD_ROOT%{develdocdir}/

# W: wrong-file-end-of-line-encoding
sed -i 's/\r$//' $RPM_BUILD_ROOT%{develdocdir}/de/Output.hhp
sed -i 's/\r$//' $RPM_BUILD_ROOT%{develdocdir}/en/Output.hhp

# W: file-not-utf8
iconv -f iso8859-1 -t utf-8 $RPM_BUILD_ROOT%{develdocdir}/de/Output.hhk > \
Output.hhk.conv && mv -f Output.hhk.conv $RPM_BUILD_ROOT%{develdocdir}/de/Output.hhk

# HTML desktop files
desktop-file-install --dir $RPM_BUILD_ROOT%{_datadir}/applications %{SOURCE1}
desktop-file-install --dir $RPM_BUILD_ROOT%{_datadir}/applications %{SOURCE2}
mkdir -p $RPM_BUILD_ROOT%{_datadir}/pixmaps
install -D -m 0644 %{SOURCE3} $RPM_BUILD_ROOT%{_datadir}/pixmaps/%{name}-docs.png

%post
/usr/bin/update-desktop-database &> /dev/null || :
/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :

%postun
if [ $1 -eq 0 ] ; then
  /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null
  /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
fi
/usr/bin/update-desktop-database &> /dev/null || :

%posttrans
/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :

%files
%doc Version.txt README TRADEMARK Credits.txt
%license COPYING COPYING-planet
%{_bindir}/openclonk
%{_bindir}/c4group
%{_datadir}/icons/hicolor/*/apps/%{name}.png
%{_datadir}/applications/%{name}.desktop
%{_datadir}/appdata/*.appdata.xml

%files data
%{_datadir}/%{name}/

%files devel-docs
%license COPYING COPYING-planet
%dir %{_docdir}/%{name}-devel
%doc %{develdocdir}
%{_datadir}/applications/%{name}-html-*.desktop
%{_datadir}/pixmaps/%{name}-docs.png

%changelog
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 7.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Tue Jan 10 2017 Orion Poplawski <orion@cora.nwra.com> - 7.0-4
- Rebuild for glew 2.0.0

* Tue May 10 2016 Antonio Trande <sagitterATfedoraproject.org> - 7.0-3
- Made sub-package for documentation

* Sun May 08 2016 Antonio Trande <sagitterATfedoraproject.org> - 7.0-2
- Unbundle getopt
- Strip all .png files
- Make an appdata file

* Sat May 07 2016 Antonio Trande <sagitterATfedoraproject.org> - 7.0-1
- First package