setup-gummiboot-conf: handle the case of absent default entry
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Wed, 26 Jun 2013 09:58:06 +0000 (12:58 +0300)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Wed, 26 Jun 2013 09:58:06 +0000 (12:58 +0300)
When the kernel which corresponds to the current default entry is removed, the
script fails. Fix this.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
setup-gummiboot-conf

index 81dda83..4af3d56 100755 (executable)
@@ -56,8 +56,12 @@ default_entry="$(cat "$conf_file" | sed -n -e 's/[ \t]*default[ \t]\+\(.\+\)[ \t
        fatal "cannot find the default entry in \"$conf_file\""
 [ "$(printf "%s\n" "$default_entry" | wc -l)" -eq "1" ] || \
        fatal "more than one default entry in \"$conf_file\""
-[ -f "$entries_dir/$default_entry" ] || \
-       fatal "the default gummiboot entry file does not exist: \"$entries_dir/$default_entry\""
+
+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
 
 # Use the default entry to prepare the pattern for other entries
 pattern="$(cat "$entries_dir/$default_entry")"