3 # Copyright 2013 Intel Corporation
4 # Author: Artem Bityutskiy
10 srcdir="$(readlink -ev -- ${0%/*})"
11 PATH="/usr/share/setup-ivi:$srcdir:$PATH"
13 if [ -f "$srcdir/setup-ivi-sh-functions" ]; then
14 . "$srcdir/setup-ivi-sh-functions"
15 . "$srcdir/installerfw-sh-functions"
17 . /usr/share/setup-ivi/setup-ivi-sh-functions
18 . /usr/share/setup-ivi/installerfw-sh-functions
21 # This is a small trick which I use to make sure my scripts are portable -
22 # check if 'dash' is present, and if yes - use it.
23 if can_switch_to_dash; then
24 exec dash -euf "$srcdir/$PROG" "$@"
30 verbose "installing gummiboot to $bootdir"
32 local installdir="$bootdir/EFI/boot"
33 local gummiboot_path="$(installerfw_mnt_prefix "/usr/lib/gummiboot")"
35 # Make sure gummiboot is installed in the system
36 if ! ([ -f $gummiboot_path/gummibootia32.efi ] || \
37 [ -f $gummiboot_path/gummibootx64.efi ]); then
38 fatal "\"$gummiboot_path/gummiboot*.efi\" files not found!"
42 mkdir -p $verbose "$installdir" >&2
43 [ -f "$gummiboot_path/gummibootia32.efi" ] && \
44 cp $verbose "$gummiboot_path/gummibootia32.efi" \
45 "$installdir/bootia32.efi" >&2
46 [ -f "$gummiboot_path/gummibootx64.efi" ] && \
47 cp $verbose "$gummiboot_path/gummibootx64.efi" \
48 "$installdir/bootx64.efi"
50 verbose "installed gummiboot to $bootdir"
55 verbose "installing extlinux to $bootdir"
57 local installdir="$bootdir/extlinux"
58 local extlinux="extlinux"
60 # Check if extlinux is available
61 if ! command -v "extlinux" >/dev/null 2>&1; then
62 extlinux="$(installerfw_mnt_prefix "/sbin/extlinux")"
64 fatal "cannot find \"$extlinux\""
67 # Get device node name for the boot partition
69 installerfw_get_part_info "/boot" "DEVNODE_NOW" "boot_devnode"
70 [ -n "$boot_devnode" ] || \
71 fatal "cannot find device node of the boot disk, probably" \
72 "INSTALLERFW_PARTx_DEVNODE_NOW environment" \
73 "variable is not defined"
76 mkdir -p $verbose "$installdir" >&2
77 "$extlinux" --device "$boot_devnode" -i "$installdir" || \
78 fatal "cannot install extlinux to \"$installdir\"" \
79 "(requires extlinux version 5 or greater)"
82 # Get device node name for the boot disk
84 installerfw_get_part_info "/boot" "DISK_DEVNODE_NOW" "mbr_devnode"
85 [ -n "$mbr_devnode" ] || \
86 fatal "cannot find device node of the boot disk, probably" \
87 "INSTALLERFW_PARTx_DISK_DEVNODE_NOW environment" \
88 "variable is not defined"
90 # Install the MBR part of extlinux
91 local mbr_bin="$(installerfw_mnt_prefix "/usr/share/syslinux/gptmbr.bin")"
92 dd if="$mbr_bin" of="$mbr_devnode" count=1 || \
93 fatal "cannot install MBR: dd if=$mbr_bin of=$mbr_devnode"
95 verbose "installed extlinux to $bootdir"
101 Usage: $PROG [options]
103 Install the EFI bootloader (gummiboot) and create the initial configuration
104 for all the currently installed kernels. This program depends on various
105 "installer framework" variables.
108 -v, --verbose be verbose
109 --version show the program version and exit
110 -h, --help show this text and exit
116 IFS= printf "%s\n\n" "$PROG: error: $*" >&2
122 tmp=`getopt -n $PROG -o v,h --long verbose,version,help -- "$@"` ||
123 show_usage_fail "cannot parse command-line options"
142 *) show_usage_fail "unrecognized option \"$1\""
148 bootdir="$(installerfw_mnt_prefix "/boot")"
150 if installerfw_available; then
153 installerfw_restore_env
157 get_os_name "os_name"
159 if installerfw_is_efi_boot_system; then
165 # Create bootloader entries for each kernel
166 kernels="$(ls -1 "$bootdir" | LC_ALL=C grep "^vmlinuz-" | sort -r)"
168 [ -n "$kernels" ] || \
169 fatal "no kernels (vmlinuz-*) found in \"$bootdir\""
171 printf "%s\n" "$kernels" | while IFS= read -r kernel; do
172 setup-ivi-bootloader-conf $verbose add --force "$kernel"
175 # Set the default kernel to the kernel with highest version
176 newest_kernel="$(get_newest_kernel "$bootdir")"
177 setup-ivi-bootloader-conf $verbose default "$newest_kernel"
179 # And finally, create the /etc/fstab file
180 setup-ivi-fstab $verbose --force