-
Notifications
You must be signed in to change notification settings - Fork 2
/
runit.spec
139 lines (125 loc) · 3.79 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
%define _sbindir /sbin
Name: runit
Version: 2.1.2
Release: 2.%{dist}
Group: System/Base
License: BSD
Packager: %{packager}
Vendor: %{vendor}
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Url: http://smarden.org/runit/
Source: http://smarden.org/runit/runit-%{version}.tar.gz
Patch: runit-2.1.1-etc-service.patch
Patch1: runit-2.1.1-runsvdir-path-cleanup.patch
Patch2: runit-2.1.1-term-hup-option.patch
Obsoletes: runit <= %{version}-%{release}
Provides: runit = %{version}-%{release}
BuildRequires: make gcc
BuildRequires: glibc-static
%{?_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
sed -i -e "s|^char\ \*varservice\ \=\"/service/\";$|char\ \*varservice\ \=\"' + service_path + '/\";|" src/sv.c
sed -i -e s:-static:: src/Makefile
%build
sh package/compile
%install
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
%__ln_s /etc/service %{buildroot}/service
%{__install} -D -m 0750 etc/2 %{buildroot}%{_sbindir}/runsvdir-start
%post
if [ $1 = 1 ] ; then
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
else
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
fi
fi
%preun
if [ $1 = 0 ]
then
if [ -f /etc/init/runsvdir.conf ]
then
stop runsvdir
fi
fi
%postun
if [ $1 = 0 ]
then
if [ -f /etc/init/runsvdir.conf ]
then
rm -f /etc/init/runsvdir.conf
else
echo " #################################################"
echo " # Remove /sbin/runsvdir-start from /etc/inittab #"
echo " # if you really want to remove runit #"
echo " #################################################"
fi
fi
%clean
[ "$RPM_BUILD_ROOT" != "/" ] && %__rm -rf $RPM_BUILD_ROOT
[ "%{buildroot}" != "/" ] && %__rm -rf %{buildroot}
[ "%{_builddir}/%{name}-%{version}" != "/" ] && %__rm -rf %{_builddir}/%{name}-%{version}
[ "%{_builddir}/%{name}" != "/" ] && %__rm -rf %{_builddir}/%{name}
%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 %{_sysconfdir}/service
/service
%changelog