File mutt.spec of Package mutt

#
# spec file for package mutt
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#


Name:           mutt
#!BuildIgnore:  sendmail
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  cyrus-sasl-devel
BuildRequires:  cyrus-sasl-gssapi
BuildRequires:  docbook-xsl-stylesheets
BuildRequires:  docbook_4
BuildRequires:  fdupes
BuildRequires:  gdbm-devel
BuildRequires:  glibc-i18ndata
BuildRequires:  ispell
BuildRequires:  krb5-devel
BuildRequires:  libcom_err
%if 0%{?suse_version} <= 1230
BuildRequires:  libgcrypt
%else
BuildRequires:  libgcrypt-devel
%endif
BuildRequires:  libgnutls-devel
BuildRequires:  libgpg-error-devel
BuildRequires:  libidn-devel
BuildRequires:  libkyotocabinet-devel
BuildRequires:  libopenssl-devel
BuildRequires:  libxml2
BuildRequires:  libxslt
BuildRequires:  lua-devel
BuildRequires:  lynx
BuildRequires:  ncurses-devel
%if 0%{?is_opensuse}
BuildRequires:  notmuch-devel
%endif
BuildRequires:  postfix
BuildRequires:  sgml-skel
BuildRequires:  update-desktop-files
BuildRequires:  xli
#if
%if 0%{?suse_version} > 1130
BuildRequires:  libassuan-devel
BuildRequires:  libgpgme-devel
%else
BuildRequires:  gpgme-devel
%endif
Url:            http://www.mutt.org
Provides:       muttssl
Obsoletes:      muttssl
Recommends:     mutt-doc
Recommends:     mutt-lang
Recommends:     smtp_daemon
Recommends:     urlscan
Recommends:     urlview
Recommends:     w3m
%if 0%{?suse_version} > 1130
Requires(post):   shared-mime-info
Requires(postun): shared-mime-info
%endif
Requires:       perl(Expect)
# NOTE: We don't want this dependency and desktop-data-SuSE is in all
# desktop selections.
#Requires:      desktop-data-SuSE
%global	neo     20170421
Version:        1.8.2
Release:        0
Summary:        Mail Program
License:        GPL-2.0+
Group:          Productivity/Networking/Email/Clients
# ftp://ftp.mutt.org/mutt/devel/
# Source0:        https://bitbucket.org/mutt/mutt/downloads/%%name-%%version.tar.gz
# Switch over to neomutt tar ball which is based on original mutt
# http://www.neomutt.org/
### https://github.com/neomutt/neomutt/archive/neomutt-20170421.tar.gz
Source0:        neomutt-%neo.tar.gz
Source1:        Signature_conversion
Source2:        README.alternates
Source3:        mutt.png
Source4:        mutt.desktop
Source5:        skel.muttrc
Source6:        krb5-config
Source9:        mutt.mailcap
Patch:          %name-%version.dif
# http://www.spinnaker.de/mutt/compressed/
Patch2:         %name-1.5.9i-pgpewrap.diff
Patch3:         %name-1.5.20-sendgroupreplyto.diff
Patch4:         %name-1.5.15-wrapcolumn.diff
Patch7:         mutt-1.6.1-opennfs.dif
Patch9:         bug-676388-largefile.patch
# http://www.wolfermann.org/mutt.html
Patch11:        aw.listreply.diff
Patch12:        patch-1.5.24.vk.pgp_verbose_mime
# PATCH-FIX-OPENSUSE: bnc#813498 - mutt crashes in fgetwc in text_enriched_handler
Patch15:        widechar.sidebar.dif
# PATCH-FIX-OPENSUSE: Be able to read signed/encrypted messsages even with CRLF
Patch16:        mutt-1.5.23-carriage-return.path
# PATCH-FIX-OPENSUSE bnc#899712 - fallback mailcap for e.g text/html
Patch18:        mutt-1.5.21-mailcap.diff
# PATCH-FIX-SUSE: bsc#907453 - CVE-2014-9116: mutt: heap-based buffer overflow in mutt_substrdup()
Patch19:        bsc907453-CVE-2014-9116-jessie.patch
# PATCH-FIX-SUSE: Fix crash in crypt routines if no from is set or found
Patch20:        mutt-1.8.2-from4crypt.diff
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%global         _sysconfdir %{_sysconfdir}

%description
A very powerful mail user agent. It supports (among other nice things)
highlighting, threading, and PGP. It takes some time to get used to,
however.

