packaging: release out (fix TIVI-2652)
[platform/adaptation/setup-scripts.git] / setup-ivi-bootloader-conf
index 4accba1..9e413aa 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh -euf
 
-# Copyright 2013 Intel Corporation
+# Copyright 2013-2014 Intel Corporation
 # Author: Artem Bityutskiy
 # License: GPLv2
 
@@ -10,13 +10,18 @@ VER="1.0"
 srcdir="$(readlink -ev -- ${0%/*})"
 PATH="/usr/share/setup-ivi:$srcdir:$PATH"
 
-. "$srcdir/setup-ivi-sh-functions"
-. "$srcdir/installerfw-sh-functions"
+if [ -f "$srcdir/setup-ivi-sh-functions" ]; then
+       . "$srcdir/setup-ivi-sh-functions"
+       . "$srcdir/installerfw-sh-functions"
+else
+       .  /usr/share/setup-ivi/setup-ivi-sh-functions
+       .  /usr/share/setup-ivi/installerfw-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
 
@@ -26,6 +31,7 @@ prepare()
        # Get the installer framework environment
        installerfw_restore_env
 
+       rootdir="$(installerfw_mnt_prefix "/")"
        bootdir="$(installerfw_mnt_prefix "/boot")"
 
        if installerfw_is_efi_boot_system; then
@@ -122,22 +128,46 @@ add_subcommand()
        local os_name=
        get_os_name "os_name"
 
-       # Add the bootloader entry
+       # Add the default bootloader entry
        setup-$boot-conf $verbose --bootdir "$bootdir" add $force \
                "$kernel" "$os_name" "$kernel" "$options"
 
-       # If there is the "quiet" option, create a non-quiet configuration
-       local dbgopts="$(printf "%s" "$options" | LC_ALL=C \
+       # Add the debug bootloader entry. If there is the "quiet" option,
+       # create a non-quiet configuration.
+       local verbose_opts="$(printf "%s" "$options" | LC_ALL=C \
                                sed -e "s/[[:blank:]]\+quiet[[:blank:]]\+/ /
                                        s/^quiet[[:blank:]]\+//
                                        s/[[:blank:]]\+quiet$//
                                        s/^quiet$//")"
 
-       dbgopts="$dbgopts ignore_loglevel initcall_debug log_buf_len=2M"
+       local debug_opts="$verbose_opts ignore_loglevel log_buf_len=2M"
+       local debug_opts="$debug_opts initcall_debug"
+
 
        setup-$boot-conf $verbose --bootdir "$bootdir" add \
-               $force "$kernel-debug" "$os_name (debug)" \
-               "$kernel" "$dbgopts"
+               $force "$kernel-debug" "Debug $os_name" \
+               "$kernel" "$verbose_opts"
+
+       # Add the clone bootloader entry, but only if the cloning tool is
+       # installed
+       if [ -f "$rootdir/usr/sbin/setup-ivi-clone" ]; then
+               clone_opts="$options systemd.unit=ivi-clone.service"
+               clone_opts="$clone_opts ivi-clone-target=autodetect"
+               setup-$boot-conf $verbose --bootdir "$bootdir" add \
+                       $force "$kernel-clone" "Clone $os_name" \
+                       "$kernel" "$clone_opts"
+       fi
+
+       # Use default gummiboot-splash file
+       local splash_path="$rootdir/usr/share/gummiboot/splash.bmp"
+
+       # Add a splash entry for fastboot testing and disable fbcon
+       if [ "$boot" = "gummiboot" ] && [ -f "$splash_path" ]; then
+               splash_opts="$options fbcon=map:9"
+               setup-$boot-conf $verbose --bootdir "$bootdir" add \
+                       $force --splash "$splash_path" "$kernel-splash" \
+                       "Splash $os_name" "$kernel" "$splash_opts"
+       fi
 }
 
 #
@@ -232,9 +262,19 @@ remove_subcommand()
                fatal "setup-$boot-conf failed to remove" \
                      "entry \"$kernel\""
        setup-$boot-conf $verbose --bootdir "$bootdir" \
-                            remove $force "$kernel-verbose" || \
+                            remove $force "$kernel-debug" || \
                fatal "setup-$boot-conf failed to remove" \
                      "entry \"$kernel-verbose\""
+       # The "clone" entry does not necessary exist, so use --force
+       setup-$boot-conf $verbose --bootdir "$bootdir" \
+                            remove --force "$kernel-clone" || \
+               fatal "setup-$boot-conf failed to remove" \
+                     "entry \"$kernel-clone\""
+       # Ditto for "splash"
+       setup-$boot-conf $verbose --bootdir "$bootdir" \
+                            remove --force "$kernel-splash" || \
+               fatal "setup-$boot-conf failed to remove" \
+                     "entry \"$kernel-splash\""
 
        # If this is not the default kernel, we are done
        [ "$kernel" = "$default_kernel" ] || return 0