Magellan Linux

Contents of /smage/trunk/core/initscripts/initscripts-0.8.6-r5.smage2

Parent Directory Parent Directory | Revision Log Revision Log


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