X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=setup-gummiboot-conf;h=83f5719007f862d6ef27cdd203fd6e27085ee26d;hb=9b1672e205379d860f66793168b3e8cd1d12867f;hp=b344029885b313fa47452f4307f8fa75f8f923ff;hpb=a24172b701d078fc03bb0eb90b472d7198254ca5;p=platform%2Fadaptation%2Fsetup-scripts.git diff --git a/setup-gummiboot-conf b/setup-gummiboot-conf index b344029..83f5719 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,10 +51,11 @@ 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 + background #000000 default $1 EOF } @@ -101,6 +102,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 +124,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 +156,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 +194,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 +203,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 +289,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 +307,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 +385,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 +412,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"\" }