#
# spec file for package pdfgrep
#
# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


Name:           pdfgrep
Version:        2.1.2
Release:        2.17
Summary:        Search in pdf files for strings matching a regular expression
License:        GPL-2.0-or-later
Group:          Productivity/Text/Utilities
URL:            https://pdfgrep.org/
Source:         https://pdfgrep.org/download/%{name}-%{version}.tar.gz
BuildRequires:  gcc-c++
BuildRequires:  libgcrypt-devel >= 1.0.0
BuildRequires:  pkgconfig >= 0.9.0
BuildRequires:  pkgconfig(libpcre)
BuildRequires:  pkgconfig(poppler-cpp)

%description
Pdfgrep is a tool to search text in PDF files. It works similar to `grep'.

Features:
- search for regular expressions.
- support for some important grep options, including:
+ filename output.
+ page number output.
+ optional case insensitivity.
+ count occurrences.

%package bash-completion
Summary:        Bash Completion for %{name}
Group:          Productivity/Networking/Security
Requires:       %{name} = %{version}
Requires:       bash-completion
Supplements:    (%{name} and bash-completion)
BuildArch:      noarch

%description bash-completion
Bash completion script for %{name}.

%package zsh-completion
Summary:        ZSH completion for %{name}
Group:          Productivity/Networking/Security
Supplements:    (%{name} and zsh)
BuildArch:      noarch

%description zsh-completion
zsh shell completions for %{name}.

%prep
%setup -q

%build
%configure \
  --with-bash-completion
%make_build

%install
%make_install

%files
%license COPYING
%doc AUTHORS NEWS.md README.md
%{_bindir}/%{name}
%{_mandir}/man1/%{name}.1%{?ext_man}

%files bash-completion
%{_datadir}/bash-completion/completions/%{name}

%files zsh-completion
%dir %{_datadir}/zsh
%dir %{_datadir}/zsh/site-functions
%{_datadir}/zsh/site-functions/_%{name}

%changelog
* Wed Mar  3 2021 Martin Hauke <mardnh@gmx.de>
- Create subpackages for bash- and zsh-completion
- Use correct upstream URL
* Wed Apr 15 2020 Martin Pluskal <mpluskal@suse.com>
- Update to version 2.1.2:
  * Bugfix: Fix crash when compiled with hardened compiler flags
    (specifically -D_GLIBCXX_ASSERTIONS)
- Changes for version 2.1.1:
  * Bugfix: Fix build with libunac support enabled
- Changes for version 2.1.0:
  * New option `--page-range` to limit search to a set of pages
  * New option `--file/-f` to read patterns from a file
  * New option `--regexp/-e` to specify multiple patterns
    (combined with OR).
  * New options `--files-with-matches/-l` and
    `--files-without-match/-L` to only list filenames of files
    that contain or don't contain matches.
  * Major manpage restructuring. It's now divided into subsections
    like the GNU grep's manpage.
  * Bugfix: Actually stop searching after first match with `-q`
* Tue Jun 27 2017 mpluskal@suse.com
- Update dependencies
- Cleanup spec file
* Tue Jun 27 2017 sebix+novell.com@sebix.at
- update to 2.0.1 [2017-03-06]
  - Bugfix: Fix --cache when used with recursive search
- update to 2.0 [2017-01-25]
  - **Incompatible change**: `--context/-C` is now line based as opposed to
    character based and works just like grep
  - Two new options from grep: `-A/--after-context` and `-B/--before-context`
  - Lines with multiple matches are now printed only once
  - Optional caching of pdf-text for faster operation (by Christian Dietrich)
    This adds a **new dependency**: libgcrypt
  - Bash-completion improvements (by Rainer Müller)
  - Bugfix: Fixed string search (`-F`) now works as advertised with multiple
    patterns
  - Bugfix: Empty pages can now be matched with `^$`
  - Bugfix: The pattern `^` now matches *only* at the beginning of pages
  - Bugfix: Text outside of PDF's CropBox but inside the MediaBox is not
    ignored anymore.
  - Various fixes for BSD support
- update to 1.4.1 [2015-09-26]
  - Test suite added
  - Bugfix: The tarball contains HACKING and README again
  - Bugfix: The zsh completion completes options as first
    argument correctly
  - Bugfix: Exit status is set as advertised
  - Bugfix: Spurious null bytes removed from output
  - Bugfix: Skipping of some matches in certain conditions fixed.
  - Bugfix: Empty matches don't trigger a loop
- update to 1.4.0 [2015-08-14]
  - PCRE support (by Julius Plenz)
  - Fixed string search
  - Ability to pass multiple passwords
  - Option to change the colon as prefix separator
  - Optional warning about PDFs that contain no searchable text
  - New option from grep: `--only-matching`
  - New option from grep: `--null`
  - Bugfix: Correctly print unicode characters
  - Installation: New configure flag `--without-libpcre`
  - Installation: New configure flag `--disable-doc` to disable
    manpage generation with asciidoc
  - Installation: pdfgrep now requires c++11
- update to 1.3.2 [2015-02-20]
  - A bash completion module
  - Don't limit output to 80 characters on non-terminals
  - Print a lot less error messages by default (only with >= poppler-0.30.0)
  - New option `--debug` to print verbose debug output
  - Installation: New configure flag `--with-zsh-completion`
* Sat Aug 16 2014 dnh@opensuse.org - 1.3.1
- updated to 1.3.1 [2014-08-10]
  - INCOMPATIBLE CHANGE: -r doesn't follow symlinks
  - A zsh completion module
  - Support for password-protected PDFs
  - Allow to omit '.' with -r to search current directory
  - Add -p or --page-count to count matches per page (by Jascha Knack)
  - Add -m or --max-count to limit matches per file (by Thibault Marin)
* Tue Mar 26 2013 David Haller <dnh@opensuse.org> - 1.3.0
- Update to 1.3.0
  - Experimental support for libunac (removing accents and
    ligatures before search)
  - Recursive search [--recursive] (by Mahmut Gundes)
  - Don't use colors on dumb terminals
  - A few minor bug fixes
  - Use poppler-cpp instead of the poppler core library (by Pino Toscano)
* Sat Apr  2 2011 David Haller <dnh@opensuse.org> - 1.2
- Update to version 1.2
- remove dependency on package "licenses"
* Thu Sep 30 2010 David Haller <dnh@opensuse.org> - 1.1
- Initial package.