%define __cmake_in_source_build 1
%bcond_with clang

Name:           lxqt-archiver
Version:        0.9.0
Release:        1%{dist}
Summary:        LXQt File Archiver
License:        GPL-2.0-or-later
Group:          System/GUI/LXQt
URL:            http://www.lxqt.org
Source0:        https://github.com/lxqt/%{name}/releases/download/%{version}/%{name}-%{version}.tar.xz
Source1:        %{name}.appdata.xml
BuildRequires:  cmake
%if %{with clang}
BuildRequires: clang >= 5.0
%else
BuildRequires: gcc-c++
%endif
BuildRequires:  libexif-devel
BuildRequires:  libarchive-devel
BuildRequires:  qt5-linguist
BuildRequires:  lxqt-build-tools >= 0.13.0
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(Qt5UiTools)
BuildRequires:  pkgconfig(Qt5Widgets) >= 5.15.0
BuildRequires:  pkgconfig(Qt5X11Extras)
BuildRequires:  pkgconfig(glib-2.0) >= 2.50.0
BuildRequires:  pkgconfig(json-glib-1.0)
BuildRequires:  pkgconfig(libfm-qt) >= 1.4.0
Requires(post): desktop-file-utils
Requires(pre):  desktop-file-utils
BuildRequires: json-glib-devel
BuildRequires: libexif-devel
BuildRequires: libappstream-glib

%description
LXQt file archiver.

%package l10n
Summary:        Translations for lxqt-archiver
Requires:       lxqt-archiver
%description l10n
This package provides translations for the lxqt-archiver package.

%prep
%setup -q

%build
%{__mkdir} -p %{_target_platform}

%if %{with clang}
export CC=clang
export CXX=clang++
%endif

pushd %{_target_platform}
%{cmake_lxqt} \
    ..

%cmake_build
popd

%install
pushd %{_target_platform}
  %cmake_install
popd

desktop-file-edit \
    --remove-category=LXQt --add-category=X-LXQt \
    %{buildroot}%{_datadir}/applications/%{name}.desktop
mkdir -p %{buildroot}%{_datadir}/lxqt/translations/%{name}

mkdir -p %{buildroot}%{_metainfodir}/
cp %{SOURCE1} %{buildroot}%{_metainfodir}/
appstream-util validate-relax --nonet %{buildroot}%{_metainfodir}/*.appdata.xml

%find_lang %{name} --with-qt

%files
%license LICENSE
%doc AUTHORS CHANGELOG README.md
%{_bindir}/lxqt-archiver
%{_datadir}/applications/lxqt-archiver.desktop
%dir %{_datadir}/icons/hicolor/
%dir %{_datadir}/icons/hicolor/scalable/
%dir %{_datadir}/icons/hicolor/scalable/apps/
%{_datadir}/icons/hicolor/scalable/apps/lxqt-archiver.svg
%{_metainfodir}/%{name}.appdata.xml

%files l10n -f %{name}.lang
%dir %{_datadir}/lxqt-archiver/
%dir %{_datadir}/lxqt-archiver/translations/
%{_datadir}/lxqt-archiver/translations/*.qm

%changelog
* Mon Nov  6 2023 Raven <raven@sysadmins.ws> - 0.9.0-1
- update to 0.9.0
- clang support

* Thu May 18 2023 Raven <raven@sysadmins.ws> - 0.8.0-1
- update to 0.8.0

* Fri Nov 11 2022 Raven <raven@sysadmins.ws> - 0.7.0-1
- update to 0.7.0

* Mon Nov 08 2021 Raven <raven@sysadmins.ws> - 0.5.0-1
- update to 0.5.0
- drop RHEL7 support

* Tue Jan 26 2021 Raven <raven@sysadmins.ws> - 0.3.0-1
- version update

* Tue Jun 16 2020 Raven <raven@sysadmins.ws> - 0.2.0-1
- version update

* Mon May 18 2020 Callum Farmer <callumjfarmer13@gmail.com>
- Removed Recommends lxqt-archiver-lang due to auto supplements
* Sun May 17 2020 Michael Vetter <mvetter@suse.com>
- Update to 0.2.0:
  * Added an icon for the app.
  * Prevent the contents of an extracted archive from being mixed
    with other files if overwriting isn't chosen.
  * Added expand and collapse actions.
  * Fixed build with GCC 10.
  * Required json-glib as a dependency.
- Remove lxqt-archiver.desktop:
  use upstream desktop file. It has its own icon now.
  See https://github.com/lxqt/lxqt-archiver/issues/157
* Fri May 15 2020 Callum Farmer <callumjfarmer13@gmail.com>
- Fixed sources and added keyring
* Sat Apr 25 2020 Callum Farmer <callumjfarmer13@gmail.com>
- Removed lxqt-archiver-execdir.patch: contained in upstream
- Update to version 0.1.1
  * Removed the unused qtdbus dependency.
  * Used 'LIBEXECDIR' instead of 'LIBDIR' for internal executables.
  * Fixed handling of RPM archives.
* Wed Apr 22 2020 Michael Vetter <mvetter@suse.com>
- Add lxqt-archiver-execdir.patch: install in helper programs
  in libexecdir not libdir
* Wed Apr 22 2020 Michael Vetter <mvetter@suse.com>
- Create package 0.1.0 for openSUSE
