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 http://bugs.opensuse.org/
#


%bcond_without tests
Name:           anki
Version:        23.12.1
Release:        0
Summary:        Spaced-Repetition Memory Training Program
License:        AGPL-3.0-or-later
Group:          Productivity/Text/Utilities
URL:            https://apps.ankiweb.net
Source0:        %{name}-%{version}.tar.gz
Source1:        vendor.tar.gz
#Source1:        %%{name}.appdata.xml
# PATCH-FIX-OPENSUSE - anki-aqt___init__.py.patch -- Load Qt4 translations from the right place
#Patch1:         %%{name}-aqt___init__.py.patch
# PATCH-FIX-OPENSUSE - anki-anki_lang.py.patch -- Load Anki translations from the right place
#Patch2:         %%{name}-anki_lang.py.patch
BuildRequires:  cargo-packaging
BuildRequires:  pkgconfig(openssl)
BuildRequires:  protobuf-devel
BuildRequires:  git
BuildArch:      noarch
BuildRequires:  fdupes
BuildRequires:  update-desktop-files

%description
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.

%prep
%autosetup -a1

%build
%{cargo_build}
target/release/runner build -- wheels

%install


# 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/README.md

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

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

# 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}

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

%post
update-mime-database %{_datadir}/mime

%postun
update-mime-database %{_datadir}/mime

%files -f %{name}.lang
%doc README.md
%license LICENSE LICENSE.logo
%{_bindir}/%{name}
%{_mandir}/man1/%{name}.1%{?ext_man}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/pixmaps/%{name}.*
%{_datadir}/appdata/%{name}.appdata.xml
%{_datadir}/mime/packages/%{name}.xml
%{_datadir}/%{name}

%changelog
openSUSE Build Service is sponsored by