X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=setup-extlinux-conf;h=2d5ce9687164c90f8c0c41da0e3b905b01568170;hb=16533686e604fcb4a94fe2096531e1422160151d;hp=060d4fcebba2ce57afaf21d506fbefb5f9d9aa50;hpb=194954b1306252f51ba01e34f8f1c010a0c6a818;p=platform%2Fadaptation%2Fsetup-scripts.git diff --git a/setup-extlinux-conf b/setup-extlinux-conf index 060d4fc..2d5ce96 100755 --- a/setup-extlinux-conf +++ b/setup-extlinux-conf @@ -1,6 +1,6 @@ #!/bin/sh -euf -# Copyright 2013 Intel Corporation +# Copyright 2013-2014 Intel Corporation # Author: Artem Bityutskiy # License: GPLv2 @@ -8,14 +8,16 @@ PROG="setup-extlinux-conf" VER="1.0" srcdir="$(readlink -ev -- ${0%/*})" -PATH="/usr/share/setup-ivi:$srcdir:$PATH" - -. setup-ivi-sh-functions +if [ -f "$srcdir/setup-scripts-sh-functions" ]; then + . "$srcdir/setup-scripts-sh-functions" +else + . /usr/share/setup-scripts/setup-scripts-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 @@ -37,8 +39,9 @@ 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 ui vesamenu.c32 prompt 0 timeout 1 @@ -94,7 +97,7 @@ remove_label() /$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" } @@ -191,7 +194,7 @@ add_subcommand() # 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)" @@ -208,7 +211,7 @@ add_subcommand() local block="label $label menu label $title ($kernel_version) - linux /$kernel + linux ../$kernel append $options" printf "\n%s\n" "$block" >> "$conf_file" @@ -286,7 +289,7 @@ remove_subcommand() 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)" @@ -319,7 +322,7 @@ get_kernel_by_label() /$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##*/}" } @@ -385,7 +388,8 @@ default_subcommand() # 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" @@ -394,7 +398,7 @@ default_subcommand() 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\"" \ @@ -415,14 +419,14 @@ default_subcommand() $ { 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"\" }