-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsaveclock.spec.in
148 lines (115 loc) · 4.07 KB
/
saveclock.spec.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
%global use_systemd 0
%if 0%{?fedora} >= 16
%global use_systemd 1
%endif
Name: saveclock
Summary: Restore/save system clock from/to a file
Version: @VERSION@
Release: 1%{?dist}
URL: https://github.com/monnerat/saveclock
Source: %{name}-%{version}.tar.gz
License: MIT
Group: System Environment/Daemons
BuildRequires: gcc
%if %{use_systemd}
BuildRequires: systemd-units
Requires(post): systemd-units
Requires(post): systemd-sysv
Requires(preun): systemd-units
Requires(postun): systemd-units
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
%description
This daemon restores the system clock from a file at start-up, then
periodically saves it back to the same file. This is particularly useful on
systems without a working hardware RTC clock, avoiding problems that may be
caused by a system believing it is still in 1970.
The save period as well as the clock file can be specified on the
command line.
#-------------------------------------------------------------------------------
%prep
#-------------------------------------------------------------------------------
%setup -q
#-------------------------------------------------------------------------------
%build
#-------------------------------------------------------------------------------
%configure
make %{?_smp_mflags}
#-------------------------------------------------------------------------------
%install
#-------------------------------------------------------------------------------
rm -rf "${RPM_BUILD_ROOT}"
make DESTDIR="${RPM_BUILD_ROOT}" install
%if %{use_systemd}
mkdir -p "${RPM_BUILD_ROOT}%{_unitdir}/"
install -p -m 0644 %{name}.service "${RPM_BUILD_ROOT}%{_unitdir}/"
%else
mkdir -p "${RPM_BUILD_ROOT}/%{_initrddir}"
install -p -m 755 %{name}.init "${RPM_BUILD_ROOT}/%{_initrddir}/%{name}"
%endif
mkdir -p "${RPM_BUILD_ROOT}/%{_sysconfdir}/sysconfig"
install -p -m 644 %{name}.sysconfig \
"${RPM_BUILD_ROOT}/%{_sysconfdir}/sysconfig/%{name}"
#-------------------------------------------------------------------------------
%clean
#-------------------------------------------------------------------------------
rm -rf "${RPM_BUILD_ROOT}"
#-------------------------------------------------------------------------------
%post
#-------------------------------------------------------------------------------
%if %{use_systemd}
if [ "${1}" = 1 ]
then /bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi
%else
/sbin/chkconfig --add %{name}
%endif
#-------------------------------------------------------------------------------
%preun
#-------------------------------------------------------------------------------
%if %{use_systemd}
if [ "${1}" = 0 ]
then /bin/systemctl --no-reload disable %{name}.service >/dev/null 2>&1 || :
/bin/systemctl stop %{name}.service >/dev/null 2>&1 || :
fi
%else
if [ "${1}" = 0 ]
then /sbin/service %{name} stop > /dev/null 2>&1 || :
/sbin/chkconfig --del %{name}
fi
%endif
#-------------------------------------------------------------------------------
%postun
#-------------------------------------------------------------------------------
%if %{use_systemd}
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
if [ "${1}" != 0 ]
then /bin/systemctl try-restart %{name}.service >/dev/null 2>&1 || :
fi
%else
if [ "${1}" != 0 ]
then /sbin/service %{name} condrestart > /dev/null 2>&1 || :
fi
%endif
#-------------------------------------------------------------------------------
%files
#-------------------------------------------------------------------------------
%defattr(-, root, root, -)
%doc AUTHORS COPYING
%doc %{_mandir}/*/*
%{_sbindir}/*
%dir %{_sharedstatedir}/%{name}
%ghost %{_sharedstatedir}/%{name}/*
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
%if %{use_systemd}
%{_unitdir}/*
%else
%{_initrddir}/*
%endif
#-------------------------------------------------------------------------------
%changelog
#-------------------------------------------------------------------------------
* Fri Nov 2 2018 Patrick Monnerat <patrick@monnerat.net> 0.2-1
- Build requires C compiler.
* Sun Jul 12 2015 Patrick Monnerat <pm@datasphere.ch> 0.1-1
- Initial rpm packaging.