Use -- some more
[platform/adaptation/setup-scripts.git] / setup-ivi-boot
index fd8ce47..ba167fc 100755 (executable)
@@ -10,13 +10,18 @@ VER="1.0"
 srcdir="$(readlink -ev -- ${0%/*})"
 PATH="/usr/share/setup-ivi:$srcdir:$PATH"
 
-. setup-ivi-sh-functions
-. 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
 
@@ -34,7 +39,7 @@ install_gummiboot()
        fi
 
        # Install gummiboot
-       mkdir -p $verbose "$installdir" >&2
+       mkdir -p $verbose -- "$installdir" >&2
        [ -f "$gummiboot_path/gummibootia32.efi" ] && \
                cp $verbose "$gummiboot_path/gummibootia32.efi" \
                            "$installdir/bootia32.efi" >&2
@@ -68,7 +73,7 @@ install_extlinux()
                      "variable is not defined"
 
        # Install extlinux
-       mkdir -p $verbose "$installdir" >&2
+       mkdir -p $verbose -- "$installdir" >&2
        "$extlinux" --device "$boot_devnode" -i "$installdir" || \
                fatal "cannot install extlinux to \"$installdir\"" \
                      "(requires extlinux version 5 or greater)"
@@ -142,12 +147,10 @@ done
 
 bootdir="$(installerfw_mnt_prefix "/boot")"
 
-# Save the installer framework variables
-installerfw_file="$(installerfw_get_env_file_name)"
-if [ -f "$installerfw_file" ]; then
-       installerfw_restore_env
-else
+if installerfw_available; then
        installerfw_save_env
+else
+       installerfw_restore_env
 fi
 
 # Get OS name
@@ -160,7 +163,7 @@ else
 fi
 
 # Create bootloader entries for each kernel
-kernels="$(ls -1 "$bootdir" | LC_ALL=C grep "^vmlinuz-" | sort -r)"
+kernels="$(ls -1 "$bootdir" | LC_ALL=C grep -- "^vmlinuz-" | sort -r)"
 
 [ -n "$kernels" ] || \
        fatal "no kernels (vmlinuz-*) found in \"$bootdir\""
@@ -172,3 +175,6 @@ done
 # Set the default kernel to the kernel with highest version
 newest_kernel="$(get_newest_kernel "$bootdir")"
 setup-ivi-bootloader-conf $verbose default "$newest_kernel"
+
+# And finally, create the /etc/fstab file
+setup-ivi-fstab $verbose --force