%package doc
Summary:        Additional Documentation about Mutt
Group:          Documentation/Other
Requires:       %{name} = %{version}
Provides:       %{name}:%{_docdir}/%name/COPYRIGHT
BuildArch:      noarch

%description doc
Some extend documentation about mutt together with muttrc examples
for different environments and requirements.

%package lang
Summary:        Languages for Mutt
Group:          System/Localization
Provides:       mutt:/usr/share/locale/en_GB/LC_MESSAGES/mutt.mo
Requires:       %{name} = %{version}
Provides:       %{name}:%{_docdir}/%name/COPYRIGHT
BuildArch:      noarch

%description lang
Provides translations to the package mutt.

%prep
ln -sf neomutt-neomutt-%neo mutt-%version
%setup -q -D -n mutt-%version
%patch -p0 -b .p0
%patch2 -p0 -b .pgpewrap
%patch3 -p0 -b .sendgroupreplyto
%patch4 -p0 -b .wrapcolumn
%patch7 -p0 -b .opennfs
%patch9 -p0 -b .largefile
%patch11 -p0 -b .listreply
%patch12 -p0 -b .pgp_verbose_mtime
%patch15 -p0 -b .widechar.sidebar
%patch16 -p0 -b .crlf
%patch18 -p0 -b .mailcap
%patch19 -p0 -b .cvw2014.9116
%patch20 -p1 -b .from4crypt
rm -vf README*.orig
rm -vf PATCHES*.orig

cp %{S:2} .

%build
%if 0%{?suse_version} > 1100
autoreconf -fi
%endif
  cflags ()
  {
    local flag=$1; shift
    local var=$1; shift
    test -n "${flag}" -a -n "${var}" || return
    case "${!var}" in
    *${flag}*) return
    esac
    set -o noclobber
    case "$flag" in
    -Wl,*)
	if echo 'int main () { return 0; }' | \
	    ${CC:-gcc} -Werror $flag -o /dev/null -xc - > /dev/null 2>&1 ; then
	    eval $var=\${$var:+\$$var\ }$flag
	fi
	;;
    *)
	if ${CC:-gcc} -Werror $flag -S -o /dev/null -xc /dev/null > /dev/null 2>&1 ; then
	    eval $var=\${$var:+\$$var\ }$flag
	fi
    esac
    set +o noclobber
  }
CC=gcc
CFLAGS="-Wall $RPM_OPT_FLAGS -I. -D_GNU_SOURCE"
#cflags -DSUSE_IMAP_FORCE_SSL		CFLAGS
cflags -fno-strict-aliasing		CFLAGS
cflags -fstack-protector		CFLAGS
cflags -fPIE				CFLAGS
cflags -g3				CFLAGS
cflags -pipe				CFLAGS
cflags -Wl,--as-needed			LDFLAGS
cflags -Wl,-O2				LDFLAGS
cflags -Wl,--hash-size=8599		LDFLAGS
cflags -pie				LDFLAGS
KRB5CFGPATH=%{S:6}
export CC CFLAGS LDFLAGS KRB5CFGPATH
chmod 755 $KRB5CFGPATH
./configure $RPM_ARCH-suse-linux \
	--prefix=%{_prefix} \
	--datadir=%{_datadir} \
	--sysconfdir=%{_sysconfdir} \
	--mandir=%{_mandir} \
	--with-docdir=%{_docdir}/%name \
	--enable-imap \
	--enable-pop \
	--enable-pgp \
%if 0%{?suse_version} >= 1100
	--enable-gpgme \
%endif
	--enable-nfs-fix \
	--enable-mailtool \
	--enable-compressed \
	--enable-sidebar \
%if 0%{?is_opensuse}
	--enable-notmuch  \
%endif
	--disable-external-dotlock \
	--with-gdbm \
	--with-kyotocabinet \
	--with-ssl=%{_prefix} \
	--with-sasl=%{_prefix} \
	--with-gss=%{_prefix} \
	--with-gnutls=%{_prefix} \
	--with-curses=%{_prefix} \
	--enable-smtp \
	--enable-lua \
	--enable-nntp \
	--with-idn
make -C doc clean
make
make -C doc

