Name:           gpgme
Version:        1.17.0
Release:        2
Summary:        GnuPG Made Easy
License:        GPLv2+ and LGPLv2+
URL:            https://gnupg.org/related_software/gpgme/
Source0:        https://gnupg.org/ftp/gcrypt/gpgme/gpgme-%{version}.tar.bz2

# upstream patches
# Don't add extra libs/cflags in gpgme-config/cmake equivalent
Patch0:         0001-don-t-add-extra-libraries-for-linking.patch
# add -D_FILE_OFFSET_BITS... to gpgme-config, upstreamable
Patch1:         gpgme-1.3.2-largefile.patch
# Let's fix stupid AX_PYTHON_DEVEL
Patch2:         0001-fix-stupid-ax_python_devel.patch
# support python3.10
Patch3:         gpgme-Add-support-for-building-with-Python3.10.patch

BuildRequires:  autoconf automake gcc gcc-c++ gawk gnupg2 >= 2.2.24
BuildRequires:  libgpg-error-devel >= 1.36 libassuan-devel >= 2.4.2
BuildRequires:  swig chrpath cmake qt5-qtbase-devel python3-devel
Requires:       gnupg2 >= 2.2.24
Provides:       %{name}%{?_isa} <= %{version}-%{release}


%description
GnuPG Made Easy (GPGME) is a library designed to make access to GnuPG
easier for applications.  It provides a high-level crypto API for
encryption, decryption, signing, signature verification and key
management.
This package provides C/C++/Qt/Python API support for GPGME.

%package -n cpp-%{name}
Summary:        C++ API wrapper for GPGME
Requires:       %{name} = %{version}-%{release}
Obsoletes:      gpgme-pp < 1.8.0-7
Obsoletes:      %{name}pp
Provides:       gpgme-pp = %{version}-%{release} 
Provides:       gpgme-pp%{?_isa} = %{version}-%{release}
Provides:       %{name}pp%{?_isa} <= %{version}-%{release}

%description -n cpp-%{name}
%{summary}.

%package -n qt-%{name}
Summary:        Qt API wrapper for GPGME
Requires:       cpp-%{name} = %{version}-%{release}
Obsoletes:      q%{name}
Provides:       q%{name}

%description -n qt-%{name}
%{summary}.

%package -n python3-%{name}
Summary:        %{name} bindings for Python3
%{?python_provide:%python_provide python3-gpg}
Requires:       %{name} = %{version}-%{release}
Obsoletes:      platform-python-gpg < %{version}-%{release}
Obsoletes:      python3-gpg
Provides:       python3-gpg

%description -n python3-%{name}
%{summary}.

%package devel
Summary:        Development headers and libraries for %{name}
Requires:       %{name} = %{version}-%{release} libgpg-error-devel >= 1.36 info
Obsoletes:      gpgme-pp-devel < 1.8.0-7 %{name}pp-devel q%{name}-devel
Provides:       gpgme-pp-devel = %{version}-%{release} %{name}pp-devel q%{name}-devel
Obsoletes:      %{name}pp-devel q%{name}-devel
provides:       %{name}pp-devel q%{name}-devel

%description devel
%{summary}.

%package help
Summary:        GPGME help info
BuildArch:      noarch

%description help
%{summary}.

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

%build
%configure --disable-static --disable-silent-rules --enable-languages=cpp,qt,python
%make_build

%install
# python-setuptools >= v60.0.0 changes the SETUPTOOLS_USE_DISTUTILS default value to local,
# it does't use Python's standard library distutils default.
# As a result, failed to build gpgme.
# Now, set SETUPTOOLS_USE_DISTUTILS value to stdlib
export SETUPTOOLS_USE_DISTUTILS=stdlib
%make_install

chrpath -d  $(find %{buildroot} -name gpgme-json)

# Delete unpackaged files
rm -fv %{buildroot}%{_infodir}/dir
rm -fv %{buildroot}%{_libdir}/lib*.la

