%define _localstatedir /var

%define	_newconfigdir	%{_sysconfdir}/uucp
%define	_oldconfigdir	%{_sysconfdir}/uucp/oldconfig
%define	_varlogdir	%{_localstatedir}/log/uucp
%define	_varlockdir	%{_localstatedir}/lock
%define	_varspooldir	%{_localstatedir}/spool

Summary: The uucp utility for copying files between systems.
Summary(ja): システム間でファイル転送を行う uucp ユーティリティ
Name: uucp
Version: 1.06.1
Release: 33vl1
Copyright: GPL
Group: Applications/Communications
Source0: ftp://prep.ai.mit.edu/pub/gnu/uucp-1.06.1.tar.gz
Source1: uucp.log
Patch0: uucp-1.06.1-misc.patch
Patch1: uucp-1.06.1-uureroute.patch
Patch2: uucp-perl.patch
Patch3: uucp-1.06.1-sigfpe.patch
Patch4: uucp-1.06.1-cfgmake.patch
Patch5: uucp-1.06.1-lock.patch
Patch6: uucp-1.06.1-baudboy.patch
Patch7: uucp-1.06.1-vetargs2.patch
Prereq: fileutils /sbin/install-info
#BuildPrereq: lockdev-devel >= 1.0.0-14
#Requires: lockdev >= 1.0.0-14
BuildRoot: %{_tmppath}/%{name}-%{version}-root

%description
The uucp command copies files between systems. Uucp is primarily used
by remote machines downloading and uploading email and news files to
local machines.

%description -l ja
uucp コマンドはシステム間でファイルをコピーします．
uucp の主な使われ方としては，電子メールやニュースファイルの
遠隔マシンへのダウンロード/アップロード等があります．

%prep
%setup -q
%patch -p1 -b .config
%patch1 -p1 -b .perlpath
%patch3 -p0
%patch4 -p1 -b .cfgmake
#%patch5 -p1 -b .lock
#%patch6 -p1 -b .baudboy
%patch7 -p1 -b .vetargs2

find . -name "*.perlpath" -exec rm {} \;
autoconf

%build

%configure
make \
    owner=uucp group=uucp \
    newconfigdir=%{_newconfigdir} \
    oldconfigdir=%{_oldconfigdir} \
    man1dir=%{_mandir}/man1 \
    man8dir=%{_mandir}/man8 \
	all

%install
rm -rf ${RPM_BUILD_ROOT}
mkdir -p ${RPM_BUILD_ROOT}%{_bindir}
mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man1
mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man8

%makeinstall \
    owner=$(id -un) group=$(id -gn) \
    newconfigdir=${RPM_BUILD_ROOT}%{_newconfigdir} \
    oldconfigdir=${RPM_BUILD_ROOT}%{_oldconfigdir} \
    man1dir=${RPM_BUILD_ROOT}%{_mandir}/man1 \
    man8dir=${RPM_BUILD_ROOT}%{_mandir}/man8 \
	install-info 

gzip -9nf ${RPM_BUILD_ROOT}%{_infodir}/uucp*

mkdir -p ${RPM_BUILD_ROOT}%{_varlogdir}
mkdir -p ${RPM_BUILD_ROOT}%{_varlockdir}

mkdir -p ${RPM_BUILD_ROOT}%{_varspooldir}/uucp
mkdir -p ${RPM_BUILD_ROOT}%{_varspooldir}/uucppublic
mkdir -p ${RPM_BUILD_ROOT}%{_oldconfigdir}

