]> git.pld-linux.org Git - projects/geninitrd.git/blob - geninitrd
Use uncompressed module file name.
[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                         mod_nocomp=${mod%.gz}
637                         $STRIP --strip-unneeded --remove-section=.comment --remove-section=.note.GNU-stack "$DESTDIR/lib/modules/$kernel/$mod_nocomp"
638                 fi
639         done
640 }
641
642 modules_add_linuxrc() {
643         local mod modpath
644
645         for mod in "$@"; do
646                 # module path without optional compression
647                 modpath=${mod%.gz}
648
649                 # name of the module
650                 local module=${modpath##*/}; module=${module%$modext}
651                 local options=$(modprobe_conf | awk -vmodule="$module" '{ if ($1 == "options" && $2 == module) { for(i=3;i<=NF;i++) printf("%s ",$i); }}' | xargs)
652                 local genericname=$(echo $module | tr - _)
653                 local usleep=$(eval echo \$MODULE_${genericname}_USLEEP)
654                 local firmware=$(eval echo \$MODULE_${genericname}_FIRMWARE)
655
656                 if [ "$module" = "scsi_mod" -a "$kernel_version_long" -ge "002006030" ]; then
657                         options="scan=sync $options"
658                 fi
659
660                 if [ -n "$verbose" ]; then
661                         s=""
662                         if [ "$options" ]; then
663                                 s="$s with options [$options]"
664                         fi
665                         if [ "$usleep" ]; then
666                                 s="$s and $usleep usleep"
667                         fi
668                         debug "Loading module [$module]$s"
669                 fi
670
671                 if [ -n "$firmware" ]; then
672                         firmware_install_module "$module" "$firmware"
673                 else
674                         for file in $(find_firmware "$module"); do
675                                 firmware_install_module "$module" "$file"
676                         done
677                 fi
678
679                 echo "insmod /lib/modules/$kernel/$modpath $options" | add_linuxrc
680                 if [ -n "$usleep" ]; then
681                         echo "usleep $usleep" | add_linuxrc
682                 fi
683                 if [ "$module" = "scsi_wait_scan" ]; then
684                         if [ "$(busybox_applet rmmod 2>/dev/null; echo $?)" = 0 ]; then
685                                 echo "rmmod scsi_wait_scan" | add_linuxrc
686                         fi
687                 fi
688
689         done
690 }
691
692 # Generates /dev nodes based on /proc/partitions information.
693 # Needs /proc mounted.
694 # Can be called multiple times.
695 initrd_gen_devices() {
696         if is_yes "$proc_partitions"; then
697                 return
698         fi
699         proc_partitions=yes
700
701         mount_dev
702         add_linuxrc <<-'EOF'
703                 : 'Making device nodes'
704                 cat /proc/partitions | (
705                         # ignore first two lines: header, empty line
706                         read b; read b
707
708                         while read major minor blocks dev rest; do
709                                 node=/dev/$dev
710                                 mkdir -p ${node%/*}
711                                 [ -e $node ] || mknod $node b $major $minor
712                         done
713                 )
714         EOF
715 }
716
717
718 initrd_gen_setrootdev() {
719         debug "Adding rootfs finding based on kernel cmdline root= option support."
720         busybox_applet ls
721         add_linuxrc <<-'EOF'
722                 if [ "${ROOT##/dev/}" != "${ROOT}" ]; then
723                         rootnr="$(busybox awk -v rootnode="${ROOT##/dev/}" '$4 == rootnode { print 256 * $1 + $2 }' /proc/partitions)"
724                         # fallback to ls
725                         if [ -z "$rootnr" ]; then
726                                 rootnr="$(busybox ls -lL ${ROOT} | busybox awk '{if (/^b/) { print 256 * $3 + $4; }}')"
727                         fi
728                         if [ -n "$rootnr" ]; then
729                                 echo "$rootnr" > /proc/sys/kernel/real-root-dev
730                         fi
731                 fi
732         EOF
733 }
734
735 initrd_gen_initramfs_switchroot() {
736         inst_d /newroot
737         if [ "$rootdev" = "/dev/nfs" ]; then
738                 echo "rootfs on NFS root=/dev/nfs"
739         else
740                 [ ! -e "$DESTDIR/$rootdev" ] && inst $rootdev $rootdev
741         fi
742
743         # parse 'root=xxx' kernel commandline
744         # We support passing root as hda3 /dev/hda3 0303 0x0303 and 303
745         add_linuxrc <<-'EOF'
746                 device=/dev/no_partition_found
747                 eval "$(busybox awk -v c="$ROOT" '
748                         BEGIN {
749                                 num_pattern_short = "[0-9a-f][0-9a-f][0-9a-f]";
750                                 num_pattern = "[0-9a-f]" num_pattern_short;
751                                 dev_pattern = "[hms][a-z][a-z]([0-9])+";
752                                 partition = "no_partition_found";
753                                 min = -1; maj = -1;
754
755                                 sub("^0x", "", c);
756                                 if (c ~ "^" num_pattern_short "$") sub("^", "0", c);
757                                 if (c ~ "^" num_pattern  "$") {
758                                         maj = sprintf("%s",substr(c,1,2));
759                                         min = sprintf("%s",substr(c,3));
760                                 }
761                                 if (c ~ "^\/dev\/" dev_pattern "$") sub("^/dev/","", c);
762                                 if (c ~ "^" dev_pattern "$") partition = c;
763                         }
764
765                         $4 ~ partition { maj = $1; min = $2; }
766                         $1 ~ maj && $2 ~ min { partition = $4; }
767
768                         END {
769                                 if (maj >= 0 && min >= 0) {
770                                         printf("device=/dev/%s; maj=%s; min=%s;\n", partition, maj, min);
771                                 }
772                         }
773                         ' /proc/partitions)"
774                 if [ "$device" != '/dev/no_partition_found' -a ! -b $device ]; then
775                         mknod $device b $maj $min
776                 fi
777         EOF
778
779         add_linuxrc <<-EOF
780                 rootdev=$rootdev
781                 rootfs=$rootFs
782         EOF
783
784         add_linuxrc <<-'EOF'
785                 if [ "$device" = '/dev/no_partition_found' ]; then
786                         device=$rootdev
787                 fi
788
789                 [ -n "$ROOTFSFLAGS" ] && ROOTFSFLAGS="-o $ROOTFSFLAGS"
790
791                 mount -t $rootfs -r $device $ROOTFSFLAGS /newroot || echo "Mount of rootfs failed."
792                 init="$(echo "$CMDLINE" | busybox awk '/init=\// { gsub(/.*init=/,NIL,$0); gsub(/ .*/,NIL,$0); print }')"
793                 if [ -z "$init" -o ! -x "/newroot$init" ]; then
794                         init=/sbin/init
795                 fi
796         EOF
797
798         umount_all
799         busybox_applet switch_root
800         add_linuxrc <<-'EOF'
801                 exec switch_root /newroot $init ${1:+"$@"}
802
803                 echo "Error! initramfs should not reach this place."
804                 echo "It probably means you've got old version of busybox, with broken"
805                 echo "initramfs support. Trying to boot anyway, but won't promise anything."
806
807                 exec chroot /newroot $init ${1:+"$@"}
808
809                 echo "Failed to chroot!"
810                 debugshell
811         EOF
812         # we need /init being real file, not symlink, otherwise the initramfs will
813         # not be ran by pid 1 which is required for switch_root
814         mv $DESTDIR/linuxrc $DESTDIR/init
815         ln -s init $DESTDIR/linuxrc
816 }
817
818 # find if $symbol exists in System.map $mapfile
819 sym_exists() {
820         local mapfile="$1"
821         local symbol="$2"
822         if [ ! -f $mapfile ]; then
823                 # missing mapfile (not a pld kernel?)
824                 return 1
825         fi
826
827         awk -vc=1 -vsymbol="$symbol" '$2 == "T" && $3 == symbol {c = 0} END {exit c}' $mapfile
828 }
829
830 # find best compressor (or forced one) for initrd
831 find_compressor() {
832         local mode="$1"
833         # fastest initrd decompression speed is first
834         local compressors='lzo gzip xz lzma bzip2'
835
836         # a specified one, take it
837         if ! is_yes "$mode"; then
838                 compressors="$mode"
839         fi
840
841         debug "finding compressor: $compressors (via $mode)"
842         # check for compressor validity
843         local c prog map=/boot/System.map-$kernel
844         for c in $compressors; do
845                 case $c in
846                 xz)
847                         sym=unxz
848                         prog=/usr/bin/xz
849                         ;;
850                 lzma)
851                         sym=unlzma
852                         prog=/usr/bin/xz
853                         ;;
854                 bzip2)
855                         sym=bzip2
856                         prog=/usr/bin/bzip2
857                         ;;
858                 gzip)
859                         sym=gunzip
860                         prog=/bin/gzip
861                         ;;
862                 lzo)
863                         sym=unlzo
864                         prog=/usr/bin/lzop
865                         ;;
866                 none|no)
867                         # any existing sym will work
868                         sym=initrd_load
869                         prog=/bin/cat
870                         ;;
871                 *)
872                         die "Unknown compressor $c"
873                         ;;
874                 esac
875                 if sym_exists $map $sym && [ -x $prog ]; then
876                         echo $c
877                         return
878                 fi
879         done
880
881         debug "using gzip for compressor (fallback)"
882         echo gzip
883 }
884
885 # compresses kernel image image
886 # in function so we could retry with other compressor on failure
887 compress_image() {
888         local compressor="$1" IMAGE="$2" target="$3" tmp
889         tmp=$(mktemp "$target".XXXXXX) || die "mktemp failed"
890
891         case "$compressor" in
892         xz)
893                 # don't use -9 here since kernel won't understand it
894                 xz --format=xz --check=crc32 --lzma2=preset=6e,dict=1MiB < "$IMAGE" > "$tmp" || return $?
895                 ;;
896         lzma)
897                 xz --format=lzma -9 < "$IMAGE" > "$tmp" || return $?
898                 ;;
899         bzip2)
900                 bzip2 -9 < "$IMAGE" > "$tmp" || return $?
901                 ;;
902         gzip)
903                 gzip -9 < "$IMAGE" > "$tmp" || return $?
904                 ;;
905         lzo)
906                 lzop -9 < "$IMAGE" > "$tmp" || return $?
907                 ;;
908         none|no)
909                 cat < "$IMAGE" > "$tmp" || return $?
910                 ;;
911         esac
912
913         mv -f "$tmp" "$target"
914 }
915
916 if [ -r /etc/sysconfig/geninitrd ]; then
917         . /etc/sysconfig/geninitrd
918 fi
919
920 if [ ! -f /proc/mounts ]; then
921         warn "/proc filesystem not mounted, may cause wrong results or failure."
922 fi
923
924 geninitrd_load_mods ide luks multipath dmraid lvm md blkid udev tuxonice suspend fbsplash condecor bootsplash uvesafb nfs sata scsi usbkbd
925
926 while [ $# -gt 0 ]; do
927         case $1 in
928         --fstab=*)
929                 fstab=${1#--fstab=}
930                 ;;
931         --fstab)
932                 fstab=$2
933                 shift
934                 ;;
935         --modules-conf=*)
936                 modulefile=${1#--modules-conf=}
937                 ;;
938         --modules-conf)
939                 modulefile=$2
940                 shift
941                 ;;
942         --with-bootsplash)
943                 BOOT_SPLASH=yes
944                 ;;
945         --without-bootsplash)
946                 BOOT_SPLASH=no
947                 ;;
948         --with-fbsplash)
949                 FB_SPLASH=yes
950                 ;;
951         --without-fbsplash)
952                 FB_SPLASH=no
953                 ;;
954         --with-fbcondecor)
955                 FB_CON_DECOR=yes
956                 ;;
957         --without-fbcondecor)
958                 FB_CON_DECOR=no
959                 ;;
960         --with-suspend)
961                 USE_SUSPEND=yes
962                 ;;
963         --without-suspend)
964                 USE_SUSPEND=no
965                 ;;
966         --with-suspend2 | --with-tuxonice)
967                 USE_TUXONICE=yes
968                 ;;
969         --without-suspend2 | --without-tuxonice)
970                 USE_TUXONICE=no
971                 ;;
972         --lvmversion=*)
973                 LVMTOOLSVERSION=${1#--lvmversion=}
974                 ;;
975         --lvmtoolsversion=*)
976                 LVMTOOLSVERSION=${1#--lvmtoolsversion=}
977                 ;;
978         --lvmtoolsversion|--lvmversion)
979                 LVMTOOLSVERSION=$2
980                 shift
981                 ;;
982         --without-udev)
983                 USE_UDEV=no
984                 ;;
985         --with-udev)
986                 USE_UDEV=yes
987                 ;;
988         --without-dmraid)
989                 USE_DMRAID=no
990                 ;;
991         --without-multipath)
992                 USE_MULTIPATH=no
993                 ;;
994         --with-multipath=*)
995                 USE_MULTIPATH=${1#--with-multipath=}
996                 ;;
997         --without-blkid)
998                 USE_BLKID=no
999                 ;;
1000         --without-luks)
1001                 USE_LUKS=no
1002                 ;;
1003         --with=*)
1004                 BASICMODULES="$BASICMODULES ${1#--with=}"
1005                 ;;
1006         --with)
1007                 BASICMODULES="$BASICMODULES $2"
1008                 shift
1009                 ;;
1010         --version)
1011                 echo "$PROGRAM: version $VERSION"
1012                 exit 0
1013                 ;;
1014         -v)
1015                 verbose=-v
1016                 ;;
1017         --compress)
1018                 COMPRESS=$2
1019                 ;;
1020         --compress=*)
1021                 COMPRESS="${1#--compress=}"
1022                 ;;
1023         --nocompress)
1024                 COMPRESS=no
1025                 ;;
1026         --nostrip)
1027                 STRIP=
1028                 ;;
1029         --strip=*)
1030                 STRIP="${1#--strip=}"
1031                 ;;
1032         --strip)
1033                 STRIP=$2
1034                 shift
1035                 ;;
1036         --ifneeded)
1037                 ifneeded=1
1038                 ;;
1039         -f)
1040                 force=1
1041                 ;;
1042         --preload=*)
1043                 PREMODS="$PREMODS ${1#--preload=}"
1044                 ;;
1045         --preload)
1046                 PREMODS="$PREMODS $2"
1047                 shift
1048                 ;;
1049         --fs=* | --fs)
1050                 die "--fs option is obsoleted. Use --initrdfs instead"
1051                 ;;
1052         --initrdfs=*)
1053                 INITRDFS=${1#--initrdfs=}
1054                 ;;
1055         --initrdfs)
1056                 INITRDFS=$2
1057                 shift
1058                 ;;
1059         --image-version)
1060                 img_vers=yes
1061                 ;;
1062         --ide-only-root)
1063                 ide_only_root="yes"
1064                 ;;
1065         *)
1066                 if [ -z "$target" ]; then
1067                         target="$1"
1068                 elif [ -z "$kernel" ]; then
1069                         kernel="$1"
1070                 else
1071                         usage
1072                         exit 1
1073                 fi
1074                 ;;
1075         esac
1076
1077         shift
1078 done
1079
1080 if [ -z "$target" -o -z "$kernel" ]; then
1081         usage
1082         exit 1
1083 fi
1084
1085 # main()
1086 if [ "$(id -u)" != 0 ]; then
1087         die "You need to be root to generate initrd"
1088 fi
1089
1090 if [ -d /lib64 -a -d /usr/lib64 ]; then
1091         _lib=lib64
1092 else
1093         _lib=lib
1094 fi
1095
1096 initrd_dir=/usr/$_lib/initrd
1097 kernel_version=$(echo "$kernel" | awk -F. '{gsub(/[_-].*/, "", $0); print sprintf("%03d%03d",$1,$2)}')
1098 kernel_version_long=$(echo "$kernel" | awk -F. '{gsub(/[_-].*/, "", $0); print sprintf("%03d%03d%03d",$1,$2,$3)}')
1099
1100 debug "# $GENINITRD_RCSID (geninitrd)"
1101 debug "Using _lib: $_lib"
1102 debug "Using initrd_dir: $initrd_dir"
1103
1104 busybox=$(find_tool $initrd_dir/busybox $initrd_dir/initrd-busybox /bin/initrd-busybox) || die "Couldn't find busybox suitable for initrd"
1105
1106 # we setup mods after parsing command line args
1107 geninitrd_setup_mods
1108
1109 if [ ! -f /boot/vmlinuz-"$kernel" ]; then
1110         warn "/boot/vmlinuz-$kernel doesn't exist, is your /boot mounted?"
1111 fi
1112
1113 if [ -z "$INITRDFS" ]; then
1114         if [ -n "$FS" ]; then
1115                 # FS= can came only via /etc/sysconfig/geninitrd likely?
1116                 die "FS configuration option is obsoleted. Use INITRDFS instead"
1117         fi
1118
1119         # default value
1120         if [ "$kernel_version" -ge "002005" ]; then
1121                 INITRDFS="initramfs"
1122         else
1123                 INITRDFS="rom"
1124         fi
1125 fi
1126
1127 case "$INITRDFS" in
1128   ext2)
1129         [ -x /sbin/mke2fs ] || die "/sbin/mke2fs is missing"
1130         ;;
1131   rom|romfs)
1132         [ -x /sbin/genromfs ] || die "/sbin/genromfs is missing"
1133         ;;
1134   cram|cramfs)
1135         [ -x /sbin/mkcramfs ] || die "/sbin/mkcramfs is missing"
1136         ;;
1137   initramfs)
1138         [ -x /bin/cpio ] || die "/bin/cpio is missing"
1139         [ -x /usr/bin/find ] || die "/usr/bin/find is missing"
1140         ;;
1141   *)
1142         die "Filesystem $INITRDFS on initrd is not supported"
1143         ;;
1144 esac
1145
1146 if [ -L "$target" ]; then
1147         target=$(readlink -f "$target")
1148 fi
1149
1150 if [ -n "$img_vers" ]; then
1151         target="$target-$kernel"
1152 fi
1153
1154 if [ -z "$force" -a -f "$target" ]; then
1155         die "$target already exists."
1156 fi
1157
1158 if [ ! -d "/lib/modules/$kernel" ]; then
1159         die "/lib/modules/$kernel is not a directory."
1160 fi
1161
1162 if [ "$kernel_version" -ge "002005" ]; then
1163         modext=".ko"
1164 fi
1165
1166 cache_modprobe_conf
1167
1168 for n in $PREMODS; do
1169         find_module "$n"
1170 done
1171
1172 if [ "$FBMODULE" ]; then
1173         find_module "$FBMODULE"
1174 fi
1175
1176 # autodetect USB keyboards
1177 find_modules_usbkbd
1178
1179 # allow forcing loading SCSI and/or IDE modules
1180 # XXX: where ADDSCSI cames from? drop?
1181 if is_yes "$ADDSCSI"; then
1182         find_modules_scsi
1183 fi
1184
1185 # autodetect SATA modules
1186 find_modules_sata
1187
1188 # XXX: where ADDIDE cames from? drop?
1189 if is_yes "$ADDIDE"; then
1190         find_modules_ide
1191 fi
1192
1193 if is_yes "$USE_SUSPEND"; then
1194         find_modules_suspend
1195 fi
1196
1197 find_root "$fstab" || exit
1198 debug "Using $rootdev as device for rootfs"
1199
1200 find_modules_for_devpath "$rootdev"
1201
1202 # if USE_MULTIPATH is path to device, scan that too
1203 # this is to bootstrap multipath setup into initrd.
1204 if ! is_no "$USE_MULTIPATH" && ! is_yes "$USE_MULTIPATH"; then
1205         find_modules_multipath $USE_MULTIPATH
1206 fi
1207
1208 find_module "-$rootFs"
1209
1210 for n in $BASICMODULES; do
1211         find_module "$n"
1212 done
1213
1214 if is_yes "$USE_TUXONICE"; then
1215         find_module "-lzf"
1216 fi
1217
1218 find_modules_fbsplash
1219
1220 if [ -n "$ifneeded" -a -z "$MODULES" ]; then
1221         debug "No modules are needed -- not building initrd image."
1222         exit 0
1223 fi
1224
1225 debug "Building initrd..."
1226 DESTDIR=$(mktemp -d -t initrd.XXXXXX) || die "mktemp failed"
1227 RCFILE="$DESTDIR/linuxrc"
1228 > "$RCFILE"
1229 chmod a+rx "$RCFILE"
1230 ln -s linuxrc $DESTDIR/init
1231
1232 # create dirs that we really need
1233 inst_d /{lib,bin,etc,dev{,/pts,/shm},loopfs,var,proc,sys}
1234
1235 modules_install "$MODULES"
1236
1237 # mknod'ing the devices instead of copying them works both with and
1238 # without devfs...
1239 mknod "$DESTDIR/dev/console" c 5 1
1240 mknod "$DESTDIR/dev/null" c 1 3
1241 mknod "$DESTDIR/dev/zero" c 1 5
1242 mknod "$DESTDIR/dev/random" c 1 8
1243 mknod "$DESTDIR/dev/urandom" c 1 9
1244
1245 inst_exec $busybox /bin/busybox
1246 ln -s busybox $DESTDIR/bin/sh
1247 # for older busyboxes who had /bin/initrd-busybox as EXEPATH
1248 ln -s busybox $DESTDIR/bin/initrd-busybox
1249
1250 add_linuxrc <<EOF
1251 #!/bin/sh
1252 # initrd generated by:
1253 # $GENINITRD_RCSID
1254
1255 EOF
1256 mount_proc
1257 add_linuxrc <<-'EOF'
1258         read CMDLINE < /proc/cmdline; export CMDLINE
1259
1260         for arg in $CMDLINE; do
1261                 if [ "${arg}" = "debuginitrd" ]; then
1262                         DEBUGINITRD=yes
1263                 fi
1264                 if [ "${arg##debuginitrd=}" != "${arg}" ]; then
1265                         DEBUGINITRD=${arg##debuginitrd=}
1266                 fi
1267                 if [ "${arg##root=}" != "${arg}" ]; then
1268                         ROOT=${arg##root=}
1269                 fi
1270                 if [ "${arg##rootfsflags=}" != "${arg}" ]; then
1271                         ROOTFSFLAGS=${arg##rootfsflags=}
1272                 fi
1273         done
1274
1275         # make debugshell() invoke subshell if $DEBUGINITRD=sh
1276         if [ "$DEBUGINITRD" = "sh" ]; then
1277                 debugshell() {
1278 EOF
1279 if is_yes "$RUN_SULOGIN_ON_ERR"; then
1280 add_linuxrc <<-'EOF'
1281         echo "debug shell disabled by /etc/sysconfig/system:RUN_SULOGIN_ON_ERR setting"
1282 EOF
1283 else
1284 add_linuxrc <<-'EOF'
1285         sh
1286 EOF
1287 fi
1288 add_linuxrc <<-'EOF'
1289                 }
1290         else
1291                 debugshell() {
1292                         :
1293                 }
1294         fi
1295
1296         if [ "$DEBUGINITRD" ]; then
1297                 set -x
1298         fi
1299 EOF
1300
1301 modules_add_linuxrc $MODULES
1302
1303 # TODO: rewrite for busybox
1304 #if [ -n "$loopDev" ]; then
1305 #       if [ ! -d /initrd ]; then
1306 #               mkdir /initrd
1307 #       fi
1308 #
1309 #       cp -a "$loopDev" "$DESTDIR/dev"
1310 #       cp -a "$rootdev" "$DESTDIR/dev"
1311 #       echo "echo Mounting device containing loopback root filesystem" >> "$RCFILE"
1312 #       echo "mount -t $loopFs $loopDev /loopfs" >> "$RCFILE"
1313 #       echo "echo Setting up loopback device $rootdev" >> $RCFILE
1314 #       echo "losetup $rootdev /loopfs$loopFile" >> "$RCFILE"
1315 #fi
1316
1317 if is_yes "$USE_UDEV"; then
1318         initrd_gen_udev
1319 fi
1320
1321 find_modules_uvesafb
1322 initrd_gen_uvesafb
1323
1324 initrd_gen_luks
1325 initrd_gen_dmraid
1326 initrd_gen_multipath
1327 initrd_gen_blkid
1328
1329 if is_yes "$have_nfs"; then
1330         initrd_gen_nfs
1331 else
1332         initrd_gen_md
1333         initrd_gen_lvm
1334         initrd_gen_luks
1335         initrd_gen_setrootdev
1336 fi
1337
1338 initrd_gen_tuxonice
1339 initrd_gen_suspend
1340
1341 # additional devs always needed
1342 [ ! -e "$DESTDIR/$rootdev_add" ] && inst $rootdev_add /dev
1343
1344 initrd_gen_stop_udevd
1345 initrd_gen_stop_uvesafb
1346
1347 if [ "$INITRDFS" = "initramfs" ]; then
1348         initrd_gen_initramfs_switchroot
1349 else
1350         umount_all
1351 fi
1352
1353 initrd_gen_fbsplash
1354 initrd_gen_fbcondecor
1355
1356 IMAGE=$(mktemp -t initrd.img-XXXXXX) || die "mktemp failed"
1357
1358 IMAGESIZE=$(du -ks $DESTDIR | awk '{print int(($1+1023+512)/1024)*1024}')
1359 debug "image size: $IMAGESIZE KiB ($DESTDIR)"
1360
1361 debug "Creating $INITRDFS image $IMAGE"
1362 case "$INITRDFS" in
1363   ext2)
1364         dd if=/dev/zero of="$IMAGE" bs=1k count="$IMAGESIZE" 2> /dev/null
1365         # NOTE: ext2 label is max 16 chars
1366         mke2fs -q -F -b 1024 -m 0 -L "PLD/$kernel" "$IMAGE" 2>/dev/null 1>&2
1367         tune2fs -i 0 "$IMAGE" >/dev/null 2>&1
1368
1369         local tmpmnt=$(mktemp -d -t initrd.mnt-XXXXXX)
1370         debug "Mounting ext2 image $IMAGE to $tmpmnt"
1371         mount -o loop -t ext2 "$IMAGE" "$tmpmnt" || die "mount failed, check dmesg(1)"
1372         # We don't need this directory, so let's save space
1373         rm -rf "$tmpmnt"/lost+found
1374
1375         debug "Copy recursively $DESTDIR -> $tmpmnt"
1376         cp -a $DESTDIR/* $tmpmnt
1377         umount "$IMAGE"
1378         rmdir "$tmpmnt"
1379
1380         ;;
1381   rom|romfs)
1382         genromfs -f "$IMAGE" -d "$DESTDIR" -V "PLD Linux/$kernel (geninitrd/$VERSION)"
1383         ;;
1384   cram|cramfs)
1385         mkcramfs "$DESTDIR" "$IMAGE"
1386         ;;
1387   initramfs)
1388         (cd $DESTDIR; find . | cpio --quiet -H newc -o > "$IMAGE")
1389         ;;
1390   *)
1391         die "Filesystem $INITRDFS not supported by $PROGRAM"
1392 esac
1393
1394 CONFIG_BLK_DEV_RAM_SIZE=$(ikconfig | awk -F= '/^CONFIG_BLK_DEV_RAM_SIZE/{print $2}')
1395 if [ -z "$CONFIG_BLK_DEV_RAM_SIZE" ]; then
1396         CONFIG_BLK_DEV_RAM_SIZE=4096
1397 fi
1398
1399 if [ "$IMAGESIZE" -gt $CONFIG_BLK_DEV_RAM_SIZE ]; then
1400         warn "Your image size is larger than $CONFIG_BLK_DEV_RAM_SIZE, Be sure to boot kernel with ramdisk_size=$IMAGESIZE!"
1401 fi
1402
1403 if ! is_no "$COMPRESS"; then
1404         compressor=$(find_compressor "$COMPRESS")
1405         debug "Compressing $target with $compressor"
1406
1407         # TODO: the image name (specified from kernel.spec) already contains
1408         # extension, which is .gz most of the time.
1409         compress_image "$compressor" "$IMAGE" "$target" || {
1410                 if [ $compressor != gzip ]; then
1411                         warn "Could not compress with $compressor, retrying with gzip"
1412                         compress_image gzip "$IMAGE" "$target" || die "compress failed with gzip" $?
1413                 else
1414                         die "Could not compress image with $compressor"
1415                 fi
1416         }
1417 else
1418         cp -a "$IMAGE" "$target"
1419 fi
1420
1421 # XXX. check if bootsplash can output data to tmp dir not directly to initramfs image.
1422 initrd_gen_bootsplash "$target"
1423
1424 rm -rf "$DESTDIR" "$IMAGE"
1425
1426 # vim:ts=4:sw=4:noet:fdm=marker
This page took 0.136709 seconds and 4 git commands to generate.