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