File arpwatch.spec of Package arpwatch

# spec file for package arpwatch
# Copyright (c) 2014 SUSE LINUX Products 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

%if 0%{?suse_version} > 1140
%define has_systemd 1

Name:           arpwatch
BuildRequires:  libpcap-devel
BuildRequires:  postfix
%if 0%{?has_systemd}
BuildRequires:  systemd
Requires:       arpwatch-ethercodes
%if 0%{?suse_version} <= 1140
PreReq:         /usr/bin/touch %insserv_prereq %fillup_prereq
PreReq:         /usr/bin/touch %fillup_prereq
Summary:        Arpwatch Keeps Track of Ethernet and IP Address Pairings
License:        BSD-3-Clause
Group:          Productivity/Networking/Diagnostic
Version:        2.1a15
Release:        0
Source:         %{name}-%{version}.tar.bz2
%if 0%{?has_systemd}
Source10:       arpwatch@.service
Source10:       arpwatch.init
Source11:       sysconfig.arpwatch
Patch0:         arpwatch-2.1a11-chrootbuild.diff
Patch1:         arpwatch-no-source-zero.dif
Patch3:         arpwatch-2.1a11-tokenring.diff
Patch4:         arpwatch-2.1a11-hname-overflow.dif
Patch5:         arpwatch-2.1a11-drop-privs-manpage.dif
Patch6:         arpwatch-2.1a11-drop-privs.dif
Patch7:         arpwatch-2.1a11-emailaddr.dif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

Arpwatch keeps track of Ethernet and IP address pairings. It logs
activity to syslog and reports certain changes via e-mail.

%package ethercodes-build
Summary:        Tool to create ethercodes.dat from meta data
Group:          Productivity/Networking/Diagnostic

%description ethercodes-build
Tool and required files to create the ethercodes.dat file from the OUI
and company ID data as provided by  This package is only
needed if you want to build the arpwatch-ethercodes package.

%setup -q
%patch -P 0 -E
%patch1 -p1 -E
%patch3 -p1 -E
%patch4 -p1 -E
%patch5 -p1 -E
%patch6 -p1 -E
%patch7 -p1 -E

%{__make} ARPDIR=/var/lib/arpwatch %{?_smp_mflags}

mkdir -p \
%if 0%{?has_systemd}
    $RPM_BUILD_ROOT/%{_unitdir} \
    $RPM_BUILD_ROOT/etc/init.d \
    $RPM_BUILD_ROOT/%{_sbindir} \
	$RPM_BUILD_ROOT/%{_datadir}/arpwatch \
	$RPM_BUILD_ROOT/%{_mandir}/man8 \
# ethercodes.dat is in the arpwatch-ethercodes package
rm -f $RPM_BUILD_ROOT/%{_datadir}/arpwatch/ethercodes.dat
for file in massagevendor euppertolower.awk duplicates.awk p.awk; do
	cp -p ${file} $RPM_BUILD_ROOT/%{_datadir}/arpwatch
make DESTDIR=$RPM_BUILD_ROOT install-man
%if 0%{?has_systemd}
install -m 0754 $RPM_SOURCE_DIR/arpwatch@.service $RPM_BUILD_ROOT/%{_unitdir}
install -m 0754 $RPM_SOURCE_DIR/arpwatch.init $RPM_BUILD_ROOT/etc/init.d/arpwatch
ln -sf ../../etc/init.d/arpwatch $RPM_BUILD_ROOT/%{_sbindir}/rcarpwatch
cp -p ${RPM_SOURCE_DIR}/sysconfig.arpwatch $RPM_BUILD_ROOT/var/adm/fillup-templates
# own the database files
touch $RPM_BUILD_ROOT/var/lib/arpwatch/arp.dat
touch $RPM_BUILD_ROOT/var/lib/arpwatch/arp.dat-

%if 0%{?has_systemd}
%service_add_pre arpwatch@.service

%if 0%{?has_systemd}
%service_del_preun arpwatch@.service
%stop_on_removal arpwatch

%if 0%{?has_systemd}
%service_add_post arpwatch@.service
if [ ! -f var/lib/arpwatch/arp.dat ]; then
	touch var/lib/arpwatch/arp.dat

%if 0%{?has_systemd}
%service_del_postun arpwatch@.service
%restart_on_update arpwatch

%if 0%{?has_systemd}
%config /etc/init.d/arpwatch
%dir /var/lib/arpwatch
%ghost %config(noreplace) /var/lib/arpwatch/arp.dat
%ghost %config(noreplace) /var/lib/arpwatch/arp.dat-
%doc %{_mandir}/man8/arpsnmp.8.gz
%doc %{_mandir}/man8/arpwatch.8.gz

%files ethercodes-build