## START: Set by rpmautospec
## (rpmautospec version 0.7.2)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 1;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

# Fedora 40+ ships with KDE 6, so the Qt6 build is preferred
%if 0%{?fedora} >= 40
%bcond_without qt6
%else
%bcond_with    qt6
%endif

Name:           chessx
Version:        1.6.2
Release:        %autorelease
Summary:        Chess Database and PGN viewer

# Various parts of code are annotated with different licenses:
# - GNU General Public License (dep/scid/code/src/*)
# - GNU General Public License v2.0 or later (src/*)
# - GNU General Public License, Version 2 (COPYING and License.txt)
# - GNU General Public License, Version 3 (src/gui/messagedialog.cpp)
# - GNU Lesser General Public License, Version 2.1 (src/gui/qled.*)
# - Expat License (dep/scid/code/src/bytebuf.h)
# - BSD 3-clause "New" or "Revised" License (src/database/downloadmanager.*)
# - LGPL (v2.1 or v3) (src/gui/textedit.*)
# In the License field below only the minimal effective license set is
# documented.
License:        GPL-2.0-only AND GPL-3.0-only
URL:            https://sourceforge.net/projects/chessx/
Source0:        https://downloads.sourceforge.net/%{name}/%{name}-%{version}.tgz

# (downstream patch)
Patch001:       0001-Work-around-Qt-Wayland-integration-issue.patch
# https://github.com/Isarhamster/chessx/pull/61
Patch002:       0002-Fix-install-path-of-icons-on-Linux.patch
# https://github.com/Isarhamster/chessx/pull/63
Patch003:       0003-Allow-linking-against-system-libraries-via-pkg-confi.patch

BuildRequires:  gcc-c++
%if %{with qt6}
BuildRequires:  pkgconfig(Qt6Core)
BuildRequires:  pkgconfig(Qt6Svg)
BuildRequires:  pkgconfig(Qt6Multimedia)
BuildRequires:  pkgconfig(quazip1-qt6)
BuildRequires:  qt6-linguist
%else
BuildRequires:  pkgconfig(Qt5Core)
BuildRequires:  pkgconfig(Qt5Svg)
BuildRequires:  pkgconfig(Qt5Multimedia)
BuildRequires:  pkgconfig(quazip1-qt5)
BuildRequires:  qt5-linguist
%endif
BuildRequires:  pkgconfig(zlib)
BuildRequires:  desktop-file-utils
BuildRequires:  libappstream-glib

# Bundles part of scid 1.0 (https://sourceforge.net/projects/scid/)
Provides:       bundled(scid) = 1.0

%description
ChessX is a free and open source chess database application for Linux, Mac OS X
and Windows.


%prep
%autosetup -p1 -n %{name}-master

# Ensure bundled quazip code is not used
rm -rf src/quazip

# Remove executable bit from regular files (the tarball is buggy)
chmod -R -x+X .


%build
%if %{with qt6}
%qmake_qt6 \
%else
%qmake_qt5 \
%endif
    -r CONFIG+=link_pkgconfig PREFIX=%{_prefix}
%make_build


%install
%make_install INSTALL_ROOT=%{buildroot}


%check
# Make sure the .metainfo.xml file passes validation
appstream-util validate-relax --nonet \
    %{buildroot}%{_metainfodir}/io.sourceforge.ChessX.metainfo.xml


%files
%license COPYING.md
%doc README.md ChangeLog.md
%{_bindir}/chessx
%{_datadir}/applications/chessx.desktop
%{_datadir}/icons/hicolor/256x256/apps/chessx.png
%{_datadir}/icons/hicolor/64x64/apps/chessx.png
%{_datadir}/icons/hicolor/32x32/apps/chessx.png
%{_metainfodir}/io.sourceforge.ChessX.metainfo.xml


%changelog
## START: Generated by rpmautospec
* Sat Sep 07 2024 Ondrej Mosnáček <omosnacek@gmail.com> - 1.6.2-1
- Update to version 1.6.2 (fedora#2310496)

* Thu Aug 08 2024 Ondrej Mosnáček <omosnacek@gmail.com> - 1.6.0-2
- Build against Qt6 on Fedora >=40

* Thu Aug 08 2024 Ondrej Mosnáček <omosnacek@gmail.com> - 1.6.0-1
- Update to version 1.6.0

* Wed Aug 07 2024 Yaakov Selkowitz <yselkowi@redhat.com> - 1.5.8-7
- Fix flatpak build

* Wed Jul 17 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.8-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Tue Jan 23 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.8-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Fri Jan 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.8-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Wed Jul 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.8-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Fri May 05 2023 Nicolas Chauvet <kwizart@gmail.com> - 1.5.8-2
- Rebuilt for quazip 1.4

* Thu Feb 02 2023 Ondrej Mosnáček <omosnacek@gmail.com> - 1.5.8-1
- Update to version 1.5.8

* Wed Feb 01 2023 Ondrej Mosnáček <omosnacek@gmail.com> - 1.5.6-15
- Convert License field to SPDX

* Wed Feb 01 2023 Ondrej Mosnáček <omosnacek@gmail.com> - 1.5.6-14
- Switch to rpmautospec

* Wed Jan 18 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.6-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Wed Jul 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.6-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Mon Apr 18 2022 Miro Hrončok <mhroncok@redhat.com> - 1.5.6-7
- Rebuilt for quazip 1.3

* Wed Jan 19 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.6-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Wed Jul 28 2021 Ondrej Mosnacek <omosnace@redhat.com> - 1.5.6-5
- Unbundle the quazip library

* Mon Jul 26 2021 Ondrej Mosnacek <omosnace@redhat.com> - 1.5.6-4
- Work around Wayland issue

* Wed Jul 07 2021 Ondrej Mosnacek <omosnace@redhat.com> - 1.5.6-3
- Install metadata and icons from upstream

* Sun Jun 13 2021 Ondrej Mosnacek <omosnace@redhat.com> - 1.5.6-2
- Add a desktop file and icon

* Sun Jun 06 2021 Ondrej Mosnacek <omosnace@redhat.com> - 1.5.6-1
- Update to version 1.5.6

* Sun Apr 19 2020 Ondrej Mosnacek <omosnace@redhat.com> - 1.5.0-1
- Initial version

## END: Generated by rpmautospec