File epymc.spec of Package epymc

#
# spec file for package epymc
#
# Copyright (c) 2017 SUSE LINUX 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/
#


Name:           epymc
Version:        @SERVICE@
Release:        0
Summary:        A Media Center designed to run on a large number of devices
License:        GPL-3.0+
Group:          Productivity/Multimedia/Video/Players
URL:            https://github.com/DaveMDS/epymc
Source0:        %{name}-%{version}.tar.xz
BuildRequires:  ImageMagick
BuildRequires:  hicolor-icon-theme
BuildRequires:  intltool
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(libdiscid)
BuildRequires:  python3-Pillow
BuildRequires:  python3-beautifulsoup4
BuildRequires:  python3-dbus-python
BuildRequires:  python3-discid
BuildRequires:  python3-distutils-extra
BuildRequires:  python3-efl >= 1.20.0
BuildRequires:  python3-imaging
BuildRequires:  python3-lxml
BuildRequires:  python3-mutagen
BuildRequires:  python3-pyudev
BuildRequires:  python3-pyxdg
BuildRequires:  pkgconfig(efl)
BuildRequires:  pkgconfig(python3)
Requires:       python3-beautifulsoup4
Requires:       python3-discid
Requires:       python3-efl
Requires:       python3-imaging
Requires:       python3-lxml
Requires:       python3-pyudev
Recommends:     %{name}-lang
BuildArch:      noarch
%if 0%{?suse_version}
BuildRequires:  fdupes
BuildRequires:  update-desktop-files
%endif
%if 0%{?suse_version}
Requires:       python3-Pillow
Requires:       python3-dbus-python
Requires:       python3-mutagen
%endif
%if !0%{?suse_version}
Requires:       python3-dbus
Requires:       python3-pillow
%if 0%{?fedora_version}
Requires:       python3-mutagen
%else
Requires:       mutagen
%endif
%endif

%description
EpyMC is a Media Center application written in python that use the
Enlightenment Foundation Library as the living base.

%lang_package

%prep
%setup -q

%build
python3 setup.py build

%install
python3 setup.py install --root %{buildroot}

if [ "$(ls %{buildroot}%{_datadir}/icons/hicolor | wc -l)" -eq 1 ]; then
  find %{buildroot}%{_datadir}/icons/ -name \*.png | while read _file; do
    _width=$(identify -format %w $_file)
    _height=$(identify -format %h $_file)
    if [ "$_width" -eq $_height ]; then
      ls %{_datadir}/icons/hicolor | grep '[0-9]x[0-9]' | sort -n | while read _size; do
        if [ "$_width" -ge ${_size%x*} ]; then
          mkdir -p %{buildroot}%{_datadir}/icons/hicolor/${_size}/apps
          convert -strip \
            $_file -resize $_size \
            %{buildroot}%{_datadir}/icons/hicolor/${_size}/apps/${_file##*/}
        fi
      done
    fi
  done
else
  echo "conversion is not required"
  exit 1
fi

mkdir -p %{buildroot}%{_datadir}/locale
mv %{buildroot}{%{python3_sitelib}/%{name}/locale/*,%{_datadir}/locale/}
find %{buildroot} -type f -name "*.po*" -delete -print

# Fix: non-executable-script
pushd %{buildroot}%{python3_sitelib}
for _file in $(grep -rl '^\#\!\/'); do
  find -name ${_file##*/} -type f -not -perm /111 -exec sed '/^\#\!\//d' -i {} +
  find -name ${_file##*/} -type f -perm /111 -exec sed 's|#!%{_bindir}/env python|#!%{_bindir}/python3|' -i {} +
done
popd
%if 0%{?suse_version}
%py3_compile %{buildroot}%{python3_sitelib}
%endif
#

%find_lang %{name}
%if 0%{?suse_version}
%suse_update_desktop_file %{name} -r Enlightenment AudioVideo Video Player
%fdupes %{buildroot}/%{_datadir}
%fdupes %{buildroot}/%{python3_sitelib}
%endif

%if 0%{?suse_version} < 1320
%post
%icon_theme_cache_post
%desktop_database_post

%postun
%icon_theme_cache_postun
%desktop_database_postun
%endif

%{?suse_version:%files}
%{!?suse_version:%files -f %{name}.lang}
%doc README.md COPYING TODO
%{_bindir}/epymc
%{_bindir}/epymc_standalone
%{_bindir}/epymc_thumbnailer
%{_bindir}/epymc_watchdog
%{_datadir}/icons/hicolor/*/apps/%{name}*.??g
%{_datadir}/applications/epymc.desktop
%{_datadir}/xsessions/epymc_xsession.desktop
%{python3_sitelib}/epymc*
%{python3_sitelib}/EpyMC*

%{?suse_version:%files lang -f %{name}.lang}

%changelog
openSUSE Build Service is sponsored by