File m64py.spec of Package m64py

# spec file for package m64py
# 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

Name:             m64py
Version:          0.2.1
Release:          0
Summary:          A frontend for Mupen64Plus
License:          GPL-3.0
Group:            System/Emulators/Other
# Source from
Source:           %{name}-%{version}.tar.gz
# PATCH-FIX-OPENSUSE m64py-0.1.7_xdg.patch -- use correct paths for icons
Patch0:           m64py-0.2.1_xdg.patch
# PATCH-FIX-UPSTREAM m64py-0.1.7_search_dir.patch -- also include /usr/lib64/mupen64plus in SEARCH_DIRS
Patch1:           m64py-0.2.1_search_dir.patch

%if 0%{?suse_version} && 0%{?suse_version} <= 1110
%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
BuildArch:        noarch
BuildRequires:    fdupes
BuildRequires:    python
BuildRequires:    python-qt4-devel
BuildRequires:    update-desktop-files
BuildRoot:        %{_tmppath}/%{name}-%{version}-build

# Fix no-dependency-on python-base on SLE11 and openSUSE 11.4
%if 0%{?suse_version} <= 1140

Requires:         SDL >= 1.2
Requires:         mupen64plus >= 2.0
Requires:         python-qt4
Requires(post):   hicolor-icon-theme
Requires(postun): hicolor-icon-theme

Provides:         mupen64plus-ui

M64Py is a Qt4 front-end (GUI) for Mupen64Plus 2.0, a cross-platform plugin-based Nintendo 64 emulator.
Front-end is written in Python and it provides a user-friendly interface over Mupen64Plus shared library.

%setup -q
%patch0 -p1
%patch1 -p1

mv xdg/application-x-m64py.xml xdg/%{name}.xml

# remove shebang from non-executable scripts
for i in src/m64py/SDL/*.py; do
  sed -i '1{\@^#!/usr/bin/env python@d}' $i 

python build

python install -O1 --root=%{buildroot} --prefix=%{_prefix} --install-lib=%{python_sitelib} --record=INSTALLED_FILES

# Use correct category in desktop file
%suse_update_desktop_file -r %{name} "System;Emulator"

# fdupes
%fdupes %{buildroot}%{python_sitelib}/%{name}/
%fdupes %{buildroot}%{_datadir}/icons/hicolor/96x96/

%if 0%{?suse_version} >= 1140

%if 0%{?suse_version} >= 1140

%dir %{python_sitelib}/%{name}
%dir %{python_sitelib}/%{name}/SDL
%dir %{python_sitelib}/%{name}/SDL2
%dir %{python_sitelib}/%{name}/core
%dir %{python_sitelib}/%{name}/frontend
%dir %{python_sitelib}/%{name}/ui