File childsplay.spec of Package childsplay

#
# spec file for package childsplay
#
# Copyright (c) 2012 Lars Vogdt <lars@linux-schulserver.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 http://bugs.opensuse.org/
#


Name:           childsplay
Version:        1.6
Release:        1
License:        GPL-3.0+
%define         realname childsplay_sp
Summary:        A suite of educational games for young children
Url:            http://www.schoolsplay.org/
Group:          Amusements/Teaching/Other
Source0:        %{name}-%{version}.tar.bz2
Source1:        childsplay.desktop
Source2:        childsplay.xpm
Source3:        childsplay-admin.desktop
Source4:        childsplay-rpmlintrc
# PATCH-MISSING-TAG -- See http://en.opensuse.org/Packaging/Patches
Patch1:         childsplay-locale.patch
# PATCH-MISSING-TAG -- See http://en.opensuse.org/Packaging/Patches
Patch2:         childsplay-missing_exceptions_module.patch
BuildRequires:  SDL_image-devel
BuildRequires:  SDL_mixer-devel
BuildRequires:  SDL_ttf-devel
BuildRequires:  libogg-devel
BuildRequires:  python-devel
## BuildArch:      noarch
Requires:       SDL
Requires:       python-pysqlite
Requires:       python-xml
Provides:       childsplay_sp = %{version}
Provides:       childsplay_plugins = %{version}
Obsoletes:      childsplay_plugins <= 0.90
Provides:       childsplay_plugins_lfc = %{version}
Obsoletes:      childsplay_plugins_lfc <= 0.90
#
# openSUSE specials
#
%if 0%{?suse_version}
BuildRequires:  dejavu
BuildRequires:  fdupes
BuildRequires:  gettext-runtime
BuildRequires:  python-gtk
BuildRequires:  python-numpy
BuildRequires:  python-pygame
BuildRequires:  python-pysqlite
BuildRequires:  python-sqlalchemy
BuildRequires:  update-desktop-files
Requires:       dejavu
Requires:       python-gtk
Requires:       python-numpy
Requires:       python-pygame
Requires:       python-sqlalchemy
Recommends:     childsplay-languagepack
%{py_requires}
%endif
#
# Mandriva specials
#
%if 0%{?mandriva_version}
BuildRequires:  fonts-ttf-dejavu
BuildRequires:  gettext-base
#BuildRequires:  pygame
BuildRequires:  pygtk2.0
BuildRequires:  python-numpy
BuildRequires:  python-sqlite2
Requires:       fonts-ttf-dejavu
Requires:       gettext-base
Requires:       pygame
Requires:       pygtk2.0
Requires:       python-numpy
Requires:       python-sqlalchemy
#BuildRequires:  python-sqlalchemy
%endif
#
# Fedora specials
#
%if 0%{?fedora_version}
BuildRequires:  atlas
#BuildRequires:  dejavu-fonts
BuildRequires:  gettext
BuildRequires:  pygame
BuildRequires:  pygtk2
BuildRequires:  python-sqlalchemy
BuildRequires:  python-sqlite2
Requires:       dejavu-fonts
Requires:       gettext
Requires:       pygame
Requires:       pygtk2
Requires:       python-sqlalchemy
Requires:       python26-numpy
#BuildRequires:  python26-numpy
%endif

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%define python_sitedir %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")

%description
Childsplay is a suite of educational games for young children. It's written in
Python and uses the SDL-libraries. The aim is to be educational and at the same
time be fun to play.

Some activities make use of language dependent voice samples, these sounds are
shared with gcompris. For those you'll have to install the gcompris-sound
package for the languages you intend to use. For example gcompris-sound-en.

%prep
%setup -q
%patch1 -p0
%patch2 -p1
rm setup.py
sed -i "s!/usr/bin/env python!%{_bindir}/python!" bin/%{name}

%build
# setup.py is not usable for our needs
cat > SPBasePaths.py << EOF
# AUTO-GENERATED MODULE, DON'T EDIT
# This module holds all the paths needed for childsplay_sp.

