%define rel 4

Summary: A Perl interface to the World-Wide Web
Name: perl-libwww-perl
Version: 5.833
Release: %{rel}%{?_dist_release}
License: GPL or Artistic
Group: Development/Libraries
Source0: ftp://ftp.cpan.org/pub/CPAN/modules/by-module/LWP/libwww-perl-%{version}.tar.gz
Source10: filter-depends-libwww-perl.sh
Patch100: lwp-download_CVE-2010-2253.patch
Patch110: lwp-download_usage.patch

URL: http://search.cpan.org/dist/libwww-perl/
BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildArch: noarch
BuildRequires: perl >= 5.8.0, perl-URI, perl-HTML-Parser perl-Compress-Zlib
Requires: perl >= 5.8.0, perl-URI, perl-HTML-Parser perl-Compress-Zlib

%if %{?_dist_release} == "vl5" || %{?_dist_release} == "vl4"
%define __find_requires %{SOURCE10}
%else if %{?_dist_release} == "vl7"
%define __perllib_requires %{SOURCE10}
%else
%define __perl_requires %{SOURCE10}
%endif

Vendor: Project Vine
Distribution: Vine Linux

%description
The libwww-perl collection is a set of Perl modules which provides a
simple and consistent application programming interface to the
World-Wide Web.  The main focus of the library is to provide classes
and functions that allow you to write WWW clients. The library also
contain modules that are of more general use and even classes that
help you implement simple HTTP servers.

%prep
%setup -q -n libwww-perl-%{version}
%patch100 -p1 -b .CVE-2010-2253
%patch110 -p0 -b .usage

%build
CFLAGS="$RPM_OPT_FLAGS" perl Makefile.PL INSTALLDIRS=vendor << EOO
y
y
y
y
y
n
n
n
EOO
make

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{_prefix}
make DESTDIR=$RPM_BUILD_ROOT install

find $RPM_BUILD_ROOT \( -name perllocal.pod -o -name .packlist \) -exec rm -v {} \;

find $RPM_BUILD_ROOT%{_prefix} -type f -print | 
	sed "s@^$RPM_BUILD_ROOT@@g" | 
	grep -v ^%{_mandir} | 
	grep -v perllocal.pod | 
	grep -v "\.packlist" > %{name}.files
if [ "$(cat %{name}.files)X" = "X" ] ; then
    echo "ERROR: EMPTY FILE LIST"
    exit -1
fi

%clean 
rm -rf $RPM_BUILD_ROOT

%check 
make test

%files -f %{name}.files
%defattr(-,root,root)
%doc README Changes
%dir %{perl_vendorlib}/Bundle
%dir %{perl_vendorlib}/File
%dir %{perl_vendorlib}/HTML
%dir %{perl_vendorlib}/HTTP
%dir %{perl_vendorlib}/HTTP/Cookies
%dir %{perl_vendorlib}/HTTP/Headers
%dir %{perl_vendorlib}/HTTP/Request
%dir %{perl_vendorlib}/LWP
%dir %{perl_vendorlib}/LWP/Authen
%dir %{perl_vendorlib}/LWP/Protocol
%dir %{perl_vendorlib}/Net
%dir %{perl_vendorlib}/Net/HTTP
%dir %{perl_vendorlib}/WWW
%dir %{perl_vendorlib}/WWW/RobotRules
%{_mandir}/man?/*

%changelog
* Mon Jun 30 2014 IWAI, Masaharu <iwaim.sub@gmail.com> 5.833-4
- build with Perl 5.16
- use __perllib_requires for vl7

* Sun Mar 27 2011 IWAI, Masaharu <iwai@alib.jp> 5.833-3
- build with perl 5.12.3
- rename Source10: filter-depends.sh to filter-depends-libwww-perl.sh
- update filter-depends (Source10): using /usr/lib/rpm/perl.req
- confine to defined __find_requires on vl4 and vl5
- defined __perl_requires without vl4 and vl5

* Sun Aug 15 2010 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 5.833-2
- add patch100,110 for fix CVE-2010-2253 (lwp-download)
- add Vendor/Dist Tags

* Thu Nov 05 2009 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 5.833-1
- new upstream release
- delete perllocal.pod and .packlist at %%install section

* Fri Apr 25 2008 IWAI, Masaharu <iwaim@cc.mbn.or.jp> 5.812-2
- new upstream release

* Sun Jul 22 2007 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 5.806-0vl1
- new upstream release
- s/Copyright/License/
- changed Group to Development/Libraries
- installed modules to vendor_perl directory
- added SOURCE10 (removed dependancy for Win32)

* Sat Dec  4 2004 IWAI, Masaharu <iwai@alib.jp> 5.802-0vl1
- new upstream release
- add perl-Compress-Zlib in {Build,}Requires

* Thu Apr 24 2003 IWAI Masaharu <iwai@alib.jp> 5.69-0vl2
- add many direcotries in %%files

* Wed Apr 16 2003 Satoshi MACHINO <machino@vinelinux.org> 5.69-0vl1
- New upstream version
	-- libwww-perl-5.69
- build on perl-5.8.0
- removed perl-MIME-Base64 and perl-libnet from BuildRequires and Requires
	-- perl-5.8.0 included them

* Sun Mar 02 2003 Satoshi MACHINO <machino@vinelinux.org> 5.65-0vl1
- New upstream version

* Sat Feb  9 2002 IWAI Masaharu <iwaim@cc.mbn.or.jp> 5.63-0vl1
- first build for Vine Linux

