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