Blame 0023-Use-the-uncompressed-kernel-file-on-arm-and-aarch-to.patch

Harald Hoyer 0840a3
From 162daf0c978ab67131f18856c816d3dbd5ed819f Mon Sep 17 00:00:00 2001
Harald Hoyer 0840a3
From: Thomas Renninger <trenn@suse.de>
Harald Hoyer 0840a3
Date: Fri, 26 Jun 2015 16:55:54 +0200
Harald Hoyer 0840a3
Subject: [PATCH] Use the uncompressed kernel file on arm and aarch to detect
Harald Hoyer 0840a3
 kernel version
Harald Hoyer 0840a3
Harald Hoyer 0840a3
This is due to file cannot read out the kernel version on these.
Harald Hoyer 0840a3
Harald Hoyer 0840a3
Many thanks to Alexander Graf finding this in old SUSE mkinitrd code.
Harald Hoyer 0840a3
Converted by Thomas Renninger.
Harald Hoyer 0840a3
Harald Hoyer 0840a3
Signed-off-by: Thomas Renninger <trenn@suse.de>
Harald Hoyer 0840a3
Harald Hoyer 0840a3
https://bugzilla.suse.com/show_bug.cgi?id=908454
Harald Hoyer 0840a3
Signed-off-by: Thomas Renninger <trenn@suse.de>
Harald Hoyer 0840a3
---
Harald Hoyer 0840a3
 mkinitrd-suse.sh | 30 +++++++++++++++++++++++++++++-
Harald Hoyer 0840a3
 1 file changed, 29 insertions(+), 1 deletion(-)
Harald Hoyer 0840a3
Harald Hoyer 0840a3
diff --git a/mkinitrd-suse.sh b/mkinitrd-suse.sh
Harald Hoyer 0840a3
index c2b314f..0f2b3c4 100755
Harald Hoyer 0840a3
--- a/mkinitrd-suse.sh
Harald Hoyer 0840a3
+++ b/mkinitrd-suse.sh
Harald Hoyer 0840a3
@@ -145,6 +145,33 @@ is_xen_kernel() {
Harald Hoyer 0840a3
     return
Harald Hoyer 0840a3
 }
Harald Hoyer 0840a3
 
Harald Hoyer 0840a3
+# kernel_image_gz_from_image() and kernel_version_from_image() are helpers
Harald Hoyer 0840a3
+# for arm* kernels which produce zImage files which cannot be read from
Harald Hoyer 0840a3
+# get_kernel_version -> get rid of this workaround if possible
Harald Hoyer 0840a3
+kernel_image_gz_from_image() {
Harald Hoyer 0840a3
+    local arch=$(uname -i)
Harald Hoyer 0840a3
+    local r=${1}.gz
Harald Hoyer 0840a3
+
Harald Hoyer 0840a3
+    # uImage kernels can't be extracted directly. Use the vmlinux.gz instead
Harald Hoyer 0840a3
+    r=${r//uImage/vmlinux}
Harald Hoyer 0840a3
+
Harald Hoyer 0840a3
+    # on ARM a zImage can't be extracted directly. Other platforms define it
Harald Hoyer 0840a3
+    # as a gzipped vmlinux file, but not ARM. So only on ARM, use vmlinux.gz.
Harald Hoyer 0840a3
+    if [[ $arch =~ arm ]] || [[ $arch =~ aarch ]]; then
Harald Hoyer 0840a3
+        r=${r//zImage/vmlinux}
Harald Hoyer 0840a3
+    fi
Harald Hoyer 0840a3
+
Harald Hoyer 0840a3
+    echo $r
Harald Hoyer 0840a3
+}
Harald Hoyer 0840a3
+
Harald Hoyer 0840a3
+kernel_version_from_image() {
Harald Hoyer 0840a3
+    local kernel_image="$1" kernel_image_gz=$(kernel_image_gz_from_image "$1")
Harald Hoyer 0840a3
+
Harald Hoyer 0840a3
+    if get_kernel_version "$kernel_image" 2>/dev/null; then
Harald Hoyer 0840a3
+        return
Harald Hoyer 0840a3
+    fi
Harald Hoyer 0840a3
+    get_kernel_version "$kernel_image_gz" 2>/dev/null
Harald Hoyer 0840a3
+}
Harald Hoyer 0840a3
 
Harald Hoyer 0840a3
 # Taken over from SUSE mkinitrd
Harald Hoyer 0840a3
 default_kernel_images() {
Harald Hoyer 0840a3
@@ -183,7 +210,8 @@ default_kernel_images() {
Harald Hoyer 0840a3
 
Harald Hoyer 0840a3
         [ -L "$boot_dir/$kernel_image" ] && continue
Harald Hoyer 0840a3
         [ "${kernel_image%%.gz}" != "$kernel_image" ] && continue
Harald Hoyer 0840a3
-        kernel_version=$(/usr/bin/get_kernel_version \
Harald Hoyer 0840a3
+
Harald Hoyer 0840a3
+        kernel_version=$(kernel_version_from_image \
Harald Hoyer 0840a3
                          $boot_dir/$kernel_image 2> /dev/null)
Harald Hoyer 0840a3
         initrd_image=$(echo $kernel_image | sed -e "s|${regex}|initrd|")
Harald Hoyer 0840a3
         if [ "$kernel_image" != "$initrd_image" -a \