File dupeguru.spec of Package dupeguru

%if 0%{?fedora_version}
%define python311_sitearch %{python3_sitearch}
%endif
Name:           dupeguru
Version:        4.3.1
Release:        0
Summary:        Duplicate Files Finder
License:        GPL-3.0-only
Group:          Productivity/File utilities
URL:            https://dupeguru.voltaicideas.net/
Source0:        %{name}-%{version}.tar.xz
BuildRequires:  ImageMagick
BuildRequires:  fdupes
BuildRequires:  hicolor-icon-theme
BuildRequires:  python-rpm-macros
BuildRequires:  python3-setuptools
%if 0%{?fedora_version}
BuildRequires:  python3-rpm-macros
BuildRequires:  pyproject-rpm-macros
#BuildRequires:  cmake-rpm-macros
BuildRequires:  python3-distutils-extra
BuildRequires:  python3-devel
BuildRequires:  python3-sphinx
BuildRequires:  python3-send2trash
BuildRequires:  python3-polib
BuildRequires:  python3-mutagen
BuildRequires:  python3-distro
BuildRequires:  python3-qt5-devel
BuildRequires:  python3-xxhash
BuildRequires:  python3-pytest
BuildRequires:  python3-flake8
BuildRequires:  python3-black
Requires:       python3-send2trash
Requires:       python3-mutagen
Requires:       python3-polib
Requires:       python3-qt5
Requires:       python3-xxhash
Requires:       python3-xml
%endif
%if 0%{?suse_version} > 1600
BuildRequires:  python311
BuildRequires:  python311-Sphinx >= 3.0.0
BuildRequires:  python311-Send2Trash >= 1.3.0
BuildRequires:  python311-polib >= 1.1.0
BuildRequires:  python311-mutagen >= 1.44.0
BuildRequires:  python311-distro >= 1.5.0
BuildRequires:  python311-qt5-devel >= 5.14.1
BuildRequires:  python311-xxhash >= 3.0.0
BuildRequires:  python311-pytest
BuildRequires:  python311-flake8
BuildRequires:  python311-black
Requires:       python311-Send2Trash >= 1.3.0
Requires:       python311-mutagen >= 1.44.0
Requires:       python311-polib >= 1.1.0
Requires:       python311-qt5 >= 5.14.1
Requires:       python311-xxhash >= 3.0.0
Requires:       python311-xml
# New requirement
Requires:       python311-semantic_version
%endif
%if 0%{?sle_version} == 150500 || 0%{?sle_version} == 150600 || 0%{?sle_version} == 160000 && 0%{?is_opensuse}
# openSUSE Leap 15.5 15.6 16.0
BuildRequires:  python3
BuildRequires:  python3-Sphinx
BuildRequires:  python3-Send2Trash
BuildRequires:  python3-polib
BuildRequires:  python3-mutagen
BuildRequires:  python3-distro
BuildRequires:  python3-qt5-devel
BuildRequires:  python3-xxhash
BuildRequires:  python3-pytest
BuildRequires:  python3-flake8
BuildRequires:  python3-black
Requires:       python3-send2trash
Requires:       python3-mutagen
Requires:       python3-polib
Requires:       python3-qt5
Requires:       python3-xxhash
Requires:       python3-xml
%endif
Provides:       dupeguru-me = %{version}
Provides:       dupeguru-pe = %{version}
Obsoletes:      dupeguru-me < 4.0.3
Obsoletes:      dupeguru-pe < 4.0.3

%description
dupeGuru is a tool to find duplicate files on your computer. It can scan
either filenames or contents. The filename scan features a fuzzy matching
algorithm that can find duplicate filenames even when they are not exactly
the same.

dupeGuru is good with music. It has a special Music mode that can scan tags
and shows music-specific information in the duplicate results window.

dupeGuru is good with pictures. It has a special Picture mode that can scan
pictures fuzzily, allowing you to find pictures that are similar, but not
exactly the same.

%prep
%setup -q
%if 0%{?suse_version} > 1600
sed -i -e 's|PYTHON ?= python3|PYTHON ?= python3.11|g' Makefile
%endif

%build
export NO_VENV=true PREFIX=%{_prefix}
%make_build

%install
cat > %{name}.desktop << EOF
[Desktop Entry]
Name=dupeGuru
GenericName=Duplicate Files Finder
GenericName[ru]=Поиск одинаковых файлов
Comment=Find duplicate files
Comment[ru]=Поиск одинаковых файлов
Type=Application
Exec=dupeguru
Icon=dupeguru
Categories=System;Utility;Filesystem;
Terminal=false
StartupNotify=true
EOF

install -dm 0755 %{buildroot}{%{_bindir}/,%{python311_sitearch}/%{name}/}
cp -R {core,hscommon,locale,qt} \
     %{buildroot}%{python311_sitearch}/%{name}/
install -m0755 run.py %{buildroot}%{python311_sitearch}/%{name}/

ln -s %{python311_sitearch}/%{name}/run.py %{buildroot}%{_bindir}/%{name}

rm -rf %{buildroot}%{python311_sitearch}/%{name}/qtlib/.tx/
rm -rf %{buildroot}%{python311_sitearch}/%{name}/qtlib/locale/
find %{buildroot}%{python311_sitearch}/%{name}/ -type f -name ".gitignore" -delete
find %{buildroot}%{python311_sitearch}/%{name}/ -type f -name "*.c" -delete
find %{buildroot}%{python311_sitearch}/%{name}/ -type f -name "*.h" -delete
find %{buildroot}%{python311_sitearch}/%{name}/ -type f -name "*.po" -delete
find %{buildroot}%{python311_sitearch}/%{name}/ -type f -name "*.pot" -delete

# byte compile.
%if 0%{?suse_version}
pushd %{buildroot}%{python311_sitearch}/%{name}/
%py3_compile .
popd
%endif
%if 0%{?fedora_version}
pushd %{buildroot}%{python3_sitearch}/%{name}/
%py_byte_compile %{python3} .
popd
%endif

install -Dm 644 images/dgse_logo_128.png \
    %{buildroot}%{_datadir}/icons/hicolor/128x128/apps/%{name}.png
for size in 96x96 64x64 48x48 32x32 22x22 16x16 ; do
install -dm 0755 \
    %{buildroot}%{_datadir}/icons/hicolor/${size}/apps
convert -strip -resize ${size} images/dgse_logo_128.png \
    %{buildroot}%{_datadir}/icons/hicolor/${size}/apps/%{name}.png
done

install -Dm 644 %{name}.desktop \
    %{buildroot}%{_datadir}/applications/%{name}.desktop

%fdupes -s %{buildroot}

%if 0%{?suse_version}
%find_lang columns
%find_lang core
%find_lang ui
%endif

%if 0%{?suse_version} && 0%{?suse_version} < 1330
%post
%icon_theme_cache_post

%postun
%icon_theme_cache_postun
%endif

%if 0%{?suse_version}
%files -f columns.lang -f core.lang -f ui.lang
%endif
%if 0%{?fedora_version}
%files
%endif
%license LICENSE
%doc CREDITS README.md
%{_bindir}/%{name}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/*/*/%{name}.*
%{python311_sitearch}/%{name}/

%changelog
openSUSE Build Service is sponsored by