%define _datadir        %{_prefix}/lib

Summary: The /bin/mail program for sending e-mail messages.
Name: mailx
Version: 8.1.1
Release: 28
Copyright: BSD
Group: Applications/Internet
Source: ftp://ftp.debian.org/pub/debian/hamm/source/mail/mailx-8.1.1.tar.gz
Source1: flock.c
Patch0: mailx-8.1.1.debian.patch
Patch1: mailx-8.1.1.security.patch
Patch2: mailx-8.1.1.nolock.patch
Patch3: mailx-8.1.1.debian2.patch
Patch4: mailx-noroot.patch
Patch5: mailx-nopanic.patch
Patch6: mailx-nullchar.patch
Patch7: mailx-8.1.1-fhs.patch
Patch8: mailx-8.1.1-environ.patch
Patch9: mailx-8.1.1-siglj.patch
Patch10: mailx-8.1.1-bug15728.patch
Patch11: mailx-8.1.1-bug10074.patch
Patch12: mailx-8.1.1-uidcheck.patch
Patch13: mailx-8.1.1-flock.patch
Patch14: mailx-8.1.1-nostrip.patch
BuildRoot: %{_tmppath}/%{name}-root

%description
The mailx package installs the /bin/mail program, which is used to
send quick email messages (i.e., without opening up a full-featured
mail user agent). Mail is often used in shell scripts.

You should install mailx because of its quick email sending ability,
which is especially useful if you're planning on writing any shell
scripts.

%prep
%setup -q
cp %{SOURCE1} .
%patch0 -p1 -b .debian
%patch1 -p1 -b .security
%patch2 -p1 -b .nolock
%patch3 -p1 -b .debian2
%patch4 -p1 -b .noroot
%patch5 -p1 -b .nopanic
%patch6 -p1 -b .nullchar
%patch7 -p1 -b .fhs
%patch8 -p1 -b .environ
%patch9 -p1 -b .siglj
%patch10 -p1 -b .bug15728
%patch11 -p1 -b .bug10074
%patch12 -p1 -b .uidcheck
%patch13 -p1 -b .flock
%patch14 -p1

%build
make CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE"

%install
rm -rf ${RPM_BUILD_ROOT}
mkdir -p ${RPM_BUILD_ROOT}/{bin,etc}
mkdir -p ${RPM_BUILD_ROOT}%{_bindir}
mkdir -p ${RPM_BUILD_ROOT}%{_datadir}
mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man1

make DESTDIR=${RPM_BUILD_ROOT} bindir=%{_bindir} mandir=%{_mandir} install

( cd ${RPM_BUILD_ROOT}
  mv .%{_bindir}/mail ./bin/mail
  chmod g-s ./bin/mail
  ln -sf ../../bin/mail .%{_bindir}/Mail
  ln -sf mail.1 .%{_mandir}/man1/Mail.1
)

%clean
rm -rf ${RPM_BUILD_ROOT}

%files
%defattr(-,root,root)
%attr(755,root,mail)    /bin/mail
%{_bindir}/Mail
%{_datadir}/mail.help
%{_datadir}/mail.tildehelp
%config(noreplace) /etc/mail.rc
%{_mandir}/man1/mail.1*
%{_mandir}/man1/Mail.1*

%changelog
* Wed Jan 22 2003 Tim Powers <timp@redhat.com>
- rebuilt

* Tue Nov 19 2002 Tim Powers <timp@redhat.com>
- rebuild on all arches

* Fri Jun 21 2002 Tim Powers <timp@redhat.com>
- automated rebuild

* Wed Jun 19 2002 Florian La Roche <Florian.LaRoche@redhat.de>
- do not strip apps

* Thu May 23 2002 Tim Powers <timp@redhat.com>
- automated rebuild

* Fri Jan 25 2002 Florian La Roche <Florian.LaRoche@redhat.de>
- rebuild

* Sun Jun 24 2001 Elliot Lee <sopwith@redhat.com>
- Bump release + rebuild.

* Thu Aug 24 2000 Nalin Dahyabhai <nalin@redhat.com>
- clean up flock() usage -- LOCK_EX shouldn't work on read-only descriptors

* Mon Aug 21 2000 Nalin Dahyabhai <nalin@redhat.com>
- patch to use fcntl() for locking instead of flock() (#15779)
- patch to ignore ~/.mailrc if it's owned by anyone other than the owner of
  this process
- clean up flock() emulation semantics

* Thu Aug 17 2000 Jeff Johnson <jbj@redhat.com>
- summaries from specspo.

* Fri Aug 11 2000 Jeff Johnson <jbj@redhat.com>
- time to use sigsetjmp/siglongjmp (#14010).
- avoid indexing on NOSTR valued pointer (#15728).
- ignore MAIL enviromment variable when invoked with -u (#10074).

* Mon Aug  7 2000 Nalin Dahyabhai <nalin@redhat.com>
- disable security-prone variables-inherited-from-environment behavior
- inherit only SHELL, DEAD, PAGER, LISTER, EDITOR, VISUAL, MBOX from environment
- document the environment variables that are used

* Wed Jul 12 2000 Prospector <bugzilla@redhat.com>
- automatic rebuild

* Wed Jun 21 2000 Preston Brown <pbrown@redhat.com>
- noreplace mail.rc

* Sun Jun 18 2000 Jeff Johnson <jbj@redhat.com>
- FHS packaging.

* Sun May  7 2000 Bill Nottingham <notting@redhat.com>
- fix explosions on ia64

* Thu Feb 03 2000 Elliot Lee <sopwith@redhat.com>
- Fix bug #8451
- Fix bug #8100

* Tue Aug 31 1999 Bill Nottingham <notting@redhat.com>
- fix pathnames
- take out makefile install crud

* Sun Mar 21 1999 Cristian Gafton <gafton@redhat.com>
- auto rebuild in the new build environment (release 8)

* Thu Aug 27 1998 Alan Cox <alan@redhat.com>
- Synchronized with the Debian people (more small edge case cures)

* Tue Aug  4 1998 Jeff Johnson <jbj@redhat.com>
- build root

* Wed Jun 24 1998 Alan Cox <alan@redhat.com>
- Switched dotlocking off. This fits the Red Hat model of not having setgid
  mail agents and fixes the "lock" problem reported.

* Mon Jun 22 1998 Alan Cox <alan@redhat.com>
- Buffer overrun patches. These dont bite us when we don't run mailx setgid
  but do want to be in as mailx needs to be setgid

* Fri Jun 12 1998 Alan Cox <alan@redhat.com>
- Moved from 5.5 to the OpenBSD 8.1 release plus Debian patches

* Tue May 05 1998 Prospector System <bugs@redhat.com>
- translations modified for de, fr, tr

* Tue Oct 21 1997 Donnie Barnes <djb@redhat.com>
- spec file cleanups

* Thu Jun 12 1997 Erik Troan <ewt@redhat.com>
- built against glibc