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