%define build_compat32 %{?_with_compat32:1}%{!?_with_compat32:0}
%define source_name    gnutls

Summary:	GNU TLS Library
Summary(ja):	GNU TLS ライブラリ
Name:		gnutls2
Version:	2.12.23
Release:	3%{?_dist_release}
License:	GPLv3+ and LGPLv2+
# The libgnutls library is LGPLv2+, utilities and remaining libraries are GPLv3+
Group:		System Environment/Libraries
URL:		http://www.gnutls.org/
#Source0:	ftp://ftp.gnutls.org/pub/gnutls/devel/%{name}-%{version}.tar.gz
#Source1:	ftp://ftp.gnutls.org/pub/gnutls/devel/%{name}-%{version}.tar.gz.sig
# XXX patent tainted SRP code removed.
Source0:	%{source_name}-%{version}.tar.bz2
Source1:	libgnutls-config

#patches from fedora development
Patch1: gnutls-2.12.11-rpath.patch
Patch2: gnutls-2.8.6-link-libgcrypt.patch
# Remove nonexisting references from texinfo file
Patch3: gnutls-2.12.2-nosrp.patch
# Skip tests that are expected to fail on libgcrypt build
Patch4: gnutls-2.12.7-dsa-skiptests.patch

Patch100: fix_denial_of_service.patch
Patch110: gnutls-2.12.23_CVE-2014-1959.patch

BuildRoot:	%{_tmppath}/%{name}-%{version}-root

BuildRequires: libgcrypt-devel >= 1.2.2, zlib-devel libtasn1-devel gmp-devel
BuildRequires: gettext readline-devel libtool
BuildRequires: guile-devel >= 1.8.6
BuildRequires: lzo-devel
BuildRequires: p11-kit-devel >= 0.11
Requires:	libgcrypt >= 1.2.2, zlib
Requires:	lzo

Requires(post):   ldconfig
Requires(postun): ldconfig

Vendor:		Project Vine
Distribution:	Vine Linux

%description
GnuTLS is a project that aims to develop a library which provides a secure
layer, over a reliable transport layer. Currently the GnuTLS library implements
the proposed standards by the IETF's TLS working group.
#'

%package -n compat32-%{name}
Summary:	GNU TLS Library
Summary(ja):	GNU TLS ライブラリ
Group:		System Environment/Libraries
Requires:	compat32-%{name} = %{version}-%{release}

%description -n compat32-%{name}
GnuTLS is a project that aims to develop a library which provides a secure
layer, over a reliable transport layer. Currently the GnuTLS library implements
the proposed standards by the IETF's TLS working group.
#'

%prep
%setup -q -n gnutls-%{version}
%patch1 -p1 -b .rpath
%patch2 -p1 -b .link
%patch3 -p1 -b .nosrp
%patch4 -p1 -b .skiptests

%patch100 -p1 -b .denial
%patch110 -p1 -b .CVE-2014-1959

for i in auth_srp_rsa.c auth_srp_sb64.c auth_srp_passwd.c auth_srp.c gnutls_srp.c ext_srp.c; do
    touch lib/$i
done

%build
#autoreconf
%configure --with-libtasn1-prefix=%{_prefix} \
	--with-lzo \
	--with-included-libcfg \
	--disable-openssl-compatibility \
	--disable-srp-authentication \
	--disable-static \
	--disable-srp-authentication \
	--disable-rpath \
	--with-libgcrypt
#	--with-included-libtasn1 \
#	--with-included-opencdk \
#	--with-included-lzo \
make
cp lib/COPYING COPYING.LIB

%install
%__rm -rf %{buildroot}
%makeinstall

rm -f $RPM_BUILD_ROOT%{_bindir}/srptool
rm -f $RPM_BUILD_ROOT%{_bindir}/gnutls-srpcrypt
# replace libgnutls*-config
%__install -p -m755 %{SOURCE1} %{buildroot}%{_bindir}/libgnutls-config
%__install -p -m755 %{SOURCE1} %{buildroot}%{_bindir}/libgnutls-extra-config

