File anki.spec of Package anki

# spec file for package anki
# Copyright (c) 2019 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

%bcond_without tests
Name:           anki
Version:        2.1.13
Release:        0
Summary:        Spaced-Repetition Memory Training Program
License:        AGPL-3.0-only
Group:          Productivity/Text/Utilities
Source1:        %{name}.appdata.xml
# PATCH-FIX-OPENSUSE - -- Load Qt4 translations from the right place
Patch1:         %{name}
# PATCH-FIX-OPENSUSE - -- Load Anki translations from the right place
Patch2:         %{name}
BuildRequires:  python3-Markdown
BuildRequires:  python3-PyAudio
BuildRequires:  python3-Send2Trash
BuildRequires:  python3-beautifulsoup4
BuildRequires:  python3-decorator
BuildRequires:  python3-jsonschema
BuildRequires:  python3-mock
BuildRequires:  python3-qt5-devel
BuildRequires:  python3-qtwebengine-qt5
BuildRequires:  python3-requests
Requires:       python3-Markdown
Requires:       python3-PyAudio
Requires:       python3-Send2Trash
Requires:       python3-beautifulsoup4
Requires:       python3-decorator
Requires:       python3-jsonschema
Requires:       python3-qt5
Requires:       python3-qtwebengine-qt5
Requires:       python3-requests
Suggests:       lame
Suggests:       mpv
Suggests:       sox
BuildArch:      noarch
%if 0%{?suse_version} >= 1550
Requires:       python3-qtwebengine-qt5
%if 0%{?suse_version}
BuildRequires:  fdupes
BuildRequires:  update-desktop-files
%if %{with tests}
BuildRequires:  python3-nose

Anki is a spaced repetition system (SRS). It helps the user remember things by
scheduling reviews, so that the user can learn a lot of information
with the minimum amount of effort.
Anki is content-agnostic and supports images, audio,
videos and scientific markup (via LaTeX).

Anki stores data in ~/.local/share/Anki2, or $XDG_DATA_HOME/Anki2
if the user has set a custom data path.

%setup -q
%patch1 -p1
%patch2 -p1

# SED-FIX-OPENSUSE -- Don't check for new updates.
sed -i -e 's|updates=True|updates=False|;
           s|suppressUpdate=False|suppressUpdate=True|' aqt/

# Use dependencies instead of bundled stuff
rm -rf thirdparty

# Remove not needed files
rm -f anki/anki

python3 -m compileall .
python3 -O -m compileall .


# install appdata
mkdir -p %{buildroot}%{_datadir}/appdata
install -m 0644 %{SOURCE1} %{buildroot}%{_datadir}/appdata

# install mime data
mkdir -p %{buildroot}%{_datadir}/mime/packages/
install -m 0644 %{name}.xml %{buildroot}%{_datadir}/mime/packages/

# Remove duplicate and unneeded doc files
rm %{buildroot}%{_datadir}/doc/anki/LICENSE
rm %{buildroot}%{_datadir}/doc/anki/LICENSE.logo
rm %{buildroot}%{_datadir}/doc/anki/README.contributing
rm %{buildroot}%{_datadir}/doc/anki/README.development
rm %{buildroot}%{_datadir}/doc/anki/

%find_lang %{name} %{name}.lang

%if 0%{?suse_version}
    %suse_update_desktop_file -r %{name} Education Languages
    %fdupes -s %{buildroot}%{_prefix}

# Fix rpmlint issues
find %{buildroot}%{_datadir}/%{name}/web/ -name '*.js' -exec chmod a-x {} +
sed -i 's|/usr/bin/env python3|/usr/bin/python3|' %{buildroot}%{_bindir}/%{name}

%if %{with tests}
# to prevent Exception("Anki requires a UTF-8 locale.")
export LC_ALL=en_US.UTF-8

update-mime-database %{_datadir}/mime

update-mime-database %{_datadir}/mime

%files -f %{name}.lang
%license LICENSE LICENSE.logo

openSUSE Build Service is sponsored by