3 # Copyright 2013-2014 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 local installdir="$bootdir/extlinux"
56 local extlinux="extlinux"
59 # Check if extlinux is available
60 if ! command -v "extlinux" >/dev/null 2>&1; then
61 extlinux="$(installerfw_mnt_prefix "/sbin/extlinux")"
63 fatal "cannot find \"$extlinux\""
66 # Get device node name for the boot partition
68 installerfw_get_part_info "/boot" "DEVNODE_NOW" "boot_devnode"
69 [ -n "$boot_devnode" ] || \
70 fatal "cannot find device node of the boot disk, probably" \
71 "INSTALLERFW_PARTx_DEVNODE_NOW environment" \
72 "variable is not defined"
75 verbose "installing extlinux to $bootdir, boot device node is" \
77 mkdir -p $verbose -- "$installdir" >&2
78 output="$("$extlinux" --device "$boot_devnode" -i "$installdir" 2>&1)" \
79 || fatal "cannot install extlinux to \"$installdir\" (note," \
80 "extlinux version 5 or greater is required)" \
83 # Get device node name for the boot disk
85 installerfw_get_part_info "/boot" "DISK_DEVNODE_NOW" "mbr_devnode"
86 [ -n "$mbr_devnode" ] || \
87 fatal "cannot find device node of the boot disk, probably" \
88 "INSTALLERFW_PARTx_DISK_DEVNODE_NOW environment" \
89 "variable is not defined"
91 # Install the MBR part of extlinux
92 local mbr_bin="$(installerfw_mnt_prefix \
93 "/usr/share/syslinux/gptmbr.bin")"
94 verbose "setting up MBR, writing \"$mbr_bin\" to \"$mbr_devnode\""
95 output="$(dd if="$mbr_bin" of="$mbr_devnode" count=1 2>&1)" || \
96 fatal "cannot install MBR, dd if=$mbr_bin of=$mbr_devnode" \
97 "failed${br}${output}"
99 verbose "installed extlinux to $bootdir"
105 Usage: $PROG [options]
107 Install the EFI bootloader (gummiboot) and create the initial configuration
108 for all the currently installed kernels. This program depends on various
109 "installer framework" variables.
112 -v, --verbose be verbose
113 --version show the program version and exit
114 -h, --help show this text and exit
120 IFS= printf "%s\n\n" "$PROG: error: $*" >&2
126 tmp=`getopt -n $PROG -o v,h --long verbose,version,help -- "$@"` ||
127 show_usage_fail "cannot parse command-line options"
146 *) show_usage_fail "unrecognized option \"$1\""
152 bootdir="$(installerfw_mnt_prefix "/boot")"
154 if installerfw_available; then
157 installerfw_restore_env
161 get_os_name "os_name"
163 if installerfw_is_efi_boot_system; then
169 # Create bootloader entries for each kernel
170 kernels="$(ls -1 "$bootdir" | LC_ALL=C grep -- "^vmlinuz-" | sort -r)"
172 [ -n "$kernels" ] || \
173 fatal "no kernels (vmlinuz-*) found in \"$bootdir\""
175 printf "%s\n" "$kernels" | while IFS= read -r kernel; do
176 setup-ivi-bootloader-conf $verbose add --force "$kernel"
179 # Set the default kernel to the kernel with highest version
180 newest_kernel="$(get_newest_kernel "$bootdir")"
181 setup-ivi-bootloader-conf $verbose default "$newest_kernel"
183 # And finally, create the /etc/fstab file
184 setup-ivi-fstab $verbose --force