Blame 0053-mkinitrd-suse-Add-SUSE-compability-wrapper-for-dracu.patch

Harald Hoyer 4734ec
From 2b3e22d60246e7c8bfa96a6d7504fb0bfa67e641 Mon Sep 17 00:00:00 2001
Harald Hoyer 4734ec
From: Hannes Reinecke <hare@suse.de>
Harald Hoyer 4734ec
Date: Fri, 29 Nov 2013 13:13:50 +0100
Harald Hoyer 4734ec
Subject: [PATCH] mkinitrd-suse: Add SUSE compability wrapper for dracut
Harald Hoyer 4734ec
Harald Hoyer 4734ec
SUSE has its own mkinitrd system. As the arguments clash
Harald Hoyer 4734ec
with the dracut-provided mkinitrd script I've added a new
Harald Hoyer 4734ec
mkinitrd-suse.sh wrapper.
Harald Hoyer 4734ec
Harald Hoyer 4734ec
Signed-off-by: Hannes Reinecke <hare@suse.de>
Harald Hoyer 4734ec
---
Harald Hoyer 4734ec
 mkinitrd-suse.sh | 354 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
Harald Hoyer 4734ec
 1 file changed, 354 insertions(+)
Harald Hoyer 4734ec
 create mode 100755 mkinitrd-suse.sh
