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