]> git.pld-linux.org Git - projects/geninitrd.git/blame - geninitrd
- lzma/bzip2 compress methods todo
[projects/geninitrd.git] / geninitrd
CommitLineData
bb529f94
JK
1#!/bin/sh
2
3# geninitrd
4#
45d4d8cb 5# by PLD Linux Team
bb529f94 6#
9e1ceabe 7# based on mkinitrd from RedHat Linux
e4b07ddc 8#
c31050f3 9
28eec2b1 10RCSID='$Id$'
ca2c2012
ER
11R=${RCSID#* * }; VERSION=${R%% *}
12PROGRAM=${0##*/}
bb529f94
JK
13
14. /etc/rc.d/init.d/functions
ded87775 15. /lib/geninitrd/functions
e2405b29 16. /etc/sysconfig/system
bb529f94 17
c124d0cf
ER
18# list of geninitrd modules which need setup routine after commandline args parsing
19GENINITRD_MODS=""
c3667d07 20COMPRESS=yes
bb529f94
JK
21target=""
22kernel=""
23force=""
24verbose=""
25MODULES=""
26img_vers=""
c3667d07 27fstab=/etc/fstab
c3667d07 28modext=.o
4e9eb79c 29rootdev_nr=0
738c05d8
ER
30# device node for rootfs from fstab
31rootdev=""
bb529f94 32
8bd582f1
ER
33# internal variables
34# is /dev on tmpfs
b64f015b
ER
35dev_mounted=no
36# is /proc mounted
37proc_mounted=no
38# is /sys mounted
39sys_mounted=no
40# is /tmp mounted on tmpfs
41tmp_mounted=no
42
43# are /dev nodes already created from /proc/devices info?
8bd582f1 44proc_partitions=no
6b013929 45
b64f015b 46usage() {
553786c4 47 uname_r=$(uname -r)
00eaa938 48 echo "usage: $PROGRAM [--version] [-v] [-f] [--ifneeded] [--preload <module>]"
ac085800 49 echo " [--with=<module>] [--image-version] [--fstab=<fstab>] [--nocompress]"
92ed99b6 50 echo " [--initrdfs=rom|initramfs|ext2|cram] [--modules-conf=<modules.conf>]"
18ece493 51 echo " [--with-raidstart] [--without-raidstart]"
ba5d09f0 52 echo " [--with-bootsplash] [--without-bootsplash]"
6c69a2d4
ER
53 echo " [--with-fbsplash] [--without-fbsplash]"
54 echo " [--with-fbcondecor] [--without-fbcondecor]"
e4b07ddc 55 echo " [--lvmtoolsversion=1|2] [--with-udev] [--without-udev]"
ba5d09f0 56 echo " [--with-suspend] [--without-suspend]"
1cd2aabd 57 echo " [--with-tuxonice] [--without-tuxonice]"
2cc3ae8b 58 echo " [--without-dmraid] [--without-multipath]"
3ef3d717 59 echo " [--without-blkid] [--without-luks]"
ac085800 60 echo " <initrd-image> <kernel-version>"
553786c4
ER
61 echo ""
62 echo "example:"
00eaa938 63 echo " $PROGRAM -f --initrdfs=rom /boot/initrd-$uname_r.gz $uname_r"
36523626 64 exit 0
bb529f94
JK
65}
66
779a218a 67msg() {
f4010f7f
AM
68 echo "$PROGRAM: $*"
69}
70
71warn() {
4a60c01f 72 msg "WARNING: $*" >&2
779a218a
AM
73}
74
94769f11 75debug() {
4a60c01f 76 [ -n "$verbose" ] && msg "$*" >&2
94769f11 77}
aa69da6e 78
bf6c3fcb
ER
79# aborts program abnormally
80die() {
b5f5c089 81 local rc=${2:-1}
046c68c9 82 msg "ERROR: $1" >&2
bf6c3fcb
ER
83 exit $rc
84}
85
684d5d2a
ER
86# find program from specified paths
87find_tool() {
88 local x
89 for x in "$@"; do
90 if [ -x "$x" ]; then
91 echo $x
92 debug "find_tool: found $x"
93 return 0
94 fi
95 done
96 debug "find_tool: did not found any of: $@"
97 return 1
98}
99
c124d0cf
ER
100# loads geninitrd modules
101geninitrd_load_mods() {
102 local mod
103 for mod in "$@"; do
104 if [ ! -f /lib/geninitrd/mod-$mod.sh ]; then
105 die "$mod geninitrd module can't be loaded"
106 fi
107 . /lib/geninitrd/mod-$mod.sh
108
109 if type setup_mod_$mod > /dev/null; then
110 # add to list which need init
111 GENINITRD_MODS="$GENINITRD_MODS $mod"
112 fi
113 done
114}
115
116# setup geninitrd modules
117geninitrd_setup_mods() {
118 local mod
119
120 for mod in $GENINITRD_MODS; do
121 eval setup_mod_$mod
122 done
123}
124
c6c6ce01
ER
125# append text to /linuxrc
126# takes STDIN as input
127add_linuxrc() {
b64f015b 128 cat >> "$RCFILE"
c6c6ce01
ER
129}
130
b64f015b
ER
131# generate code to mount /dev on tmpfs and create initial nodes
132# can be called multiple times. /dev is cleaned up (umounted) automatically at
133# the end of script.
134mount_dev() {
135 if [ "$INITRDFS" = "initramfs" ]; then
136 # initramfs is read-write filesystem, no need for tmpfs
137 return
138 fi
139
140 # we already generated tmpfs code; return
141 if is_yes "$dev_mounted"; then
142 return
143 fi
144
145 dev_mounted=yes
146
147 busybox_applet mount mknod mkdir
148 add_linuxrc <<-EOF
149 : 'Creating /dev'
150 mount -o mode=0755 -t tmpfs none /dev
151 mknod /dev/console c 5 1
152 mknod /dev/null c 1 3
153 mknod /dev/zero c 1 5
154 mkdir /dev/pts
155 mkdir /dev/shm
156 EOF
157}
158
159# generate code to mount /proc on initrd
160# can be called multiple times
161mount_proc() {
162 if is_yes "$proc_mounted"; then
163 return
164 fi
165
166 proc_mounted=yes
2bface63
ER
167 if [ "$INITRDFS" = "initramfs" ]; then
168 # /proc is mounted with initramfs 2.6.22.14 kernel
169 # XXX: remove when it is clear why proc was already mounted
170 echo "[ -f /proc/cmdline ] || mount -t proc none /proc" | add_linuxrc
171 else
172 echo "mount -t proc none /proc" | add_linuxrc
173 fi
b64f015b
ER
174}
175
176# generate code to mount /sys on initrd
177# can be called multiple times
178mount_sys() {
179 if is_yes "$sys_mounted"; then
180 return
181 fi
182
183 sys_mounted=yes
184 echo "mount -t sysfs none /sys" | add_linuxrc
185}
186
187# generate code to mount /tmp on initrd
188# can be called multiple times
189mount_tmp() {
190 if [ "$INITRDFS" = "initramfs" ]; then
191 # initramfs is read-write filesystem, no need for tmpfs
192 return
193 fi
194
195 if is_yes "$tmp_mounted"; then
196 return
197 fi
198
199 tmp_mounted=yes
200 echo "mount -t tmpfs none /tmp" | add_linuxrc
201}
202
203# unmount all mountpoints mounted by geninitrd
204umount_all() {
ec49b7e6
ER
205
206 add_linuxrc <<-'EOF'
903f21ea 207 : Last shell before umounting all and giving control over to real init.
ec49b7e6
ER
208 debugshell
209 EOF
5b70f84d 210
b64f015b
ER
211 if is_yes "$dev_mounted"; then
212 echo 'umount /dev' | add_linuxrc
213 dev_mounted=no
214 fi
215 if is_yes "$proc_mounted"; then
216 echo 'umount /proc' | add_linuxrc
217 proc_mounted=no
218 fi
219 if is_yes "$sys_mounted"; then
220 echo 'umount /sys' | add_linuxrc
221 sys_mounted=no
222 fi
223 if is_yes "$tmp_mounted"; then
224 echo 'umount /tmp' | add_linuxrc
225 tmp_mounted=no
226 fi
227}
228
229
9299682f
ER
230# Checks if busybox has support for APPLET(s)
231# Exits from geninitrd if the support is not present.
232#
233# NB! XXX do not output to STDOUT, it will appear in initrd images in some cases!
234busybox_applet() {
235 local err=0
236
237 if [ -z "$busybox_functions" ]; then
684d5d2a 238 local tmp=$($busybox 2>&1)
9b1373fb
ER
239
240 # BusyBox v1.1.3 says applet not found if it's not called 'busybox'.
241 if [[ "$tmp" = *applet\ not\ found* ]]; then
242 local t=$(mktemp -d)
684d5d2a 243 ln -s $busybox $t/busybox
9b1373fb
ER
244 local tmp=$($t/busybox 2>&1)
245 rm -rf $t
246 fi
247
248 busybox_functions=$(echo "$tmp" | \
9299682f
ER
249 sed -ne '/Currently defined functions:/,$p' | \
250 xargs | sed -e 's,.*Currently defined functions: ,,'
251 )
252 fi
253 for applet in $*; do
254 local have
255 # try cache
256 eval have='$'busybox_have_$applet
257 if [ -z "$have" ]; then
258 have=$(echo "$busybox_functions" | egrep -c "( |^)$applet(,|$)")
259 if [ "$have" = 0 ]; then
f4010f7f 260 warn "This setup requires busybox-initrd compiled with applet '$applet' support"
9299682f
ER
261 err=1
262 fi
263 eval busybox_have_$applet=$have
264 fi
265 done
266 if [ $err = 1 ]; then
00eaa938 267 die "Aborted"
9299682f
ER
268 fi
269}
270
7ffba534
ER
271# Finds module dependencies
272#
7ffba534
ER
273# @param $module
274#
046c68c9 275# Outputs full path to module and it's dependencies
7ffba534 276find_depmod() {
fe280785 277 local module="$1"
046c68c9
ER
278 local skiperrors=0
279
280 # if module is prefixed with dash, we should ignore errors if the module
281 # can't be found.
282 if [ ${module#-} != $module ]; then
283 skiperrors=1
284 module=${module#-}
285 fi
286
046c68c9
ER
287 # This works when user has module-init-tools installed even on 2.4 kernels
288 local modprobe
289 modprobe=$(modprobe --set-version $kernel --show-depends $module --ignore-install 2>&1)
290
291 if [ $? != 0 ]; then
292 if [ $skiperrors = 1 ]; then
7cac5014
ER
293 return
294 fi
046c68c9 295 echo >&2 "$modprobe"
7cac5014 296
7ffba534 297 if ! is_no "$EXIT_IF_MISSING"; then
046c68c9 298 die "$module: module not found for $kernel kernel"
7ffba534 299 fi
046c68c9
ER
300
301 warn "$module: module not found for $kernel kernel"
302 warn "If $module isn't compiled in kernel then this initrd may not start your system."
7ffba534
ER
303 fi
304
046c68c9 305 echo "$modprobe" | \
c25765ed 306 while read insmod modpath options; do
59a68735 307 [ "$insmod" = "insmod" ] && echo $modpath
7ffba534
ER
308 done
309}
310
4a60c01f
AM
311find_firmware() {
312 local module="$1"
601127ea
ER
313
314 # no firmware support in 2.4 kernels
315 if [ "$kernel_version_long" -lt "002005048" ]; then
316 return
317 fi
318 echo -n $(NEW_MODINFO=1 modinfo -k $kernel -F firmware $module 2>/dev/null | xargs)
4a60c01f
AM
319}
320
046c68c9
ER
321# @param $module
322find_module() {
323 local mod depmod module=$1
ac085800 324
046c68c9 325 depmod=$(find_depmod $module) || exit 1
fe280785 326 for mod in $depmod; do
7ffba534 327 mod=${mod#/lib/modules/$kernel/}
fe280785
ER
328
329 # add each module only once
330 local m have=0
331 for m in $MODULES; do
332 [ $m = $mod ] && have=1
333 done
334 if [ $have = 0 ]; then
c2eb7d4f 335 MODULES="$MODULES $mod"
fe280785 336 fi
10c3df06 337 done
bb529f94
JK
338}
339
034fdd5d
ER
340# install a file to temporary mount image.
341# it will operate recursively (copying directories)
342# and will symlink destinations if source is symlink.
bb529f94 343inst() {
17e97aec 344 if [ $# -lt 2 ]; then
a9ace64a 345 die 'Usage: inst <file> [<file>] <destination>'
c31050f3 346 fi
17e97aec
ER
347
348 local src i=0 c=$(($# - 1))
349 while [ $i -lt $c ]; do
350 src="$src $1"
351 i=$((i + 1))
352 shift
353 done
354 local dest=$1
355 set -- $src
242f2358
PZ
356 parentDir=$(dirname $DESTDIR$dest)
357 [ ! -d "$parentDir" ] && (debug "+ mkdir -p $parentDir"; mkdir -p $parentDir)
d8056591 358 debug "+ cp $* $DESTDIR$dest"
9b557a09 359 cp -HR "$@" "$DESTDIR$dest"
bb529f94
JK
360}
361
dab92b1d 362inst_d() {
17e97aec 363 if [ $# = 0 ]; then
a9ace64a 364 die 'Usage: inst_d <destination> <destination>'
034fdd5d
ER
365 fi
366 for dir in "$@"; do
9b557a09 367 install -d "$DESTDIR$dir"
034fdd5d
ER
368 done
369}
370
209061e3
ER
371# install executable and it's shared libraries
372inst_exec() {
17e97aec 373 if [ $# -lt 2 ]; then
3601c2fa 374 die "Invalid params ($@), Usage: inst_exec <file>[, <file>] <destination>"
17e97aec 375 fi
209061e3
ER
376 local src i=0 c=$(($# - 1))
377 while [ $i -lt $c ]; do
378 src="$src $1"
379 i=$((i + 1))
380 shift
381 done
9b532fe6 382 local dest=$1
209061e3
ER
383 set -- $src
384
9b532fe6
ER
385 inst "$@" $dest
386
5265962d 387 local lib libs=$(ldd "$@" | awk '/statically|linux-(gate|vdso)\.so/{next} NF == 2 {print $1} /=/{print $3}' | sort -u)
9b532fe6 388 for lib in $libs; do
9b557a09 389 if [ ! -f "$DESTDIR/$_lib/${lib##*/}" ]; then
7efbe841
ER
390 inst_d /$_lib
391 inst_exec $lib /$_lib
17e97aec 392 fi
209061e3 393 done
c7ade647
ER
394
395 # hack for uclibc linked binaries requiring this fixed path
396 # XXX: shouldn't rpath be used here instead so th
397 if [ -f $DESTDIR/$_lib/libc.so.0 ]; then
398 local lib=$DESTDIR/$_lib/libc.so.0
399 lib=$(ldd "$lib" | awk '/statically|linux-(gate|vdso)\.so/{next} NF == 2 {print $1} /=/{print $3}' | sort -u)
400 local libdir=$(cd $(dirname "$lib"); pwd)
401 if [ ! -e $DESTDIR$libdir ]; then
402 libdir=$(dirname "$libdir")
403 inst_d $libdir
404 debug "+ ln -s /$_lib $DESTDIR$libdir"
405 ln -s /$_lib $DESTDIR$libdir
406 fi
407 fi
209061e3
ER
408}
409
82474db9
ER
410# output modules.conf / modprobe.conf
411modprobe_conf() {
412 echo "$modprobe_conf_cache"
413}
414
415#
416# defaults to modprobe -c if not told otherwise, this means include statements
417# work from there.
418cache_modprobe_conf() {
707f5e60 419 if [ "$kernel_version" -lt "002005" ]; then
82474db9
ER
420 modulefile=/etc/modules.conf
421 if [ ! -f "$modulefile" -a -f /etc/conf.modules ]; then
422 modulefile=/etc/conf.modules
423 fi
424 fi
425
426 if [ -n "$modulefile" ]; then
d8056591 427 debug "Using $modulefile for modules config"
82474db9
ER
428 modprobe_conf_cache=$(cat $modulefile)
429 else
d8056591 430 debug "Using modprobe -c to get modules config"
520412e9 431 modprobe_conf_cache=$(modprobe -c --set-version $kernel)
82474db9
ER
432 fi
433}
434
bc0d6f2d 435# find modules for $devpath
d8056591 436find_modules_for_devpath() {
bc0d6f2d
ER
437 local devpath="$1"
438 if [ -z "$devpath" ]; then
d8056591 439 die "No argument passed to find_modules_for_devpath() - is your /etc/fstab correct?"
f6536797 440 fi
ac085800 441
c2eb7d4f
ER
442 if [[ "$devpath" = /dev/dm-* ]]; then
443 # /dev/dm-3 -> /dev/mapper/sil_ahbgadcbchfc3
bc0d6f2d 444 devpath=$(dm_longname "$devpath")
c2eb7d4f
ER
445 fi
446
67aa84bd 447 if [ -L "$devpath" ] && ! is_lvm "$devpath"; then
c2eb7d4f
ER
448 # sanitize things like:
449 # /dev/block/104:2 -> /dev/cciss/c0d0p2
450 devpath=$(readlink -f "$devpath")
451 fi
452
d8056591 453 debug "Finding modules for device path $devpath"
bc0d6f2d 454
3ef3d717
ER
455 if is_luks "$devpath"; then
456 find_modules_luks "$devpath"
457 return
458 fi
459
74d45ce1
ER
460 if is_nfs "$devpath"; then
461 find_modules_nfs "$devpath"
d9179777
ER
462 return
463 fi
464
e16414d9 465 if is_md "$devpath"; then
df738638 466 find_modules_md "$devpath"
d9179777
ER
467 return
468 fi
469
c3b54060 470 if is_multipath "$devpath"; then
07137fe3 471 if find_modules_multipath "$devpath"; then
9baf4f3f 472 return
9baf4f3f 473 fi
9baf4f3f
ER
474 # fallback
475 fi
476
36523626 477 if is_dmraid "$devpath"; then
c083ae23
ER
478 if find_modules_dmraid "$devpath"; then
479 return
480 fi
481 # fallback
482 fi
483
35043b20
ER
484 if is_scsi "$devpath"; then
485 find_modules_scsi "$devpath"
d9179777
ER
486 return
487 fi
488
30ca4815 489 if is_ide "$devpath"; then
bc0d6f2d 490 find_modules_ide "$devpath"
d9179777
ER
491 return
492 fi
493
07b09cf9 494 if [[ "$devpath" == /dev/rd/* ]]; then
046c68c9 495 find_module "DAC960"
c3313cd6 496 rootdev_add=/dev/rd/
d9179777
ER
497 return
498 fi
499
07b09cf9 500 if [[ "$devpath" == /dev/ida/* ]]; then
046c68c9 501 find_module "cpqarray"
c3313cd6 502 rootdev_add=/dev/ida/
d9179777
ER
503 return
504 fi
505
08651ad1 506 if [[ "$devpath" == /dev/cciss/* ]]; then
046c68c9 507 find_module "cciss"
c3313cd6 508 rootdev_add=/dev/cciss/
d9179777
ER
509 return
510 fi
511
07b09cf9 512 if [[ "$devpath" == /dev/ataraid/* ]]; then
ac085800 513 find_modules_ide
046c68c9 514 find_module "ataraid"
82474db9 515 ataraidmodules=$(modprobe_conf | awk '/ataraid_hostadapter/ && ! /^[\t ]*#/ { print $3; }')
9ae446b9 516 if [ -n "$ataraidmodules" ]; then
7c38b114 517 # FIXME: think about modules compiled in kernel
82474db9 518 die "ataraid_hostadapter alias not defined in modprobe.conf! Please set it and run $PROGRAM again."
7c38b114
AF
519 fi
520 for n in $ataraidmodules; do
046c68c9 521 find_module "$n"
7c38b114 522 done
c3313cd6 523 rootdev_add=/dev/ataraid/
d9179777
ER
524 return
525 fi
526
7c38b114 527 # check to see if we need to set up a loopback filesystem
07b09cf9 528 if [[ "$devpath" == /dev/loop* ]]; then
00eaa938 529 die "Sorry, root on loop device isn't supported."
7c38b114
AF
530 # TODO: rewrite for bsp and make nfs ready
531 if [ ! -x /sbin/losetup ]; then
00eaa938 532 die "losetup is missing"
7c38b114 533 fi
bc0d6f2d 534 key="^# $(echo $devpath | awk -F/ '{print($3);}' | tr '[a-z]' '[A-Z]'):"
82474db9 535 if ! is_yes "`awk '/'$key'/ { print( "yes"); }' $fstab`"; then
42820142 536 die "The root filesystem is on a $devpath, but there is no magic entry in $fstab for this device. Consult the $PROGRAM man page for more information"
7c38b114
AF
537 fi
538
539 line="`awk '/'$key'/ { print $0; }' $fstab`"
540 loopDev="$(echo $line | awk '{print $3}')"
541 loopFs="$(echo $line | awk '{print $4}')"
542 loopFile="$(echo $line | awk '{print $5}')"
543
544 BASICMODULES="$BASICMODULES -loop"
046c68c9 545 find_module "-$loopFs"
7c38b114 546 BASICMODULES="$BASICMODULES -${loopFs}"
d9179777
ER
547 return
548 fi
549
67aa84bd
ER
550 if is_lvm "$devpath"; then
551 find_modules_lvm "$devpath"
d9179777 552 return
7c38b114
AF
553 fi
554}
555
b64f015b 556firmware_install_module() {
c3667d07 557 local module="$1"
c6c6ce01 558 local firmware_files="$2"
9ed6e1db 559
94769f11 560 debug "Adding Firmwares ($firmware_files) to initrd for module $module"
9ed6e1db 561 # firmware not yet installed
9b557a09 562 if [ ! -f "$DESTDIR/lib/firmware/firmware.sh" ]; then
034fdd5d 563 inst_d /lib/firmware
9b557a09 564cat << 'EOF' >> "$DESTDIR/lib/firmware/firmware.sh"
9ed6e1db 565#!/bin/sh -e
8639f99a
AM
566echo 1 > /sys$DEVPATH/loading
567cat "/lib/firmware/$FIRMWARE" > /sys$DEVPATH/data
568echo 0 > /sys$DEVPATH/loading
569exit 0
9ed6e1db 570EOF
9b557a09 571 chmod 755 "$DESTDIR/lib/firmware/firmware.sh"
9ed6e1db
AM
572 fi
573
574 for firmware in $firmware_files; do
4a60c01f 575 if [ ! -f "/lib/firmware/$firmware" ]; then
4a60c01f 576 die "firmware file /lib/firmware/$firmware doesn't exist."
4a60c01f 577 else
486d26a5 578 FIRMWAREDIR=${firmware%/*}
4a9920e7 579 [ "$FIRMWAREDIR" != "$firmware" ] && inst_d /lib/firmware/$FIRMWAREDIR
7fde1ea5 580 inst /lib/firmware/$firmware /lib/firmware/$firmware
4a60c01f 581 fi
9ed6e1db
AM
582 done
583
b64f015b 584 mount_sys
c6c6ce01 585 echo "echo -n "/lib/firmware/firmware.sh" > /proc/sys/kernel/hotplug" | add_linuxrc
9ed6e1db
AM
586}
587
2a5bcca9 588modules_install() {
c3667d07
ER
589 local modules="$1"
590 local mod
2a5bcca9
AM
591
592 for mod in $modules; do
fe280785 593 MODULEDIR=${mod%/*}
4a9920e7 594 inst_d "/lib/modules/$kernel/$MODULEDIR"
9b557a09
ER
595 cp -a "/lib/modules/$kernel/$mod" "$DESTDIR/lib/modules/$kernel/$mod"
596 gunzip "$DESTDIR/lib/modules/$kernel/$mod" 2> /dev/null
2a5bcca9
AM
597 done
598}
599
600modules_add_linuxrc() {
fe280785 601 local mod modpath
ac085800 602
fe280785
ER
603 for mod in "$@"; do
604 # module path without optional compression
605 modpath=${mod%.gz}
606
607 # name of the module
608 module=${modpath##*/}
609 module=${module%$modext}
610
611 options=$(modprobe_conf | awk -vmodule="$module" '{ if ($1 == "options" && $2 == module) { for(i=3;i<=NF;i++) printf("%s ",$i); }}' | xargs)
ffa1b198 612
fe280785
ER
613 generic_module=$(echo $module | tr - _)
614 sleep_var=$(eval echo \$MODULE_${generic_module}_USLEEP)
615 firmware_var=$(eval echo \$MODULE_${generic_module}_FIRMWARE)
2a5bcca9 616
ac085800 617 if [ -n "$verbose" ]; then
8a47b72c
ER
618 s=""
619 if [ "$options" ]; then
620 s="$s with options [$options]"
621 fi
622 if [ "$sleep_var" ]; then
623 s="$s and $sleep_var usleep"
624 fi
4a60c01f 625 debug "Loading module [$module]$s"
ac085800
ER
626 fi
627
9ed6e1db 628 if [ -n "$firmware_var" ]; then
d814e616 629 firmware_install_module "$module" "$firmware_var"
4a60c01f
AM
630 else
631 firmware_files=$(find_firmware "$module")
632 if [ -n "$firmware_files" ]; then
633 for file in $firmware_files; do
634 firmware_install_module "$module" "$file"
635 done
636 fi
9ed6e1db 637 fi
4a60c01f 638
18ece493 639 echo "insmod /lib/modules/$kernel/$modpath $options" | add_linuxrc
fe280785 640 if [ -n "$sleep_var" ]; then
c6c6ce01 641 echo "usleep $sleep_var" | add_linuxrc
8e598759 642 fi
2a5bcca9
AM
643 done
644}
645
82b2dba2
ER
646# Generates /dev nodes based on /proc/partitions information.
647# Needs /proc mounted.
648# Can be called multiple times.
649initrd_gen_devices() {
650 if is_yes "$proc_partitions"; then
651 return
652 fi
653 proc_partitions=yes
335cd101 654
82b2dba2
ER
655 mount_dev
656 add_linuxrc <<-'EOF'
657 : 'Making device nodes'
658 cat /proc/partitions | (
8d4aba01 659 # ignore first two lines: header, empty line
82b2dba2 660 read b; read b
2cc3ae8b 661
82b2dba2
ER
662 while read major minor blocks dev rest; do
663 node=/dev/$dev
664 mkdir -p ${node%/*}
8d4aba01 665 [ -e $node ] || mknod $node b $major $minor
82b2dba2
ER
666 done
667 )
668 EOF
669}
bb529f94 670
82b2dba2 671
4828c787 672initrd_gen_setrootdev() {
5a761721 673 debug "Adding rootfs finding based on kernel cmdline root= option support."
82b2dba2 674 add_linuxrc <<-'EOF'
dcdf6b49
ER
675 if [ "${ROOT##/dev/}" != "${ROOT}" ]; then
676 rootnr="$(busybox awk -v rootnode="${ROOT##/dev/}" '$4 == rootnode { print 256 * $1 + $2 }' /proc/partitions)"
82b2dba2
ER
677 if [ -n "$rootnr" ]; then
678 echo "$rootnr" > /proc/sys/kernel/real-root-dev
679 fi
680 fi
b64f015b 681 EOF
1606e343
AM
682}
683
4671d086
ER
684initrd_gen_initramfs_switchroot() {
685 inst_d /newroot
686 if [ "$rootdev" = "/dev/nfs" ]; then
687 echo "rootfs on NFS root=/dev/nfs"
688 else
689 [ ! -e "$DESTDIR/$rootdev" ] && inst $rootdev $rootdev
690 fi
5845b321
ER
691
692 # parse 'root=xxx' kernel commandline
4671d086
ER
693 # We support passing root as hda3 /dev/hda3 0303 0x0303 and 303
694 add_linuxrc <<-'EOF'
695 device=/dev/no_partition_found
696 eval "$(busybox awk -v c="$ROOT" '
697 BEGIN {
698 num_pattern_short = "[0-9a-f][0-9a-f][0-9a-f]";
699 num_pattern = "[0-9a-f]" num_pattern_short;
700 dev_pattern = "[hms][a-z][a-z]([0-9])+";
701 partition = "no_partition_found";
702 min = -1; maj = -1;
703
704 sub("^0x", "", c);
705 if (c ~ "^" num_pattern_short "$") sub("^", "0", c);
706 if (c ~ "^" num_pattern "$") {
707 maj = sprintf("%s",substr(c,1,2));
708 min = sprintf("%s",substr(c,3));
709 }
710 if (c ~ "^\/dev\/" dev_pattern "$") sub("^/dev/","", c);
711 if (c ~ "^" dev_pattern "$") partition = c;
712 }
713
714 $4 ~ partition { maj = $1; min = $2; }
715 $1 ~ maj && $2 ~ min { partition = $4; }
716
717 END {
fa3a5452
ER
718 if (maj >= 0 && min >= 0) {
719 printf("device=/dev/%s; maj=%s; min=%s;\n", partition, maj, min);
720 }
4671d086
ER
721 }
722 ' /proc/partitions)"
723 if [ "$device" != '/dev/no_partition_found' -a ! -b $device ]; then
724 mknod $device b $maj $min
725 fi
726 EOF
727
728 add_linuxrc <<-EOF
729 rootdev=$rootdev
730 rootfs=$rootFs
731 EOF
732
733 add_linuxrc <<-'EOF'
734 if [ "$device" = '/dev/no_partition_found' ]; then
735 device=$rootdev
736 fi
737
738 mount -t $rootfs -r $device /newroot
739 init="$(echo "$CMDLINE" | busybox awk '/init=\// { gsub(/.*init=/,NIL,$0); gsub(/ .*/,NIL,$0); print }')"
740 if [ -z "$init" -o ! -x "/newroot$init" ]; then
741 init=/sbin/init
742 fi
743 EOF
744
745 umount_all
746 busybox_applet switch_root
747 add_linuxrc <<-'EOF'
748 exec switch_root /newroot $init
749
750 echo "Error! initramfs should not reach this place."
751 echo "It probably means you've got old version of busybox, with broken"
752 echo "initramfs support. Trying to boot anyway, but won't promise anything."
753
754 exec chroot /newroot $init
755
756 echo "Failed to chroot!"
757 EOF
758 # we need /init being real file, not symlink, otherwise the initramfs will
759 # not be ran by pid 1 which is required for switch_root
760 mv $DESTDIR/linuxrc $DESTDIR/init
761 ln -s init $DESTDIR/linuxrc
762}
763
034056fd
ER
764# main()
765if [ "$(id -u)" != 0 ]; then
766 die "You need to be root to generate initrd"
767fi
768
82b2dba2
ER
769if [ -r /etc/sysconfig/geninitrd ]; then
770 . /etc/sysconfig/geninitrd
771fi
2cc3ae8b 772
35043b20 773geninitrd_load_mods ide luks multipath dmraid lvm md blkid udev tuxonice suspend fbsplash condecor bootsplash uvesafb nfs scsi
c124d0cf 774
82b2dba2
ER
775while [ $# -gt 0 ]; do
776 case $1 in
777 --fstab=*)
778 fstab=${1#--fstab=}
779 ;;
780 --fstab)
781 fstab=$2
782 shift
783 ;;
784 --modules-conf=*)
785 modulefile=${1#--modules-conf=}
786 ;;
787 --modules-conf)
788 modulefile=$2
789 shift
790 ;;
791 --use-raidstart|--with-raidstart)
792 USERAIDSTART=yes
793 ;;
794 --without-raidstart)
795 USERAIDSTART=no
796 ;;
82b2dba2
ER
797 --with-bootsplash)
798 BOOT_SPLASH=yes
799 ;;
800 --without-bootsplash)
801 BOOT_SPLASH=no
802 ;;
803 --with-fbsplash)
804 FB_SPLASH=yes
805 ;;
806 --without-fbsplash)
807 FB_SPLASH=no
808 ;;
6c69a2d4
ER
809 --with-fbcondecor)
810 FB_CON_DECOR=yes
811 ;;
812 --without-fbcondecor)
813 FB_CON_DECOR=no
814 ;;
82b2dba2
ER
815 --with-suspend)
816 USE_SUSPEND=yes
817 ;;
818 --without-suspend)
819 USE_SUSPEND=no
820 ;;
821 --with-suspend2 | --with-tuxonice)
822 USE_TUXONICE=yes
823 ;;
824 --without-suspend2 | --without-tuxonice)
825 USE_TUXONICE=no
826 ;;
80b1ed79 827 --lvmversion=*)
7308edee 828 LVMTOOLSVERSION=${1#--lvmversion=}
82b2dba2 829 ;;
80b1ed79 830 --lvmtoolsversion=*)
831 LVMTOOLSVERSION=${1#--lvmtoolsversion=}
832 ;;
82b2dba2
ER
833 --lvmtoolsversion|--lvmversion)
834 LVMTOOLSVERSION=$2
835 shift
836 ;;
837 --without-udev)
838 USE_UDEV=no
839 ;;
840 --with-udev)
841 USE_UDEV=yes
842 ;;
843 --without-dmraid)
844 USE_DMRAID=no
845 ;;
846 --without-multipath)
847 USE_MULTPATH=no
848 ;;
af075488 849 --without-blkid)
850 USE_BLKID=no
289fbc9b 851 ;;
3ef3d717
ER
852 --without-luks)
853 USE_LUKS=no
854 ;;
82b2dba2
ER
855 --with=*)
856 BASICMODULES="$BASICMODULES ${1#--with=}"
857 ;;
858 --with)
859 BASICMODULES="$BASICMODULES $2"
860 shift
861 ;;
862 --version)
863 echo "$PROGRAM: version $VERSION"
864 exit 0
865 ;;
866 -v)
867 verbose=-v
868 ;;
869 --nocompress)
870 COMPRESS=no
871 ;;
872 --ifneeded)
873 ifneeded=1
874 ;;
875 -f)
876 force=1
877 ;;
878 --preload=*)
879 PREMODS="$PREMODS ${1#--preload=}"
880 ;;
881 --preload)
882 PREMODS="$PREMODS $2"
883 shift
884 ;;
885 --fs=*)
bbbc32d0 886 die "--fs option is obsoleted. Use --initrdfs instead"
82b2dba2
ER
887 INITRDFS=${1#--fs=}
888 ;;
889 --fs)
bbbc32d0 890 die "--fs option is obsoleted. Use --initrdfs instead"
82b2dba2
ER
891 INITRDFS=$2
892 shift
893 ;;
894 --initrdfs=*)
895 INITRDFS=${1#--initrdfs=}
896 ;;
897 --initrdfs)
898 INITRDFS=$2
899 shift
900 ;;
901 --image-version)
902 img_vers=yes
903 ;;
904 --ide-only-root)
905 ide_only_root="yes"
906 ;;
907 *)
908 if [ -z "$target" ]; then
909 target="$1"
910 elif [ -z "$kernel" ]; then
911 kernel="$1"
912 else
36523626
ER
913 usage >&2
914 exit 1
82b2dba2
ER
915 fi
916 ;;
917 esac
f5db170b 918
82b2dba2
ER
919 shift
920done
921
922if [ -z "$target" -o -z "$kernel" ]; then
36523626
ER
923 usage >&2
924 exit 1
82b2dba2
ER
925fi
926
c124d0cf
ER
927if [ -d /usr/lib64 ]; then
928 _lib=lib64
929else
930 _lib=lib
130aadc1
ER
931fi
932
c124d0cf 933initrd_dir=/usr/$_lib/initrd
707f5e60
ER
934kernel_version=$(echo "$kernel" | awk -F. '{print sprintf("%03d%03d",$1,$2)}')
935kernel_version_long=$(echo "$kernel" | awk -F. '{print sprintf("%03d%03d%03d",$1,$2,$3)}')
82b2dba2 936
c124d0cf
ER
937debug "# $RCSID"
938debug "Using _lib: $_lib"
939debug "Using initrd_dir: $initrd_dir"
940
941busybox=$(find_tool $initrd_dir/initrd-busybox /bin/initrd-busybox) || die "Couldn't find busybox suitable for initrd"
942
943# we setup mods after parsing command line args
944geninitrd_setup_mods
945
946if [ ! -f /boot/vmlinuz-"$kernel" ]; then
947 warn "/boot/vmlinuz-$kernel doesn't exist, is your /boot mounted?"
948fi
949
82b2dba2 950if [ -z "$INITRDFS" ]; then
bbbc32d0
ER
951 if [ -n "$FS" ]; then
952 # FS= can came only via /etc/sysconfig/geninitrd likely?
953 die "FS configuration option is obsoleted. Use INITRDFS instead"
f5db170b 954 fi
f5db170b 955
bbbc32d0
ER
956 # default value
957 if [ "$kernel_version" -ge "002005" ]; then
958 INITRDFS="initramfs"
959 else
960 INITRDFS="rom"
961 fi
82b2dba2 962fi
966c32cc 963
82b2dba2 964case "$INITRDFS" in
4877276e
ER
965 ext2)
966 [ -x /sbin/mke2fs ] || die "/sbin/mke2fs is missing"
967 ;;
968 rom|romfs)
969 [ -x /sbin/genromfs ] || die "/sbin/genromfs is missing"
970 ;;
971 cram|cramfs)
972 [ -x /sbin/mkcramfs ] || die "/sbin/mkcramfs is missing"
973 ;;
974 initramfs)
975 [ -x /bin/cpio ] || die "/bin/cpio is missing"
976 [ -x /usr/bin/find ] || die "/usr/bin/find is missing"
977 ;;
978 *)
979 die "Filesystem $INITRDFS on initrd is not supported"
980 ;;
82b2dba2 981esac
f5db170b 982
9323ada3 983if [ -L "$target" ]; then
984 target=$(readlink -f "$target")
985fi
986
82b2dba2
ER
987if [ -n "$img_vers" ]; then
988 target="$target-$kernel"
989fi
8bd582f1 990
82b2dba2
ER
991if [ -z "$force" -a -f "$target" ]; then
992 die "$target already exists."
993fi
c6c6ce01 994
82b2dba2
ER
995if [ ! -d "/lib/modules/$kernel" ]; then
996 die "/lib/modules/$kernel is not a directory."
997fi
2ffb1734 998
bbbc32d0
ER
999if [ ! -f /proc/mounts ]; then
1000 warn "/proc filesystem not mounted, may cause wrong results or failure."
1001fi
1002
1003if [ "$kernel_version" -ge "002005" ]; then
1004 modext=".ko"
1005fi
1006
82b2dba2
ER
1007cache_modprobe_conf
1008
1009for n in $PREMODS; do
046c68c9 1010 find_module "$n"
82b2dba2
ER
1011done
1012
ed30e3a8 1013if [ "$FBMODULE" ]; then
046c68c9 1014 find_module "$FBMODULE"
ed30e3a8
ER
1015fi
1016
82b2dba2 1017# allow forcing loading SCSI and/or IDE modules
35043b20 1018# XXX: where ADDSCSI cames from? drop?
82b2dba2
ER
1019if is_yes "$ADDSCSI"; then
1020 find_modules_scsi
1021fi
1022
35043b20 1023# XXX: where ADDIDE cames from? drop?
82b2dba2
ER
1024if is_yes "$ADDIDE"; then
1025 find_modules_ide
1026fi
1027
4c16dac4
ER
1028if is_yes "$USE_SUSPEND"; then
1029 find_modules_suspend
1030fi
1031
82b2dba2
ER
1032find_root "$fstab" || exit
1033debug "Using $rootdev as device for rootfs"
1034
d8056591 1035find_modules_for_devpath "$rootdev"
ac085800 1036
046c68c9 1037find_module "-$rootFs"
ac085800 1038
82b2dba2 1039for n in $BASICMODULES; do
046c68c9 1040 find_module "$n"
82b2dba2 1041done
4e9eb79c 1042
82b2dba2 1043if is_yes "$USE_TUXONICE"; then
046c68c9 1044 find_module "-lzf"
82b2dba2 1045fi
33d24e12 1046
bf6d9c64 1047find_modules_fbsplash
2968c9dd 1048
82b2dba2
ER
1049if [ -n "$ifneeded" -a -z "$MODULES" ]; then
1050 debug "No modules are needed -- not building initrd image."
1051 exit 0
1052fi
c6c6ce01 1053
6fc274fb 1054debug "Building initrd..."
d8056591 1055DESTDIR=$(mktemp -d -t initrd.XXXXXX) || die "mktemp failed"
9b557a09 1056RCFILE="$DESTDIR/linuxrc"
82b2dba2
ER
1057> "$RCFILE"
1058chmod a+rx "$RCFILE"
9b557a09 1059ln -s linuxrc $DESTDIR/init
e8d178ff 1060
82b2dba2
ER
1061# create dirs that we really need
1062inst_d /{lib,bin,etc,dev{,/pts,/shm},loopfs,var,proc,sys}
e8d178ff 1063
82b2dba2 1064modules_install "$MODULES"
b64f015b 1065
82b2dba2
ER
1066# mknod'ing the devices instead of copying them works both with and
1067# without devfs...
9b557a09
ER
1068mknod "$DESTDIR/dev/console" c 5 1
1069mknod "$DESTDIR/dev/null" c 1 3
1070mknod "$DESTDIR/dev/zero" c 1 5
be2f3ecc 1071
684d5d2a 1072inst_exec $busybox /bin/initrd-busybox
9b557a09 1073ln -s initrd-busybox $DESTDIR/bin/sh
684d5d2a
ER
1074# for older busyboxes who had /bin/busybox as EXEPATH
1075ln -s initrd-busybox $DESTDIR/bin/busybox
2ffb1734 1076
82b2dba2
ER
1077add_linuxrc <<EOF
1078#!/bin/sh
1079# initrd generated by:
1080# $RCSID
c6c6ce01 1081
82b2dba2
ER
1082EOF
1083mount_proc
1084add_linuxrc <<-'EOF'
3a1d3d88 1085 read CMDLINE < /proc/cmdline; export CMDLINE
c6c6ce01 1086
82b2dba2
ER
1087 for arg in $CMDLINE; do
1088 if [ "${arg}" = "debuginitrd" ]; then
1089 DEBUGINITRD=yes
1090 fi
1091 if [ "${arg##debuginitrd=}" != "${arg}" ]; then
1092 DEBUGINITRD=${arg##debuginitrd=}
1093 fi
fc787d45 1094 if [ "${arg##root=}" != "${arg}" ]; then
1095 ROOT=${arg##root=}
1096 fi
82b2dba2 1097 done
c6c6ce01 1098
82b2dba2
ER
1099 # make debugshell() invoke subshell if $DEBUGINITRD=sh
1100 if [ "$DEBUGINITRD" = "sh" ]; then
1101 debugshell() {
e2405b29
AM
1102EOF
1103if is_yes "$RUN_SULOGIN_ON_ERR"; then
1104add_linuxrc <<-'EOF'
1105 echo "debug shell disabled by /etc/sysconfig/system:RUN_SULOGIN_ON_ERR setting"
1106EOF
1107else
1108add_linuxrc <<-'EOF'
1109 sh
1110EOF
1111fi
1112add_linuxrc <<-'EOF'
82b2dba2
ER
1113 }
1114 else
1115 debugshell() {
1116 :
1117 }
1118 fi
e934d044 1119
82b2dba2
ER
1120 if [ "$DEBUGINITRD" ]; then
1121 set -x
cff3058d 1122 fi
82b2dba2 1123EOF
2df2e995 1124
fe280785 1125modules_add_linuxrc $MODULES
82b2dba2
ER
1126
1127# TODO: rewrite for busybox
1128#if [ -n "$loopDev" ]; then
1129# if [ ! -d /initrd ]; then
1130# mkdir /initrd
1131# fi
1132#
9b557a09
ER
1133# cp -a "$loopDev" "$DESTDIR/dev"
1134# cp -a "$rootdev" "$DESTDIR/dev"
82b2dba2
ER
1135# echo "echo Mounting device containing loopback root filesystem" >> "$RCFILE"
1136# echo "mount -t $loopFs $loopDev /loopfs" >> "$RCFILE"
1137# echo "echo Setting up loopback device $rootdev" >> $RCFILE
1138# echo "losetup $rootdev /loopfs$loopFile" >> "$RCFILE"
1139#fi
2b1a3707 1140
1606e343
AM
1141if is_yes "$USE_UDEV"; then
1142 initrd_gen_udev
1143fi
1144
1cd2aabd
ER
1145if is_yes "$USE_TUXONICE"; then
1146 initrd_gen_tuxonice
2df2e995
AM
1147fi
1148
3dd50160
ER
1149find_modules_uvesafb
1150initrd_gen_uvesafb
43258faf 1151
3ef3d717
ER
1152if is_yes "$have_luks"; then
1153 initrd_gen_luks
1154fi
1155
cc8e8a99 1156if is_yes "$have_dmraid"; then
882472ae
ER
1157 initrd_gen_dmraid
1158fi
1159
c083ae23 1160if is_yes "$have_multipath"; then
2cc3ae8b
ER
1161 initrd_gen_multipath
1162fi
1163
cc8e8a99 1164if is_yes "$USE_BLKID"; then
289fbc9b 1165 initrd_gen_blkid
1166fi
1167
69b1e935 1168if is_yes "$have_nfs"; then
2df2e995 1169 initrd_gen_nfs
df738638
ER
1170elif is_yes "$USERAIDSTART" && is_yes "$have_md"; then
1171 initrd_gen_md
69b1e935 1172 if is_yes "$have_lvm"; then
2df2e995 1173 initrd_gen_lvm
bfea009a 1174 else
4828c787 1175 initrd_gen_setrootdev
2df2e995 1176 fi
69b1e935 1177elif is_yes "$have_lvm"; then
2df2e995 1178 initrd_gen_lvm
2b1a3707 1179else
4828c787 1180 initrd_gen_setrootdev
7c38b114
AF
1181fi
1182
4c16dac4
ER
1183if is_yes "$USE_SUSPEND"; then
1184 initrd_gen_suspend
1185fi
1186
5101a385 1187# additional devs always needed
9b557a09 1188[ ! -e "$DESTDIR/$rootdev_add" ] && inst $rootdev_add /dev
5101a385 1189
82de999f
ER
1190if is_yes "$USE_UDEV"; then
1191 initrd_gen_stop_udevd
1192fi
1193
f8f9e56d 1194if [ "$INITRDFS" = "initramfs" ]; then
4671d086 1195 initrd_gen_initramfs_switchroot
b64f015b 1196else
b64f015b 1197 umount_all
f8f9e56d
AM
1198fi
1199
b7feffb3
ER
1200if is_yes "$FB_SPLASH"; then
1201 initrd_gen_fbsplash
1202fi
1203
6c69a2d4
ER
1204if is_yes "$FB_CON_DECOR"; then
1205 initrd_gen_fbcondecor
1206fi
1207
d8056591 1208IMAGE=$(mktemp -t initrd.img-XXXXXX) || die "mktemp failed"
51dc1fe6
AM
1209
1210debug "Creating $INITRDFS image $IMAGE"
2ad94d8a 1211case "$INITRDFS" in
4877276e
ER
1212 ext2)
1213 IMAGESIZE=$(du -ks $DESTDIR | awk '{print int(($1+1023+512)/1024)*1024}')
1214 debug "ext2 image size: $IMAGESIZE ($DESTDIR)"
1215 if [ "$IMAGESIZE" -gt 4096 ]; then
1216 warn "Your image size is larger than 4096, Be sure to boot kernel with ramdisk_size=$IMAGESIZE!"
1217 fi
d8056591 1218
4877276e
ER
1219 dd if=/dev/zero of="$IMAGE" bs=1k count="$IMAGESIZE" 2> /dev/null
1220 mke2fs -q -F -b 1024 -m 0 "$IMAGE" 2>/dev/null 1>&2
1221 tune2fs -i 0 "$IMAGE" >/dev/null 2>&1
1222
1223 local tmpmnt=$(mktemp -d -t initrd.mnt-XXXXXX)
1224 debug "Mounting ext2 image $IMAGE to $tmpmnt"
1225 mount -o loop -t ext2 "$IMAGE" "$tmpmnt"
1226 # We don't need this directory, so let's save space
1227 rm -rf "$tmpmnt"/lost+found
1228
1229 debug "Copy recursively $DESTDIR -> $tmpmnt"
1230 cp -a $DESTDIR/* $tmpmnt
1231 umount "$IMAGE"
1232 rmdir "$tmpmnt"
1233
1234 ;;
1235 rom|romfs)
1236 genromfs -f "$IMAGE" -d "$DESTDIR" -V "PLD initrd for kernel $kernel"
1237 IMAGESIZE=$(stat -c %s $IMAGE | awk '{print int((($1/1024)+1023)/1024)*1024}')
1238 debug "Image size for romfs: ${IMAGESIZE}KiB ($IMAGE)"
1239 if [ "$IMAGESIZE" -gt 4096 ]; then
1240 warn "Your image size is larger than 4096, Be sure to boot kernel with ramdisk_size=$IMAGESIZE!"
1241 fi
1242 ;;
1243 cram|cramfs)
1244 mkcramfs "$DESTDIR" "$IMAGE"
1245 ;;
1246 initramfs)
1247 (cd $DESTDIR; find . | cpio --quiet -H newc -o > "$IMAGE")
1248 ;;
1249 *)
1250 echo "Filesystem $INITRDFS not supported by $PROGRAM";
c31050f3 1251esac
bb529f94 1252
82474db9 1253if is_yes "$COMPRESS"; then
aecfd33d 1254 tmp=$(mktemp "$target".XXXXXX) || die "mktemp failed"
d8056591
ER
1255 debug "Compressing $target"
1256 gzip -9 < "$IMAGE" > "$tmp"
1257 mv -f "$tmp" "$target"
bb529f94 1258else
7d2fc5eb 1259 cp -a "$IMAGE" "$target"
bb529f94 1260fi
5b71959c 1261
edd9c362
ER
1262size=$(stat -c %s $target | awk '{print int((($1/1024)+1023)/1024)*1024}')
1263debug "Minimum RAM size that could be used for $target is: ramdisk_size=$size"
1264
7992356a 1265# XXX. check if bootsplash can output data to tmp dir not directly to initramfs image.
5b71959c 1266if is_yes "$BOOT_SPLASH"; then
f5db170b 1267 initrd_gen_bootsplash "$target"
5b71959c
AM
1268fi
1269
d8056591 1270rm -rf "$DESTDIR" "$IMAGE"
ac085800
ER
1271
1272# vim:ts=4:sw=4:noet:fdm=marker
This page took 0.406954 seconds and 4 git commands to generate.