summaryrefslogtreecommitdiff
path: root/setup-efi-ivi
diff options
context:
space:
mode:
Diffstat (limited to 'setup-efi-ivi')
-rwxr-xr-xsetup-efi-ivi75
1 files changed, 75 insertions, 0 deletions
diff --git a/setup-efi-ivi b/setup-efi-ivi
new file mode 100755
index 0000000..972bf74
--- /dev/null
+++ b/setup-efi-ivi
@@ -0,0 +1,75 @@
+#!/bin/sh -ef
+
+PROG="setup-efi-ivi"
+
+# This is a helper function which prints an error message and exits
+fatal()
+{
+ echo "$PROG: error: $1" 1>&2
+ exit 1
+}
+
+boot_mountpoint="/boot"
+
+# Make sure the installer framework variables are defined
+[ "x$INSTALLERFW_INSTALLER_NAME" != "x" ] ||
+ fatal "installer framework environment variables not found"
+
+# Find the root and boot paritions
+pnum=0
+root_partuuid=
+boot_fstype=
+
+while [ "$pnum" -lt "$INSTALLERFW_PART_COUNT" ]; do
+ mountpoint="INSTALLERFW_PART${pnum}_MOUNTPOINT"
+ mountpoint="$(eval echo '$'$mountpoint)"
+
+ # Find out all the required data for the root and boot partition
+ if [ "$mountpoint" == "/" ]; then
+ root_partuuid=INSTALLERFW_PART${pnum}_PARTUUID
+ root_partuuid="$(eval echo '$'$root_partuuid)"
+ elif [ "$mountpoint" == "$boot_mountpoint" ]; then
+ boot_fstype=INSTALLERFW_PART${pnum}_FSTYPE
+ boot_fstype="$(eval echo '$'$boot_fstype)"
+ fi
+
+ pnum="$((pnum+1))"
+done
+
+# Make sure that the boot partition has a FAT file-system
+[ "$boot_fstype" == "vfat" ] || \
+ fatal "boot partition has to have type \"vfat\""
+
+# Make sure gummiboot is installed in the system
+if ! ([ -f /usr/lib/gummiboot/gummibootia32.efi ] || \
+ [ -f /usr/lib/gummiboot/gummibootx64.efi ]); then
+ fatal "\"/usr/lib/gummiboot/gummiboot*.efi\" files not found!"
+fi
+
+# Install gummiboot
+mkdir -p "$boot_mountpoint/EFI/boot"
+[ -f "/usr/lib/gummiboot/gummibootia32.efi" ] &&
+ cp "/usr/lib/gummiboot/gummibootia32.efi" "$boot_mountpoint/EFI/boot/bootia32.efi"
+[ -f "/usr/lib/gummiboot/gummibootx64.efi" ] &&
+ cp "/usr/lib/gummiboot/gummibootx64.efi" "$boot_mountpoint/boot/EFI/boot/bootx64.efi"
+
+# Find out the latest kernel binary in boot partition
+vmlinuz="$(ls -1 "$boot_mountpoint" | grep "^vmlinuz-" | sort -r | head -n1)"
+vmlinuz_version="$(echo $vmlinuz | sed -e 's/vmlinuz-\(.*\)/\1/')"
+
+# Create the gummiboot configuration file
+mkdir -p "$boot_mountpoint/loader"
+
+cat > "$boot_mountpoint/loader/loader.conf" <<-EOF
+timeout 0
+default vmlinuz-default.conf
+EOF
+
+# Create the default gummiboot entry
+mkdir -p "$boot_mountpoint/loader/entries"
+cat > "$boot_mountpoint/loader/entries/vmlinuz-default.conf" <<-EOF
+title Tizen IVI 3.0
+version $vmlinuz_version
+efi /$vmlinuz
+options $INSTALLERFW_KERNEL_OPTS root=PARTUUID=$root_partuuid
+EOF