File mutt.spec of Package mutt

# spec file for package mutt
# Copyright (c) 2024 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

%global         _sysconfdir %{_sysconfdir}
%bcond_with    mutt_openssl
%bcond_without mutt_gnutls
Name:           mutt
Version:        2.2.13
Release:        0
Summary:        Mail Program
# https:///
License:        GPL-2.0-or-later
Group:          Productivity/Networking/Email/Clients
Source1:        Signature_conversion
Source2:        README.alternates
Source3:        mutt.png
Source4:        mutt.desktop
Source5:        skel.muttrc
Source8:        backports-datetime-fromisoformat-1.0.0.tar.gz
Source9:        mutt.mailcap
Source11:       mutt.keyring
Patch0:         %{name}-1.13.3.dif
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
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-ENHANCE-SUSE: allow to list current imap folders
Patch20:        mutt-1.10.1-imap.patch
# PATCH-ENHANCE-SUSE: boo#1156477 - Mutt has an option to ask before quitting on ^C but quits immediately on ^4
Patch21:        mutt-Fix-SIGQUIT-handling.patch
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  cyrus-sasl-gssapi
BuildRequires:  docbook-xsl-stylesheets
BuildRequires:  hunspell
BuildRequires:  iso_ent
BuildRequires:  libgpgme-devel
BuildRequires:  libxslt-tools
BuildRequires:  opensp
BuildRequires:  pkgconfig
BuildRequires:  w3m
BuildRequires:  pkgconfig(gssrpc)
BuildRequires:  pkgconfig(krb5)
BuildRequires:  pkgconfig(libsasl2)
%if 0%{suse_version} >= 1500
BuildRequires:  python3-base
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
BuildRequires:  smtp_daemon
Requires:       glibc-locale
Suggests:       smtp_daemon
Requires(post): %{_bindir}/cat
Requires(post): %{_bindir}/mkdir
Requires(pre):  %{_bindir}/grep
Requires(pre):  %{_bindir}/zcat
Recommends:     hunspell
Recommends:     mutt-doc
Recommends:     mutt-lang
Recommends:     urlscan
Recommends:     urlview
Recommends:     w3m
%if %{with mutt_openssl}
BuildRequires:  pkgconfig(openssl)
%if %{with mutt_gnutls}
BuildRequires:  pkgconfig(gnutls)
%if 0%{?suse_version} > 1315
BuildRequires:  pkgconfig(kyotocabinet)
BuildRequires:  libkyotocabinet-devel
%if 0%{?suse_version} > 1315
BuildRequires:  pkgconfig(libidn2)
BuildRequires:  pkgconfig(libidn)
%if 0%{?suse_version} > 1315
BuildRequires:  pkgconfig(ncurses)
BuildRequires:  ncurses-devel
%if 0%{?suse_version} > 1130
BuildRequires:  pkgconfig(shared-mime-info)
%if 0%{?suse_version}
BuildRequires:  update-desktop-files
%if 0%{?suse_version} > 1130
Requires(post): shared-mime-info

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. This version is based on NeoMutt, that is it includes many

%package doc
Summary:        Additional Documentation about Mutt
Group:          Documentation/Other
Requires:       %{name} = %{version}
Requires(post): %{install_info_prereq}
Recommends:     perl(Expect)
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
# FIXME: consider using %%lang_package macro
Summary:        Languages for Mutt
Group:          System/Localization
Requires:       %{name} = %{version}
Provides:       mutt:%{_datadir}/locale/en_GB/LC_MESSAGES/
BuildArch:      noarch

%description lang
Provides translations to the package mutt.

%setup -q -n mutt-%{version}
%patch -P 0  -b .p0
%patch -P 2  -b .pgpewrap
%patch -P 3  -b .sendgroupreplyto
%patch -P 4  -b .wrapcolumn
%patch -P 7  -b .opennfs
%patch -P 11  -b .listreply
%patch -P 12  -b .pgp_verbose_mtime
%patch -P 15  -b .widechar.sidebar
%patch -P 16  -b .crlf
%patch -P 18  -b .mailcap
%patch -P 19  -b .cvw2014.9116
%patch -P 20  -b .imap
%patch -P 21  -b .quit

cp %{SOURCE2} .

%if %{with mutt_gnutls}
echo 'set ssl_ca_certificates_file="%{_sysconfdir}/ssl/ca-bundle.pem"' >> doc/Muttrc.head
autoreconf -fi
  cflags ()
    local flag=$1; shift
    local var=$1; shift
    test -n "${flag}" -a -n "${var}" || return
    case "${!var}" in
    *${flag}*) return
    set -o noclobber
    case "$flag" in
	if echo 'int main () { return 0; }' | \
	    ${CC:-gcc} -Werror $flag -o /dev/null -xc - > /dev/null 2>&1 ; then
	    eval $var=\${$var:+\$$var\ }$flag
	if ${CC:-gcc} -Werror $flag -S -o /dev/null -xc /dev/null > /dev/null 2>&1 ; then
	    eval $var=\${$var:+\$$var\ }$flag
    set +o noclobber
