#!/bin/sh -euf
-# Copyright 2013 Intel Corporation
+# Copyright 2013-2014 Intel Corporation
# Author: Artem Bityutskiy
# License: GPLv2
VER="1.0"
srcdir="$(readlink -ev -- ${0%/*})"
-. "$srcdir/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
ui vesamenu.c32
/$anyl_regexp/!bl # a different label, stop skipping
}
/$l_regexp/!p # print all other lines
- " "$conf_file"
+ " -- "$conf_file"
remove_trailing_empty_lines "$conf_file"
}
# Make sure the extlinux configuration file exists
check_and_create_default_conf_file "$label"
- if LC_ALL=C grep -q -e "$(label_regexp "$label")" "$conf_file" && \
+ if LC_ALL=C grep -q -e "$(label_regexp "$label")" -- "$conf_file" && \
[ -z "$force" ]; then
fatal "extlinux boot menu label \"$label\" already exists" \
"(use -f to force re-creating it)"
local label="$1"
- if ! LC_ALL=C grep -q -e "$(label_regexp "$label")" "$conf_file" && \
+ if ! LC_ALL=C grep -q -e "$(label_regexp "$label")" -- "$conf_file" && \
[ -z "$force" ]; then
fatal "cannot find label \"$label\" in \"$conf_file\"" \
"(use -f to ignore this error)"
/$linux_regexp/ { s/$linux_regexp/\2/p }
/$kernel_regexp/ { s/$kernel_regexp/\2/p }
/$anyl_regexp/!bl # Loop till the next label
- }" "$conf_file")"
+ }" -- "$conf_file")"
printf "%s" "${result##*/}"
}
# Find the current default label
local regexp="$(get_regexp "default")"
- local default_label="$(LC_ALL=C sed -n -e "s/$regexp/\2/p" "$conf_file")"
+ local default_label="$(LC_ALL=C sed -n -e "s/$regexp/\2/p" -- \
+ "$conf_file")"
if [ -z "$label" ]; then
printf "%s\n" "label: $default_label"
fi
local l_regexp="$(label_regexp "$label")"
- local labels="$(LC_ALL=C grep -e "$l_regexp" "$conf_file" | wc -l)"
+ local labels="$(LC_ALL=C grep -e "$l_regexp" -- "$conf_file" | wc -l)"
if [ "$labels" -eq "0" ] && [ -z "$force" ]; then
fatal "cannot find label \"$label\" in \"$conf_file\"" \
$ { s/.*/&\n$def/; q }
/^[[:blank:]]*$/ { s/.*/$def\n&/; q }
/$(anyl_regexp)/ { s/.*/$def\n&/; q }
- " "$conf_file"
+ " -- "$conf_file"
return 0
fi
# Escape special sed characters in "$entry" and replace the old default
# entry with the new one
local esc_label="$(esc_sed_replacement "$label")"
- LC_ALL=C sed -i -e "s/$regexp/\1$esc_label\3/" "$conf_file"
+ LC_ALL=C sed -i -e "s/$regexp/\1$esc_label\3/" -- "$conf_file"
verbose "set the default boot kernel to \"$label"\"
}