%define real_name IPTables-libiptc

Summary:        Perl extension for iptables libiptc
Name:           perl-IPTables-libiptc
Version:        0.51
Release:        1%{?_dist_release}
License:        GPLv2+
Group:          Development/Libraries
URL:            http://search.cpan.org/dist/IPTables-libiptc/
Source:         http://search.cpan.org/CPAN/authors/id/H/HA/HAWK/%{real_name}-%{version}.tar.gz
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root

BuildRequires:  iptables-devel >= 1.4

BuildRequires:  perl
BuildRequires:  perl(AutoLoader)
BuildRequires:  perl(Carp)
BuildRequires:  perl(ExtUtils::MakeMaker)
BuildRequires:  perl(Test::More)
BuildRequires:  perl(File::Basename)

Requires:       perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version))
Requires:       perl(AutoLoader)
Requires:       perl(Carp)
Requires:       perl(File::Basename)

Vendor:         Project Vine
Distribution:   Vine Linux

%description
This package provides a perl interface to the netfilter/iptables
C-code and library C<libiptc>.

Advantages of this module: Many rule changes can be done very
fast. Several rule changes is committed atomically.

This module is heavily inspired by the CPAN module IPTables-IPv4.  The
CPAN module IPTables-IPv4 could not be used because it has not been
kept up-to-date, with the newest iptables extensions.  This is a
result of the module design, as it contains every extension and thus
needs to port them individually.

This package has another approach, it links with the systems libiptc.a
library and depend on dynamic loading of iptables extensions available
on the system.

The module only exports the libiptc chain manipulation functions.  All
rule manipulations are done through the iptables.c C<do_command>
function.  As iptables.c is not made as a library, the package
unfortunately needs to maintain/contain this C file.

%prep
%setup -q -n %{real_name}-%{version}

%build
perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="%{optflags}" PREFIX='/usr'
make %{?_smp_mflags}

%install
rm -rf %{buildroot}
make pure_install DESTDIR=%{buildroot}
find %{buildroot} -type f -name .packlist -exec rm -f {} ';'
find %{buildroot} -depth -type d -exec rmdir {} ';' 2>/dev/null
%{_fixperms} %{buildroot}

%check
# skip the tests because you must be root
#make test

%clean
rm -rf %{buildroot}

%files
%defattr(-, root, root, -)
%doc Changes META.yml README
%{perl_vendorarch}/*
%{_mandir}/man?/*

%changelog
* Sun Mar 11 2012 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 0.51-1
- initial build for Vine Linux
