Name: gnupg2
Version: 2.4.3
Release: 6
Summary: Utility for secure communication and data storage

License: GPLv3+
URL: https://gnupg.org/
Source0: https://www.gnupg.org/ftp/gcrypt/gnupg/gnupg-%{version}.tar.bz2
Source1: https://www.gnupg.org/ftp/gcrypt/gnupg/gnupg-%{version}.tar.bz2.sig

Patch0:  gnupg-2.1.10-secmem.patch
Patch1:  gnupg-2.1.1-fips-algo.patch
Patch2:  gnupg-2.2.23-large-rsa.patch
Patch4:  gnupg-2.2.18-gpg-accept-subkeys-with-a-good-revocation-but-no-self-sig.patch
Patch5:  gnupg-2.2.18-gpg-allow-import-of-previously-known-keys-even-without-UI.patch
Patch6:  gnupg-2.2.18-tests-add-test-cases-for-import-without-uid.patch
Patch7:  gnupg-2.2.20-file-is-digest.patch
Patch8:  gnupg-2.2.21-coverity.patch
Patch9:  gnupg2-revert-rfc4880bis.patch
Patch10: backport-dirmngr-Enable-the-call-of-ks_ldap_help_variables-wh.patch
Patch11: backport-gpg-Make-no-literal-work-again-for-c-and-store.patch
Patch12: backport-gpg-Fix-minor-memory-leak-during-certain-smartcard-o.patch
Patch13: supports-sm2-algorithm-signature-and-uses-sm3-hash-algorithm.patch

BuildRequires: gcc
BuildRequires: autoconf automake
BuildRequires: zlib-devel, npth-devel, texinfo
BuildRequires: libgpg-error-devel >= 1.46
BuildRequires: libgcrypt-devel >= 1.10.2-3
BuildRequires: libksba-devel >= 1.6.3
BuildRequires: libassuan-devel >= 2.5.0
# compile dirmngr module, need gnutls
BuildRequires: gnutls-devel gettext-devel

Requires: libgcrypt >= 1.10.2-3
Requires: libgpg-error >= 1.46

Recommends: pinentry
Recommends: gnupg2-smime

Provides: gpg = %{version}-%{release}
Provides: gnupg = %{version}-%{release}
Provides: dirmngr = %{version}-%{release}
Provides: gnupg2-smime = %{version}-%{release}

Obsoletes: gnupg <= 1.4.24
Obsoletes: dirmngr < 1.2.0-1
Obsoletes: gnupg2-smime <  %{version}-%{release}

%description
GnuPG is a complete and free implementation of the OpenPGP standard
as defined by RFC4880 (also known as PGP).  GnuPG enables encryption
and signing of data and communication, and features a versatile key
management system as well as access modules for public key
directories.

GnuPG 2.0 adds support for smart cards and S/MIME encryption and
signing to the base GnuPG package.

%package_help

%prep
%autosetup -n gnupg-%{version} -p1
autoreconf -f

%global pcsclib %(basename $(ls -1 %{_libdir}/libpcsclite.so.? 2>/dev/null ) 2>/dev/null )

sed -i -e 's/"libpcsclite\.so"/"%{pcsclib}"/' scd/scdaemon.c

%build
# add --disable-ccid-driver to solve #2005714
# disable tpm2 module
%configure \
  --disable-rpath \
  --enable-g13 \
  --disable-ccid-driver \
  --disable-tpm2d \
  --enable-large-secmem \
  --enable-sm2

%make_build

%install
%make_install

%find_lang %{name}

mkdir -p %{buildroot}%{_sysconfdir}/gnupg
touch %{buildroot}%{_sysconfdir}/gnupg/gpgconf.conf

ln -sf gpg %{buildroot}%{_bindir}/gpg2
ln -sf gpgv %{buildroot}%{_bindir}/gpgv2
ln -sf gpg.1 %{buildroot}%{_mandir}/man1/gpg2.1
ln -sf gpgv.1 %{buildroot}%{_mandir}/man1/gpgv2.1
ln -sf gnupg.7 %{buildroot}%{_mandir}/man7/gnupg2.7

rm -f %{buildroot}%{_infodir}/dir

%check
make check

