watchdog/watchdog.spec

147 lines
4.3 KiB
RPMSpec

#
# spec file for package watchdog
#
# Copyright (c) 2018 SUSE LINUX 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 http://bugs.opensuse.org/
#
%if 0%{?suse_version} >= 1220
%define with_systemd 1
%else
%define with_systemd 0
%endif
%if 0%{?suse_version} >= 1500
%define with_tirpc 1
%else
%define with_tirpc 0
%endif
Summary: Software and/or Hardware watchdog daemon
Name: watchdog
Version: 5.15
Release: 1
License: GPL-2.0
Group: System/Daemons
Url: http://sourceforge.net/projects/watchdog/
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Source0: %{name}-%{version}.tar.gz
Source4: watchdog.service
Source5: watchdog-ping.service
Patch0: watchdog-sysconfdir.diff
Patch1: watchdog-initscript.diff
%if %{with_tirpc}
BuildRequires: libtirpc-devel
%endif
%if %{with_systemd}
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
%endif
%description
The watchdog program can be used as a powerful software watchdog daemon
or may be alternately used with a hardware watchdog device such as the
IPMI hardware watchdog driver interface to a resident Baseboard
Management Controller (BMC). watchdog periodically writes to /dev/watchdog;
the interval between writes to /dev/watchdog is configurable through settings
in the watchdog sysconfig file. This configuration file is also used to
set the watchdog to be used as a hardware watchdog instead of its default
software watchdog operation. In either case, if the device is open but not
written to within the configured time period, the watchdog timer expiration
will trigger a machine reboot. When operating as a software watchdog, the
ability to reboot will depend on the state of the machine and interrupts.
When operating as a hardware watchdog, the machine will experience a hard
reset (or whatever action was configured to be taken upon watchdog timer
expiration) initiated by the BMC.
%prep
%setup -q -n %{name}-%{version}
mv README README.orig
iconv -f ISO-8859-1 -t UTF-8 < README.orig > README
%patch0 -p1
%patch1 -p1
%build
%configure \
%if %{with_tirpc}
CFLAGS="$CFLAGS -I/usr/include/tirpc" \
LIBS="$LIBS -ltirpc"
%endif
%__make %{?_smp_mflags}
%install
install -d -m0755 %{buildroot}%{_sysconfdir}
make DESTDIR=%{buildroot} install
%if %{with_systemd}
install -Dp -m0644 %{SOURCE4} %{buildroot}%{_unitdir}/watchdog.service
install -Dp -m0644 %{SOURCE5} %{buildroot}%{_unitdir}/watchdog-ping.service
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rcwatchdog
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rcwatchdog-ping
%else
install -d -m0755 %{buildroot}%{_sysconfdir}/init.d
install -m0755 suse/rc.watchdog.suse %{buildroot}%{_sysconfdir}/init.d/watchdog
ln -sf ../../%{_sysconfdir}/init.d/watchdog %{buildroot}/%{_sbindir}/rcwatchdog
%endif
%pre
%if %{with_systemd}
%service_add_pre %{name}.service watchdog-ping.service
%endif
%post
%if %{with_systemd}
%service_add_post %{name}.service watchdog-ping.service
%endif
%preun
%if %{with_systemd}
%service_del_preun %{name}.service watchdog-ping.service
%else
%{stop_on_removal %{name}}
%endif
%postun
%if %{with_systemd}
%service_del_postun %{name}.service watchdog-ping.service
%else
%{restart_on_update %{name}}
%{insserv_cleanup}
%endif
%files
%defattr(-, root, root, -)
%doc AUTHORS ChangeLog COPYING examples/ IAFA-PACKAGE NEWS README TODO README.watchdog.ipmi
%config(noreplace) %{_sysconfdir}/watchdog.conf
%if %{with_systemd}
%{_unitdir}/watchdog.service
%{_unitdir}/watchdog-ping.service
%{_sbindir}/rcwatchdog-ping
%else
%{_sysconfdir}/init.d/watchdog
%endif
%{_sbindir}/rcwatchdog
%{_sbindir}/watchdog
%{_sbindir}/wd_keepalive
%{_sbindir}/wd_identify
%{_mandir}/man5/watchdog.conf.5*
%{_mandir}/man8/watchdog.8*
%{_mandir}/man8/wd_keepalive.8*
%{_mandir}/man8/wd_identify.8*
%changelog