+# TODO:
+# - split /usr/share/perl* part into perl-ack subpackage
#
-%include /usr/lib/rpm/macros.perl
-Summary: grep-like tool
+# Conditional build:
+%bcond_without tests # do not perform "make test"
+%bcond_with pty_tests # do not perform tests requiring a pty
+#
+%define pdir ack
+Summary: grep-like text finder
Summary(pl.UTF-8): produkt grepopodobny
Name: ack
-Version: 1.90
-Release: 0.1
-License: GPL
-Group: Applications
-Source0: http://betterthangrep.com/ack-standalone
-# Source0-md5: d15d059166beff6103d2401aa2d783c7
+Version: 2.28
+Release: 1
+License: GPL v1+ or Artistic
+Group: Development/Languages/Perl
+Source0: http://www.cpan.org/modules/by-authors/id/P/PE/PETDANCE/%{name}-%{version}.tar.gz
+# Source0-md5: 5c363d701cb40cbc3806441b2a887b43
+Patch0: %{name}-deps.patch
+Patch1: %{name}-interactive-tests.patch
URL: http://betterthangrep.com/
-BuildRequires: perl-tools-pod
-BuildRequires: rpm-perlprov
-Suggests: perl-perldoc
+Requires: perl-ack = %{version}
+%if %{with tests}
+BuildRequires: perl-File-Next >= 1.16
+%{?with_pty_tests:BuildRequires: perl-IO-Tty}
+BuildRequires: perl-Test-Simple >= 0.98
+%endif
+BuildRequires: perl-devel >= 1:5.8.0
+BuildRequires: perl-perldoc
+BuildRequires: rpm-perlprov >= 4.1-13
BuildArch: noarch
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%description
-ack is a tool like grep, designed for programmers with large trees of
-heterogeneous source code.
+Ack is designed as a replacement for 99% of the uses of grep.
+
+Ack searches the named input FILEs (or standard input if no files are
+named, or the file name - is given) for lines containing a match to
+the given PATTERN. By default, ack prints the matching lines.
+
+Ack can also list files that would be searched, without actually
+searching them, to let you take advantage of ack's file-type filtering
+capabilities.
+
+%description -l pl.UTF-8
+ack jest narzędziem podobnym do grepa, zaprojektowanym dla
+programistów pracujących z dużymi drzewami różnorodnych plików.
-ack is written purely in Perl, and takes advantage of the power of Perl's
-regular expressions.
+ack jest napisany w czystym perlu i korzysta z potęgi wyrażeń
+regularnych tego języka.
-%description -l pld.UTF-8
-ack jest narzędziem podobnym do grepa, zaprojektowanym dla programistów
-pracujących z dużymi drzewami różnorodnych plików.
+%package -n perl-ack
+Summary: ack perl library
+Summary(pl.UTF-8): biblioteka ack dla języka perl
+Group: Development/Languages/Perl
-ack jest napisane w czystym Perlu i korzysta z ptęgi wyrażeń regularnych
-języka Perl.
+%description -n perl-ack
+ack perl library.
+
+%description -n perl-ack -l pl.UTF-8
+ack perl library.
%prep
-%setup -q -c -T
+%setup -q -n %{pdir}-%{version}
+%patch0 -p0
+%patch1 -p0
%build
-pod2man %SOURCE0 > ack.1
-pod2text %SOURCE0 > ack.txt
+%{__perl} Makefile.PL \
+ INSTALLDIRS=vendor
+%{__make} \
+ CC="%{__cc}" \
+ OPTIMIZE="%{rpmcflags}"
+
+%{?with_tests:%{!?with_pty_tests: RUN_INTERACTIVE=0} %{__make} -j1 test}
%install
rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT{%{_bindir},%{_mandir}/man1}
-install %SOURCE0 $RPM_BUILD_ROOT%{_bindir}/%{name}
-install ack.1 $RPM_BUILD_ROOT%{_mandir}/man1/ack.1
+%{__make} pure_install \
+ DESTDIR=$RPM_BUILD_ROOT
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(644,root,root,755)
-%attr(755,root,root) %{_bindir}/%{name}
-%{_mandir}/man1/ack.1*
-%doc ack.txt
+%doc Changes README.md
+%attr(755,root,root) %{_bindir}/ack
+%{_mandir}/man1/ack.1p*
+
+%files -n perl-ack
+%defattr(644,root,root,755)
+%{perl_vendorlib}/App/Ack.pm
+%{perl_vendorlib}/App/Ack