Contents of /smage/trunk/core/initscripts/initscripts-0.8.0-r2.smage2
Parent Directory | Revision Log
Revision 4647 -
(show annotations)
(download)
Wed Mar 20 12:39:33 2013 UTC (11 years, 1 month ago) by niro
File size: 10517 byte(s)
Wed Mar 20 12:39:33 2013 UTC (11 years, 1 month ago) by niro
File size: 10517 byte(s)
-fixed post/pre handling
1 | # $Id$ |
2 | |
3 | PNAME="initscripts" |
4 | PVER="0.8.0" |
5 | PBUILD="r2" |
6 | |
7 | # enable busybox initscripts y|n |
8 | # disabled atm, busybox missing in tree |
9 | BUSYBOX_ENABLED="n" |
10 | # enable sysvinit initscripts y|n |
11 | # disabled, we have replaced sysvinit with systemd |
12 | SYSVINIT_ENABLED="n" |
13 | |
14 | SPLIT_PACKAGES="systemd-initscripts" |
15 | |
16 | [[ ${BUSYBOX_ENABLED} = y ]] && SPLIT_PACKAGES+=" busybox-initscripts" |
17 | [[ ${SYSVINIT_ENABLED} = y ]] && SPLIT_PACKAGES+=" initscripts" |
18 | |
19 | PCAT="sys-apps" |
20 | HOMEPAGE="http://magellan-linux.net" |
21 | |
22 | # the pkgs "coreutils, findutils, sed, gawk, bzip2, tar, rsync, wget" |
23 | # are needed to fix the /etc/profile issue |
24 | COMMON_DEPEND=">= sys-apps/base-files-0.5 |
25 | >= sys-apps/mage-release-0 |
26 | >= sys-apps/coreutils-5 |
27 | >= sys-apps/findutils-4 |
28 | >= virtual/grep |
29 | >= virtual/sed |
30 | >= sys-apps/gawk-3 |
31 | >= virtual/bzip2 |
32 | >= virtual/tar |
33 | >= net-misc/rsync-2 |
34 | >= virtual/wget |
35 | >= virtual/which" |
36 | |
37 | SYSTEMD_DEPEND=">= sys-apps/systemd-28" |
38 | |
39 | SDEPEND="${COMMON_DEPEND} |
40 | ${SYSTEMD_DEPEND}" |
41 | |
42 | if [[ ${BUSYBOX_ENABLED} = y ]] |
43 | then |
44 | BUSYBOX_DEPEND=">= sys-apps/busybox-1.17" |
45 | SDEPEND="${SDEPEND} |
46 | ${BUSYBOX_DEPEND}" |
47 | fi |
48 | |
49 | if [[ ${SYSVINIT_ENABLED} = y ]] |
50 | then |
51 | SYSVINIT_DEPEND=">= sys-apps/sysvinit-2.88" |
52 | SDEPEND="${SDEPEND} |
53 | ${SYSVINIT_DEPEND}" |
54 | fi |
55 | |
56 | PROVIDE="virtual/initscripts" |
57 | |
58 | SRCFILE="${PNAME}-${PVER}.tar.bz2" |
59 | SRCDIR="${BUILDDIR}/${PNAME}-${PVER}" |
60 | |
61 | sminclude mtools alx |
62 | |
63 | SRC_URI=( mirror://${PNAME}/${SRCFILE} ) |
64 | |
65 | SPECIAL_VARS="BLOCKER SYSVINIT_ENABLED BUSYBOX_ENABLED" |
66 | SPECIAL_FUNCTIONS="preinstall_common postinstall_common preremove_common" |
67 | |
68 | if [[ ${SYSVINIT_ENABLED} = y ]] |
69 | then |
70 | split_info_initscripts() |
71 | { |
72 | DESCRIPTION="Magellan Initscripts for sysVinit." |
73 | DEPEND="${COMMON_DEPEND} |
74 | ${SYSVINIT_DEPEND}" |
75 | |
76 | BLOCKER="sys-apps/systemd-initscripts sys-apps/busybox-initscripts" |
77 | } |
78 | fi |
79 | |
80 | split_info_systemd-initscripts() |
81 | { |
82 | DESCRIPTION="Magellan Initscripts for systemd." |
83 | DEPEND="${COMMON_DEPEND} |
84 | ${SYSTEMD_DEPEND}" |
85 | |
86 | BLOCKER="sys-apps/initscripts sys-apps/busybox-initscripts" |
87 | } |
88 | |
89 | if [[ ${BUSYBOX_ENABLED} = y ]] |
90 | then |
91 | split_info_busybox-initscripts() |
92 | { |
93 | DESCRIPTION="Magellan Initscripts for busybox." |
94 | DEPEND="${COMMON_DEPEND} |
95 | ${BUSYBOX_DEPEND}" |
96 | |
97 | BLOCKER="sys-apps/initscripts sys-apps/systemd-initscripts" |
98 | } |
99 | fi |
100 | |
101 | src_prepare() |
102 | { |
103 | munpack ${SRCFILE} || die |
104 | } |
105 | |
106 | src_compile() |
107 | { |
108 | cd ${SRCDIR} |
109 | mmake || die |
110 | } |
111 | |
112 | common_install() |
113 | { |
114 | local method="$1" |
115 | local MCONFIG |
116 | local config_protect_ignore |
117 | |
118 | cd ${SRCDIR} |
119 | make DESTDIR=${BINDIR} LIBDIR=/usr/lib SBINDIR=/usr/sbin install_${method} || die |
120 | |
121 | # always keep this files even if the user edited them |
122 | config_protect_ignore="/etc/fstab" |
123 | config_protect_ignore+=" /etc/hostname" |
124 | config_protect_ignore+=" /etc/hosts" |
125 | config_protect_ignore+=" /etc/inittab" |
126 | config_protect_ignore+=" /etc/conf.d/net.eth0" |
127 | config_protect_ignore+=" /etc/conf.d/net.routes" |
128 | minstalldir /etc/env.d || die |
129 | MCONFIG="/etc/env.d/01initscripts" |
130 | mclearconfig || die |
131 | maddconfig "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" || die |
132 | } |
133 | |
134 | if [[ ${SYSVINIT_ENABLED} = y ]] |
135 | then |
136 | src_install_initscripts() |
137 | { |
138 | local flavor="sysvinit" |
139 | local config_protect_ignore |
140 | local MCONFIG |
141 | |
142 | cd ${SRCDIR} |
143 | common_install ${flavor} || die |
144 | |
145 | # CONFIG_PROTECT_MASK for /etc/rc.d/init.d |
146 | minstalldir /etc/env.d || die |
147 | MCONFIG="/etc/env.d/01${flavor}" |
148 | mclearconfig || die |
149 | maddconfig "CONFIG_PROTECT_MASK=\"/etc/rc.d/init.d\"" || die |
150 | config_protect_ignore+=" /etc/modules.autoload.d/kernel-2.4" |
151 | config_protect_ignore+=" /etc/modules.autoload.d/kernel-2.6" |
152 | config_protect_ignore+=" /etc/modules.autoload" |
153 | maddconfig "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" || die |
154 | |
155 | # on alx we use systemd combined with busybox, so we need default network settings for udhcpc |
156 | minstallfile ${SRCDIR}/busybox/conf.d/network /etc/conf.d/network || die |
157 | } |
158 | fi |
159 | |
160 | src_install_systemd-initscripts() |
161 | { |
162 | local flavor="systemd" |
163 | local config_protect_ignore |
164 | local MCONFIG |
165 | |
166 | cd ${SRCDIR} |
167 | common_install ${flavor} || die |
168 | |
169 | # install these binaries for old sysvinit compat only |
170 | if [[ ${SYSVINIT_ENABLED} = n ]] |
171 | then |
172 | minstalldir /usr/sbin || die |
173 | minstallexec ${SRCDIR}/sysvinit/sbin/rc-config /usr/sbin || die |
174 | minstalldir /etc/rc.d/init.d || die |
175 | minstallfile ${SRCDIR}/sysvinit/rc/functions /etc/rc.d/init.d/ || die |
176 | fi |
177 | |
178 | # CONFIG_PROTECT_MASK for /etc/rc.d/init.d |
179 | MCONFIG="/etc/env.d/01${flavor}" |
180 | minstalldir /etc/env.d || die |
181 | config_protect_ignore+=" /etc/systemd/system" |
182 | mclearconfig || die |
183 | maddconfig "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" || die |
184 | |
185 | # alx only: fix issue file for busybox getty |
186 | minstallfile busybox/etc/issue /etc/issue || die |
187 | } |
188 | |
189 | if [[ ${BUSYBOX_ENABLED} = y ]] |
190 | then |
191 | src_install_busybox-initscripts() |
192 | { |
193 | local flavor="busybox" |
194 | local config_protect_ignore |
195 | local MCONFIG |
196 | |
197 | cd ${SRCDIR} |
198 | common_install ${flavor} || die |
199 | |
200 | # CONFIG_PROTECT_MASK for /etc/rc.d/init.d |
201 | minstalldir /etc/env.d || die |
202 | MCONFIG="/etc/env.d/01${flavor}" |
203 | mclearconfig || die |
204 | maddconfig "CONFIG_PROTECT_MASK=\"/etc/rc.d/init.d\"" || die |
205 | config_protect_ignore+=" /etc/modules.autoload.d/kernel-2.4" |
206 | config_protect_ignore+=" /etc/modules.autoload.d/kernel-2.6" |
207 | config_protect_ignore+=" /etc/modules.autoload" |
208 | maddconfig "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" || die |
209 | # add conf.d/kernel to protect current udev|mdev configuration |
210 | config_protect_ignore+=" /etc/conf.d/kernel" |
211 | maddconfig "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" || die |
212 | } |
213 | fi |
214 | |
215 | postinstall_common() |
216 | { |
217 | # emulate seq; its needed to run rc-config |
218 | # this fixes some annyoing warning when building |
219 | # livecd or bootstrapping a system. |
220 | # this hack will be removed when the toolchain is fixed |
221 | if [ ! -f /usr/bin/seq ] |
222 | then |
223 | echo "Using fake 'seq' command ..." |
224 | seq() { |
225 | start=$1 |
226 | end=$2 |
227 | for ((i=start; i < end+1; i++)) |
228 | do |
229 | echo $i |
230 | done |
231 | } |
232 | export -f seq |
233 | fi |
234 | |
235 | # keep this only for transitional purposes |
236 | # do not ask the user about following files |
237 | # |
238 | # if they exist let config_protect process them |
239 | # but then remove the protected files, to keep only the original file |
240 | # |
241 | # file-root is ${MROOT}/etc |
242 | local CONFIG_IGNORE="fstab hostname hosts inittab conf.d/net.eth0 modules.autoload.d/kernel-2.4 modules.autoload.d/kernel-2.6 modules.autoload" |
243 | local i file path |
244 | for i in ${CONFIG_IGNORE} |
245 | do |
246 | file="$(basename ${i})" |
247 | path="$(dirname ${i})/" |
248 | [[ ${path} == ./ ]] && path="" |
249 | |
250 | rm -f ${MROOT}/etc/${path}._cfg????_${file} |
251 | done |
252 | |
253 | # initscripts >= 0.5.0: rc file moved to /etc/conf.d/rc |
254 | if [[ -f ${MROOT}/etc/conf.d/rc ]] && [[ -f ${MROOT}/etc/sysconfig/rc ]] |
255 | then |
256 | rm -f ${MROOT}/etc/sysconfig/rc |
257 | fi |
258 | |
259 | # aliases and i368 got renamed to *.conf |
260 | local i |
261 | for i in aliases i386 |
262 | do |
263 | if [[ -f ${MROOT}/etc/modules.d/${i} ]] |
264 | then |
265 | rm ${MROOT}/etc/modules.d/${i} |
266 | fi |
267 | done |
268 | } |
269 | |
270 | postinstall_systemd-initscripts() |
271 | { |
272 | postinstall_common |
273 | |
274 | # enable network.service (systemd only) |
275 | mstartunit network.service |
276 | } |
277 | |
278 | postinstall_sysvinit-initscripts() |
279 | { |
280 | postinstall_common |
281 | |
282 | if [ -f ${MROOT}/etc/rc.d/init.d/functions ] |
283 | then |
284 | # create service state dir mountpoint |
285 | # needed by >=initscripts-0.3.2-r1 |
286 | [ ! -d ${MROOT}/var/lib/init.d ] && install -d ${MROOT}/var/lib/init.d |
287 | |
288 | # mark this dir as undeletable |
289 | touch ${MROOT}/var/lib/init.d/.keep |
290 | |
291 | if [[ -x ${MROOT}/usr/sbin/rc-config ]] |
292 | then |
293 | echo "Creating Runlevels ..." |
294 | local i |
295 | for i in checkfs cleanfs halt \ |
296 | loadkeys localnet modules mountfs \ |
297 | network reboot sendsignals \ |
298 | setclock swap sysctl consolefont |
299 | do |
300 | echo -e "\tAdded ${i} ..." |
301 | ${MROOT}/usr/sbin/rc-config del ${i} > /dev/null |
302 | ${MROOT}/usr/sbin/rc-config add ${i} > /dev/null |
303 | done |
304 | fi |
305 | fi |
306 | } |
307 | |
308 | postinstall_busybox-initscripts() |
309 | { |
310 | postinstall_common |
311 | |
312 | if [ -f ${MROOT}/etc/rc.d/init.d/functions ] |
313 | then |
314 | # create service state dir mountpoint |
315 | # needed by >=initscripts-0.3.2-r1 |
316 | [ ! -d ${MROOT}/var/lib/init.d ] && install -d ${MROOT}/var/lib/init.d |
317 | |
318 | # mark this dir as undeletable |
319 | touch ${MROOT}/var/lib/init.d/.keep |
320 | |
321 | if [[ -x ${MROOT}/usr/sbin/rc-config ]] |
322 | then |
323 | echo "Creating Runlevels ..." |
324 | local i |
325 | for i in checkfs cleanfs loadkeys localnet \ |
326 | modules mountfs network setclock swap |
327 | do |
328 | echo -e "\tAdded ${i} ..." |
329 | ${MROOT}/usr/sbin/rc-config del ${i} > /dev/null |
330 | ${MROOT}/usr/sbin/rc-config add ${i} > /dev/null |
331 | done |
332 | fi |
333 | fi |
334 | } |
335 | |
336 | preinstall_common() |
337 | { |
338 | # ignore this while package building |
339 | if [[ ! -f /.installrc ]] |
340 | then |
341 | local package |
342 | for package in ${BLOCKER} |
343 | do |
344 | if [[ ! -z $(magequery -n ${package##*/}) ]] |
345 | then |
346 | echo -e ${COLRED} |
347 | echo -e "Error: ${package} is installed!!" |
348 | echo -e "This initscript flavor cannot co-exist ${package}." |
349 | echo -e "Please uninstall ${package} first!" |
350 | echo -e ${COLDEFAULT} |
351 | die "${package} found!" |
352 | fi |
353 | done |
354 | fi |
355 | } |
356 | |
357 | preinstall_systemd-initscripts() |
358 | { |
359 | preinstall_common |
360 | |
361 | add_conf_prot_mask /etc/env.d /etc/modprobe.d /etc/rc.d/init.d /etc/profile /etc/inputrc \ |
362 | /etc/shells /etc/issue /etc/DIR_COLORS /etc/inittab \ |
363 | /etc/conf.d/net.sample /etc/conf.d/kernel /etc/conf.d/rc /etc/conf.d/network |
364 | |
365 | add_conf_prot_ignore /etc/fstab /etc/group /etc/hostname /etc/hosts /etc/modules.autoload \ |
366 | /etc/passwd /etc/shadow /etc/conf.d/clock /etc/conf.d/editor /etc/conf.d/keymap \ |
367 | /etc/conf.d/net.routes |
368 | } |
369 | |
370 | preinstall_sysvinit-initscripts() |
371 | { |
372 | preinstall_common |
373 | |
374 | add_conf_prot_mask /etc/env.d /etc/modprobe.d /etc/rc.d/init.d /etc/profile /etc/inputrc \ |
375 | /etc/shells /etc/issue /etc/DIR_COLORS /etc/inittab \ |
376 | /etc/conf.d/net.sample /etc/conf.d/kernel /etc/conf.d/rc /etc/conf.d/network |
377 | |
378 | add_conf_prot_ignore /etc/fstab /etc/group /etc/hostname /etc/hosts /etc/modules.autoload \ |
379 | /etc/passwd /etc/shadow /etc/conf.d/clock /etc/conf.d/editor /etc/conf.d/keymap \ |
380 | /etc/conf.d/net.routes |
381 | } |
382 | |
383 | preinstall_busybox-initscripts() |
384 | { |
385 | preinstall_common |
386 | |
387 | add_conf_prot_mask /etc/env.d /etc/modprobe.d /etc/rc.d/init.d /etc/profile /etc/inputrc \ |
388 | /etc/shells /etc/issue /etc/DIR_COLORS /etc/inittab \ |
389 | /etc/conf.d/net.sample /etc/conf.d/kernel /etc/conf.d/rc /etc/conf.d/network |
390 | |
391 | add_conf_prot_ignore /etc/fstab /etc/group /etc/hostname /etc/hosts /etc/modules.autoload \ |
392 | /etc/passwd /etc/shadow /etc/conf.d/clock /etc/conf.d/editor /etc/conf.d/keymap \ |
393 | /etc/conf.d/net.routes |
394 | } |
395 | |
396 | preremove_common() |
397 | { |
398 | # protect these files, that they do not get removed from the system |
399 | local CONFIG_IGNORE="fstab hostname hosts" |
400 | for i in ${CONFIG_IGNORE} |
401 | do |
402 | [[ -e ${MROOT}/etc/${i} ]] && touch ${MROOT}/etc/${i} |
403 | done |
404 | } |
405 | |
406 | preremove_systemd-initscripts() |
407 | { |
408 | preremove_common |
409 | } |
410 | |
411 | preremove_sysvinit-initscripts() |
412 | { |
413 | preremove-common |
414 | } |
415 | |
416 | preremove_busybox-initscripts() |
417 | { |
418 | preremove_common |
419 | } |