File tuptime.spec of Package tuptime
#
# spec file for package tuptime
#
# Copyright (c) 2020 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/
#
Name: tuptime
Version: 5.2.4
Release: 0
Summary: Like uptime command but with more interesting output
License: GPL-2.0-only
URL: https://github.com/rfrail3/tuptime
Source0: %{name}-%{version}.tar.gz
Source1: system-user-tuptime.conf
Source2: tuptime.preset
Patch0: tuptime-systemd-service-fix.patch
BuildRequires: sysuser-shadow
BuildRequires: sysuser-tools
BuildRequires: cron
%{?systemd_requires}
PreReq: permissions
Requires: user(tuptime)
Provides: system-user-tuptime = %{version}-%{release}
Obsoletes: system-user-tuptime < %{version}-%{release}
BuildArch: noarch
%description
Tuptime is a tool for report the historical and statistical real time of the system, keeping it between restarts. Like uptime command but with more interesting output.
%package -n system-user-tuptime
Summary: System user for the tuptime
%{sysusers_requires}
%description -n system-user-tuptime
System user for the tuptime.
%prep
%autosetup -p1
find ./ -type f -exec sed -i -e 's/_tuptime/tuptime/g' {} \;
%build
%sysusers_generate_pre %{SOURCE1} system-user-tuptime
%install
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_sbindir}
mkdir -p %{buildroot}%{_unitdir}
mkdir -p %{buildroot}%{_sharedstatedir}/%{name}
mkdir -p %{buildroot}%{_sysusersdir}
mkdir -p %{buildroot}%{_localstatedir}/tuptime
pushd src
chmod +x tuptime
install -D -m 0755 tuptime $RPM_BUILD_ROOT/%{_bindir}/tuptime
sed -i -e '1d;2i#!/usr/bin/python3' %{buildroot}%{_bindir}/tuptime
install -D -m 0644 systemd/tuptime.service %{buildroot}%{_unitdir}/%{name}.service
install -D -m 0644 systemd/tuptime-sync.timer %{buildroot}%{_unitdir}/%{name}-sync.timer
install -D -m 0644 systemd/tuptime-sync.service %{buildroot}%{_unitdir}/%{name}-sync.service
install -D -m 0644 %{SOURCE1} %{buildroot}%{_sysusersdir}/system-user-tuptime.conf
install -D -m 0644 %{SOURCE2} %{buildroot}/%{_presetdir}/99-tuptime.preset
ln -sf service %{buildroot}%{_sbindir}/rctuptime
ln -sf service %{buildroot}%{_sbindir}/rctuptime-sync
%pre -n system-user-tuptime -f system-user-tuptime.pre
%pre
%service_add_pre %{name}.service
%service_add_pre %{name}-sync.timer
%service_add_pre %{name}-sync.service
%post
%service_add_post %{name}.service
%service_add_post %{name}-sync.timer
%service_add_post %{name}-sync.service
%preun
%service_del_preun %{name}.service
%service_del_preun %{name}-sync.timer
%service_del_preun %{name}-sync.service
%postun
%service_del_postun %{name}.service
%service_del_postun %{name}-sync.timer
%service_del_postun %{name}-sync.service
%files
%license LICENSE
%doc README.md CHANGELOG CONTRIBUTING.md tuptime-manual.txt
%{_bindir}/tuptime
%{_sbindir}/rctuptime
%{_sbindir}/rctuptime-sync
%{_unitdir}/*.service
%{_unitdir}/*.timer
%{_presetdir}/99-tuptime.preset
%defattr(664,tuptime,tuptime,775)
%{_sharedstatedir}/%{name}
%files -n system-user-tuptime
%{_sysusersdir}/system-user-tuptime.conf
%changelog