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