Contents of /smage/trunk/core/initscripts/initscripts-0.8.8-r7.smage2
Parent Directory | Revision Log
Revision 17128 -
(show annotations)
(download)
Tue Oct 24 09:34:51 2023 UTC (7 months, 1 week ago) by niro
File size: 12298 byte(s)
Tue Oct 24 09:34:51 2023 UTC (7 months, 1 week ago) by niro
File size: 12298 byte(s)
fixed up2date
1 | # $Id$ |
2 | |
3 | PNAME="initscripts" |
4 | PVER="0.8.8" |
5 | PBUILD="r7" |
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 systemd alx |
62 | |
63 | SRC_URI=( |
64 | mirror://${PNAME}/${SRCFILE} |
65 | mirror://${PNAME}/${PNAME}-0.8.8-cluster-failover-state.patch |
66 | ) |
67 | |
68 | UP2MODULE="init" |
69 | UP2REPO="magellan-source" |
70 | UP2DATE="wget -qO- http://magellan-linux.de/viewvc/${UP2REPO}/tags/ | grep 'tags/${UP2MODULE}-.*/\"' | sed 's:.*${UP2MODULE}-\(.*\)\/.*:\1:;s:_:.:g;' | upsort_pipe" |
71 | |
72 | SPECIAL_VARS="BLOCKER SYSVINIT_ENABLED BUSYBOX_ENABLED" |
73 | SPECIAL_FUNCTIONS="preinstall_common postinstall_common preremove_common" |
74 | |
75 | if [[ ${SYSVINIT_ENABLED} = y ]] |
76 | then |
77 | split_info_initscripts() |
78 | { |
79 | DESCRIPTION="Magellan Initscripts for sysVinit." |
80 | DEPEND="${COMMON_DEPEND} |
81 | ${SYSVINIT_DEPEND}" |
82 | |
83 | BLOCKER="sys-apps/systemd-initscripts sys-apps/busybox-initscripts" |
84 | } |
85 | fi |
86 | |
87 | split_info_systemd-initscripts() |
88 | { |
89 | DESCRIPTION="Magellan Initscripts for systemd." |
90 | DEPEND="${COMMON_DEPEND} |
91 | ${SYSTEMD_DEPEND}" |
92 | |
93 | BLOCKER="sys-apps/initscripts sys-apps/busybox-initscripts" |
94 | } |
95 | |
96 | if [[ ${BUSYBOX_ENABLED} = y ]] |
97 | then |
98 | split_info_busybox-initscripts() |
99 | { |
100 | DESCRIPTION="Magellan Initscripts for busybox." |
101 | DEPEND="${COMMON_DEPEND} |
102 | ${BUSYBOX_DEPEND}" |
103 | |
104 | BLOCKER="sys-apps/initscripts sys-apps/systemd-initscripts" |
105 | } |
106 | fi |
107 | |
108 | src_prepare() |
109 | { |
110 | munpack ${SRCFILE} || die |
111 | cd ${SRCDIR} |
112 | |
113 | # print cluster state if available |
114 | mpatch ${PNAME}-0.8.8-cluster-failover-state.patch || die |
115 | } |
116 | |
117 | src_compile() |
118 | { |
119 | cd ${SRCDIR} |
120 | mmake || die |
121 | } |
122 | |
123 | common_install() |
124 | { |
125 | local method="$1" |
126 | local MCONFIG |
127 | local config_protect_ignore |
128 | |
129 | cd ${SRCDIR} |
130 | make DESTDIR=${BINDIR} LIBDIR=/usr/lib SBINDIR=/usr/sbin install_${method} || die |
131 | |
132 | # always keep this files even if the user edited them |
133 | config_protect_ignore="/etc/fstab" |
134 | config_protect_ignore+=" /etc/hostname" |
135 | config_protect_ignore+=" /etc/hosts" |
136 | config_protect_ignore+=" /etc/inittab" |
137 | config_protect_ignore+=" /etc/resolv.conf" |
138 | config_protect_ignore+=" /etc/conf.d/net.eth0" |
139 | config_protect_ignore+=" /etc/conf.d/net.routes" |
140 | minstalldir /etc/env.d || die |
141 | MCONFIG="/etc/env.d/01initscripts" |
142 | mclearconfig || die |
143 | maddconfig "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" || die |
144 | } |
145 | |
146 | if [[ ${SYSVINIT_ENABLED} = y ]] |
147 | then |
148 | src_install_initscripts() |
149 | { |
150 | local flavor="sysvinit" |
151 | local config_protect_ignore |
152 | local MCONFIG |
153 | |
154 | cd ${SRCDIR} |
155 | common_install ${flavor} || die |
156 | |
157 | # CONFIG_PROTECT_MASK for /etc/rc.d/init.d |
158 | minstalldir /etc/env.d || die |
159 | MCONFIG="/etc/env.d/01${flavor}" |
160 | mclearconfig || die |
161 | maddconfig "CONFIG_PROTECT_MASK=\"/etc/rc.d/init.d\"" || die |
162 | config_protect_ignore+=" /etc/modules.autoload.d/kernel-2.4" |
163 | config_protect_ignore+=" /etc/modules.autoload.d/kernel-2.6" |
164 | config_protect_ignore+=" /etc/modules.autoload" |
165 | maddconfig "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" || die |
166 | } |
167 | fi |
168 | |
169 | src_install_systemd-initscripts() |
170 | { |
171 | local flavor="systemd" |
172 | local config_protect_ignore |
173 | local MCONFIG |
174 | |
175 | cd ${SRCDIR} |
176 | common_install ${flavor} || die |
177 | |
178 | # install these binaries for old sysvinit compat only |
179 | if [[ ${SYSVINIT_ENABLED} = n ]] |
180 | then |
181 | minstalldir /usr/sbin || die |
182 | minstallexec ${SRCDIR}/sysvinit/sbin/rc-config /usr/sbin || die |
183 | minstalldir /etc/rc.d/init.d || die |
184 | minstallfile ${SRCDIR}/sysvinit/rc/functions /etc/rc.d/init.d/ || die |
185 | fi |
186 | |
187 | # CONFIG_PROTECT_MASK for /etc/rc.d/init.d |
188 | MCONFIG="/etc/env.d/01${flavor}" |
189 | minstalldir /etc/env.d || die |
190 | config_protect_ignore+=" /etc/systemd/system" |
191 | mclearconfig || die |
192 | maddconfig "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" || die |
193 | |
194 | # alx only: fix issue file for busybox getty |
195 | minstallfile busybox/etc/issue /etc/issue || die |
196 | |
197 | # on alx we use systemd combined with busybox, so we need default network settings for udhcpc |
198 | minstallfile ${SRCDIR}/busybox/conf.d/network /etc/conf.d/network || die |
199 | |
200 | # we use systemd-networkd from now on, so we provide a default configuration |
201 | # to auto-enable all NICs via DHCP |
202 | MCONFIG="/etc/systemd/network/default.network" |
203 | minstalldir /etc/systemd/network || die |
204 | mclearconfig |
205 | maddconfig '[Match]' || die |
206 | maddconfig 'Name=en*' || die |
207 | maddconfig || die |
208 | maddconfig '[Network]' || die |
209 | # only use ipv4 on alx |
210 | maddconfig 'DHCP=ipv4' || die |
211 | # required to get the interfaces into the 'configured' state |
212 | # without it systemd-networkd-wait-online will always fail |
213 | maddconfig 'IPForward=yes' || die |
214 | maddconfig || die |
215 | # always use the mac address not the client identifier duid (which is default) |
216 | # because a new machine-id will always be generated at boot with netboot images |
217 | maddconfig '[DHCP]' || die |
218 | maddconfig 'ClientIdentifier=mac' || die |
219 | # always precede dhcp configured dns and ntp servers instead of local configured ones |
220 | maddconfig 'UseDNS=yes' || die |
221 | maddconfig 'UseNTP=yes' || die |
222 | # # set up resolve.conf for systemd-resolved |
223 | # mlink /run/systemd/resolve/resolv.conf /etc/resolv.conf || die |
224 | } |
225 | |
226 | if [[ ${BUSYBOX_ENABLED} = y ]] |
227 | then |
228 | src_install_busybox-initscripts() |
229 | { |
230 | local flavor="busybox" |
231 | local config_protect_ignore |
232 | local MCONFIG |
233 | |
234 | cd ${SRCDIR} |
235 | common_install ${flavor} || die |
236 | |
237 | # CONFIG_PROTECT_MASK for /etc/rc.d/init.d |
238 | minstalldir /etc/env.d || die |
239 | MCONFIG="/etc/env.d/01${flavor}" |
240 | mclearconfig || die |
241 | maddconfig "CONFIG_PROTECT_MASK=\"/etc/rc.d/init.d\"" || die |
242 | config_protect_ignore+=" /etc/modules.autoload.d/kernel-2.4" |
243 | config_protect_ignore+=" /etc/modules.autoload.d/kernel-2.6" |
244 | config_protect_ignore+=" /etc/modules.autoload" |
245 | maddconfig "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" || die |
246 | # add conf.d/kernel to protect current udev|mdev configuration |
247 | config_protect_ignore+=" /etc/conf.d/kernel" |
248 | maddconfig "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" || die |
249 | } |
250 | fi |
251 | |
252 | postinstall_common() |
253 | { |
254 | # emulate seq; its needed to run rc-config |
255 | # this fixes some annyoing warning when building |
256 | # livecd or bootstrapping a system. |
257 | # this hack will be removed when the toolchain is fixed |
258 | if [ ! -f /usr/bin/seq ] |
259 | then |
260 | echo "Using fake 'seq' command ..." |
261 | seq() { |
262 | start=$1 |
263 | end=$2 |
264 | for ((i=start; i < end+1; i++)) |
265 | do |
266 | echo $i |
267 | done |
268 | } |
269 | export -f seq |
270 | fi |
271 | |
272 | # keep this only for transitional purposes |
273 | # do not ask the user about following files |
274 | # |
275 | # if they exist let config_protect process them |
276 | # but then remove the protected files, to keep only the original file |
277 | # |
278 | # file-root is ${MROOT}/etc |
279 | 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" |
280 | local i file path |
281 | for i in ${CONFIG_IGNORE} |
282 | do |
283 | file="$(basename ${i})" |
284 | path="$(dirname ${i})/" |
285 | [[ ${path} == ./ ]] && path="" |
286 | |
287 | rm -f ${MROOT}/etc/${path}._cfg????_${file} |
288 | done |
289 | |
290 | # initscripts >= 0.5.0: rc file moved to /etc/conf.d/rc |
291 | if [[ -f ${MROOT}/etc/conf.d/rc ]] && [[ -f ${MROOT}/etc/sysconfig/rc ]] |
292 | then |
293 | rm -f ${MROOT}/etc/sysconfig/rc |
294 | fi |
295 | |
296 | # aliases and i368 got renamed to *.conf |
297 | local i |
298 | for i in aliases i386 |
299 | do |
300 | if [[ -f ${MROOT}/etc/modules.d/${i} ]] |
301 | then |
302 | rm ${MROOT}/etc/modules.d/${i} |
303 | fi |
304 | done |
305 | } |
306 | |
307 | postinstall_systemd-initscripts() |
308 | { |
309 | postinstall_common |
310 | |
311 | # enable network.service (systemd only) |
312 | #mstartunit network.service |
313 | |
314 | # use networkd from systemd |
315 | mstartunit systemd-networkd |
316 | mstartunit systemd-resolved |
317 | # required by mcore-register-client |
318 | mstartunit systemd-networkd-wait-online |
319 | } |
320 | |
321 | postinstall_sysvinit-initscripts() |
322 | { |
323 | postinstall_common |
324 | |
325 | if [ -f ${MROOT}/etc/rc.d/init.d/functions ] |
326 | then |
327 | # create service state dir mountpoint |
328 | # needed by >=initscripts-0.3.2-r1 |
329 | [ ! -d ${MROOT}/var/lib/init.d ] && install -d ${MROOT}/var/lib/init.d |
330 | |
331 | # mark this dir as undeletable |
332 | touch ${MROOT}/var/lib/init.d/.keep |
333 | |
334 | if [[ -x ${MROOT}/usr/sbin/rc-config ]] |
335 | then |
336 | echo "Creating Runlevels ..." |
337 | local i |
338 | for i in checkfs cleanfs halt \ |
339 | loadkeys localnet modules mountfs \ |
340 | network reboot sendsignals \ |
341 | setclock swap sysctl consolefont |
342 | do |
343 | echo -e "\tAdded ${i} ..." |
344 | ${MROOT}/usr/sbin/rc-config del ${i} > /dev/null |
345 | ${MROOT}/usr/sbin/rc-config add ${i} > /dev/null |
346 | done |
347 | fi |
348 | fi |
349 | } |
350 | |
351 | postinstall_busybox-initscripts() |
352 | { |
353 | postinstall_common |
354 | |
355 | if [ -f ${MROOT}/etc/rc.d/init.d/functions ] |
356 | then |
357 | # create service state dir mountpoint |
358 | # needed by >=initscripts-0.3.2-r1 |
359 | [ ! -d ${MROOT}/var/lib/init.d ] && install -d ${MROOT}/var/lib/init.d |
360 | |
361 | # mark this dir as undeletable |
362 | touch ${MROOT}/var/lib/init.d/.keep |
363 | |
364 | if [[ -x ${MROOT}/usr/sbin/rc-config ]] |
365 | then |
366 | echo "Creating Runlevels ..." |
367 | local i |
368 | for i in checkfs cleanfs loadkeys localnet \ |
369 | modules mountfs network setclock swap |
370 | do |
371 | echo -e "\tAdded ${i} ..." |
372 | ${MROOT}/usr/sbin/rc-config del ${i} > /dev/null |
373 | ${MROOT}/usr/sbin/rc-config add ${i} > /dev/null |
374 | done |
375 | fi |
376 | fi |
377 | } |
378 | |
379 | preinstall_common() |
380 | { |
381 | # ignore this while package building |
382 | if [[ ! -f /.installrc ]] |
383 | then |
384 | local package |
385 | for package in ${BLOCKER} |
386 | do |
387 | if [[ ! -z $(magequery -n ${package##*/}) ]] |
388 | then |
389 | echo -e ${COLRED} |
390 | echo -e "Error: ${package} is installed!!" |
391 | echo -e "This initscript flavor cannot co-exist ${package}." |
392 | echo -e "Please uninstall ${package} first!" |
393 | echo -e ${COLDEFAULT} |
394 | die "${package} found!" |
395 | fi |
396 | done |
397 | fi |
398 | } |
399 | |
400 | preinstall_systemd-initscripts() |
401 | { |
402 | preinstall_common |
403 | |
404 | add_conf_prot_mask /etc/env.d /etc/modprobe.d /etc/rc.d/init.d /etc/profile /etc/inputrc \ |
405 | /etc/shells /etc/issue /etc/DIR_COLORS /etc/inittab \ |
406 | /etc/conf.d/net.sample /etc/conf.d/kernel /etc/conf.d/rc /etc/conf.d/network \ |
407 | /etc/systemd/network/default.network |
408 | |
409 | add_conf_prot_ignore /etc/fstab /etc/group /etc/hostname /etc/hosts /etc/modules.autoload \ |
410 | /etc/passwd /etc/shadow /etc/conf.d/clock /etc/conf.d/editor /etc/conf.d/keymap \ |
411 | /etc/conf.d/net.routes /etc/locale.conf /etc/vconsole.conf /etc/resolv.conf |
412 | } |
413 | |
414 | preinstall_sysvinit-initscripts() |
415 | { |
416 | preinstall_common |
417 | |
418 | add_conf_prot_mask /etc/env.d /etc/modprobe.d /etc/rc.d/init.d /etc/profile /etc/inputrc \ |
419 | /etc/shells /etc/issue /etc/DIR_COLORS /etc/inittab \ |
420 | /etc/conf.d/net.sample /etc/conf.d/kernel /etc/conf.d/rc /etc/conf.d/network |
421 | |
422 | add_conf_prot_ignore /etc/fstab /etc/group /etc/hostname /etc/hosts /etc/modules.autoload \ |
423 | /etc/passwd /etc/shadow /etc/conf.d/clock /etc/conf.d/editor /etc/conf.d/keymap \ |
424 | /etc/conf.d/net.routes /etc/resolv.conf |
425 | } |
426 | |
427 | preinstall_busybox-initscripts() |
428 | { |
429 | preinstall_common |
430 | |
431 | add_conf_prot_mask /etc/env.d /etc/modprobe.d /etc/rc.d/init.d /etc/profile /etc/inputrc \ |
432 | /etc/shells /etc/issue /etc/DIR_COLORS /etc/inittab \ |
433 | /etc/conf.d/net.sample /etc/conf.d/kernel /etc/conf.d/rc /etc/conf.d/network |
434 | |
435 | add_conf_prot_ignore /etc/fstab /etc/group /etc/hostname /etc/hosts /etc/modules.autoload \ |
436 | /etc/passwd /etc/shadow /etc/conf.d/clock /etc/conf.d/editor /etc/conf.d/keymap \ |
437 | /etc/conf.d/net.routes /etc/resolv.conf |
438 | } |
439 | |
440 | preremove_common() |
441 | { |
442 | # protect these files, that they do not get removed from the system |
443 | local CONFIG_IGNORE="fstab hostname hosts" |
444 | for i in ${CONFIG_IGNORE} |
445 | do |
446 | [[ -e ${MROOT}/etc/${i} ]] && touch ${MROOT}/etc/${i} |
447 | done |
448 | } |
449 | |
450 | preremove_systemd-initscripts() |
451 | { |
452 | preremove_common |
453 | } |
454 | |
455 | preremove_sysvinit-initscripts() |
456 | { |
457 | preremove-common |
458 | } |
459 | |
460 | preremove_busybox-initscripts() |
461 | { |
462 | preremove_common |
463 | } |