Contents of /smage/trunk/core/initscripts/initscripts-0.7.6-r1.smage2
Parent Directory | Revision Log
Revision 4370 -
(show annotations)
(download)
Fri Nov 16 13:25:38 2012 UTC (11 years, 6 months ago) by niro
File size: 10250 byte(s)
Fri Nov 16 13:25:38 2012 UTC (11 years, 6 months ago) by niro
File size: 10250 byte(s)
-reworked pre/postinstall preremove
1 | # $Id$ |
2 | |
3 | PNAME="initscripts" |
4 | PVER="0.7.6" |
5 | PBUILD="r1" |
6 | |
7 | # enable busybox initscripts y|n |
8 | # disabled atm, busybox missing in tree |
9 | BUSYBOX_ENABLED="y" |
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 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 | |
183 | if [[ ${BUSYBOX_ENABLED} = y ]] |
184 | then |
185 | src_install_busybox-initscripts() |
186 | { |
187 | local flavor="busybox" |
188 | local config_protect_ignore |
189 | local MCONFIG |
190 | |
191 | cd ${SRCDIR} |
192 | common_install ${flavor} || die |
193 | |
194 | # CONFIG_PROTECT_MASK for /etc/rc.d/init.d |
195 | minstalldir /etc/env.d || die |
196 | MCONFIG="/etc/env.d/01${flavor}" |
197 | mclearconfig || die |
198 | maddconfig "CONFIG_PROTECT_MASK=\"/etc/rc.d/init.d\"" || die |
199 | config_protect_ignore+=" /etc/modules.autoload.d/kernel-2.4" |
200 | config_protect_ignore+=" /etc/modules.autoload.d/kernel-2.6" |
201 | config_protect_ignore+=" /etc/modules.autoload" |
202 | maddconfig "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" || die |
203 | # add conf.d/kernel to protect current udev|mdev configuration |
204 | config_protect_ignore+=" /etc/conf.d/kernel" |
205 | maddconfig "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" || die |
206 | } |
207 | fi |
208 | |
209 | postinstall-common() |
210 | { |
211 | # emulate seq; its needed to run rc-config |
212 | # this fixes some annyoing warning when building |
213 | # livecd or bootstrapping a system. |
214 | # this hack will be removed when the toolchain is fixed |
215 | if [ ! -f /usr/bin/seq ] |
216 | then |
217 | echo "Using fake 'seq' command ..." |
218 | seq() { |
219 | start=$1 |
220 | end=$2 |
221 | for ((i=start; i < end+1; i++)) |
222 | do |
223 | echo $i |
224 | done |
225 | } |
226 | export -f seq |
227 | fi |
228 | |
229 | # keep this only for transitional purposes |
230 | # do not ask the user about following files |
231 | # |
232 | # if they exist let config_protect process them |
233 | # but then remove the protected files, to keep only the original file |
234 | # |
235 | # file-root is ${MROOT}/etc |
236 | 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" |
237 | local i file path |
238 | for i in ${CONFIG_IGNORE} |
239 | do |
240 | file="$(basename ${i})" |
241 | path="$(dirname ${i})/" |
242 | [[ ${path} == ./ ]] && path="" |
243 | |
244 | rm -f ${MROOT}/etc/${path}._cfg????_${file} |
245 | done |
246 | |
247 | # initscripts >= 0.5.0: rc file moved to /etc/conf.d/rc |
248 | if [[ -f ${MROOT}/etc/conf.d/rc ]] && [[ -f ${MROOT}/etc/sysconfig/rc ]] |
249 | then |
250 | rm -f ${MROOT}/etc/sysconfig/rc |
251 | fi |
252 | |
253 | # aliases and i368 got renamed to *.conf |
254 | local i |
255 | for i in aliases i386 |
256 | do |
257 | if [[ -f ${MROOT}/etc/modules.d/${i} ]] |
258 | then |
259 | rm ${MROOT}/etc/modules.d/${i} |
260 | fi |
261 | done |
262 | } |
263 | |
264 | postinstall-systemd-initscripts() |
265 | { |
266 | postinstall-common |
267 | |
268 | # enable network.service (systemd only) |
269 | mstartunit network.service |
270 | } |
271 | |
272 | postinstall-sysvinit-initscripts() |
273 | { |
274 | postinstall-common |
275 | |
276 | if [ -f ${MROOT}/etc/rc.d/init.d/functions ] |
277 | then |
278 | # create service state dir mountpoint |
279 | # needed by >=initscripts-0.3.2-r1 |
280 | [ ! -d ${MROOT}/var/lib/init.d ] && install -d ${MROOT}/var/lib/init.d |
281 | |
282 | # mark this dir as undeletable |
283 | touch ${MROOT}/var/lib/init.d/.keep |
284 | |
285 | if [[ -x ${MROOT}/usr/sbin/rc-config ]] |
286 | then |
287 | echo "Creating Runlevels ..." |
288 | local i |
289 | for i in checkfs cleanfs halt \ |
290 | loadkeys localnet modules mountfs \ |
291 | network reboot sendsignals \ |
292 | setclock swap sysctl consolefont |
293 | do |
294 | echo -e "\tAdded ${i} ..." |
295 | ${MROOT}/usr/sbin/rc-config del ${i} > /dev/null |
296 | ${MROOT}/usr/sbin/rc-config add ${i} > /dev/null |
297 | done |
298 | fi |
299 | fi |
300 | } |
301 | |
302 | postinstall-busybox-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 loadkeys localnet \ |
320 | modules mountfs network setclock swap |
321 | do |
322 | echo -e "\tAdded ${i} ..." |
323 | ${MROOT}/usr/sbin/rc-config del ${i} > /dev/null |
324 | ${MROOT}/usr/sbin/rc-config add ${i} > /dev/null |
325 | done |
326 | fi |
327 | fi |
328 | } |
329 | |
330 | preinstall-common() |
331 | { |
332 | # ignore this while package building |
333 | if [[ ! -f /.installrc ]] |
334 | then |
335 | local package |
336 | for package in ${BLOCKER} |
337 | do |
338 | if [[ ! -z $(magequery -n ${package##*/}) ]] |
339 | then |
340 | echo -e ${COLRED} |
341 | echo -e "Error: ${package} is installed!!" |
342 | echo -e "This initscript flavor cannot co-exist ${package}." |
343 | echo -e "Please uninstall ${package} first!" |
344 | echo -e ${COLDEFAULT} |
345 | die "${package} found!" |
346 | fi |
347 | done |
348 | fi |
349 | } |
350 | |
351 | preinstall-systemd-initscripts() |
352 | { |
353 | preinstall-common |
354 | |
355 | add_conf_prot_mask /etc/env.d /etc/modprobe.d /etc/rc.d/init.d /etc/profile /etc/inputrc \ |
356 | /etc/shells /etc/issue /etc/DIR_COLORS /etc/inittab \ |
357 | /etc/conf.d/net.sample /etc/conf.d/kernel /etc/conf.d/rc /etc/conf.d/network |
358 | |
359 | add_conf_prot_ignore /etc/fstab /etc/group /etc/hostname /etc/hosts /etc/modules.autoload \ |
360 | /etc/passwd /etc/shadow /etc/conf.d/clock /etc/conf.d/editor /etc/conf.d/keymap \ |
361 | /etc/conf.d/net.routes |
362 | } |
363 | |
364 | preinstall-sysvinit-initscripts() |
365 | { |
366 | preinstall-common |
367 | |
368 | add_conf_prot_mask /etc/env.d /etc/modprobe.d /etc/rc.d/init.d /etc/profile /etc/inputrc \ |
369 | /etc/shells /etc/issue /etc/DIR_COLORS /etc/inittab \ |
370 | /etc/conf.d/net.sample /etc/conf.d/kernel /etc/conf.d/rc /etc/conf.d/network |
371 | |
372 | add_conf_prot_ignore /etc/fstab /etc/group /etc/hostname /etc/hosts /etc/modules.autoload \ |
373 | /etc/passwd /etc/shadow /etc/conf.d/clock /etc/conf.d/editor /etc/conf.d/keymap \ |
374 | /etc/conf.d/net.routes |
375 | } |
376 | |
377 | preinstall-busybox-initscripts() |
378 | { |
379 | preinstall-common |
380 | |
381 | add_conf_prot_mask /etc/env.d /etc/modprobe.d /etc/rc.d/init.d /etc/profile /etc/inputrc \ |
382 | /etc/shells /etc/issue /etc/DIR_COLORS /etc/inittab \ |
383 | /etc/conf.d/net.sample /etc/conf.d/kernel /etc/conf.d/rc /etc/conf.d/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 |
388 | } |
389 | |
390 | preremove-common() |
391 | { |
392 | # protect these files, that they do not get removed from the system |
393 | local CONFIG_IGNORE="fstab hostname hosts" |
394 | for i in ${CONFIG_IGNORE} |
395 | do |
396 | [[ -e ${MROOT}/etc/${i} ]] && touch ${MROOT}/etc/${i} |
397 | done |
398 | } |
399 | |
400 | preremove-systemd-initscripts() |
401 | { |
402 | preremove-common |
403 | } |
404 | |
405 | preremove-sysvinit-initscripts() |
406 | { |
407 | preremove-common |
408 | } |
409 | |
410 | preremove-busybox-initscripts() |
411 | { |
412 | preremove-common |
413 | } |