DOCDIR = '%{_defaultdocdir}/%{realname}'
PYTHONCPDIR = '%{py_sitedir}/%{realname}'
BASEDIR = '%{_datadir}/%{realname}'
SHARELIBDATADIR = '%{_datadir}/%{realname}'
ALPHABETDIR = '%{_datadir}/alphabet_sounds'
LOCALEDIR = '%{_datadir}/locale'
EOF

#
# regenerate the .mo files from the .po files
rm -rf locale
mkdir -p locale
pushd po >/dev/null
for i in *.po; do
	longlang=$(basename ${i/childsplay_sp_/} .po);
	lang=${longlang/_*/};
	mkdir -p ../locale/$lang/LC_MESSAGES
	msgfmt $i -o ../locale/$lang/LC_MESSAGES/childsplay_sp.mo
done
popd >/dev/null

%install
mkdir -p %{buildroot}
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{py_sitedir}/%{realname}/lib
mkdir -p %{buildroot}%{_datadir}/locale
mkdir -p %{buildroot}%{_datadir}/%{realname}
install -m755 bin/%{name}  %{buildroot}%{_bindir}/

cp -a lib/CPData %{buildroot}%{_datadir}/%{realname}/
cp -a lib/SPData %{buildroot}%{_datadir}/%{realname}/
cp -a alphabetsounds/* %{buildroot}%{_datadir}/alphabet_sounds/
cp -a locale/* %{buildroot}%{_datadir}/locale/

cp -a *.py %{buildroot}%{py_sitedir}/%{realname}
cp -a gui %{buildroot}%{py_sitedir}/%{realname}
cp -a lib/*.py %{buildroot}%{py_sitedir}/%{realname}/lib
cp -a ocempgui %{buildroot}%{py_sitedir}/%{realname}
#
# below is the desktop file and icon stuff.
install -Dm 644 %{SOURCE1} %{buildroot}%{_datadir}/applications/childsplay.desktop
install -Dm 644 %{SOURCE2} %{buildroot}%{_datadir}/pixmaps/childsplay.xpm
install -m 644  %{SOURCE3} %{buildroot}%{_datadir}/applications/childsplay-admin.desktop
%if 0%{?suse_version}
  %suse_update_desktop_file -n -N Childsplay -G "Educational games for young children" childsplay
  %suse_update_desktop_file -n -N Childsplay -G "Childsplay Administration" childsplay-admin System SystemSetup
%endif
# docu
mkdir -p %{buildroot}%{_defaultdocdir}/%{name}
cp -a doc/* %{buildroot}%{_defaultdocdir}/%{name}
install -m644 COPYING README Changelog %{buildroot}%{_defaultdocdir}/%{name}/
sed -i "s|||" %{buildroot}%{_defaultdocdir}/%{name}/*
# link the font into the right directory
if [ -f "%{_datadir}/fonts/truetype/DejaVuSansCondensed-Bold.ttf" ]; then
  for file in DejaVuSansCondensed-Bold.ttf SPData/DejaVu-ttf.copyright; do
	test -f "%{buildroot}%{_datadir}/%{realname}/SPData/$file" && rm "%{buildroot}%{_datadir}/%{realname}/SPData/$file"
  done
  ln -s "%{_datadir}/fonts/truetype/DejaVuSansCondensed-Bold.ttf" "%{buildroot}%{_datadir}/%{realname}/SPData/DejaVuSansCondensed-Bold.ttf"
fi
%if 0%{?suse_version}
  # save space
  %fdupes -s %{buildroot}
%endif
%find_lang %{realname}

%clean
rm -rf %{buildroot}

%files -f %{realname}.lang
%defattr(-, root, root, -)
%doc %{_defaultdocdir}/%name
%{_bindir}/childsplay
%{_datadir}/%{realname}
%{_datadir}/applications/*.desktop
%{_datadir}/pixmaps/childsplay.xpm
%{py_sitedir}/%{realname}/
%dir %{_datadir}/alphabet_sounds
%{_datadir}/alphabet_sounds

%changelog
openSUSE Build Service is sponsored by