[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#783278: patch v2



Tags: patch

I botched the first patch. This one fixes it correctly.
>From 6eb082b42ad9a7c22f08ecb9f18fab7f8891be95 Mon Sep 17 00:00:00 2001
From: David Lechner <david@lechnology.com>
Date: Fri, 24 Apr 2015 19:13:00 -0500
Subject: [PATCH] Handle case when kernel == kfile check in boot_kernel_path
 handler.

This only applies to Method: generic.

Old behavior:

If the db entry specifies Boot-Kernel-Path, one of Dtb-Append, Machine-Id
or U-Boot-Kernel-Address must be specified which changes the value of $kernel.
When checking what to do wht Boot-Kernel-Path, the script checks to see if
$kernel was changed from the original value ($kfile). If it did not change,
it does nothing. There is a TODO comment about handling symlinks, but this
does not make sense since this is the generic method, not the symlink method.

New behavior:

If $kernel was not changed, copy it to a temporary file before calling
backup_and_install. backup_and_install moves the temporary file, effectivly
deleting it. Also applied same fix to initrd.

Use case:

On Raspberry Pi, the boot loader uses the vmlinux-* file directly, but it
needs to be renamed to kernel.img, which flash-kernel should be doing.
---
 functions | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/functions b/functions
index a7ff6de..6579b18 100644
--- a/functions
+++ b/functions
@@ -684,13 +684,11 @@ case "$method" in
 		if [ -n "$boot_kernel_path" ]; then
 			boot_kernel_path="$boot_mnt_dir/$boot_kernel_path"
 			# don't mv the original kernel
-			if [ "$kernel" != "$kfile" ]; then
-				backup_and_install "$kernel" \
-					"$boot_kernel_path"
-			else
-				# TODO add support for kernel symlink
-				:
+			if [ "$kernel" = "$kfile" ]; then
+				cp "$kernel" "$tmpdir/kernel"
+				kernel="$tmpdir/kernel"
 			fi
+			backup_and_install "$kernel" "$boot_kernel_path"
 		elif [ -n "$kmtd" ]; then
 			flash_kernel "$tmpdir/uImage" "$kmtd" ""
 			rm -f "$tmpdir/uImage"
@@ -706,13 +704,11 @@ case "$method" in
 		if [ -n "$boot_initrd_path" ]; then
 			boot_initrd_path="$boot_mnt_dir/$boot_initrd_path"
 			# don't mv the original initrd
-			if [ "$initrd" != "$ifile" ]; then
-				backup_and_install "$initrd" \
-					"$boot_initrd_path"
-			else
-				# TODO add support for initrd symlink
-				:
+			if [ "$initrd" = "$ifile" ]; then
+				cp "$initrd" "$tmpdir/initrd"
+				initrd="$tmpdir/initrd"
 			fi
+			backup_and_install "$initrd" "$boot_initrd_path"
 		elif [ -n "$imtd" ]; then
 			ipad=0
 			# padding isn't needed for U-Boot images
-- 
1.9.1


Reply to: