#!/bin/sh -euf
-# Copyright 2013 Intel Corporation
+# Copyright 2013-2014 Intel Corporation
# Author: Artem Bityutskiy
# License: GPLv2
VER="1.0"
srcdir="$(readlink -ev -- ${0%/*})"
-PATH="/usr/share/setup-ivi:$srcdir:$PATH"
-
-. setup-ivi-sh-functions
+if [ -f "$srcdir/setup-ivi-sh-functions" ]; then
+ . "$srcdir/setup-ivi-sh-functions"
+else
+ . /usr/share/setup-ivi/setup-ivi-sh-functions
+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
{
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
}
-f, --force if the entry already exists - re-write it, if
<bootdir>/loader/loader.conf does not exist - create one,
if <bootdir>/<kernel> does not exist - do not fail
+ -s, --splash <file>
+ add a splash field to the entry file. <file> is a
+ mandatory parameter to specify splash image location.
-h, --help show this text and exit
EOF
}
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
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
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
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
}
"(use -f to ignore this error)"
fi
- rm -rf $verbose "$entry_path" >&2
+ rm -rf $verbose -- "$entry_path" >&2
verbose "removed $entry_path"
}
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
# 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"
# 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"\"
}