Name:           mutt
Version:        1.10.1
Release:        3
Epoch:          5
Summary:        Text-based mail client
License:        GPLv2+ and Public Domain
URL:            http://www.mutt.org
Source:         ftp://ftp.mutt.org/pub/%{name}/%{name}-%{version}.tar.gz
Source1:        mutt_ldap_query

Patch10:        mutt-1.9.4-lynx_no_backscapes.patch
Patch12:        mutt-1.9.5-nodotlock.patch
Patch1:         mutt-1.10.0-muttrc.patch
Patch2:         mutt-1.8.0-cabundle.patch
Patch3:         mutt-1.7.0-syncdebug.patch
Patch8:         mutt-1.5.23-system_certs.patch
Patch9:         mutt-1.9.0-ssl_ciphers.patch
Patch13:        CVE-2020-28896.patch

BuildRequires:  gcc ncurses-devel gettext automake /usr/bin/xsltproc
BuildRequires:  lynx docbook-style-xsl perl-interpreter perl-generators
BuildRequires:  tokyocabinet-devel gnutls-devel cyrus-sasl-devel
BuildRequires:  krb5-devel libidn2-devel gpgme-devel
Requires:       mailcap urlview

%description
Mutt is a small but very powerful text-based mail client for Unix operating systems.

%package_help

%prep
%autosetup -n %{name}-%{version} -p1

autoreconf --install

sed -i -r 's/`$GPGME_CONFIG --libs`/"\0 -lgpg-error"/' configure

install -p -m644 %{SOURCE1} mutt_ldap_query

if echo %{release} | grep -E -q '\\.(201[0-9])([0-1][0-9])([0-3][0-9])hg\\.(201[0-9])([0-1][0-9])([0-3][0-9])hg'; then
  echo -n 'const char *ReleaseDate = ' > reldate.h
  echo %{release} | sed -r 's/.*\\.(201[0-9])([0-1][0-9])([0-3][0-9])hg.*/"\1-\2-\3";/' >> reldate.h
fi

rm -f mutt_ssl.c

%build
%configure \
    SENDMAIL=%{_sbindir}/sendmail \
    ISPELL=%{_bindir}/hunspell \
    --enable-debug \
    --enable-pop \
    --enable-imap \
    --enable-smtp \
    --enable-hcache \
    --without-gdbm \
    --without-qdbm \
    --with-gnutls \
    --with-sasl \
    --with-gss \
    --without-idn \
    --with-idn2 \
    --enable-gpgme \
    --enable-sidebar \
    --with-docdir=%{_docdir}/%{name}-%{version}}

%make_build

sed -i -r 's/<a id="id[a-z0-9]\+">/<a id="id">/g' doc/manual.html

%install
%make_install

cat contrib/gpg.rc >> \
      %{buildroot}%{_sysconfdir}/Muttrc

grep -5 "^color" contrib/sample.muttrc >> \
      %{buildroot}%{_sysconfdir}/Muttrc

cat >> %{buildroot}%{_sysconfdir}/Muttrc <<\EOF
source %{_sysconfdir}/Muttrc.local
EOF

echo "# Local configuration for Mutt." > \
      %{buildroot}%{_sysconfdir}/Muttrc.local

ln -sf ./muttrc.5 %{buildroot}%{_mandir}/man5/muttrc.local.5

%find_lang %{name}

%files -f %{name}.lang
%{!?_licensedir:%global license %doc}
%license COPYRIGHT GPL
%doc ChangeLog NEWS README* UPDATING mutt_ldap_query
%doc contrib/*.rc contrib/sample.* contrib/colors.*
%doc doc/manual.html doc/manual.txt doc/smime-notes.txt
%config(noreplace) %{_sysconfdir}/Muttrc
%config(noreplace) %{_sysconfdir}/Muttrc.local
%{_bindir}/mutt
%{_bindir}/pgpring
%{_bindir}/pgpewrap
%{_bindir}/smime_keys
%exclude %{_sysconfdir}/*.dist
%exclude %{_sysconfdir}/mime.types
%exclude %{_bindir}/mutt_dotlock
%exclude %{_bindir}/muttbug
%exclude %{_bindir}/flea
%exclude %{_mandir}/man1/mutt_dotlock.1*
%exclude %{_mandir}/man1/muttbug.1*
%exclude %{_mandir}/man1/flea.1*
%exclude %{_mandir}/man5/mbox.5*
%exclude %{_mandir}/man5/mmdf.5*
%exclude %{_docdir}/%{name}-%{version}}

%files help
%{_mandir}/man1/mutt.*
%{_mandir}/man1/smime_keys.*
%{_mandir}/man1/pgpring.*
%{_mandir}/man1/pgpewrap.*
%{_mandir}/man5/muttrc.*

%changelog
* Thu Jan 07 2021 wangyue<wangyue92@huawei.com> - 1.10.1-3
- fix CVE-2020-28896

* Tue Nov 19 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.10.1-2
- Package init