Harald Hoyer 4734ec
Harald Hoyer 4734ec
diff --git a/mkinitrd-suse.sh b/mkinitrd-suse.sh
Harald Hoyer 4734ec
new file mode 100755
Harald Hoyer 4734ec
index 0000000..d20270a
Harald Hoyer 4734ec
--- /dev/null
Harald Hoyer 4734ec
+++ b/mkinitrd-suse.sh
Harald Hoyer 4734ec
@@ -0,0 +1,354 @@
Harald Hoyer 4734ec
+#!/bin/bash --norc
Harald Hoyer 4734ec
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
Harald Hoyer 4734ec
+# ex: ts=8 sw=4 sts=4 et filetype=sh
Harald Hoyer 4734ec
+#
Harald Hoyer 4734ec
+# mkinitrd compability wrapper for SUSE.
Harald Hoyer 4734ec
+#
Harald Hoyer 4734ec
+# Copyright (c) 2013 SUSE Linux Products GmbH. All rights reserved.
Harald Hoyer 4734ec
+#
Harald Hoyer 4734ec
+# This program is free software; you can redistribute it and/or modify
Harald Hoyer 4734ec
+# it under the terms of the GNU General Public License as published by
Harald Hoyer 4734ec
+# the Free Software Foundation; either version 2 of the License, or
Harald Hoyer 4734ec
+# (at your option) any later version.
Harald Hoyer 4734ec
+#
Harald Hoyer 4734ec
+# This program is distributed in the hope that it will be useful,
Harald Hoyer 4734ec
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
Harald Hoyer 4734ec
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Harald Hoyer 4734ec
+# GNU General Public License for more details.
Harald Hoyer 4734ec
+#
Harald Hoyer 4734ec
+# You should have received a copy of the GNU General Public License
Harald Hoyer 4734ec
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Harald Hoyer 4734ec
+#
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+boot_dir="/boot"
Harald Hoyer 4734ec
+quiet=0
Harald Hoyer 4734ec
+host_only=1
Harald Hoyer 4734ec
+force=0
Harald Hoyer 4734ec
+logfile=/var/log/YaST2/mkinitrd.log
Harald Hoyer 4734ec
+dracut_cmd=dracut
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+error() { echo "$@" >&2; }
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+usage () {
Harald Hoyer 4734ec
+    [[ $1 = '-n' ]] && cmd=echo || cmd=error
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+    $cmd "usage: ${0##*/} [options]"
Harald Hoyer 4734ec
+    $cmd ""
Harald Hoyer 4734ec
+    $cmd "	Create initial ramdisk images that contain all kernel modules needed"
Harald Hoyer 4734ec
+    $cmd "	in the early boot process, before the root file system becomes"
Harald Hoyer 4734ec
+    $cmd "	available."
Harald Hoyer 4734ec
+    $cmd "	This usually includes SCSI and/or RAID modules, a file system module"
Harald Hoyer 4734ec
+    $cmd "	for the root file system, or a network interface driver module for dhcp."
Harald Hoyer 4734ec
+    $cmd ""
Harald Hoyer 4734ec
+    $cmd "	options:"
Harald Hoyer 4734ec
+    $cmd "	-f \"feature list\"	Features to be enabled when generating initrd."
Harald Hoyer 4734ec
+    $cmd "				Available features are:"
Harald Hoyer 4734ec
+    $cmd "					iscsi, md, multipath, lvm, lvm2,"
Harald Hoyer 4734ec
+    $cmd "					ifup, fcoe, dcbd"
Harald Hoyer 4734ec
+    $cmd "	-k \"kernel list\"	List of kernel images for which initrd files are"
Harald Hoyer 4734ec
+    $cmd "				created. Defaults to all kernels found in /boot."
Harald Hoyer 4734ec
+    $cmd "	-i \"initrd list\"	List of file names for the initrd; position have"
Harald Hoyer 4734ec
+    $cmd "				match to \"kernel list\". Defaults to all kernels"
Harald Hoyer 4734ec
+    $cmd "				found in /boot."
Harald Hoyer 4734ec
+    $cmd "	-b boot_dir		Boot directory. Defaults to /boot."
Harald Hoyer 4734ec
+    $cmd "	-t tmp_dir		Temporary directory. Defaults to /var/tmp."
Harald Hoyer 4734ec
+    $cmd "	-M map			System.map file to use."
Harald Hoyer 4734ec
+    $cmd "	-A			Create a so called \"monster initrd\" which"
Harald Hoyer 4734ec
+    $cmd "				includes all features and modules possible."
Harald Hoyer 4734ec
+    $cmd "	-B			Do not update bootloader configuration."
Harald Hoyer 4734ec
+    $cmd "	-v			Verbose mode."
Harald Hoyer 4734ec
+    $cmd "	-L			Disable logging."
Harald Hoyer 4734ec
+    $cmd "	-h			This help screen."
Harald Hoyer 4734ec
+    $cmd "	-m \"module list\"	Modules to include in initrd. Defaults to the"
Harald Hoyer 4734ec
+    $cmd "				INITRD_MODULES variable in /etc/sysconfig/kernel"
Harald Hoyer 4734ec
+    $cmd "	-u \"DomU module list\"	Modules to include in initrd. Defaults to the"
Harald Hoyer 4734ec
+    $cmd "				DOMU_INITRD_MODULES variable in"
Harald Hoyer 4734ec
+    $cmd "				/etc/sysconfig/kernel."
Harald Hoyer 4734ec
+    $cmd "	-d root_device		Root device. Defaults to the device from"
Harald Hoyer 4734ec
+    $cmd "				which / is mounted. Overrides the rootdev"
Harald Hoyer 4734ec
+    $cmd "				enviroment variable if set."
Harald Hoyer 4734ec
+    $cmd "	-j device		Journal device"
Harald Hoyer 4734ec
+    $cmd "	-D interface		Run dhcp on the specified interface."
Harald Hoyer 4734ec
+    $cmd "	-I interface		Configure the specified interface statically."
Harald Hoyer 4734ec
+    $cmd "	-a acpi_dsdt		Attach compiled ACPI DSDT (Differentiated"
Harald Hoyer 4734ec
+    $cmd "				System Description Table) to initrd. This"
Harald Hoyer 4734ec
+    $cmd "				replaces the DSDT of the BIOS. Defaults to"
Harald Hoyer 4734ec
+    $cmd "				the ACPI_DSDT variable in /etc/sysconfig/kernel."
Harald Hoyer 4734ec
+    $cmd "	-s size			Add splash animation and bootscreen to initrd."
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+    [[ $1 = '-n' ]] && exit 0
Harald Hoyer 4734ec
+    exit 1
Harald Hoyer 4734ec
+}
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+# Little helper function for reading args from the commandline.
Harald Hoyer 4734ec
+# it automatically handles -a b and -a=b variants, and returns 1 if
Harald Hoyer 4734ec
+# we need to shift $3.
Harald Hoyer 4734ec
+read_arg() {
Harald Hoyer 4734ec
+    # $1 = arg name
Harald Hoyer 4734ec
+    # $2 = arg value
Harald Hoyer 4734ec
+    # $3 = arg parameter
Harald Hoyer 4734ec
+    param="$1"
Harald Hoyer 4734ec
+    local rematch='^[^=]*=(.*)$' result
Harald Hoyer 4734ec
+    if [[ $2 =~ $rematch ]]; then
Harald Hoyer 4734ec
+        read "$param" <<< "${BASH_REMATCH[1]}"
Harald Hoyer 4734ec
+    else
Harald Hoyer 4734ec
+	for ((i=3; $i <= $#; i++)); do
Harald Hoyer 4734ec
+            # Only read next arg if it not an arg itself.
Harald Hoyer 4734ec
+            if [[ ${@:$i:1} = -* ]];then
Harald Hoyer 4734ec
+		break
Harald Hoyer 4734ec
+            fi
Harald Hoyer 4734ec
+            result="$result ${@:$i:1}"
Harald Hoyer 4734ec
+            # There is no way to shift our callers args, so
Harald Hoyer 4734ec
+            # return "no of args" to indicate they should do it instead.
Harald Hoyer 4734ec
+	done
Harald Hoyer 4734ec
+	read "$1" <<< "$result"
Harald Hoyer 4734ec
+        return $(($i - 3))
Harald Hoyer 4734ec
+    fi
Harald Hoyer 4734ec
+}
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+# Helper functions to calculate ipconfig command line
Harald Hoyer 4734ec
+calc_netmask() {
Harald Hoyer 4734ec
+    local prefix=$1
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+    [ -z "$prefix" ] && return
Harald Hoyer 4734ec
+    mask=$(echo "(2 ^ 32) - (2 ^ $prefix)" | bc -l)
Harald Hoyer 4734ec
+    byte1=$(( mask >> 24 ))
Harald Hoyer 4734ec
+    byte2=$(( mask >> 16 ))
Harald Hoyer 4734ec
+    byte3=$(( mask >> 8 ))
Harald Hoyer 4734ec
+    byte4=$(( mask & 0xff ))
Harald Hoyer 4734ec
+    netmask=$(printf "%d.%d.%d.%d" $(( byte1 & 0xff )) $(( byte2 & 0xff )) $(( byte3 & 0xff )) $byte4);
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+    echo $netmask
Harald Hoyer 4734ec
+}
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+ipconfig() {
Harald Hoyer 4734ec
+    local interface=$1
Harald Hoyer 4734ec
+    local iplink macaddr broadcast gateway ipaddr prefix netmask
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+    iplink=$(ip addr show dev $interface | sed -n 's/ *inet \(.*\) brd.*/\1/p')
Harald Hoyer 4734ec
+    macaddr=$(ip addr show dev $interface | sed -n 's/.*ether \(.*\) brd.*/\1/p')
Harald Hoyer 4734ec
+    broadcast=$(ip addr show dev $interface | sed -n 's/.*brd \(.*\) scope.*/\1/p')
Harald Hoyer 4734ec
+    gateway=$(ip route show dev $interface | sed -n 's/default via \([0-9\.]*\).*/\1/p')
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+    ipaddr=${iplink%%/*}
Harald Hoyer 4734ec
+    prefix=${iplink##*/}
Harald Hoyer 4734ec
+    netmask=$(calc_netmask $prefix)
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+    echo "${ipaddr}:${serveraddr}:${gateway}:${netmask}:${hostname}:${interface}:none::${macaddr}"
Harald Hoyer 4734ec
+}
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+is_xen_kernel() {
Harald Hoyer 4734ec
+    local kversion=$1
Harald Hoyer 4734ec
+    local root_dir=$2
Harald Hoyer 4734ec
+    local cfg
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+    for cfg in ${root_dir}/boot/config-$kversion $root_dir/lib/modules/$kversion/build/.config
Harald Hoyer 4734ec
+    do
Harald Hoyer 4734ec
+        test -r $cfg || continue
Harald Hoyer 4734ec
+        grep -q "^CONFIG_XEN=y\$" $cfg
Harald Hoyer 4734ec
+        return
Harald Hoyer 4734ec
+    done
Harald Hoyer 4734ec
+    test $kversion != "${kversion%-xen*}"
Harald Hoyer 4734ec
+    return
Harald Hoyer 4734ec
+}
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+# Taken over from SUSE mkinitrd
Harald Hoyer 4734ec
+default_kernel_images() {
Harald Hoyer 4734ec
+    local regex kernel_image kernel_version version_version initrd_image
Harald Hoyer 4734ec
+    local qf='%{NAME}-%{VERSION}-%{RELEASE}\n'
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+    case "$(uname -m)" in
Harald Hoyer 4734ec
+        s390|s390x)
Harald Hoyer 4734ec
+            regex='image'
Harald Hoyer 4734ec
+            ;;
Harald Hoyer 4734ec
+        ppc|ppc64)
Harald Hoyer 4734ec
+            regex='vmlinux'
Harald Hoyer 4734ec
+            ;;
Harald Hoyer 4734ec
+        i386|x86_64)
Harald Hoyer 4734ec
+            regex='vmlinuz'
Harald Hoyer 4734ec
+            ;;
Harald Hoyer 4734ec
+        arm*)
Harald Hoyer 4734ec
+            regex='[uz]Image'
Harald Hoyer 4734ec
+            ;;
Harald Hoyer 4734ec
+        aarch64)
Harald Hoyer 4734ec
+            regex='Image'
Harald Hoyer 4734ec
+            ;;
Harald Hoyer 4734ec
+        *)  regex='vmlinu.'
Harald Hoyer 4734ec
+            ;;
Harald Hoyer 4734ec
+    esac
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+    kernel_images=""
Harald Hoyer 4734ec
+    initrd_images=""
Harald Hoyer 4734ec
+    for kernel_image in $(ls $boot_dir \
Harald Hoyer 4734ec
+            | sed -ne "\|^$regex\(-[0-9.]\+-[0-9]\+-[a-z0-9]\+$\)\?|p" \
Harald Hoyer 4734ec
+            | grep -v kdump$ ) ; do
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+        # Note that we cannot check the RPM database here -- this
Harald Hoyer 4734ec
+        # script is itself called from within the binary kernel
Harald Hoyer 4734ec
+        # packages, and rpm does not allow recursive calls.
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+        [ -L "$boot_dir/$kernel_image" ] && continue
Harald Hoyer 4734ec
+        [ "${kernel_image%%.gz}" != "$kernel_image" ] && continue
Harald Hoyer 4734ec
+        kernel_version=$(/usr/bin/get_kernel_version \
Harald Hoyer 4734ec
+                         $boot_dir/$kernel_image 2> /dev/null)
Harald Hoyer 4734ec
+        initrd_image=$(echo $kernel_image | sed -e "s|${regex}|initrd|")
Harald Hoyer 4734ec
+        if [ "$kernel_image" != "$initrd_image" -a \
Harald Hoyer 4734ec
+             -n "$kernel_version" -a \
Harald Hoyer 4734ec
+             -d "/lib/modules/$kernel_version" ]; then
Harald Hoyer 4734ec
+                kernel_images="$kernel_images $boot_dir/$kernel_image"
Harald Hoyer 4734ec
+                initrd_images="$initrd_images $boot_dir/$initrd_image"
Harald Hoyer 4734ec
+        fi
Harald Hoyer 4734ec
+    done
Harald Hoyer 4734ec
+    for kernel_image in $kernel_images;do
Harald Hoyer 4734ec
+	kernels="$kernels ${kernel_image#*-}"
Harald Hoyer 4734ec
+    done
Harald Hoyer 4734ec
+    for initrd_image in $initrd_images;do
Harald Hoyer 4734ec
+	targets="$targets $initrd_image"
Harald Hoyer 4734ec
+    done
Harald Hoyer 4734ec
+    host_only=1
Harald Hoyer 4734ec
+    force=1
Harald Hoyer 4734ec
+}
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+while (($# > 0)); do
Harald Hoyer 4734ec
+    case ${1%%=*} in
Harald Hoyer 4734ec
+	-f) read_arg feature_list "$@" || shift $?
Harald Hoyer 4734ec
+	    # Could be several features
Harald Hoyer 4734ec
+	    ;;
Harald Hoyer 4734ec
+	-k) # Would be nice to get a list of images here
Harald Hoyer 4734ec
+	    read_arg kernel_images "$@" || shift $?
Harald Hoyer 4734ec
+	    for kernel_image in $kernel_images;do
Harald Hoyer 4734ec
+		kernels="$kernels ${kernel_image#*-}"
Harald Hoyer 4734ec
+	    done
Harald Hoyer 4734ec
+	    host_only=1
Harald Hoyer 4734ec
+	    force=1
Harald Hoyer 4734ec
+	    ;;
Harald Hoyer 4734ec
+	-i) read_arg initrd_images "$@" || shift $?
Harald Hoyer 4734ec
+	    for initrd_image in $initrd_images;do
Harald Hoyer 4734ec
+		# Check if the initrd_image contains a path.
Harald Hoyer 4734ec
+		# if not, then add the default boot_dir
Harald Hoyer 4734ec
+		dname=`dirname $initrd_image`
Harald Hoyer 4734ec
+		if [ "$dname" == "." ]; then
Harald Hoyer 4734ec
+                    targets="$targets $boot_dir/$initrd_image";
Harald Hoyer 4734ec
+		else
Harald Hoyer 4734ec
+                    targets="$targets $initrd_image";
Harald Hoyer 4734ec
+		fi
Harald Hoyer 4734ec
+	    done
Harald Hoyer 4734ec
+	    ;;
Harald Hoyer 4734ec
+	-b) read_arg boot_dir "$@" || shift $?
Harald Hoyer 4734ec
+	    if [ ! -d $boot_dir ];then
Harald Hoyer 4734ec
+		error "Boot directory $boot_dir does not exist"
Harald Hoyer 4734ec
+		exit 1
Harald Hoyer 4734ec
+	    fi
Harald Hoyer 4734ec
+	    ;;
Harald Hoyer 4734ec
+	-t) read_arg tmp_dir "$@" || shift $?
Harald Hoyer 4734ec
+	    dracut_args="${dracut_args} --tmpdir $tmp_dir"
Harald Hoyer 4734ec
+	    ;;
Harald Hoyer 4734ec
+	-M) read_arg map_file "$@" || shift $?
Harald Hoyer 4734ec
+	    ;;
Harald Hoyer 4734ec
+	-A) host_only=0;;
Harald Hoyer 4734ec
+	-B) skip_update_bootloader=1;;
Harald Hoyer 4734ec
+        -v|--verbose) dracut_args="${dracut_args} -v";;
Harald Hoyer 4734ec
+	-L) logfile=;;
Harald Hoyer 4734ec
+        -h|--help) usage -n;;
Harald Hoyer 4734ec
+	-m) read_arg module_list "$@" || shift $? ;;
Harald Hoyer 4734ec
+	-u) read_arg domu_module_list "$@" || shift $?
Harald Hoyer 4734ec
+	    echo "mkinitrd: DomU modules not yet supported" ;;
Harald Hoyer 4734ec
+        -d) read_arg rootfs "$@" || shift $?
Harald Hoyer 4734ec
+            dracut_args="${dracut_args} --filesystems $rootfs" ;;
Harald Hoyer 4734ec
+	-D) read_arg dhcp_if "$@" || shift $?
Harald Hoyer 4734ec
+	    dracut_cmdline="${dracut_cmdline} ip=${dhcp_if}:dhcp"
Harald Hoyer 4734ec
+	    ;;
Harald Hoyer 4734ec
+	-I) read_arg static_if "$@" || shift $?
Harald Hoyer 4734ec
+	    dracut_cmdline="${dracut_cmdline} ip=$(ipconfig $static_if)":
Harald Hoyer 4734ec
+	    ;;
Harald Hoyer 4734ec
+	-a) read_arg acpi_dsdt "$@" || shift $?
Harald Hoyer 4734ec
+	    echo "mkinitrd: custom DSDT not yet supported"
Harald Hoyer 4734ec
+	    exit 1
Harald Hoyer 4734ec
+	    ;;
Harald Hoyer 4734ec
+	-s) read_arg boot_splash "$@" || shift $?
Harald Hoyer 4734ec
+	    echo "mkinitrd: boot splash not yet supported"
Harald Hoyer 4734ec
+	    exit 1
Harald Hoyer 4734ec
+	    ;;
Harald Hoyer 4734ec
+	-V) echo "mkinitrd: vendor scipts are no longer supported"
Harald Hoyer 4734ec
+	    exit 1;;
Harald Hoyer 4734ec
+	--dracut)
Harald Hoyer 4734ec
+	    read_arg dracut_cmd "$@" || shift $? ;;
Harald Hoyer 4734ec
+        --version|-R)
Harald Hoyer 4734ec
+            echo "mkinitrd: dracut compatibility wrapper"
Harald Hoyer 4734ec
+            exit 0;;
Harald Hoyer 4734ec
+        --force) force=1;;
Harald Hoyer 4734ec
+	--quiet|-q) quiet=1;;
Harald Hoyer 4734ec
+        *)  if [[ ! $targets ]]; then
Harald Hoyer 4734ec
+            targets=$1
Harald Hoyer 4734ec
+            elif [[ ! $kernels ]]; then
Harald Hoyer 4734ec
+            kernels=$1
Harald Hoyer 4734ec
+            else
Harald Hoyer 4734ec
+            usage
Harald Hoyer 4734ec
+            fi;;
Harald Hoyer 4734ec
+    esac
Harald Hoyer 4734ec
+    shift
Harald Hoyer 4734ec
+done
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+[[ $targets && $kernels ]] || default_kernel_images
Harald Hoyer 4734ec
+[[ $targets && $kernels ]] || (error "No kernel found in $boot_dir" && usage)
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+# We can have several targets/kernels, transform the list to an array
Harald Hoyer 4734ec
+targets=( $targets )
Harald Hoyer 4734ec
+[[ $kernels ]] && kernels=( $kernels )
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+[[ $logfile ]]        && dracut_args="${dracut_args} --logfile $logfile"
Harald Hoyer 4734ec
+[[ $host_only == 1 ]] && dracut_args="${dracut_args} --hostonly"
Harald Hoyer 4734ec
+[[ $force == 1 ]]     && dracut_args="${dracut_args} --force"
Harald Hoyer 4734ec
+[[ $dracut_cmdline ]] && dracut_args="${dracut_args} --kernel-cmdline ${dracut_cmdline}"
Harald Hoyer 4734ec
+[ -z "$(type -p update-bootloader)" ] && skip_update_bootloader=1
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+# Update defaults from /etc/sysconfig/kernel
Harald Hoyer 4734ec
+if [ -f /etc/sysconfig/kernel ] ; then
Harald Hoyer 4734ec
+    . /etc/sysconfig/kernel
Harald Hoyer 4734ec
+fi
Harald Hoyer 4734ec
+[[ $module_list ]] || module_list="${INITRD_MODULES}"
Harald Hoyer 4734ec
+basicmodules="$basicmodules ${module_list}"
Harald Hoyer 4734ec
+[[ $domu_module_list ]] || domu_module_list="${DOMU_INITRD_MODULES}"
Harald Hoyer 4734ec
+[[ $acpi_dsdt ]] || acpi_dsdt="${ACPI_DSDT}"
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+echo "Creating: target|kernel|dracut args|basicmodules "
Harald Hoyer 4734ec
+for ((i=0 ; $i<${#targets[@]} ; i++)); do
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+    if [[ $img_vers ]];then
Harald Hoyer 4734ec
+	target="${targets[$i]}-${kernels[$i]}"
Harald Hoyer 4734ec
+    else
Harald Hoyer 4734ec
+	target="${targets[$i]}"
Harald Hoyer 4734ec
+    fi
Harald Hoyer 4734ec
+    kernel="${kernels[$i]}"
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+    # Duplicate code: No way found how to redirect output based on $quiet
Harald Hoyer 4734ec
+    if [[ $quiet == 1 ]];then
Harald Hoyer 4734ec
+	echo "$target|$kernel|$dracut_args|$basicmodules"
Harald Hoyer 4734ec
+	if is_xen_kernel $kernel $rootfs ; then
Harald Hoyer 4734ec
+	    basicmodules="$basicmodules ${domu_module_list}"
Harald Hoyer 4734ec
+	fi
Harald Hoyer 4734ec
+	if [[ $basicmodules ]]; then
Harald Hoyer 4734ec
+            $dracut_cmd $dracut_args --add-drivers "$basicmodules" "$target" \
Harald Hoyer 4734ec
+		"$kernel" &>/dev/null
Harald Hoyer 4734ec
+	else
Harald Hoyer 4734ec
+            $dracut_cmd $dracut_args "$target" "$kernel" &>/dev/null
Harald Hoyer 4734ec
+	fi
Harald Hoyer 4734ec
+    else
Harald Hoyer 4734ec
+	if is_xen_kernel $kernel $rootfs ; then
Harald Hoyer 4734ec
+	    basicmodules="$basicmodules ${domu_module_list}"
Harald Hoyer 4734ec
+	fi
Harald Hoyer 4734ec
+	if [[ $basicmodules ]]; then
Harald Hoyer 4734ec
+            $dracut_cmd $dracut_args --add-drivers "$basicmodules" "$target" \
Harald Hoyer 4734ec
+		"$kernel"
Harald Hoyer 4734ec
+	else
Harald Hoyer 4734ec
+            $dracut_cmd $dracut_args "$target" "$kernel"
Harald Hoyer 4734ec
+	fi
Harald Hoyer 4734ec
+    fi
Harald Hoyer 4734ec
+done
Harald Hoyer 4734ec
+
Harald Hoyer 4734ec
+if [ "$skip_update_bootloader" ] ; then
Harald Hoyer 4734ec
+    echo 2>&1 "Did not refresh the bootloader. You might need to refresh it manually."
Harald Hoyer 4734ec
+else
Harald Hoyer 4734ec
+    update-bootloader --refresh
Harald Hoyer 4734ec
+fi