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