Bugfix: Support command delivery to syscall
[external/sysvinit.git] / packaging / sysvinit.spec
1 Summary: Programs which control basic system processes
2 Name: sysvinit
3 Version: 2.87
4 Release: 6
5 License: GPLv2+
6 Group: System/Base
7 Url: http://savannah.nongnu.org/projects/sysvinit
8
9 Requires: /bin/cp
10
11 Source: %{name}-%{version}dsf.tar.gz
12 Source1: inittab
13 Source2: update-rc.d
14 Source3: service
15 Source1001:     %{name}.manifest
16
17 Patch0: 21_ifdown_kfreebsd.patch
18 Patch1: 50_bootlogd_devsubdir.patch
19 Patch2: 54_bootlogd_findptyfail.patch
20 Patch3: 55_bootlogd_flush.patch
21 Patch4: 60_init_selinux_ifdef.patch
22 Patch5: 62_init_freebsdterm.patch
23 Patch6: 63_init_keep_utf8_ttyflag.patch
24 Patch7: 70_compiler_warnings.patch
25 Patch8: 91_sulogin_lockedpw.patch
26 Patch9: 94_fstab-decode.patch
27 Patch10: 96_shutdown_acctoff.patch
28 Patch11: 97_init_starttest.patch
29 Patch12: 98_installtarget.patch
30 Patch13: startpar.patch
31 Patch14: always_use_lcrypt.patch
32 Patch15: dont_set_ownership.patch
33 Patch16: add_initscripts.patch
34 Patch18: 64_init_add_cmd_for_reboot.dpatch
35 Patch19: 0001-Fixing-syntax-error-in-start-stop-daemon.c.patch
36 Patch20: systemd_param.patch
37
38 %description
39 The sysvinit package contains a group of processes that control
40 the very basic functions of your system. sysvinit includes the init
41 program, the first program started by the Linux kernel when the
42 system boots. Init then controls the startup, running, and shutdown
43 of all other programs.
44
45 %package utils
46 Summary: System-V-like utilities
47 Group: System/Base
48 Provides: /usr/sbin/service
49 Provides: /bin/pidof
50
51 %description utils
52  This package contains the important System-V-like utilities.
53  Specifically, this package includes:
54  killall5, last, lastb, mesg, pidof, service, sulogin
55
56 %package -n initscripts
57 Summary: scripts for initializing the system
58 Group: System/Base
59 Requires: /lib/lsb/init-functions
60
61 %description -n initscripts
62  scripts for initializing and shutting down the system
63  The scripts in this package initialize a system at boot time
64  and shut it down at halt or reboot time.
65
66 %doc_package
67
68 %prep
69 %setup -q -n %{name}-%{version}dsf
70
71 %patch0 -p1 -b .ifdown_kfreebsd
72 %patch1 -p1 -b .bootlogd_devsubdir
73 %patch2 -p1 -b .bootlogd_findptyfail
74 %patch3 -p1 -b .bootlogd_flush
75 %patch4 -p1 -b .init_selinux_ifdef
76 %patch5 -p1 -b .init_freebsdterm
77 %patch6 -p1 -b .init_keep_utf8_ttyflag
78 %patch7 -p1 -b .compiler_warnings
79 %patch8 -p1 -b .sulogin_lockedpw
80 %patch9 -p1 -b .fstab-decode
81 %patch10 -p1 -b .shutdown_acctoff
82 %patch11 -p1 -b .init_starttest
83 %patch12 -p1 -b .installtarget
84 %patch13 -p1 -b .startpar
85 %patch14 -p1 -b .always_use_lcrypt
86 %patch15 -p1 -b .dont_set_ownership
87 %patch16 -p1
88 %patch18 -p1
89 %patch19 -p1
90 %patch20 -p1
91
92 %build
93 cp %{SOURCE1001} .
94 make -C src
95 make -C startpar
96
97 export CFLAGS='-ansi -W -Wall -O2 -fomit-frame-pointer -D_GNU_SOURCE'
98 export LDFLAGS='-s'
99 gcc $LDFLAGS -o start-stop-daemon contrib/start-stop-daemon.c
100
101 %install
102 make -C src ROOT=$RPM_BUILD_ROOT install
103 make -C startpar DESTDIR=$RPM_BUILD_ROOT install
104 make -C initscripts DESTDIR=$RPM_BUILD_ROOT install
105
106 install -d $RPM_BUILD_ROOT/%{_datadir}/%{name}/
107 install %SOURCE1 $RPM_BUILD_ROOT/%{_datadir}/%{name}/
108 install %SOURCE2 $RPM_BUILD_ROOT/%{_datadir}/%{name}/
109 install -d $RPM_BUILD_ROOT/usr/sbin/
110 install %SOURCE3 $RPM_BUILD_ROOT/usr/sbin/
111
112 install start-stop-daemon $RPM_BUILD_ROOT/usr/sbin/
113
114 rm -f $RPM_BUILD_ROOT/usr/bin/wall
115 rm -f $RPM_BUILD_ROOT/usr/bin/lastb
116 rm -f $RPM_BUILD_ROOT/usr/bin/utmpdump
117 rm -f $RPM_BUILD_ROOT/usr/share/man/man1/wall.1*
118 rm -f $RPM_BUILD_ROOT%{_includedir}/initreq.h
119
120 rm -rf %{buildroot}/%{_docdir}
121
122 mkdir -p $RPM_BUILD_ROOT%{_datadir}/license
123 for keyword in LICENSE COPYING COPYRIGHT;
124 do
125         for file in `find %{_builddir} -name $keyword`;
126         do
127                 cat $file >> $RPM_BUILD_ROOT%{_datadir}/license/%{name};
128                 echo "";
129         done;
130 done
131
132 %post
133 echo ".... sysvinit post ....."
134 [ -f /etc/inittab ] || /bin/cp -p /usr/share/sysvinit/inittab /etc/inittab
135 exit 0
136
137 %post -n initscripts
138
139 set -e
140 umask 022
141 #
142 # Initialize rcS default file.
143 #
144 if [ ! -f /etc/default/rcS ]
145 then
146         cp -p /usr/share/initscripts/default.rcS /etc/default/rcS
147 fi
148
149 #
150 # When installing for the first time or upgrading from version before
151 # 2.86.ds1-27, a reboot is needed to make the /lib/init/rw/ tmpfs
152 # available.  Flag this using notify-reboot-required.  Not mounting it
153 # here as it creates problem for debootstrap, vservers, pbuilder and
154 # cowbuilder.
155 #
156 if [ -x /usr/share/update-notifier/notify-reboot-required ]; then
157         /usr/share/update-notifier/notify-reboot-required
158 fi
159
160 #
161 # Create initial log files
162 #
163 for F in /var/log/dmesg /var/log/boot /var/log/fsck/checkroot /var/log/fsck/checkfs
164 do
165         if [ ! -f "$F" ] && touch "$F" >/dev/null 2>&1
166         then
167                 echo "(Nothing has been logged yet.)" >| "$F"
168                 # root UID is 0, adm GID is ordinary 4
169                 chown 0:4 "$F"
170                 chmod 640 "$F"
171         fi
172 done
173
174 #
175 # Set up nologin symlink so that dynamic-login-disabling will work
176 # (when DELAYLOGIN is set to "yes")
177 #
178 if [ ! -L /etc/nologin ] && [ ! -e /etc/nologin ]
179 then
180         rm -f /var/lib/initscripts/nologin
181         ln -s /var/lib/initscripts/nologin /etc/nologin
182 fi
183
184 #
185 # Set up motd stuff, putting variable file in /var/run/
186 #
187 if [ ! -f /etc/motd.tail ]
188 then
189         if [ -f /etc/motd ]
190         then
191                 sed 1d /etc/motd > /etc/motd.tail
192                 [ -s /etc/motd.tail ] || rm -f /etc/motd.tail
193         fi
194 fi
195 if [ ! -f /var/run/motd ]
196 then
197         if [ -f /etc/motd ]
198         then
199                 cat /etc/motd > /var/run/motd
200         else
201                 :>/var/run/motd
202         fi
203 fi
204 if [ ! -L /etc/motd ]
205 then
206         [ -f /etc/default/rcS ] && . /etc/default/rcS
207         if [ "$EDITMOTD" = no ]
208         then
209                 cat /var/run/motd > /etc/motd.static
210                 ln -sf motd.static /etc/motd
211         else
212                 ln -sf /var/run/motd /etc/motd
213         fi
214 fi
215
216 #
217 # Mount kernel virtual filesystems...not.
218 # This causes problems in pbuilder.
219 #
220 #
221 #if [ -x /etc/init.d/mountkernfs.sh ]
222 #then
223 #       if which invoke-rc.d >/dev/null 2>&1
224 #       then
225 #               invoke-rc.d mountkernfs.sh start || :
226 #       else
227 #               /etc/init.d/mountkernfs.sh start
228 #       fi
229 #fi
230
231 #
232 # Create /dev/pts, /dev/shm directories
233 #
234 if [ "$(uname -s)" = Linux ]
235 then
236         #
237         # Only create /dev/{pts,shm} if /dev is on the
238         # root file system. If some package has mounted a
239         # seperate /dev (ramfs from udev, devfs) it is
240         # responsible for the presence of those subdirs.
241         # (it is OK for these to fail under fakechroot)
242         #
243         if ! mountpoint -q /dev
244         then
245                 # root UID is 0
246                 [ -d /dev/pts ] || { mkdir --mode=755 /dev/pts ; chown 0:0 /dev/pts || [ "$FAKECHROOT" = true ]; }
247                 [ -d /dev/shm ] || { mkdir --mode=755 /dev/shm ; chown 0:0 /dev/shm || [ "$FAKECHROOT" = true ]; }
248         fi
249 fi
250
251 #
252 # Create /etc/rc.local on first time install and when upgrading from
253 # versions before "2.86.ds1-16"
254 #
255 if [ ! -e /etc/rc.local ]; then
256         cat << EOF > /etc/rc.local
257 #!/bin/sh -e
258 #
259 # rc.local
260 #
261 # This script is executed at the end of each multiuser runlevel.
262 # Make sure that the script will "exit 0" on success or any other
263 # value on error.
264 #
265 # In order to enable or disable this script just change the execution
266 # bits.
267 #
268 # By default this script does nothing.
269
270 exit 0
271 EOF
272                 # make sure it's enabled by default.
273                 chmod 755 /etc/rc.local
274 fi
275
276 %clean
277 rm -rf $RPM_BUILD_ROOT
278
279
280 %docs_package
281
282 %files
283 %manifest %{name}.manifest
284 %defattr(-,root,root)
285 %{_datadir}/license/%{name}
286 /sbin/init
287 /sbin/runlevel
288 /sbin/shutdown
289 %if 0%{?simulator}
290 %exclude /sbin/halt
291 %exclude /sbin/poweroff
292 %exclude /sbin/reboot
293 %else
294 /sbin/halt
295 /sbin/poweroff
296 /sbin/reboot
297 %endif
298 /sbin/telinit
299 %{_datadir}/%{name}/inittab
300 %{_datadir}/%{name}/update-rc.d
301 #%{_includedir}/initreq.h
302
303 %files utils
304 %manifest %{name}.manifest
305 /bin/pidof
306 /sbin/bootlogd
307 /sbin/fstab-decode
308 /sbin/killall5
309 /sbin/sulogin
310 /sbin/startpar
311 /usr/sbin/start-stop-daemon
312 %attr(755,root,root)/usr/sbin/service
313 /usr/bin/last
314 /usr/bin/mesg
315
316 %files -n initscripts
317 %manifest %{name}.manifest
318 %{_sysconfdir}/init.d/*
319 %{_sysconfdir}/init.d/.slp
320 %{_sysconfdir}/default/*
321 %{_datadir}/initscripts/default.rcS
322 /etc/network/if-up.d/mountnfs
323 /sbin/fsck.nfs
324 /lib/init/*
325 /bin/mountpoint
326