Summary: SAX(Simple API for XML) for Perl 
Name: perl-XML-SAX
Version: 0.16
Release: 3%{?_dist_release}
License: distributable
Group: Development/Libraries
Source0: http://www.cpan.org/authors/id/M/MS/MSERGEANT/XML-SAX-%{version}.tar.gz
Source1: filter-requires-XML-SAX.sh
Source2: filter-provides-XML-SAX.sh

URL: http://search.cpan.org/search?dist=XML-SAX
BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildArch: noarch
BuildRequires: perl >= 5.8.2
BuildRequires: perl-XML-NamespaceSupport
Requires: perl >= 5.8.2
Requires: perl-XML-NamespaceSupport
#Requires(post): perl-XML-LibXML
#Requires(preun): perl-XML-LibXML

%if %{?_dist_release} == "vl5" || %{?_dist_release} == "vl4"
# Filter unwanted Requires: perl-XML-SAX has some poorly-structured
#                           packages that confuse RPM.
%define __find_requires %{SOURCE1}

# Filter unwanted Provides: perl-XML-SAX should not Provide an
#                           unversioned perl(XML::SAX) along with the
#                           versioned one
%define __find_provides %{SOURCE2}
%else
%define __perl_requires %{SOURCE1}
%endif



%description
XML::SAX consists of several framework classes for using and building
Perl SAX2 XML parsers, filters, and drivers. It is designed around the
need to be able to "plug in" different SAX parsers to an application
without requiring programmer intervention. Those of you familiar with
the DBI will be right at home. Some of the designs come from the Java
JAXP specification (SAX part), only without the javaness.

%prep
%setup -q -n XML-SAX-%{version} 

%build
%{__perl} Makefile.PL INSTALLDIRS=vendor <<_OPTION_
N
_OPTION_
make OPTIMIZE="$RPM_OPT_FLAGS"

%check
make test

%clean 
rm -rf $RPM_BUILD_ROOT

%install
rm -rf $RPM_BUILD_ROOT
make pure_install DESTDIR=$RPM_BUILD_ROOT
find $RPM_BUILD_ROOT -type f -name .packlist -exec rm -f {} ';'
find $RPM_BUILD_ROOT -depth -type d -exec rmdir {} 2>/dev/null ';'
chmod -R u+w $RPM_BUILD_ROOT/*

touch $RPM_BUILD_ROOT%{perl_vendorlib}/XML/SAX/ParserDetails.ini

[ -x /usr/lib/rpm/brp-compress ] && /usr/lib/rpm/brp-compress

#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

%post
perl -MXML::SAX -e \
  'XML::SAX->add_parser(q(XML::SAX::PurePerl))->save_parsers()' 2>/dev/null

%preun
if [ $1 -eq 0 ]; then
  perl -MXML::SAX -e \
    'XML::SAX->remove_parser(q(XML::SAX::PurePerl))->save_parsers()'
fi

%files 
%defattr(-,root,root)
%doc README Changes LICENSE
%dir %{perl_vendorlib}/XML
%{perl_vendorlib}/XML/SAX.pm
%dir %{perl_vendorlib}/XML/SAX
%{perl_vendorlib}/XML/SAX/*.pm
%{perl_vendorlib}/XML/SAX/*.pod
%{perl_vendorlib}/XML/SAX/PurePerl
%{_mandir}/man3/*3pm*
%ghost %{perl_vendorlib}/XML/SAX/ParserDetails.ini
%exclude %{perl_vendorlib}/XML/SAX/placeholder.pl

%changelog
* Sun Mar 27 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.16-3
- drebuild with perl-5.12.3
- using __perl_requires macro for VineSeed (vl6)

* Sun Jun  1 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 0.16-2
- added Requires(post,preun): perl-XML-LibXML

* Sat May 31 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 0.16-1
- new upstream release
- built with perl-5.10.0-2
- added SOURCE1, 2 for avoiding unwanted dependancies

* Sun Jan  2 2005 IWAI, Masaharu <iwai@alib.jp> 0.12-0vl2
- build on perl-5.8.6-0vl1

* Sun Oct 17 2004 Satoshi MACHINO <machino@vinelinux.org> 0.12-0vl1
- new upstream version
- updated patch0 to perl-XML-SAX-0.12-makefile.patch

* Mon Apr 15 2002 IWAI Masaharu <iwaim@cc.mbn.or.jp> 0.10-0vl1
- first build for Vine Linux
