Implement setup-ivi-clone
[platform/adaptation/setup-scripts.git] / setup-ivi-sh-functions
index 2a973f3..f1aa2c6 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2013 Intel Corporation
+# Copyright 2013-2014 Intel Corporation
 # Author: Artem Bityutskiy
 # License: GPLv2
 
@@ -17,6 +17,16 @@ fatal()
        exit 1
 }
 
+warning()
+{
+       IFS= printf "%s\n" "$PROG: Warning!: $*" >&2
+}
+
+message()
+{
+       IFS= printf "%s\n" "$PROG: $*"
+}
+
 verbose()
 {
        if [ -n "$verbose" ]; then
@@ -34,7 +44,8 @@ get_os_name()
                fatal "the \"$osrelease_path\" file not found"
 
        # Get the OS name
-       local __os_name="$(LC_ALL=C sed -n -e 's/^PRETTY_NAME="\(.*\)"$/\1/p' "$osrelease_path")"
+       local __os_name="$(LC_ALL=C sed -n -e 's/^PRETTY_NAME="\(.*\)"$/\1/p' \
+                          -- "$osrelease_path")"
        [ -n "$__os_name" ] || \
                fatal "cannot find \"PRETTY_NAME\" variable in \"$osrelease_path\""
 
@@ -92,12 +103,14 @@ get_newest_kernel()
        local bootdir="$1"; shift
 
        # Generate the list of installed kernels
-       local kernels="$(ls -1 "$bootdir" | LC_ALL=C grep "^vmlinuz-" | sort -r)"
+       local kernels="$(ls -1 "$bootdir" | LC_ALL=C grep -- "^vmlinuz-" | \
+                        sort -r)"
 
        # Exclude the unwanted kernel, if any
        if [ -n "${1:-}" ]; then
                local kernel="$(esc_regexp "$1")"
-               kernels="$(printf "%s" "$kernels" | LC_ALL=C grep -v "^$kernel$")"
+               kernels="$(printf "%s" "$kernels" | LC_ALL=C grep -v -- \
+                          "^$kernel$")"
        fi
 
        printf "%s" "$kernels" | head -n1
@@ -118,5 +131,5 @@ remove_trailing_empty_lines()
                 bl              # and start over
            }
            /^[[:blank:]]*$/!p   # print the pattern buffer for non-blank lines
-           ' "$file"
+           ' -- "$file"
 }