%files -f %{name}.lang
%defattr(-,root,root)
%license COPYING
%doc README AUTHORS
%dir %{_sysconfdir}/gnupg
%ghost %config(noreplace) %{_sysconfdir}/gnupg/gpgconf.conf
%{_bindir}/gpg*
%{_bindir}/g13
%{_bindir}/dirmngr*
%{_bindir}/watchgnupg
%{_bindir}/kbxutil
%{_sbindir}/*
%{_libexecdir}/*


%files help
%defattr(-,root,root)
%doc NEWS TODO THANKS
%{_infodir}/*info*.gz
%{_datadir}/gnupg/
%{_datadir}/doc/gnupg/*
%exclude %{_datadir}/gnupg/sks-keyservers.netCA.pem
%{_mandir}/man?/*


%changelog
* Tue Jan 21 2025 Jia Chao <jiac13@chinaunicom.cn> - 2.4.3-6
- Fix: add autoconf, automake to buildrequires.

* Sat Oct 26 2024 zhengxiaoxiao <zhengxiaoxiao2@huawei.com> - 2.4.3-5
- Supports sm2 algorithm signature and uses sm3 hash algorithm.

* Mon Sep 30 2024 yixiangzhike <yixiangzhike007@163.com> - 2.4.3-4
- backport upstream patch to fix minor memory leak

* Wed Sep 25 2024 yixiangzhike <yixiangzhike007@163.com> - 2.4.3-3
- gpg Make --no-literal work again for -c and --store

* Tue Jan 2 2024 yixiangzhike <yixiangzhike007@163.com> - 2.4.3-2
- use gpgtar to replace gpg-zip

* Mon Jul 17 2023 yixiangzhike <yixiangzhike007@163.com> - 2.4.3-1
- update to 2.4.3

* Wed Jun 14 2023 yixiangzhike <yixiangzhike007@163.com> - 2.3.6-4
- backport upstream patch

* Mon Aug 15 2022 yixiangzhike <yixiangzhike007@163.com> - 2.3.6-3
- fix CVE-2022-34903

* Wed Jul 6 2022 yixiangzhike <yixiangzhike007@163.com> - 2.3.6-2
- cleanup unused patch files

* Mon Jun 27 2022 yixiangzhike <yixiangzhike007@163.com> - 2.3.6-1
- update to 2.3.6, need require new version libgpg-error(1.41) and libgcrypt(1.9.4)
- do not provide unused sks-keyserver CA certificate

* Mon Jan 10 2022 yixiangzhike <yixiangzhike007@163.com> - 2.3.4-1
- update to 2.3.4

* Mon Aug 2 2021 yixiangzhike <zhangxingliang3@huawei.com> - 2.2.27-4
- fix the insttools patch

* Mon Jul 26 2021 zoulin <zoulin13@huawei.com> - 2.2.27-3
- remove unnecessary BuildRequires:gdb

* Wed May 26 2021 yixiangzhike <zhangxingliang3@huawei.com> - 2.2.27-2
- add gcc to BuildRequires

* Thu Jan 28 2021 yixiangzhike <zhangxingliang3@huawei.com> - 2.2.27-1
- update to 2.2.27

* Thu Sep 10 2020 zhangxingliang <zhangxingliang3@huawei.com> - 2.2.21-3
- fix AEAD preference list overflow for CVE-2020-25125

* Tue Aug 4 2020 wangchen <wangchen137@huawei.com> - 2.2.21-2
- fix undefined shift in block_filter()

* Sat Jul 25 2020 yang_zhuang_zhuang <yangzhuangzhuang1@huawei.com> - 2.2.21-1
- update version to 2.2.21

* Wed Jun 3 2020 Anakin Zhang <nbztx@126.com> - 2.2.17-7
- fix a memory leak in g10

* Wed Apr 22 2020 Anakin Zhang <nbztx@126.com> - 2.2.17-6
- fix CVE-2019-14855

* Sat Mar 14 2020 openEuler Buildteam <buildteam@openeuler.org> - 2.2.17-5
- Add build requires of gdb

* Fri Jan 10 2020 openEuler Buildteam <buildteam@openeuler.org> - 2.2.17-4
- clean code

* Fri Oct 25 2019 openEuler Buildteam <buildteam@openeuler.org> - 2.2.17-3
- add gpg and gpgv

* Thu Oct 24 2019 openEuler Buildteam <buildteam@openeuler.org> - 2.2.17-2
- add symlinks

* Thu Sep 12 2019 openEuler Buildteam <buildteam@openeuler.org> - 2.2.17-1
- Package init
