File clewarecontrol.spec of Package clewarecontrol

#
# spec file for package clewarecontrol
#
# Copyright (c) 2022 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


%define clewareuser  _clewarecontrol
%define clewaregroup _clewarecontrol
Name:           clewarecontrol
Version:        5.0
Release:        0
Summary:        Control Cleware USB devices
License:        GPL-2.0-only
Group:          Hardware/Other
URL:            https://vanheusden.com/drivers/cleware/
Source:         https://vanheusden.com/drivers/cleware/%{name}-%{version}.tgz
Source1:        %{name}.service
Source2:        clewarecontrol.rc
Source3:        %{name}.conf
Source12:       check_temperature
Source100:      clewarecontrol-rpmlintrc
Patch0:         fix-path.patch
BuildRequires:  gcc-c++
BuildRequires:  nagios-rpm-macros
BuildRequires:  pkgconfig
BuildRequires:  systemd-rpm-macros
BuildRequires:  pkgconfig(hidapi-hidraw)
Requires(pre):  shadow
%{?systemd_requires}

%description
This program lets you control the USB-devices made by Cleware GmbH.

You can measure the temperature or humidity, switch on and off and configure
switches, control the watchdog, etc.

%lang_package

%package    check_temperature
Summary:        Nagios script to monitor the temperature through clewarecontrol
Group:          System/Monitoring
Recommends:     nrpe

%description check_temperature
Provides a small bash script which interacts with nagios or icinga through
NRPE.

%prep
%autosetup -p1

%build
CXXFLAGS+=" %{optflags}"
export CXXFLAGS
%make_build

%pre
%{_sbindir}/groupadd -r %{clewaregroup} >/dev/null 2>&1 || :
%{_sbindir}/useradd -g %{clewaregroup} -s /bin/false -r \
  -c "clewarecontrol" -d %{_localstatedir}/run/clewarecontrol %{clewareuser} >/dev/null 2>&1 || :
%service_add_pre %{name}.service

%post
systemd-tmpfiles --create %{_tmpfilesdir}/%{name}.conf || true
%service_add_post %{name}.service

%preun
%service_del_preun %{name}.service

%postun
%service_del_postun %{name}.service

%install
install -d %{buildroot}/%{_bindir} %{buildroot}%{_sbindir}
make install DESTDIR=%{buildroot} PREFIX=%{_prefix}
install -Dm 0755 %{SOURCE12} %{buildroot}/%{nagios_plugindir}/check_temperature
install -Dm 0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
install -Dm 0644 %{SOURCE3} %{buildroot}%{_tmpfilesdir}/%{name}.conf
%find_lang %{name} --all-name %{?no_lang_C}

%files
%doc readme.txt
%{_sbindir}/rc%{name}
%{_bindir}/%{name}
%dir %{_tmpfilesdir}
%{_tmpfilesdir}/%{name}.conf
%{_unitdir}/%{name}.service
%{_mandir}/man1/clewarecontrol.1%{?ext_man}

%files lang -f %{name}.lang

%files check_temperature
%defattr(0755,root,root)
%dir %{nagios_libdir}
%dir %{nagios_plugindir}
%{nagios_plugindir}/check_temperature

%changelog
openSUSE Build Service is sponsored by