## START: Set by rpmautospec
## (rpmautospec version 0.7.3)
## 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

%global _xinputconf %{_sysconfdir}/X11/xinit/xinput.d/fcitx5.conf
%global __provides_exclude_from ^%{_libdir}/%{name}/.*\\.so$

Name:           fcitx5
Version:        5.1.11
Release:        %autorelease
Summary:        Next generation of fcitx
# Automatically converted from old format: LGPLv2+ - review is highly recommended.
License:        LicenseRef-Callaway-LGPLv2+
URL:            https://github.com/fcitx/fcitx5
Source:         https://download.fcitx-im.org/fcitx5/fcitx5/fcitx5-%{version}_dict.tar.zst
Source1:        https://download.fcitx-im.org/fcitx5/fcitx5/fcitx5-%{version}_dict.tar.zst.sig
# Checked by chatting, this key is used to verify fcitx* tarballs
Source2:        https://pgp.key-server.io/download/0x8E8B898CBF2412F9
Source3:        fcitx5-xinput
Source4:        fcitx5.sh

BuildRequires:  cmake
BuildRequires:  ninja-build
BuildRequires:  gnupg2
BuildRequires:  desktop-file-utils
BuildRequires:  extra-cmake-modules
BuildRequires:  gcc-c++
BuildRequires:  systemd-rpm-macros
BuildRequires:  pkgconfig(cairo)
BuildRequires:  pkgconfig(cldr-emoji-annotation)
BuildRequires:  pkgconfig(dri)
BuildRequires:  pkgconfig(enchant-2)
BuildRequires:  pkgconfig(expat)
BuildRequires:  pkgconfig(fmt)
BuildRequires:  pkgconfig(gdk-pixbuf-2.0)
BuildRequires:  pkgconfig(iso-codes)
BuildRequires:  pkgconfig(json-c)
BuildRequires:  pkgconfig(pango)
BuildRequires:  pkgconfig(uuid)
BuildRequires:  pkgconfig(libsystemd)
BuildRequires:  pkgconfig(wayland-egl)
BuildRequires:  pkgconfig(wayland-client)
BuildRequires:  pkgconfig(wayland-protocols)
BuildRequires:  pkgconfig(xcb)
BuildRequires:  pkgconfig(xkbcommon-x11)
BuildRequires:  pkgconfig(xkbfile)
BuildRequires:  pkgconfig(xcb-ewmh)
BuildRequires:  pkgconfig(xcb-imdkit)
BuildRequires:  pkgconfig(xcb-icccm)
BuildRequires:  pkgconfig(xcb-keysyms)
BuildRequires:  pkgconfig(xkeyboard-config)
BuildRequires:  /usr/bin/appstream-util
Requires:       dbus-common
Requires:       %{name}-data = %{version}-%{release}
Requires:       %{name}-libs%{?_isa} = %{version}-%{release}
Requires:       setup
Requires(post):     %{_sbindir}/alternatives
Requires(postun):   %{_sbindir}/alternatives

Recommends:       (fcitx5-gtk if (gtk2 or gtk3 or gtk4))
Recommends:       (fcitx5-qt if (qt5-qtbase or qt6-qtbase))
Recommends:       (fcitx5-qt-module if (qt5-qtbase or qt6-qtbase))
Recommends:       fcitx5-configtool

%description
Fcitx 5 is a generic input method framework released under LGPL-2.1+.

%package libs
Summary:        Libraries for %{name}

%description libs
The %{name}-libs package contains runtime shared libraries necessary for
running programs using Fcitx5 libraries.

%package data
Summary:        Data files of Fcitx5
BuildArch:      noarch
# require with isa will lead to problem on koji build
Requires:       %{name} = %{version}-%{release}
Requires:       hicolor-icon-theme
Requires:       dbus

%description data
The %{name}-data package provides shared data for Fcitx5.

%package devel
Summary:        Development files for %{name}
Requires:       %{name}-libs%{?_isa} = %{version}-%{release}

%description devel
The %{name}-devel package contains libraries and header files necessary for
developing programs using Fcitx5 libraries.

%package autostart
Summary:        This package will make fcitx5 start with your GUI session
BuildArch:      noarch
Requires:       %{name} = %{version}-%{release}

%description autostart
This package will setup autostart and environment needed for fcitx5 to work properly.

%prep
%{gpgverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1}' --data='%{SOURCE0}'
%autosetup -p1

%build
%cmake -GNinja
%cmake_build 

%install
%cmake_install
install -pm 644 -D %{S:3} %{buildroot}%{_xinputconf}
install -pm 644 -D %{S:4} %{buildroot}%{_sysconfdir}/profile.d/fcitx5.sh
install -d                %{buildroot}%{_datadir}/%{name}/inputmethod
install -d                %{buildroot}%{_datadir}/%{name}/table
desktop-file-install --delete-original \
  --dir %{buildroot}%{_datadir}/applications \
  %{buildroot}%{_datadir}/applications/%{name}-configtool.desktop
 