CFLAGS="-Wall %{optflags} -I. -D_GNU_SOURCE"
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 -pie				LDFLAGS
export SENDMAIL=%{_sbindir}/sendmail
export ISPELL=%{_bindir}/hunspell
export PATH="%{_prefix}/lib/mit/bin:$PATH"
export KRB5CFGPATH="$(type -p krb5-config)"
$KRB5CFGPATH --cflags gssapi
$KRB5CFGPATH --libs gssapi
$KRB5CFGPATH --version
%configure \
	--with-docdir=%{_docdir}/%{name} \
%if %{with mutt_openssl}
	--without-gnutls \
	--with-ssl=%{_prefix} \
%if %{with mutt_gnutls}
	--without-ssl \
	--with-gnutls=%{_prefix} \
	--enable-imap \
	--enable-pop \
	--enable-pgp \
	--enable-gpgme \
	--enable-nfs-fix \
	--enable-mailtool \
	--enable-compressed \
	--enable-sidebar \
	--disable-external-dotlock \
	--with-kyotocabinet \
	--with-sasl=%{_prefix} \
	--with-gss=%{_prefix} \
	--with-curses=%{_prefix} \
	--enable-smtp \
	--enable-hcache \
	--enable-debug \
%if 0%{?suse_version} > 1315
%make_build -C doc clean
%make_build -C doc

install -m 755 %{SOURCE1} %{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 \
mv %{buildroot}%{_mandir}/man5/mmdf.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}/

mv  %{buildroot}%{_sysconfdir}/Muttrc %{buildroot}%{_datadir}/%{name}/Muttrc
sed -rn '/Command formats for gpg/,$p' %{SOURCE5} >> %{buildroot}%{_datadir}/%{name}/Muttrc

%if 0%{?suse_version}
%suse_update_desktop_file mutt

%if 0%{suse_version} >= 1500
mkdir -p %{buildroot}%{_docdir}/%{name}
install -m 755 %{SOURCE6} %{buildroot}%{_docdir}/%{name}/
install -m 644 %{SOURCE7} %{buildroot}%{_docdir}/%{name}/
%if %{?pkg_vcmp:%{pkg_vcmp python3-base < 3.7.0}}%{!?pkg_vcmp:0}
tar xf %{SOURCE8}
pushd backports-datetime-fromisoformat-1.0.0
    python3 install --root %{buildroot}

if test $1 -gt 1 -a -e %{_docdir}/%{name}/manual.txt.gz
    zcat %{_docdir}/%{name}/manual.txt.gz |  grep -F 'version %{version}' > /run/mutt-version || :

if test -f /run/mutt-version -a ! -s /run/mutt-version
    mkdir -p %{_localstatedir}/adm/update-messages
    cat > %{_localstatedir}/adm/update-messages/%{name}-%{version}-%{release}-notify <<-'EOF'
	With %{name}-%{version} some variables and the behaviour changes:
	   $send_multipart_alternative changes to run in batch mode on ask-yes.
	   $write_bcc changes to default off

rm -f %{_localstatedir}/adm/update-messages/%{name}-%{version}-%{release}-notify

%post doc
%install_info --info-dir=%{_infodir} "%{_infodir}/"

%preun doc
%install_info_delete --info-dir=%{_infodir} "%{_infodir}/"

%config(noreplace) %{_sysconfdir}/skel/.muttrc
%dir %{_datadir}/mutt/
%dir %doc %{_docdir}/%{name}/
%doc %{_docdir}/%{name}/manual.txt.gz
%if 0%{suse_version} >= 1500
%if %{?pkg_vcmp:%{pkg_vcmp python3-base < 3.7.0}}%{!?pkg_vcmp:0}

%files doc
%doc %{_docdir}/%{name}/COPYRIGHT
%doc %{_docdir}/%{name}/ChangeLog
%doc %{_docdir}/%{name}/GPL
%doc %{_docdir}/%{name}/NEWS
%doc %{_docdir}/%{name}/README*
%doc %{_docdir}/%{name}/TODO
%doc %{_docdir}/%{name}/*.html
%doc %{_docdir}/%{name}/*.txt
%dir %doc %{_docdir}/%{name}/samples/
%doc %{_docdir}/%{name}/samples/*.rc
%doc %{_docdir}/%{name}/samples/ca-bundle.crt
%doc %{_docdir}/%{name}/samples/colors.*
%doc %{_docdir}/%{name}/samples/markdown2html
%doc %{_docdir}/%{name}/samples/
%doc %{_docdir}/%{name}/samples/
%doc %{_docdir}/%{name}/samples/mutt_xtitle
%doc %{_docdir}/%{name}/samples/sample.*
%doc %{_docdir}/%{name}/samples/
%doc %{_docdir}/%{name}/samples/
%doc %{_docdir}/%{name}/samples/
%dir %doc %{_docdir}/%{name}/samples/iconv/
%doc %{_docdir}/%{name}/samples/iconv/*.rc

%files lang -f %{name}.lang

openSUSE Build Service is sponsored by