3 # Copyright 2013 Intel Corporation
4 # Author: Artem Bityutskiy
9 # This is a helper function which prints an error message and exits
12 printf "%s\n" "$PROG: error: $1" 1>&2
16 boot_mountpoint="/boot"
18 # Make sure the installer framework variables are defined
19 [ "x$INSTALLERFW_INSTALLER_NAME" != "x" ] ||
20 fatal "installer framework environment variables not found"
22 # Find the root and boot paritions
27 while [ "$pnum" -lt "$INSTALLERFW_PART_COUNT" ]; do
28 mountpoint="INSTALLERFW_PART${pnum}_MOUNTPOINT"
29 mountpoint="$(eval printf "%s" '$'$mountpoint)"
31 # Find out all the required data for the root and boot partition
32 if [ "$mountpoint" == "/" ]; then
33 root_partuuid=INSTALLERFW_PART${pnum}_PARTUUID
34 root_partuuid="$(eval printf "%s" '$'$root_partuuid)"
35 elif [ "$mountpoint" == "$boot_mountpoint" ]; then
36 boot_fstype=INSTALLERFW_PART${pnum}_FSTYPE
37 boot_fstype="$(eval printf "%s" '$'$boot_fstype)"
43 # Make sure that the boot partition has a FAT file-system
44 [ "$boot_fstype" == "vfat" ] || \
45 fatal "boot partition has to have type \"vfat\""
47 # Make sure gummiboot is installed in the system
48 if ! ([ -f /usr/lib/gummiboot/gummibootia32.efi ] || \
49 [ -f /usr/lib/gummiboot/gummibootx64.efi ]); then
50 fatal "\"/usr/lib/gummiboot/gummiboot*.efi\" files not found!"
54 mkdir -p "$boot_mountpoint/EFI/boot"
55 [ -f "/usr/lib/gummiboot/gummibootia32.efi" ] &&
56 cp "/usr/lib/gummiboot/gummibootia32.efi" "$boot_mountpoint/EFI/boot/bootia32.efi"
57 [ -f "/usr/lib/gummiboot/gummibootx64.efi" ] &&
58 cp "/usr/lib/gummiboot/gummibootx64.efi" "$boot_mountpoint/boot/EFI/boot/bootx64.efi"
60 # Find out the latest kernel binary in boot partition
61 vmlinuz="$(ls -1 "$boot_mountpoint" | grep "^vmlinuz-" | sort -r | head -n1)"
62 vmlinuz_version="$(printf "%s" $vmlinuz | sed -e 's/vmlinuz-\(.*\)/\1/')"
64 # Create the gummiboot configuration file
65 mkdir -p "$boot_mountpoint/loader"
67 cat > "$boot_mountpoint/loader/loader.conf" <<-EOF
69 default vmlinuz-$vmlinuz_version.conf
72 # Create the default gummiboot entry
73 mkdir -p "$boot_mountpoint/loader/entries"
74 cat > "$boot_mountpoint/loader/entries/vmlinuz-$vmlinuz_version.conf" <<-EOF
76 version $vmlinuz_version
78 options $INSTALLERFW_KERNEL_OPTS root=PARTUUID=$root_partuuid