strip ${RPM_BUILD_ROOT}%{_sbindir}/* || :
strip ${RPM_BUILD_ROOT}%{_bindir}/* || :

mkdir -p ${RPM_BUILD_ROOT}/usr/lib/uucp
ln -sf ../../sbin/uucico ${RPM_BUILD_ROOT}/usr/lib/uucp/uucico

mkdir -p ${RPM_BUILD_ROOT}/etc/logrotate.d
install -m 644 $RPM_SOURCE_DIR/uucp.log ${RPM_BUILD_ROOT}/etc/logrotate.d/uucp

# Create ghost files
for n in Log Stats Debug; do
    touch ${RPM_BUILD_ROOT}%{_varlogdir}/$n
done

# the following is kind of gross, but it is effective
for i in dial passwd port dialcode sys call ; do
cat > ${RPM_BUILD_ROOT}%{_newconfigdir}/$i <<EOF 
# This is an example of a $i file. This file have the syntax compatible
# with Taylor UUCP (not HDB, not anything else). Please check uucp
# documentation if you are not sure how Taylor config files are supposed to 
# look like. Edit it as appropriate for your system.

# Everything after a '#' character is a comment.
EOF
done

# some more documentation
texi2html -monolithic uucp.texi

%clean
rm -rf ${RPM_BUILD_ROOT}

%post
# Create initial log files so that logrotate doesn't complain
for n in Log Stats Debug; do
	[ -f %{_varlogdir}/$n ] || touch %{_varlogdir}/$n
	chown uucp:uucp %{_varlogdir}/$n
done
chmod 644 %{_varlogdir}/Log %{_varlogdir}/Stats
chmod 600 %{_varlogdir}/Debug

/sbin/install-info %{_infodir}/uucp.info.gz %{_infodir}/dir

%preun
/sbin/install-info --del %{_infodir}/uucp.info.gz %{_infodir}/dir

# 1.06.1-31vl0, 1.06.1-31vl1 owned /var/lock directory
%triggerpostun -- uucp = 1.06.1-31vl1
# owner/group/perms inconsistency with filesystem 775 root.uucp be fixed
if [ -d /var/lock ];then
	chown root.uucp /var/lock >/dev/null 2>&1 || :
	chmod 775 /var/lock >/dev/null 2>&1 || :
fi
exit 0

%triggerpostun -- uucp = 1.06.1-31vl0
# owner/group/perms inconsistency with filesystem 775 root.uucp be fixed
if [ -d /var/lock ];then
	chown root.uucp /var/lock >/dev/null 2>&1 || :
	chmod 775 /var/lock >/dev/null 2>&1 || :
fi
exit 0

%files
%defattr(-,root,root)
%doc README COPYING ChangeLog MANIFEST NEWS
%doc sample contrib uucp.html

%attr(6555,uucp,uucp)		%{_bindir}/cu
%attr(4555,uucp,uucp)		%{_bindir}/uucp
%attr(0755,root,root)		%{_bindir}/uulog
%attr(6555,uucp,uucp)		%{_bindir}/uuname
%attr(0755,root,root)		%{_bindir}/uupick
%attr(4555,uucp,uucp)		%{_bindir}/uustat
%attr(0755,root,root)		%{_bindir}/uuto
%attr(4555,uucp,uucp)		%{_bindir}/uux

%attr(6555,uucp,uucp)		%{_sbindir}/uucico
%attr(6555,uucp,uucp)		%{_sbindir}/uuxqt
%attr(0755,uucp,uucp)		%{_sbindir}/uuchk
%attr(0755,uucp,uucp)		%{_sbindir}/uuconv
%attr(0755,root,root)		%{_sbindir}/uusched


%attr(755,uucp,uucp)	%dir	/usr/lib/uucp
/usr/lib/uucp/uucico

%{_mandir}/man[18]/*
%{_infodir}/uucp.info*

%attr(0755,uucp,uucp)	%dir	%{_varlogdir}
%attr(0644,uucp,uucp)	%ghost	%{_varlogdir}/Log
%attr(0644,uucp,uucp)	%ghost	%{_varlogdir}/Stats
%attr(0600,uucp,uucp)	%ghost	%{_varlogdir}/Debug
#XXX: we dont put this file at the momennt 
#%attr(755,uucp,uucp)	%dir	%{_varlockdir}
%attr(755,uucp,uucp)	%dir	%{_varspooldir}/uucp
%attr(755,uucp,uucp)	%dir	%{_varspooldir}/uucppublic

%config(noreplace)	/etc/logrotate.d/uucp

%dir	%{_newconfigdir}
%dir	%{_oldconfigdir}
%attr(0640,root,uucp)	%config(noreplace)	%{_newconfigdir}/call
%config(noreplace)	%{_newconfigdir}/dial
%config(noreplace)	%{_newconfigdir}/dialcode
%attr(0640,root,uucp)	%config(noreplace)	%{_newconfigdir}/passwd
%config(noreplace)	%{_newconfigdir}/port
%config(noreplace)	%{_newconfigdir}/sys

%changelog
* Sat Feb 09 2002 Toru Sagami <sagami@vinelinux.org> 1.06.1-33vl1
- sync with 1.06.1-33.6.2 (filter all the long option aliases as well.)
- don't own /var/lock and fix owner/permission in triggerpostun script

* Wed Jan 23 2002 Toru Sagami <sagami@vinelinux.org> 1.06.1-31vl1
- follow up with 1.06.1-31.6x (RHSA-2001:165-08)
- fixed: man8 pages are installed into man1 dir

* Mon Sep 03 2001 Toru Sagami <sagami@vinelinux.org>
- 1.06.1-25vl2
- define %%_localstatedir as /var (might implicitly want it done by rpmmacros)

* Wed Jan 10 2001 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rhythmaning.org>
- 1.06.1-25vl1
- based on 1.06.1-25 from Rawhide
- added nochown patch for non-root rebuild (Patch10)
- added Japanese summary and description

* Thu Jul 13 2000 Prospector <bugzilla@redhat.com>
- automatic rebuild

* Fri Jun  2 2000 Jeff Johnson <jbj@redhat.com>
- FHS packaging.
- map perms/owners into %%files to build as non-root.

* Tue Mar  7 2000 Jeff Johnson <jbj@redhat.com>
- rebuild for sparc baud rates > 38400.

* Sun Feb 13 2000 Florian La Roche <Florian.LaRoche@redhat.com>
- change perms to be root:root for the config files and
  0640,root:uucp for config files containing passwords
- add patch from #6151 (division by zero, SIGFPE)
- make %post work also for simple sh-versions

* Mon Feb  7 2000 Jeff Johnson <jbj@redhat.com>
- compress man pages.

* Mon Aug 23 1999 Jeff Johnson <jbj@redhat.com>
- add notifempty/missingok to logrotate config file (#4138).

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

* Tue Dec 22 1998 Bill Nottingham <notting@redhat.com>
- expunge /usr/local/bin/perl reference in docs

* Thu Dec 17 1998 Cristian Gafton <gafton@redhat.com>
- build for glibc 2.1

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

* Sat Apr 11 1998 Cristian Gafton <gafton@redhat.com>
- manhattan rebuild
- added sample config files in /etc/uucp

* Sun Oct 19 1997 Erik Troan <ewt@redhat.com>
- spec file cleanups
- added install-info support
- uses a build root

* Fri Oct 10 1997 Erik Troan <ewt@redhat.com>
- patched uureroute to find perl in /usr/bin instead of /usr/local/bin
- made log files ghosts

* Mon Jul 21 1997 Erik Troan <ewt@redhat.com>
- built against glibc

* Tue Apr 22 1997 Erik Troan <ewt@redhat.com>
- Brian Candler fixed /usr/lib/uucp/uucico symlink
- Added "create" entries to log file rotation configuration
- Touch log files on install if they don't already exist to allow proper
  rotation

* Tue Mar 25 1997 Erik Troan <ewt@redhat.com>
- symlinked /usr/sbin//uucico into /usr/lib/uucp
- (all of these changes are from Brian Candler <B.Candler@pobox.com>)
- sgid bit added on uucico so it can create lock files
- log files moved to /var/log/uucp/ owned by uucp (so uucico can create them)
- log rotation added
- uses /etc/uucp/oldconfig instead of /usr/lib/uucp for old config files
- package creates /etc/uucp and /etc/uucp/oldconfig directories
- man pages reference the correct locations for spool and config files