rm -f $RPM_BUILD_ROOT%{_mandir}/man1/srptool.1
rm -f $RPM_BUILD_ROOT%{_mandir}/man3/*srp*
rm -f $RPM_BUILD_ROOT%{_infodir}/dir
rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
rm -f $RPM_BUILD_ROOT%{_libdir}/libguile*.a

# remove unneeded files
%__rm -f %{buildroot}%{_libdir}/*.la

%find_lang libgnutls

%check
make check

%clean
rm -rf %{buildroot}

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%post -n compat32-%{name} -p /sbin/ldconfig

%postun -n compat32-%{name} -p /sbin/ldconfig

%files -f libgnutls.lang
%defattr(-,root,root,-)
%{_libdir}/libgnutls.so.*
%{_libdir}/libgnutls-extra.so.*
%doc COPYING COPYING.LIB README AUTHORS

%if %{build_compat32}
%files -n compat32-%{name}
%defattr(-,root,root,-)
%{_libdir}/libgnutls*.so.*
%endif

%changelog
* Wed Feb 19 2014 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.12.23-3
- add patch110 for fix CVE-2014-1959
- compat package gnutls2

* Fri Jun 07 2013 Toshiharu Kudoh <toshi.kd2@gmail.com> 2.12.23-2
- added Patch100 from upstream to fix CVE-2013-2116

* Fri Feb 08 2013 Toshiharu Kudoh <toshi.kd2@gmail.com> 2.12.23-1
- new upstream release
- fixed a day of the week in %%changelog

* Sat Jan 26 2013 Toshiharu Kudoh <toshi.kd2@gmail.com> 2.12.22-1
- new upstream release

* Sun Nov 11 2012 Toshiharu Kudoh <toshi.kd2@gmail.com> 2.12.21-1
- new upstream release

* Sun Jun 10 2012 Toshiharu Kudoh <toshi.kd2@gmail.com> 2.12.20-1
- new upstream release

* Tue May 08 2012 Toshiharu Kudoh <toshi.kd2@gmail.com> 2.12.19-1
- new upstream release

* Sun Mar 18 2012 Toshiharu Kudoh <toshi.kd2@gmail.com> 2.12.18-1
- new upstream release
- changed BuildRequires: p11-kit-devel >= 0.11

* Fri Mar 16 2012 Toshiharu Kudoh <toshi.kd2@gmail.com> 2.12.17-1
- new upstream release

* Sat Jan 14 2012 Toshiharu Kudoh <toshi.kd2@gmail.com> 2.12.16-1
- new upstream release

* Mon Dec 05 2011 Toshiharu Kudoh <toshi.kd2@gmail.com> 2.12.14-3
- added BuildRequires: p11-kit-devel

* Sun Dec 04 2011 Toshiharu Kudoh <toshi.kd2@gmail.com> 2.12.14-2
- deleted BuildRequires: nettle-devel
  - mistake.. fixed.

* Sun Dec 04 2011 Toshiharu Kudoh <toshi.kd2@gmail.com> 2.12.14-1
- new upstream release
- synced Fedora development package
- add new sub-package: c++

* Sun Apr 10 2011 IWAI, Masaharu <iwai@alib.jp> 2.10.5-2
- add Requires: libtasn1-devel for devel subpackage

* Sun Apr  3 2011 IWAI, Masaharu <iwai@alib.jp> 2.10.5-1
- new upstream release

* Sun Dec 12 2010 Toshiharu Kudoh <toshi.kd2@gmail.com> 2.10.4-1
- new upstream release

* Tue Nov 23 2010 Toshiharu Kudoh <toshi.kd2@gmail.com> 2.10.3-1
- new upstream release
- dropt patch1

* Sat Oct 9 2010 Toshiharu Kudoh <toshi.kd2@gmail.com> 2.10.2-1
- new upstream release
- added patch1,2,3,4 from Fedora development
- added BuildRequires: gettext readline-devel libtool
- added configure option
  --disable-static,--disable-srp-authentication
  - dropt *.a files from -devel package again

* Tue Sep 21 2010 IWAI, Masaharu <iwai@alib.jp> 2.8.6-2
- build with rpm-4.8.1-1 for pkg-config file

* Mon Mar 22 2010 Toshiharu Kudoh <toshi.kd2@gmail.com> 2.8.6-1
- new upstream release
- applied new naming policy to spec

* Thu Nov 19 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> 2.8.5-1
- new upstream release

* Sat Sep 19 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> 2.8.4-1
- new upstream release

* Wed Aug 19 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> 2.8.3-1
- new upstream release

* Thu Aug 13 2009 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.8.2-1
- new upstream release with security fix (handling X.509 CN or SAN fields)

* Sat Jun 27 2009 NAKAMURA Kenta <kenta@vinelinux.org> 2.8.1-2vl5
- added compat32 package for x86_64 arch support

* Thu Jun 11 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> 2.8.1-1vl5
- new upstream release
- added autoreconf
- deleted libguile*.a
- dropt Patch3
- added %post guile, %postun guile

* Sun May 03 2009 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.6.6-2
- drop *.a files from -devel package
- build with system lzo

* Sun May 03 2009 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.6.6-1
- new upstream release with security fixes (CVE-2009-1415,1416,1417)

* Wed Apr 15 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> 2.6.5-1vl5
- update to 2.6.5

* Wed Mar 25 2009 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.6.4-2
- spec in UTF-8

* Sun Feb 8 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> 2.6.4-1vl5
- update to 2.6.4
- modifeid Source0

* Mon Jan 19 2009 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.6.3-2vl5
- add BuildRequires: guile-devel >= 1.8.6

* Tue Jan 13 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> 2.6.3-1vl5
- update to 2.6.3
- import from fedora developing's 2.6.3
  - License tag fixed
- dropped patch0, patch1, patch2
- added patch3
- added BuildRequires: gmp-devel
- add new sub-package: guile
  - added %package guile, %description guile, %files guile

* Sat Mar 22 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.6.3-2vl5
- used %%{?_dist_release} macro

* Mon Mar 17 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.6.3-2vl1
- update to 1.6.3 (use no-SRP source)
- import from fedora core's 1.6.3-2
  - nosrc.tar.bz2 (source0)
  - license tag fix
- build with system libtasn1

* Fri Mar 09 2007 KAZUKI SHIMURA <kazuki@ma.ccnw.ne.jp> 1.4.5-0vl1
- update to 1.4.5 (use no-SRP source)
- import from fedora core's 1.4.5-1
  - nosrc.tar.bz2 (source0)
- drop obsolete cve-2006-4790.patch (patch3)

* Tue Oct 24 2006 KAZUKI SHIMURA <kazuki@ma.ccnw.ne.jp> 1.4.1-2vl1
- [SECURITY] update to 1.4.1 (use no-SRP source)
- import from fedora core's 1.4.1-2
  - nosrp.tar.bz2 (source0)
  - libgnutls-config (source1)
  - nosrc.patch (patch0)
  - enable-psk.patch (patch1)
  - cve-2006-4790.patch (patch3)
- update required version of libgcrypt (>= 1.2.2)
- add Requires: pkgconfig to -devel package
- add %%check section
- update %%files
- add new sub-package: utils

* Sat May 14 2005 KAZUKI SHIMURA <kazuki@ma.ccnw.ne.jp> 1.0.25-0vl1
- [SECURITY FIX] upstream release
  - record packet parsing denial of service (CAN-2005-1431)

* Mon Mar 28 2005 KAZUKI SHIMURA <kazuki@ma.ccnw.ne.jp> 1.0.24-0vl1
- initial build for Vine Linux
- upstream release

* Wed Mar  2 2005 Warren Togami <wtogami@redhat.com> 1.0.20-6
- gcc4 rebuild

* Tue Jan  4 2005 Ivana Varekova <varekova@redhat.com> 1.0.20-5
- add gnutls Requires zlib-devel (#144069)

* Mon Nov 08 2004 Colin Walters <walters@redhat.com> 1.0.20-4
- Make gnutls-devel Require libgcrypt-devel

* Tue Sep 21 2004 Jeff Johnson <jbj@redhat.com> 1.0.20-3
- rebuild with release++, otherwise unchanged.

* Tue Sep  7 2004 Jeff Johnson <jbj@redhat.com> 1.0.20-2
- patent tainted SRP code removed.

* Sun Sep  5 2004 Jeff Johnson <jbj@redhat.com> 1.0.20-1
- update to 1.0.20.
- add --with-included-opencdk --with-included-libtasn1
- add --with-included-libcfg --with-included-lzo
- add --disable-srp-authentication.
- do "make check" after build.

* Fri Mar 21 2003 Jeff Johnson <jbj@redhat.com> 0.9.2-1
- upgrade to 0.9.2

* Tue Jun 25 2002 Jeff Johnson <jbj@redhat.com> 0.4.4-1
- update to 0.4.4.

* Fri Jun 21 2002 Tim Powers <timp@redhat.com>
- automated rebuild

* Sat May 25 2002 Jeff Johnson <jbj@redhat.com> 0.4.3-1
- update to 0.4.3.

* Tue May 21 2002 Jeff Johnson <jbj@redhat.com> 0.4.2-1
- update to 0.4.2.
- change license to LGPL.
- include splint annotations patch.

* Tue Apr  2 2002 Nalin Dahyabhai <nalin@redhat.com> 0.4.0-1
- update to 0.4.0

* Thu Jan 17 2002 Nalin Dahyabhai <nalin@redhat.com> 0.3.2-1
- update to 0.3.2

* Thu Jan 10 2002 Nalin Dahyabhai <nalin@redhat.com> 0.3.0-1
- add a URL

* Thu Dec 20 2001 Nalin Dahyabhai <nalin@redhat.com>
- initial package
