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