-
Notifications
You must be signed in to change notification settings - Fork 42
/
runit.spec
185 lines (156 loc) · 4.97 KB
/
runit.spec
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#
# spec file for package runit (Version 2.1.2)
#
# Copyright (c) 2010 Ian Meyer <[email protected]>
## This package understands the following switches:
## --with dietlibc ... statically links against dietlibc
Name: runit
Version: 2.1.2
Release: 1%{?_with_dietlibc:diet}%{?dist}
Group: System/Base
License: BSD
# Override _sbindir being /usr/sbin
%define _sbindir /sbin
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Url: http://smarden.org/runit/
Source0: http://smarden.org/runit/runit-%{version}.tar.gz
Source1: runsvdir-start.service
Patch: runit-2.1.2-etc-service.patch
Patch1: runit-2.1.2-runsvdir-path-cleanup.patch
Patch2: runit-2.1.2-term-hup-option.patch
Obsoletes: runit <= %{version}-%{release}
Provides: runit = %{version}-%{release}
BuildRequires: make gcc
%if 0%{?rhel} >= 6
BuildRequires: glibc-static
%endif
%if 0%{?rhel} >= 7
BuildRequires: systemd-units
%endif
%{?_with_dietlibc:BuildRequires: dietlibc}
Summary: A UNIX init scheme with service supervision
%description
runit is a cross-platform Unix init scheme with service supervision; a
replacement for sysvinit and other init schemes. It runs on GNU/Linux, *BSD,
Mac OS X, and Solaris, and can easily be adapted to other Unix operating
systems. runit implements a simple three-stage concept. Stage 1 performs the
system's one-time initialization tasks. Stage 2 starts the system's uptime
services (via the runsvdir program). Stage 3 handles the tasks necessary to
shutdown and halt or reboot.
Authors:
---------
Gerrit Pape <[email protected]>
%prep
%setup -q -n admin/%{name}-%{version}
pushd src
echo "%{?_with_dietlibc:diet -Os }%__cc $RPM_OPT_FLAGS" >conf-cc
echo "%{?_with_dietlibc:diet -Os }%__cc -Os -pipe" >conf-ld
popd
%patch
%patch1
%patch2
%build
sh package/compile
%install
EXTRA_FILES=$RPM_BUILD_ROOT/extra_files
touch %{EXTRA_FILES}
for i in $(< package/commands) ; do
%{__install} -D -m 0755 command/$i %{buildroot}%{_sbindir}/$i
done
for i in man/*8 ; do
%{__install} -D -m 0755 $i %{buildroot}%{_mandir}/man8/${i##man/}
done
%{__install} -d -m 0755 %{buildroot}/etc/service
%{__install} -D -m 0750 etc/2 %{buildroot}%{_sbindir}/runsvdir-start
# For systemd only
%if 0%{?rhel} >= 7
%{__install} -D -p -m 0644 $RPM_SOURCE_DIR/runsvdir-start.service \
$RPM_BUILD_ROOT%{_unitdir}/runsvdir-start.service
echo %{_unitdir}/runsvdir-start.service > %{EXTRA_FILES}
%endif
%clean
%{__rm} -rf %{buildroot}
%post
if [ $1 = 1 ] ; then
%if 0%{?rhel} >= 6 <= 7
rpm --queryformat='%%{name}' -qf /sbin/init | grep -q upstart
if [ $? -eq 0 ]; then
cat >/etc/init/runsvdir.conf <<\EOT
# for runit - manage /usr/sbin/runsvdir-start
start on runlevel [2345]
stop on runlevel [^2345]
normal exit 0 111
respawn
exec /sbin/runsvdir-start
EOT
# tell init to start the new service
start runsvdir
fi
%endif
%if 0%{?rhel} >= 7
systemctl enable runsvdir-start
systemctl start runsvdir-start
%endif
%if 0%{?rhel} < 6
grep -q 'RI:2345:respawn:/sbin/runsvdir-start' /etc/inittab
if [ $? -eq 1 ]; then
echo -n "Installing /sbin/runsvdir-start into /etc/inittab.."
echo "RI:2345:respawn:/sbin/runsvdir-start" >> /etc/inittab
echo " success."
# Reload init
telinit q
fi
%endif
fi
%preun
if [ $1 = 0 ]; then
if [ -f /etc/init/runsvdir.conf ]; then
stop runsvdir
fi
if [ -f /usr/lib/systemd/system/runsvdir-start.service ]; then
systemctl stop runsvdir-start
systemctl disable runsvdir-start
fi
fi
%postun
if [ $1 = 0 ]; then
if [ -f /etc/init/runsvdir.conf ]; then
rm -f /etc/init/runsvdir.conf
fi
if grep -q runsvdir-start /etc/inittab 2>/dev/null; then
echo " #################################################"
echo " # Remove /sbin/runsvdir-start from /etc/inittab #"
echo " # if you really want to remove runit #"
echo " #################################################"
fi
fi
%files -f %{EXTRA_FILES}
%defattr(-,root,root,-)
%{_sbindir}/chpst
%{_sbindir}/runit
%{_sbindir}/runit-init
%{_sbindir}/runsv
%{_sbindir}/runsvchdir
%{_sbindir}/runsvdir
%{_sbindir}/sv
%{_sbindir}/svlogd
%{_sbindir}/utmpset
%{_sbindir}/runsvdir-start
%{_mandir}/man8/*.8*
%doc doc/* etc/
%doc package/CHANGES package/COPYING package/README package/THANKS package/TODO
%dir /etc/service
%changelog
* Thu Aug 21 2014 Chris Gaffney <[email protected]> 2.1.2-1
- Initial release of 2.1.2
* Fri Jan 20 2012 Joe Miller <[email protected]> 2.1.1-6
- modified spec to build on centos-5 (by only requiring glibc-static on centos-6)
* Wed Oct 26 2011 Karsten Sperling <[email protected]> 2.1.1-5
- Optionally shut down cleanly even on TERM
- Don't call rpm in preun, it can cause problems
- Upstart / inittab tweaks
* Wed Jul 20 2011 Robin Bowes <[email protected]> 2.1.1-4
- 2.1.1-3 Add BuildRequires
- 2.1.1-4 Support systems using upstart
* Sun Jan 23 2011 [email protected]
- Make compatible with Redhat based systems