]> git.pld-linux.org Git - projects/geninitrd.git/blobdiff - geninitrd
Use kernel ready compression settings for xz.
[projects/geninitrd.git] / geninitrd
index fbaaa163849c61a8e0bba0d044de51ccd70241dd..f08fdd63d1c9b1c999f0ca75ab26df4a634870ec 100755 (executable)
--- a/geninitrd
+++ b/geninitrd
@@ -47,7 +47,7 @@ usage() {
        uname_r=$(uname -r)
        echo "usage: $PROGRAM [--version] [-v] [-f] [--ifneeded] [--preload <module>]"
        echo "       [--with=<module>] [--image-version] [--fstab=<fstab>] [--nocompress]"
-       echo "       [--compress=yes|lzma|bzip2|gzip]"
+       echo "       [--compress=yes|xz|lzma|bzip2|gzip]"
        echo "       [--initrdfs=rom|initramfs|ext2|cram] [--modules-conf=<modules.conf>]"
        echo "       [--with-bootsplash] [--without-bootsplash]"
        echo "       [--with-fbsplash] [--without-fbsplash]"
@@ -152,6 +152,7 @@ mount_dev() {
                mknod /dev/console c 5 1
                mknod /dev/null c 1 3
                mknod /dev/zero c 1 5
+               mknod /dev/urandom c 1 9
                mkdir /dev/pts
                mkdir /dev/shm
        EOF
@@ -233,7 +234,7 @@ umount_all() {
 #
 # NB! XXX do not output to STDOUT, it will appear in initrd images in some cases!
 busybox_applet() {
-       local err=0
+       local err=0 applet
 
        if [ -z "$busybox_functions" ]; then
                local tmp=$($busybox 2>&1)
@@ -646,6 +647,12 @@ modules_add_linuxrc() {
                if [ -n "$sleep_var" ]; then
                        echo "usleep $sleep_var" | add_linuxrc
                fi
+               if [ "$module" = "scsi_wait_scan" ]; then
+                       if [ "$(busybox_applet rmmod 2>/dev/null; echo $?)" = 0 ]; then
+                               echo "rmmod scsi_wait_scan" | add_linuxrc
+                       fi
+               fi
+
        done
 }
 
@@ -783,11 +790,11 @@ sym_exists() {
 find_compressor() {
        local mode="$1"
        # the best compressor list
-       local compressors='lzma bzip2 gzip'
+       local compressors='xz lzma bzip2 gzip'
 
        # a specified one, take it
        if ! is_yes "$mode"; then
-               compressors=gzip
+               compressors="$mode"
        fi
 
        debug "finding compressor: $compressors (via $mode)"
@@ -795,9 +802,13 @@ find_compressor() {
        local c prog map=/boot/System.map-$kernel
        for c in $compressors; do
                case $c in
+               xz)
+                       sym=unxz
+                       prog=/usr/bin/xz
+                       ;;
                lzma)
                        sym=unlzma
-                       prog=/usr/bin/lzma
+                       prog=/usr/bin/xz
                        ;;
                bzip2)
                        sym=bzip2
@@ -811,7 +822,7 @@ find_compressor() {
                        die "Unknown compressor $c"
                        ;;
                esac
-               if sym_exists $map $sum && [ -x $prog ]; then
+               if sym_exists $map $sym && [ -x $prog ]; then
                        echo $c
                        return
                fi
@@ -825,6 +836,10 @@ if [ -r /etc/sysconfig/geninitrd ]; then
        . /etc/sysconfig/geninitrd
 fi
 
+if [ ! -f /proc/mounts ]; then
+       warn "/proc filesystem not mounted, may cause wrong results or failure."
+fi
+
 geninitrd_load_mods ide luks multipath dmraid lvm md blkid udev tuxonice suspend fbsplash condecor bootsplash uvesafb nfs scsi
 
 while [ $# -gt 0 ]; do
@@ -1053,10 +1068,6 @@ if [ ! -d "/lib/modules/$kernel" ]; then
        die "/lib/modules/$kernel is not a directory."
 fi
 
-if [ ! -f /proc/mounts ]; then
-       warn "/proc filesystem not mounted, may cause wrong results or failure."
-fi
-
 if [ "$kernel_version" -ge "002005" ]; then
        modext=".ko"
 fi
@@ -1131,6 +1142,7 @@ modules_install "$MODULES"
 mknod "$DESTDIR/dev/console" c 5 1
 mknod "$DESTDIR/dev/null" c 1 3
 mknod "$DESTDIR/dev/zero" c 1 5
+mknod "$DESTDIR/dev/urandom" c 1 9
 
 inst_exec $busybox /bin/initrd-busybox
 ln -s initrd-busybox $DESTDIR/bin/sh
@@ -1319,8 +1331,12 @@ if ! is_no "$COMPRESS"; then
        # TODO: the image name (specified from kernel.spec) already contains
        # extension, which is .gz most of the time.
        case "$compressor" in
+       xz)
+               # don't use -9 here since kernel won't understand it
+               xz --format=xz --check=crc32 --lzma2=preset=6e,dict=1MiB < "$IMAGE" > "$tmp"
+               ;;
        lzma)
-               lzma -9 < "$IMAGE" > "$tmp"
+               xz --format=lzma -9 < "$IMAGE" > "$tmp"
                ;;
        bzip2)
                bzip2 -9 < "$IMAGE" > "$tmp"
This page took 0.033035 seconds and 4 git commands to generate.