File anki.spec of Package anki
%global debug_package %{nil}
%global __provides_exclude_from ^%{_libexecdir}/.*$
%global __requires_exclude_from ^%{_libexecdir}/.*$
%define program_version 25.02
Name: anki
Version: %{program_version}
Release: 0%{?dist}
Summary: An intelligent spaced-repetition memory training program
License: AGPL-3.0-only
Group: Productivity/Text/Utilities
URL: https://apps.ankiweb.net/
Source0: %{name}.tar.zst
BuildRequires: hicolor-icon-theme
BuildRequires: desktop-file-utils
BuildRequires: chrpath
%if 0%{?suse_version} || 0%{?fedora} || 0%{?mageia}
BuildRequires: fdupes
%endif
BuildRequires: zstd
Provides: python3-anki
Provides: mimehandler(application/x-colpkg)
Provides: mimehandler(application/x-apkg)
Provides: mimehandler(application/x-ankiaddon)
ExclusiveArch: x86_64
%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).
%define source_dir %{name}-%{version}-linux-qt6
%prep
tar -I zstd -xf %{SOURCE0} -C %{_builddir}/
%build
# fix rpath error
# Fix invalid RPATH
# bad example: /home/qt/work/install/lib
STRIP_FILE_LIST=$(find %{_builddir}/ -type f -name "*.so*")
for f in ${STRIP_FILE_LIST}
do
RPATH_DIR_LIST=$(chrpath -l ${f}|cut -d' ' -f2|cut -d'=' -f2|tr ':' '\n')
# No RPATH
[ "${RPATH_DIR_LIST}" = "no" ] && continue
RPATH_DIR=""
for p in ${RPATH_DIR_LIST}
do
[ -z "${p}" ] && continue
[[ "${p}" =~ "home/qt" ]] && continue
[ -z "${RPATH_DIR}" ] && RPATH_DIR=${p} || RPATH_DIR=${RPATH_DIR}":"${p}
done
# Remove invalid RPATH
[ -z "${RPATH_DIR}" ] && chrpath --delete ${f} && continue
chrpath -r "${RPATH_DIR}" ${f}
done
# remove devel files
find %{_builddir}/ -type f -name "*.h" -delete;
find %{_builddir}/ -type f -name "*.c" -delete;
%install
install -Dm755 %{_builddir}/%{source_dir}/%{name} %{buildroot}%{_libexecdir}/%{name}/%{name}
cp -av %{_builddir}/%{source_dir}/lib %{buildroot}%{_libexecdir}/%{name}/lib
mkdir -p %{buildroot}%{_bindir}
ln -s ../../%{_libexecdir}/%{name}/%{name} %{buildroot}%{_bindir}/%{name}
install -Dm644 %{_builddir}/%{source_dir}/%{name}.xpm %{buildroot}%{_datadir}/pixmaps/%{name}.xpm
install -Dm644 %{_builddir}/%{source_dir}/%{name}.png %{buildroot}%{_datadir}/pixmaps/%{name}.png
# file association
install -Dm644 %{_builddir}/%{source_dir}/%{name}.xml %{buildroot}%{_datadir}/mime/packages/%{name}.xml
# .desktop
install -Dm644 %{_builddir}/%{source_dir}/%{name}.desktop %{buildroot}%{_datadir}/applications/%{name}.desktop
# man1
gzip %{_builddir}/%{source_dir}/%{name}.1 -9 -c > %{name}.1.gz
install -Dm644 %{name}.1.gz %{buildroot}%{_mandir}/man1/%{name}.1.gz
%if 0%{?suse_version} || 0%{?fedora} || 0%{?mageia}
%fdupes -s %{buildroot}
%endif
%files
%{_bindir}/%{name}
%{_libexecdir}/%{name}/
%{_datadir}/pixmaps/%{name}.*
%{_datadir}/mime/packages/%{name}.xml
%{_datadir}/applications/%{name}.desktop
%{_mandir}/man1/%{name}.1.gz
%changelog