#!/bin/sh -euf
-# Copyright 2013 Intel Corporation
+# Copyright 2013-2014 Intel Corporation
# Author: Artem Bityutskiy
# License: GPLv2
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
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
install_extlinux()
{
- verbose "installing extlinux to $bootdir"
-
local installdir="$bootdir/extlinux"
local extlinux="extlinux"
+ local output
# Check if extlinux is available
if ! command -v "extlinux" >/dev/null 2>&1; then
"variable is not defined"
# Install extlinux
- mkdir -p $verbose "$installdir" >&2
- "$extlinux" --device "$boot_devnode" -i "$installdir" || \
- fatal "cannot install extlinux to \"$installdir\"" \
- "(requires extlinux version 5 or greater)"
-
+ verbose "installing extlinux to $bootdir, boot device node is" \
+ "\"$boot_devnode\""
+ mkdir -p $verbose -- "$installdir" >&2
+ output="$("$extlinux" --device "$boot_devnode" -i "$installdir" 2>&1)" \
+ || fatal "cannot install extlinux to \"$installdir\" (note," \
+ "extlinux version 5 or greater is required)" \
+ "${br}${output}"
# Get device node name for the boot disk
local mbr_devnode
"variable is not defined"
# Install the MBR part of extlinux
- local mbr_bin="$(installerfw_mnt_prefix "/usr/share/syslinux/gptmbr.bin")"
- dd if="$mbr_bin" of="$mbr_devnode" count=1 || \
- fatal "cannot install MBR: dd if=$mbr_bin of=$mbr_devnode"
+ local mbr_bin="$(installerfw_mnt_prefix \
+ "/usr/share/syslinux/gptmbr.bin")"
+ verbose "setting up MBR, writing \"$mbr_bin\" to \"$mbr_devnode\""
+ output="$(dd if="$mbr_bin" of="$mbr_devnode" count=1 2>&1)" || \
+ fatal "cannot install MBR, dd if=$mbr_bin of=$mbr_devnode" \
+ "failed${br}${output}"
verbose "installed extlinux to $bootdir"
}
bootdir="$(installerfw_mnt_prefix "/boot")"
if installerfw_available; then
- if ! [ -s "$(installerfw_get_env_file_name)" ]; then
- installerfw_save_env
- fi
+ installerfw_save_env
else
installerfw_restore_env
fi
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\""
# 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