3 # Copyright 2013 Intel Corporation
4 # Author: Artem Bityutskiy
10 srcdir="$(readlink -ev -- ${0%/*})"
11 PATH="/usr/share/setup-ivi:$srcdir:$PATH"
13 . setup-ivi-sh-functions
14 . installerfw-sh-functions
16 # This is a small trick which I use to make sure my scripts are portable -
17 # check if 'dash' is present, and if yes - use it.
18 if can_switch_to_dash; then
19 exec dash -euf "$srcdir/$PROG" "$@"
25 verbose "installing gummiboot to $bootdir"
27 local installdir="$bootdir/EFI/boot"
28 local gummiboot_path="$(installerfw_mnt_prefix "/usr/lib/gummiboot")"
30 # Make sure gummiboot is installed in the system
31 if ! ([ -f $gummiboot_path/gummibootia32.efi ] || \
32 [ -f $gummiboot_path/gummibootx64.efi ]); then
33 fatal "\"$gummiboot_path/gummiboot*.efi\" files not found!"
37 mkdir -p $verbose "$installdir" >&2
38 [ -f "$gummiboot_path/gummibootia32.efi" ] && \
39 cp $verbose "$gummiboot_path/gummibootia32.efi" \
40 "$installdir/bootia32.efi" >&2
41 [ -f "$gummiboot_path/gummibootx64.efi" ] && \
42 cp $verbose "$gummiboot_path/gummibootx64.efi" \
43 "$installdir/bootx64.efi"
45 verbose "installed gummiboot to $bootdir"
50 verbose "installing extlinux to $bootdir"
52 local installdir="$bootdir/extlinux"
53 local extlinux="extlinux"
55 # Check if extlinux is available
56 if ! command -v "extlinux" >/dev/null 2>&1; then
57 extlinux="$(installerfw_mnt_prefix "/sbin/extlinux")"
59 fatal "cannot find \"$extlinux\""
62 # Get device node name for the boot partition
64 installerfw_get_part_info "/boot" "DEVNODE_NOW" "boot_devnode"
65 [ -n "$boot_devnode" ] || \
66 fatal "cannot find device node of the boot disk, probably" \
67 "INSTALLERFW_PARTx_DEVNODE_NOW environment" \
68 "variable is not defined"
71 mkdir -p $verbose "$installdir" >&2
72 "$extlinux" --device "$boot_devnode" -i "$installdir" || \
73 fatal "cannot install extlinux to \"$installdir\"" \
74 "(requires extlinux version 5 or greater)"
77 # Get device node name for the boot disk
79 installerfw_get_part_info "/boot" "DISK_DEVNODE_NOW" "mbr_devnode"
80 [ -n "$mbr_devnode" ] || \
81 fatal "cannot find device node of the boot disk, probably" \
82 "INSTALLERFW_PARTx_DISK_DEVNODE_NOW environment" \
83 "variable is not defined"
85 # Install the MBR part of extlinux
86 local mbr_bin="$(installerfw_mnt_prefix "/usr/share/syslinux/gptmbr.bin")"
87 dd if="$mbr_bin" of="$mbr_devnode" count=1 || \
88 fatal "cannot install MBR: dd if=$mbr_bin of=$mbr_devnode"
90 verbose "installed extlinux to $bootdir"
96 Usage: $PROG [options]
98 Install the EFI bootloader (gummiboot) and create the initial configuration
99 for all the currently installed kernels. This program depends on various
100 "installer framework" variables.
103 -v, --verbose be verbose
104 --version show the program version and exit
105 -h, --help show this text and exit
111 IFS= printf "%s\n\n" "$PROG: error: $*" >&2
117 tmp=`getopt -n $PROG -o v,h --long verbose,version,help -- "$@"` ||
118 show_usage_fail "cannot parse command-line options"
137 *) show_usage_fail "unrecognized option \"$1\""
143 bootdir="$(installerfw_mnt_prefix "/boot")"
145 if installerfw_available; then
146 if ! [ -s "$(installerfw_get_env_file_name)" ]; then
150 installerfw_restore_env
154 get_os_name "os_name"
156 if installerfw_is_efi_boot_system; then
162 # Create bootloader entries for each kernel
163 kernels="$(ls -1 "$bootdir" | LC_ALL=C grep "^vmlinuz-" | sort -r)"
165 [ -n "$kernels" ] || \
166 fatal "no kernels (vmlinuz-*) found in \"$bootdir\""
168 printf "%s\n" "$kernels" | while IFS= read -r kernel; do
169 setup-ivi-bootloader-conf $verbose add --force "$kernel"
172 # Set the default kernel to the kernel with highest version
173 newest_kernel="$(get_newest_kernel "$bootdir")"
174 setup-ivi-bootloader-conf $verbose default "$newest_kernel"