X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=setup-gummiboot-conf;h=4a840398ef1171838b830ca41e2ff214e1f7204e;hb=e4918ab0787fe9cbcde4db579d2666f3d6b7ca5e;hp=b344029885b313fa47452f4307f8fa75f8f923ff;hpb=a24172b701d078fc03bb0eb90b472d7198254ca5;p=profile%2Fivi%2Fsetup-ivi.git diff --git a/setup-gummiboot-conf b/setup-gummiboot-conf index b344029..4a84039 100755 --- a/setup-gummiboot-conf +++ b/setup-gummiboot-conf @@ -1,6 +1,6 @@ #!/bin/sh -euf -# Copyright 2013 Intel Corporation +# Copyright 2013-2014 Intel Corporation # Author: Artem Bityutskiy # License: GPLv2 @@ -17,7 +17,7 @@ fi # This is a small trick which I use to make sure my scripts are portable - # check if 'dash' is present, and if yes - use it. if can_switch_to_dash; then - exec dash -euf "$srcdir/$PROG" "$@" + exec dash -euf -- "$srcdir/$PROG" "$@" exit $? fi @@ -51,7 +51,7 @@ create_default_conf_file() { verbose "creating the default configuration file \"$conf_file\"" - mkdir -p $verbose "$conf_dir" >&2 + mkdir -p $verbose -- "$conf_dir" >&2 cat > "$conf_file" <<-EOF # Generated by $PROG timeout 0 @@ -101,6 +101,9 @@ Options: -f, --force if the entry already exists - re-write it, if /loader/loader.conf does not exist - create one, if / does not exist - do not fail + -s, --splash + add a splash field to the entry file. is a + mandatory parameter to specify splash image location. -h, --help show this text and exit EOF } @@ -120,16 +123,20 @@ add_subcommand() fi local tmp - tmp=`getopt -n $PROG -o f,h --long force,help -- "$@"` || + tmp=`getopt -n $PROG -o f,s:,h --long force,splash:,help -- "$@"` || show_add_usage_fail "cannot parse command-line options" eval set -- "$tmp" local force= + local splash= while true; do case "$1" in -f|--force) force="-f" ;; + -s|--splash) + splash="$2"; shift + ;; -h|--help) show_add_usage exit 0 @@ -148,6 +155,9 @@ add_subcommand() if [ "$#" -gt 4 ]; then show_add_usage_fail "too many arguments: \"$1\"" fi + if [ -n "$splash" ] && ! [ -f "$splash" ]; then + show_add_usage_fail "splash file not found: \"$splash\"" + fi prepare @@ -183,7 +193,7 @@ add_subcommand() fatal "cannot fetch kernel version from \"$kernel\"" # Create the new entry - mkdir -p $verbose "$entries_dir" >&2 + mkdir -p $verbose -- "$entries_dir" >&2 cat > "$entry_path" <<-EOF # Generated by $PROG title $title @@ -192,9 +202,16 @@ add_subcommand() options $options EOF + # Add an optional splash image entry if the image file exists + if [ -n "$splash" ]; then + cp $verbose -- "$splash" "$entries_dir" + printf "%s\n" "splash \\loader\\entries\\${splash##*/}" \ + >> "$entry_path" + fi + if [ -n "$verbose" ]; then verbose "contents of \"$entry_path\":" - cat "$entry_path" >&2 + cat -- "$entry_path" >&2 fi } @@ -271,7 +288,7 @@ remove_subcommand() "(use -f to ignore this error)" fi - rm -rf $verbose "$entry_path" >&2 + rm -rf $verbose -- "$entry_path" >&2 verbose "removed $entry_path" } @@ -289,11 +306,13 @@ get_kernel_from_entry() if [ -f "$entry" ]; then local regexp="$(get_regexp "efi")" - local result="$(LC_ALL=C sed -n -e "s/$regexp/\2/p" "$entry")" + local result="$(LC_ALL=C sed -n -e "s/$regexp/\2/p" -- \ + "$entry")" if [ -z "$result" ]; then regexp="$(get_regexp "linux")" - result="$(LC_ALL=C sed -n -e "s/$regexp/\2/p" "$entry")" + result="$(LC_ALL=C sed -n -e "s/$regexp/\2/p" -- \ + "$entry")" [ -n "$result" ] || return 0 fi @@ -365,7 +384,8 @@ default_subcommand() # Find the current default entry local regexp="$(get_regexp "default")" - local default_entry="$(LC_ALL=C sed -n -e "s/$regexp/\2/p" "$conf_file")" + local default_entry="$(LC_ALL=C sed -n -e "s/$regexp/\2/p" -- \ + "$conf_file")" if [ -z "$entry" ]; then printf "%s\n" "entry: $default_entry" @@ -391,7 +411,7 @@ default_subcommand() # Escape special sed characters in "$entry" and replace the old default # entry with the new one local entry_esc="$(esc_sed_replacement "$entry")" - LC_ALL=C sed -i -e "s/$regexp/\1$entry_esc\3/" "$conf_file" + LC_ALL=C sed -i -e "s/$regexp/\1$entry_esc\3/" -- "$conf_file" verbose "set the default boot kernel to \"$entry"\" }