Name: gnupg2
Version: 2.2.17
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: fix-CVE-2019-14855-0-Ignore-all-SHA-1-3rd-party-key-sig.patch
Patch1: fix-CVE-2019-14855-1-Add-option-allow-weak-key-signatures.patch
Patch2: fix-CVE-2019-14855-2-Forbid-creation-of-SHA-1-3rd-party-key-sig.patch

BuildRequires: zlib-devel, npth-devel, gdb, texinfo
BuildRequires: libgpg-error-devel >= 1.31
BuildRequires: libgcrypt-devel >= 1.7.0
BuildRequires: libksba-devel >= 1.3.0
BuildRequires: libassuan-devel >= 2.1.0

Requires: libgcrypt >= 1.7.0
Requires: libgpg-error >= 1.31

Recommends: pinentry
Recommends: gnupg2-smime

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

Obsoletes: gnupg <= 1.4.24
Obsoletes: dirmngr < 1.2.0-1
Obsoletes: gnupg2-smime

%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

%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
%configure \
  --disable-gpgtar \
  --disable-rpath \
  --enable-g13 \
  --enable-large-secmem

%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/*
%{_mandir}/man?/*


%changelog
* 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