desktop-file-install --delete-original \
  --dir %{buildroot}%{_datadir}/applications \
  %{buildroot}%{_datadir}/applications/org.fcitx.Fcitx5.desktop

desktop-file-install --delete-original \
  --dir %{buildroot}%{_datadir}/applications \
  %{buildroot}%{_datadir}/applications/%{name}-wayland-launcher.desktop
  
# convert symlinked icons to copied icons, this will help co-existing with
# fcitx4
for iconfile in $(find %{buildroot}%{_datadir}/icons -type l)
do
  origicon=$(readlink -f ${iconfile})
  rm -f ${iconfile}
  cp ${origicon} ${iconfile}
done 
appstream-util validate-relax --nonet %{buildroot}%{_metainfodir}/*.metainfo.xml
%find_lang %{name}

%check
%ctest

%post
%{_sbindir}/alternatives --install %{_sysconfdir}/X11/xinit/xinputrc xinputrc %{_xinputconf} 55 || :

%postun
if [ "$1" = "0" ]; then
  %{_sbindir}/alternatives --remove xinputrc %{_xinputconf} || :
  # if alternative was set to manual, reset to auto
  [ -L %{_sysconfdir}/alternatives/xinputrc -a "`readlink %{_sysconfdir}/alternatives/xinputrc`" = "%{_xinputconf}" ] && %{_sbindir}/alternatives --auto xinputrc || :
fi

%files -f %{name}.lang
%license LICENSES/LGPL-2.1-or-later.txt
%doc README.md 
%config %{_xinputconf}
%{_bindir}/%{name}
%{_bindir}/%{name}-configtool
%{_bindir}/%{name}-remote
%{_bindir}/%{name}-diagnose
%{_libdir}/%{name}/
%{_libexecdir}/fcitx5-wayland-launcher
%{_sysconfdir}/xdg/Xwayland-session.d/20-fcitx-x11

%files libs
%license LICENSES/LGPL-2.1-or-later.txt
%{_libdir}/libFcitx5*.so.*.*
%{_libdir}/libFcitx5Config.so.6
%{_libdir}/libFcitx5Core.so.7
%{_libdir}/libFcitx5Utils.so.2

%files devel
%{_includedir}/Fcitx5/
%{_libdir}/cmake/Fcitx5*
%{_libdir}/libFcitx5*.so
%{_libdir}/pkgconfig/Fcitx5*.pc


%files data
%{_datadir}/%{name}
%{_datadir}/dbus-1/services/org.fcitx.Fcitx5.service
%{_datadir}/applications/org.fcitx.Fcitx5.desktop
%{_metainfodir}/org.fcitx.Fcitx5.metainfo.xml
%{_datadir}/applications/%{name}-configtool.desktop
%{_datadir}/applications/%{name}-wayland-launcher.desktop
%{_datadir}/icons/hicolor/*/apps/*

%files autostart
%config %{_sysconfdir}/xdg/autostart/org.fcitx.Fcitx5.desktop
%config %{_sysconfdir}/profile.d/fcitx5.sh

%changelog
## START: Generated by rpmautospec
* Thu Oct 10 2024 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.11-1
- update to upstream release 5.1.11

* Sat Oct 05 2024 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.10-5
- Also detect qt6 plugin in xinput script (#2316572)

* Wed Aug 28 2024 Miroslav Suchý <msuchy@redhat.com> - 5.1.10-4
- convert license to SPDX

* Mon Jul 22 2024 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.10-3
- Disable xinput on Wayland (RHBZ#2256267)

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

* Sat Jun 01 2024 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.10-1
- update to upstream release 5.1.10

* Tue Apr 23 2024 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.9-1
- update to upstream release 5.1.9

* Fri Mar 01 2024 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.8-1
- update to upstream release 5.1.8

* Wed Jan 24 2024 Fedora Release Engineering <releng@fedoraproject.org> - 5.1.7-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

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

* Wed Jan 17 2024 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.7-1
- update to upstream release 5.1.7

* Fri Jan 05 2024 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.6-1
- update to upstream release 5.1.6

* Tue Nov 14 2023 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.5-1
- update to upstream release 5.1.5

* Mon Nov 06 2023 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.4-1
- update to upstream release 5.1.4

* Sat Nov 04 2023 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.3-1
- update to upstream release 5.1.3

* Thu Nov 02 2023 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.2-1
- update to upstream release 5.1.2

* Fri Oct 20 2023 Yaakov Selkowitz <yselkowi@redhat.com> - 5.1.1-3
- Separate libs subpackage

* Tue Oct 10 2023 Yaakov Selkowitz <yselkowi@redhat.com> - 5.1.1-2
- Use enchant2

* Mon Oct 02 2023 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.1-1
- update to upstream release 5.1.1

* Fri Aug 18 2023 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.0-1
- update to upstream release 5.1.0

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

* Wed Jun 28 2023 Vitaly Zaitsev <vitaly@easycoding.org> - 5.0.23-2
- Rebuilt due to fmt 10 update.

* Sat Mar 18 2023 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.23-1
- update to upstream release 5.0.23

* Sun Mar 12 2023 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.22-1
- update to upstream release 5.0.22

* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 5.0.21-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Fri Nov 25 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.21-1
- update to upstream release 5.0.21

* Mon Nov 21 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.20-1
- update to upstream release 5.0.20

* Tue Aug 30 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.19-1
- update to upstream release 5.0.19

* Sun Aug 28 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.18-3
- add weak dep: fcitx5-configtool (#2122011)

* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 5.0.18-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Mon Jul 04 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.18-1
- update to upstream release 5.0.18

* Fri Jun 10 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.17-2
- Update using upstream's new 5.0.17 tarball

* Thu Jun 02 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.17-1
- update to upstream release 5.0.17

* Mon May 23 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.16-1
- update to upstream release 5.0.16

* Sat Mar 26 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.15-2
- fix env for xim

* Thu Mar 10 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.15-1
- update to upstream release 5.0.15

* Wed Feb 16 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.14-5
- fix weak deps

* Wed Feb 02 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.14-4
- use Suggests instead to workaround an updating issue

* Wed Feb 02 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.14-3
- Add fcitx5-wayland-launcher

* Wed Feb 02 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.14-2
- update sources

* Wed Feb 02 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.14-1
- update to upstream release 5.0.14

* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 5.0.13-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Tue Jan 11 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.13-1
- update to 5.0.13

* Sun Jan 02 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.12-1
- update to 5.0.12

* Sun Dec 05 2021 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.11-1
- update to 5.0.11

* Sat Nov 06 2021 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.10-1
- update to 5.0.10

* Sun Sep 26 2021 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.9-1
- update to 5.0.9

* Wed Jul 21 2021 Fedora Release Engineering <releng@fedoraproject.org> - 5.0.8-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Sat Jul 10 2021 Björn Esser <besser82@fedoraproject.org> - 5.0.8-4
- Rebuild for versioned symbols in json-c

* Thu Jul 01 2021 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.8-3
- Cleanup dependences

* Fri May 07 2021 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.8-2
- Workaround a flatpak problem

* Wed May 05 2021 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.8-1
- Update to 5.0.8 upstream release

* Tue Mar 23 2021 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.7-1
- Update to 5.0.7 upstream release

* Mon Mar 22 2021 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.6-1
- Update to 5.0.6 upstream release

* Sat Feb 20 2021 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.5-1
- update to 5.0.5 upstream release

* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 5.0.4-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Wed Jan 13 12:19:25 CST 2021 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.4-2
- use conditional suggests

* Tue Jan 12 21:48:18 CST 2021 yan - 5.0.4-1
- update to 5.0.4 upstream release

* Fri Dec 11 16:49:42 CST 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.3-3
- fix conlict with fcitx4

* Wed Dec  9 00:25:45 CST 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.3-2
- explicit Conflicts against fcitx-data

* Mon Dec  7 10:40:52 CST 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.3-1
- Update to 5.0.3 upstream release

* Sat Dec  5 15:14:08 CST 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.2-2
- add weak dep to im-modules

* Sat Dec  5 13:30:48 CST 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.2-1
- Update to 5.0.2 upstream release

* Tue Nov  3 21:20:30 CST 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.1-2
- add fcitx5-autostart package to auto setup env and autostart

* Tue Nov  3 18:00:49 CST 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.1-1
- update to 5.0.1 upstream release

* Sat Oct 31 22:01:00 CST 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 0-0.10
- update to a5a0551a22971738283fc4812d2afe77efb626e3 upstream commit
- upstream added dbus service

* Fri Oct 16 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 0-0.9.20201016gitdd9dc94
- update to dd9dc94c42ee98ea04782bdb4d4aa3f7822e56f0 upstream commit

* Wed Sep 16 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 0-0.8
- upstream commit 5415db391c1b84ea9964b0d508c053ae5c25e4aa

* Sat Sep 12 2020 Karuboniru <yanqiyu01@gmail.com> - 0-0.7
- Drop imsetting
- Update to commit d0383bc4a8e65e71189c18e31f7b832e543144c1
- sobump from libFcitx5Core.so.6 to libFcitx5Core.so.7

* Wed Sep  2 08:44:37 CST 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 0-0.6
- Fix a typo

* Tue Sep  1 09:07:22 CST 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 0-0.5.20200830git4706f37
- Own /usr/share/fcitx5/inputmethod

* Sun Aug 30 23:39:20 CST 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 0-0.4.20200830git4706f37
- rebuild to push to f32

* Sun Aug 30 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 0-0.3.20200830git4706f37
- update to commit 4706f37e60686d391a7f9a45ca1be6df6052ec4d
- fix a wrong xinputrc file

* Sun Aug 16 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 0-0.2.20200813git87fb655
- change according to review suggestions

* Thu Aug 13 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 0-0.1.20200813git87fb655
- new version

* Wed Aug 12 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 0-0.1.20200811gitc87ea48
- initial package

## END: Generated by rpmautospec