File monitoring-plugins-zypper.spec of Package monitoring-plugins-zypper

#
# spec file for package monitoring-plugins-zypper
#
# Copyright (c) 2016 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} >= 1230
%bcond_without systemd
%else
%bcond_with systemd
%endif

Name:           monitoring-plugins-zypper
Summary:        Check for software updates via zypper
License:        BSD-3-Clause
Group:          System/Monitoring
Version:        1.91
Release:        0
Url:            http://en.opensuse.org/Monitoring-plugins-zypper
Source0:        check_zypper.pl
Source1:        usr.lib.nagios.plugins.check_zypper 
Source2:        apparmor-abstractions-zypp
Source3:        apparmor-abstractions-ssl
Source4:        apparmor-abstractions-rpm
Requires:       gawk
Requires:       grep
Requires:       rpm
%if 0%{?suse_version} > 1010
# nagios can execute the script with embedded perl
Recommends:     perl 
Recommends:     apparmor-parser
BuildRequires:  apparmor-parser
%if 0%{?suse_version} > 1320
Requires:       apparmor-abstractions
%else
Requires:       apparmor-profiles
%endif
%endif
Requires:       zypper
BuildArch:      noarch
%if 0%{?suse_version}
BuildRequires:  distribution-release
%endif
%if %{with systemd}
%if 0%{?suse_version} >= 1210
BuildRequires:  systemd-rpm-macros
%endif
%{?systemd_requires}
%endif
BuildRequires:  nagios-rpm-macros
Provides:       nagios-plugins-zypper = %{version}-%{release}
Obsoletes:      nagios-plugins-zypper < %{version}-%{release}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
This plugin checks for software updates on systems that use package
management systems based on the zypper command found in (open)SUSE.

It checks for security, recommended and optional patches and also for
optional package updates.

You can define the status by patch category. Use a commata to list more
than one category to a state.

If you like to know the names of available patches and packages, use
the "-v" option.


%prep

%build

%install
install -D -m755 %{SOURCE0} %buildroot/%{nagios_plugindir}/check_zypper
%if 0%{?suse_version} > 01100
install -D -m644 %{SOURCE1} %{buildroot}%{_sysconfdir}/apparmor.d/usr.lib.nagios.plugins.check_zypper
install -D -m644 %{SOURCE4} %{buildroot}%{_sysconfdir}/apparmor.d/abstractions/rpm
install -D -m644 %{SOURCE3} %{buildroot}%{_sysconfdir}/apparmor.d/abstractions/ssl
install -D -m644 %{SOURCE2} %{buildroot}%{_sysconfdir}/apparmor.d/abstractions/zypp
mkdir -p %{buildroot}%{_sysconfdir}/apparmor.d/local
for file in usr.lib.nagios.plugins.check_zypper.zypp_refresh usr.lib.nagios.plugins.check_zypper ; do
cat > %{buildroot}%{_sysconfdir}/apparmor.d/local/$file << EOF
# Site-specific additions and overrides for usr.lib.nagios.plugins.check_zypper
# See /etc/apparmor.d/local/README for details.
EOF
done
%else
install -D -m644 %{SOURCE1} %{buildroot}%{_sysconfdir}/apparmor/profiles/extras/usr.lib.nagios.plugins.check_zypper
%endif

%check
# generic test if check_zypper is working at all
%buildroot/%{nagios_plugindir}/check_zypper --help
if [ "$?" != "0" ]; then
    echo "Test failed: check_zypper can not print help text" >&2
    exit 1
fi

%clean
rm -rf %buildroot

%post
%{_sysconfdir}/init.d/boot.apparmor try-restart || echo "restarting boot.apparmor failed" >&2

%files 
%defattr(-,root,root)
# avoid build dependecy of nagios - own the dirs
%dir %{nagios_libdir}
%dir %{nagios_plugindir}
%if 0%{?suse_version} > 01100
%dir %{_sysconfdir}/apparmor.d
%dir %{_sysconfdir}/apparmor.d/abstractions
%config(noreplace) %{_sysconfdir}/apparmor.d/abstractions/rpm
%config(noreplace) %{_sysconfdir}/apparmor.d/abstractions/ssl
%config(noreplace) %{_sysconfdir}/apparmor.d/abstractions/zypp
%dir %{_sysconfdir}/apparmor.d/local
%config %{_sysconfdir}/apparmor.d/usr.lib.nagios.plugins.check_zypper
%config(noreplace) %{_sysconfdir}/apparmor.d/local/usr.lib.nagios.plugins.check_zypper
%config(noreplace) %{_sysconfdir}/apparmor.d/local/usr.lib.nagios.plugins.check_zypper.zypp_refresh
%else
%dir %{_sysconfdir}/apparmor
%dir %{_sysconfdir}/apparmor/profiles
%dir %{_sysconfdir}/apparmor/profiles/extras
%config(noreplace) %{_sysconfdir}/apparmor/profiles/extras/usr.lib.nagios.plugins.check_zypper
%endif
%{nagios_plugindir}/check_zypper

%changelog
openSUSE Build Service is sponsored by