Blob Blame History Raw
%if 0%{?fedora} || 0%{?rhel} >= 9
%global with_python3legacy 1
%global with_python3CFFI 1

%if 0%{?rhel} && 0%{?rhel} <= 8
%global with_python2 1

%if 0%{?rhel} && 0%{?rhel} <= 6
%{!?__python2: %global __python2 /usr/bin/python2}
%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}

# build python 3 modules with python 3 ;)
%if 0%{?with_python3legacy} || 0%{?with_python3CFFI}
%global with_python3 1

Name:           notmuch
Version:        0.34.1
Release:        %autorelease
Summary:        System for indexing, searching, and tagging email
License:        GPLv3+
# Imported from public key servers; author provides no fingerprint!
Source2:        gpgkey-7A18807F100A4570C59684207E4E65C8720B706B.gpg

BuildRequires:  make
BuildRequires:  bash-completion
BuildRequires:  emacs
BuildRequires:  emacs-el
BuildRequires:  emacs-nox
Buildrequires:  gcc gcc-c++
BuildRequires:  glib libtool
BuildRequires:  doxygen
BuildRequires:  texinfo
BuildRequires:  gnupg2
BuildRequires:  gnupg2-smime
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
BuildRequires:  gmime30-devel
BuildRequires:  gmime-devel
BuildRequires:  libtalloc-devel
BuildRequires:  perl-interpreter
BuildRequires:  perl-generators
BuildRequires:  perl-podlators
%if 0%{?with_python2}
BuildRequires:  python2-devel
BuildRequires:  python2-docutils
BuildRequires:  python2-sphinx
BuildRequires:  ruby-devel
BuildRequires:  xapian-core-devel
BuildRequires:  zlib-devel

%if 0%{?with_python3}
BuildRequires:  python3-devel
BuildRequires:  python3-docutils
BuildRequires:  python3-sphinx

%if 0%{?with_python3CFFI}
BuildRequires:  python3-setuptools
BuildRequires:  python3-pytest
BuildRequires:  python3-pytest-shutil
BuildRequires:  python3-cffi

Requires(post): /sbin/install-info
Requires(postun): /sbin/install-info

Fast system for indexing, searching, and tagging email.  Even if you
receive 12000 messages per month or have on the order of millions of
messages that you've been saving for decades, Notmuch will be able to
quickly search all of it.

Notmuch is not much of an email program. It doesn't receive messages
(no POP or IMAP support). It doesn't send messages (no mail composer,
no network code at all). And for what it does do (email search) that
work is provided by an external library, Xapian. So if Notmuch
provides no user interface and Xapian does all the heavy lifting, then
what's left here? Not much.

%package    devel
Summary:    Development libraries and header files for the Notmuch library
Requires:   %{name} = %{version}-%{release}

%description devel
Notmuch-devel contains the development libraries and header files for
Notmuch email program.  These libraries and header files are
necessary if you plan to do development using Notmuch.

Install notmuch-devel if you are developing C programs which will use the
Notmuch library.  You'll also need to install the notmuch package.

%package -n emacs-notmuch
Summary:    Not much support for Emacs
BuildArch:  noarch
Requires:   %{name} = %{version}-%{release}
Requires:   emacs(bin) >= %{_emacs_version}

%description -n emacs-notmuch

%if 0%{?with_python2}
%package -n python2-notmuch
Summary:    Python2 bindings for notmuch
%{?python_provide:%python_provide python2-notmuch}

Requires:       python2

%description -n python2-notmuch

%if 0%{?with_python3legacy}
%package -n python3-notmuch
Summary:    Python3 bindings for notmuch (legacy)
%{?python_provide:%python_provide python3-notmuch}

Requires:       python3

%description -n python3-notmuch

%if 0%{?with_python3CFFI}
%package -n python3-notmuch2
Summary:    Python3 bindings for notmuch (cffi)
%{?python_provide:%python_provide python3-notmuch2}

Requires:       python3

%description -n python3-notmuch2

%package -n ruby-notmuch
Summary:    Ruby bindings for notmuch
Requires:   %{name} = %{version}-%{release}

%description -n ruby-notmuch

%package    mutt
Summary:    Notmuch (of a) helper for Mutt
BuildArch:  noarch
Requires:   %{name} = %{version}-%{release}
Requires:   perl(Term::ReadLine::Gnu)

%description mutt
notmuch-mutt provide integration among the Mutt mail user agent and
the Notmuch mail indexer.

%package    vim
Summary:    A Vim plugin for notmuch
Requires:   ruby-%{name} = %{version}-%{release}
Requires:   rubygem-mail
Requires:   vim-enhanced
# Required for updating helptags in scriptlets.
Requires(post):    vim-enhanced
Requires(postun):  vim-enhanced

%description vim
notmuch-vim is a Vim plugin that provides a fully usable mail client
interface, utilizing the notmuch framework.

%{gpgverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1}' --data='%{SOURCE0}'
%setup -q

# The %%configure macro cannot be used because notmuch doesn't support
# some arguments the macro adds to the ./configure call.
./configure --prefix=%{_prefix} --sysconfdir=%{_sysconfdir} \
   --libdir=%{_libdir} --mandir=%{_mandir} --includedir=%{_includedir} \
make %{?_smp_mflags} CFLAGS="%{optflags} -fPIC"

# Build the python bindings
pushd bindings/python
    %if 0%{?with_python2}
    %if 0%{?with_python3}

# Build the python cffi bindings
pushd bindings/python-cffi
    %if 0%{?with_python3CFFI}

# Build notmuch-mutt
pushd contrib/notmuch-mutt

make install DESTDIR=%{buildroot}

# Enable dynamic library stripping.
find %{buildroot}%{_libdir} -name *.so* -exec chmod 755 {} \;

# Install the python bindings and documentation
pushd bindings/python
    %if 0%{?with_python2}
    %if 0%{?with_python3legacy}

# Install the python cffi bindings and documentation
pushd bindings/python-cffi
    %if 0%{?with_python3CFFI}

# Install the ruby bindings
pushd bindings/ruby
    make install DESTDIR=%{buildroot}

# Install notmuch-mutt
install -m0755 contrib/notmuch-mutt/notmuch-mutt \
install -m0644 contrib/notmuch-mutt/notmuch-mutt.1 \

# Install notmuch-vim
pushd vim
    make install DESTDIR=%{buildroot} prefix="%{_datadir}/vim/vimfiles"

rm -f %{buildroot}/%{_datadir}/applications/mimeinfo.cache
rm -f %{buildroot}%{_infodir}/dir

ls -lR %{buildroot}%{_mandir}

%post vim
cd %{_datadir}/vim/vimfiles/doc
vim -u NONE -esX -c "helptags ." -c quit

%postun vim
cd %{_datadir}/vim/vimfiles/doc
vim -u NONE -esX -c "helptags ." -c quit


%files devel

%files -n emacs-notmuch

%if 0%{?with_python2}
%files -n python2-notmuch
%doc bindings/python/README

%if 0%{?with_python3legacy}
%files -n python3-notmuch
%doc bindings/python/README

%if 0%{?with_python3CFFI}
%files -n python3-notmuch2

%files -n ruby-notmuch

%files mutt

%files vim