Skip to content

Commit c875b8e

Browse files
Update Fedora spec file following review (#63)
1 parent 170dc65 commit c875b8e

File tree

1 file changed

+51
-26
lines changed

1 file changed

+51
-26
lines changed

misc/rpm/tuptime.spec

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Name: tuptime
22
Version: 5.0.2
3-
Release: 1%{?dist}
3+
Release: 5%{?dist}
44
Summary: Report historical system real time
55

66
License: GPLv2+
@@ -11,63 +11,74 @@ Source0: https://github.com/rfrail3/tuptime/archive/%{version}.tar.gz
1111
%{?systemd_requires}
1212
# Check for EPEL Python (python34, python36)
1313
%if 0%{?python3_pkgversion}
14-
Requires: python%{python3_pkgversion}
14+
BuildRequires: python%{python3_pkgversion}-devel
1515
%else
16-
Requires: python3
16+
BuildRequires: python3-devel
17+
%endif
18+
%if 0%{?el7}
19+
BuildRequires: systemd
20+
%else
21+
BuildRequires: systemd-rpm-macros
1722
%endif
18-
BuildRequires: sed python3-rpm-macros python-srpm-macros systemd
1923
Requires: systemd
2024
Requires(pre): shadow-utils
2125

2226

2327
%description
2428
Tuptime track and report historical and statistical real time of the
25-
system, keeping the uptime and downtime between shutdowns.
29+
system, keeping the uptime and downtime between shutdowns.
2630

2731

2832
%prep
2933
%setup -q
3034
# Fix python shebang
31-
sed -i '1s=^#!/usr/bin/\(python\|env python\)[23]\?=#!%{__python3}=' src/tuptime
35+
%if %{?py3_shebang_fix:1}%{!?py3_shebang_fix:0}
36+
%py3_shebang_fix src/tuptime
37+
%else
38+
# EPEL7 does not have py3_shebang_fix
39+
/usr/bin/pathfix.py -pni "%{__python3} -s" src/tuptime
40+
%endif
3241

3342

3443
%pre
35-
getent group tuptime >/dev/null && groupmod -n _tuptime tuptime
36-
getent passwd tuptime >/dev/null && usermod -l _tuptime tuptime
37-
getent group _tuptime >/dev/null || groupadd -r _tuptime
44+
# Conversion to new group and usernames for previously installed version
45+
getent group tuptime >/dev/null && groupmod --new-name _tuptime tuptime
46+
getent passwd tuptime >/dev/null && usermod --login _tuptime tuptime
47+
getent group _tuptime >/dev/null || groupadd --system _tuptime
3848
getent passwd _tuptime >/dev/null || useradd --system --gid _tuptime --home-dir "/var/lib/tuptime" --shell '/sbin/nologin' --comment 'Tuptime execution user' _tuptime > /dev/null
3949

4050

4151
%build
42-
exit 0
4352

4453

4554
%install
4655
install -d %{buildroot}%{_bindir}/
4756
install -d %{buildroot}%{_unitdir}/
4857
install -d %{buildroot}%{_mandir}/man1/
4958
install -d %{buildroot}%{_sharedstatedir}/tuptime/
50-
install -d %{buildroot}%{_docdir}/tuptime/
51-
cp -R %{_topdir}/BUILD/%{name}-%{version}/src/tuptime %{buildroot}%{_bindir}/
52-
cp -R %{_topdir}/BUILD/%{name}-%{version}/src/systemd/tuptime.service %{buildroot}%{_unitdir}/
53-
cp -R %{_topdir}/BUILD/%{name}-%{version}/src/systemd/tuptime-cron.service %{buildroot}%{_unitdir}/
54-
cp -R %{_topdir}/BUILD/%{name}-%{version}/src/systemd/tuptime-cron.timer %{buildroot}%{_unitdir}/
55-
cp -R %{_topdir}/BUILD/%{name}-%{version}/src/man/tuptime.1 %{buildroot}%{_mandir}/man1/
56-
cp -R %{_topdir}/BUILD/%{name}-%{version}/tuptime-manual.txt %{buildroot}%{_docdir}/tuptime/
57-
cp -R %{_topdir}/BUILD/%{name}-%{version}/CHANGELOG %{buildroot}%{_docdir}/tuptime/
59+
install -d %{buildroot}%{_datadir}/tuptime/
60+
cp src/tuptime %{buildroot}%{_bindir}/
61+
cp src/systemd/tuptime.service %{buildroot}%{_unitdir}/
62+
cp src/systemd/tuptime-cron.service %{buildroot}%{_unitdir}/
63+
cp src/systemd/tuptime-cron.timer %{buildroot}%{_unitdir}/
64+
cp src/man/tuptime.1 %{buildroot}%{_mandir}/man1/
65+
cp misc/scripts/* %{buildroot}%{_datadir}/tuptime/
66+
chmod +x %{buildroot}%{_datadir}/tuptime/*.sh
67+
chmod +x %{buildroot}%{_datadir}/tuptime/*.py
5868

5969

6070
%post
71+
# Create and initialise the tuptime DB with consistent permissions, etc.
6172
su -s /bin/sh _tuptime -c "(umask 0022 && /usr/bin/tuptime -x)"
6273
%systemd_post tuptime.service
6374
%systemd_post tuptime-cron.service
6475
%systemd_post tuptime-cron.timer
6576

6677

6778
%preun
68-
%systemd_user_preun tuptime.service
69-
%systemd_user_preun tuptime-cron.service
70-
%systemd_user_preun tuptime-cron.timer
79+
%systemd_preun tuptime.service
80+
%systemd_preun tuptime-cron.service
81+
%systemd_preun tuptime-cron.timer
7182

7283

7384
%postun
@@ -77,18 +88,32 @@ su -s /bin/sh _tuptime -c "(umask 0022 && /usr/bin/tuptime -x)"
7788

7889

7990
%files
80-
%defattr(-,root,root)
8191
%{_unitdir}/tuptime.service
8292
%{_unitdir}/tuptime-cron.service
8393
%{_unitdir}/tuptime-cron.timer
8494
%attr(0755, root, root) %{_bindir}/tuptime
8595
%dir %attr(0755, _tuptime, _tuptime) %{_sharedstatedir}/tuptime/
86-
%docdir %{_docdir}/tuptime/
87-
%{_docdir}/tuptime/tuptime-manual.txt
88-
%{_docdir}/tuptime/CHANGELOG
89-
%{_mandir}/man1/tuptime.1.gz
96+
%doc tuptime-manual.txt
97+
%doc CHANGELOG README.md CONTRIBUTING.md
98+
%license LICENSE
99+
%{_mandir}/man1/tuptime.1.*
100+
%dir %{_datadir}/tuptime
101+
%{_datadir}/tuptime/*
90102

91103

92104
%changelog
105+
* Thu Jan 06 2022 Frank Crawford <frank@crawford.emu.id.au> 5.0.2-5
106+
- First offical release in Fedora
107+
108+
* Tue Jan 04 2022 Frank Crawford <frank@crawford.emu.id.au> 5.0.2-4
109+
- Futher updates to spec file following review comments
110+
111+
* Mon Dec 13 2021 Frank Crawford <frank@crawford.emu.id.au> 5.0.2-3
112+
- Update spec file following review comments
113+
114+
* Sun Sep 26 2021 Frank Crawford <frank@crawford.emu.id.au> 5.0.2-2
115+
- Update spec file for Fedora package review
116+
- Copy all relevant documentation
117+
93118
* Sat Jan 02 2021 Ricardo Fraile <rfraile@rfraile.eu> 5.0.2-1
94119
- RPM release

0 commit comments

Comments
 (0)