From 11eb2c69d49e56e5d5fec2cf02e428419eebbadd Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 7 Nov 2013 14:54:34 +0200 Subject: [PATCH] setup-gummiboot-conf: fix non-existing kernels handling This patch is a bug-fix and it fixes the case when the default entry in 'loader.conf' does not actually exist in 'loader/entries'. Instead of failing, we should just find the newest existing version of the kernel. Change-Id: I61e169f37b5487b8abd6188a771f37f2f08ab328 Signed-off-by: Artem Bityutskiy --- setup-gummiboot-conf | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/setup-gummiboot-conf b/setup-gummiboot-conf index fa0cf58..5a84ad9 100755 --- a/setup-gummiboot-conf +++ b/setup-gummiboot-conf @@ -68,11 +68,13 @@ default_entry="$(cat "$conf_file" | sed -n -e 's/[ \t]*default[ \t]\+\(.\+\)[ \t [ "$(printf "%s\n" "$default_entry" | wc -l)" -eq "1" ] || \ fatal "more than one default entry in \"$conf_file\"" -if ! [ -f "$entries_dir/$default_entry" ]; then - # The default entry does not exist anymore. Pick the entry - # corresponding to the newest kernel then. - default_entry="$(printf "%s" "$entries" | head -n1)" -fi +while ! [ -f "$entries_dir/$default_entry" ]; do + # The default entry does not exist anymore. Remove it and pick the + # entry corresponding to the newest installed kerne. + rm -f "$entries_dir/$default_entry" + entries="$(printf "%s" "$entries" | tail -n+2)" + default_entry="$(printf "%s" "$entries" | head -n1).conf" +done # Use the default entry to prepare the pattern for other entries pattern="$(cat "$entries_dir/$default_entry")" -- 2.7.4