%install
make install DESTDIR=%{buildroot}
install -m 755 %{S:1} %{buildroot}%{_bindir}
gzip -n -9 doc/manu*.txt
rm -f contrib/Makefile*
# datadir not automatically created:
mkdir -p %{buildroot}%{_datadir}/mutt
# INSTALL file should be removed:
rm -rf %{buildroot}%{_docdir}/%{name}/INSTALL
# mbox/mmdf manual page conflicts with the one from tin, so rename it
mv %{buildroot}%{_mandir}/man5/mbox.5 \
   %{buildroot}%{_mandir}/man5/mbox_mutt.5
mv %{buildroot}%{_mandir}/man5/mmdf.5 \
   %{buildroot}%{_mandir}/man5/mmdf_mutt.5
   %find_lang %name
# We get mime.types from aaa_base
rm -f %{buildroot}%{_sysconfdir}/mime.types
# Mutt BTS is gone
rm -f %{buildroot}%{_mandir}/man1/{flea*,muttbug*}
rm -f %{buildroot}%{_bindir}/{flea,muttbug}
rm -f %{buildroot}%{_sysconfdir}/Muttrc.dist
rm -f %{buildroot}%{_sysconfdir}/mime.types.dist
mkdir -p %{buildroot}%{_datadir}/pixmaps
install -m 644 %{SOURCE3} %{buildroot}%{_datadir}/pixmaps/
mkdir -p %{buildroot}%{_datadir}/applications
install -m 644 %{SOURCE4} %{buildroot}%{_datadir}/applications/
install -D -m 644 %{SOURCE5} %{buildroot}%{_sysconfdir}/skel/.muttrc
install -D -m 644 %{SOURCE9} %{buildroot}%{_datadir}/%name/mailcap
rm -vf %{buildroot}%{_docdir}/%name/manual.txt
install -D -m 644 doc/manual.txt.gz %{buildroot}%{_docdir}/%name/
chmod a-x %{buildroot}%{_docdir}/%name/keybase/*.sh
%suse_update_desktop_file mutt

%if 0%{?suse_version} >= 1140

%post
%mime_database_post

%postun
%mime_database_postun
%endif

%files
%defattr(-,root,root)
%config(noreplace) %{_sysconfdir}/skel/.muttrc
%config(noreplace) %{_sysconfdir}/Muttrc
%{_bindir}/mutt
%{_bindir}/pgpewrap
%{_bindir}/pgpring
%{_bindir}/smime_keys
%{_bindir}/Signature_conversion
%{_datadir}/applications/*.desktop
%{_datadir}/pixmaps/mutt.png
%{_mandir}/man1/mutt.1.gz
%{_mandir}/man1/pgp*.1.gz
%{_mandir}/man1/smime_keys.1.gz
%{_mandir}/man5/mmdf_mutt.5.gz
%{_mandir}/man5/muttrc.5.gz
%{_mandir}/man5/mbox_mutt.5.gz
%dir %{_datadir}/mutt/
%{_datadir}/mutt/mailcap
%dir %doc %{_docdir}/%name/
%doc %{_docdir}/%name/manual.txt.gz

%files doc
%defattr(-,root,root)
%doc %{_docdir}/%name/COPYRIGHT
%doc %{_docdir}/%name/README*
%doc %{_docdir}/%name/NEWS
%doc %{_docdir}/%name/TODO
%doc %{_docdir}/%name/ChangeLog
%doc %{_docdir}/%name/ChangeLog.neomutt
%doc %{_docdir}/%name/LICENSE.md
%doc %{_docdir}/%name/*.html
%doc %{_docdir}/%name/*.txt
%dir %doc %{_docdir}/%name/keybase/
%doc %{_docdir}/%name/keybase/*
%doc %{_docdir}/%name/muttrc.*
%doc %{_docdir}/%name/neomutt-syntax.vim
%dir %doc %{_docdir}/%name/samples/
%doc %{_docdir}/%name/samples/*.rc
%doc %{_docdir}/%name/samples/ca-bundle.crt
%doc %{_docdir}/%name/samples/colors.*
%dir %doc %{_docdir}/%name/samples/iconv/
%doc %{_docdir}/%name/samples/iconv/*.rc
%doc %{_docdir}/%name/samples/mutt_xtitle
%doc %{_docdir}/%name/samples/sample.*
%doc %{_docdir}/%name/samples/smime_keys_test.pl
%dir %doc %{_docdir}/%name/vim-keys/
%doc %{_docdir}/%name/vim-keys/*

%files lang -f %name.lang
%defattr(-,root,root)

%changelog
openSUSE Build Service is sponsored by