chrpath -d %{buildroot}%{_bindir}/%{name}-tool
chrpath -d %{buildroot}%{_libdir}/lib%{name}pp.so*
chrpath -d %{buildroot}%{_libdir}/libq%{name}.so*

%check
make check

%ldconfig_scriptlets

%post help
/sbin/install-info %{_infodir}/%{name}.info %{_infodir}/dir 2>/dev/null || :

%preun help
if [ $1 -eq 0 ] ; then
  /sbin/install-info --delete %{_infodir}/%{name}.info %{_infodir}/dir 2>/dev/null || :
fi

%files
%defattr(-,root,root)
%license COPYING*
%doc AUTHORS ChangeLog NEWS README THANKS TODO VERSION
%{_bindir}/%{name}-json
%{_libdir}/lib%{name}.so.11*

%files -n cpp-%{name}
%doc lang/cpp/README
%{_libdir}/lib%{name}pp.so.*

%files -n qt-%{name}
%doc lang/qt/README
%{_libdir}/libq%{name}.so.*

%files -n python3-%{name}
%doc lang/python/README
%{python3_sitearch}/gpg-*.egg-info
%{python3_sitearch}/gpg/

%files devel
%defattr(-,root,root)
%{_bindir}/{%{name}-config,%{name}-tool}
%{_includedir}/{%{name}.h,%{name}++/,q%{name}/,QGpgME/}
%{_libdir}/{lib%{name}.so,lib%{name}pp.so,cmake/Gpgmepp/,libq%{name}.so,cmake/QGpgme/}
%{_datadir}/aclocal/%{name}.m4
%{_libdir}/pkgconfig/%{name}*.pc
%files help
%defattr(-,root,root)
%{_infodir}/%{name}.info*


%changelog
* Mon Apr 10 2023 lilong <lilong@kylinos.cn> - 1.17.0-2
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:Add gpgme.pc file

* Wed Aug 3 2022 yixiangzhike <yixiangzhike007@163.com> - 1.17.0-1
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:update to 1.17.0

* Tue Jul 26 2022 yixiangzhike <yixiangzhike007@163.com> - 1.16.0-2
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:fix the gpgme build failure issue

* Mon Jan 24 2022 yixiangzhike <yixiangzhike007@163.com> - 1.16.0-1
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:update to 1.16.0

* Tue Aug 10 2021 yixiangzhike <zhangxingliang3@huawei.com> - 1.15.1-3
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:fix the compilation failure with new version glibc (glibc-2.34)

* Thu Jul 22 2021 yangzhuangzhuang <yangzhuangzhuang1@huawei.com> - 1.15.1-2
- Type:enhancement
- CVE:NA
- SUG:NA
- DESC:Remove unnecessary buildrequires:gdb

* Sat Jan 23 2021 panxiaohe <panxiaohe@huawei.com> - 1.15.1-1
- Type:enhancement
- CVE:NA
- SUG:NA
- DESC:update to 1.15.1

* Thu Oct 29 2020 zhangxingliang <zhangxingliang3@huawei.com> - 1.14.0-2
- Type:requirement
- CVE:NA
- SUG:NA
- DESC:remove python2 subpackage

* Mon Jul 27 2020 zhangxingliang <zhangxingliang3@huawei.com> - 1.14.0-1
- Type:update
- ID:NA
- SUG:NA
- DESC:update to 1.14.0

* Thu Mar 19 2020 openEuler Buildteam <buildteam@openeuler.org> - 1.13.1-5
- add BuildRequires: gdb

* Fri Sep 20 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.13.1-4
- Adjust buildrequires as gnupg2-smime is provided by gnupg2

* Fri Sep 20 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.13.1-3
- Delete redundant information

* Wed Sep 4 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.13.1-2
- Delete postfix '_isa' for Provides symbols

* Tue Sep 3 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.13.1-1
- Package init
