+# Determine what CPU type and EFI bit depth we're using.
+# Sets Platform global variable to lowercase EFI platform code (currently
+# "x64", "ia32", or "aa64") -- the same code used in filenames.
+DeterminePlatform() {
+ local CpuType
+ case "$OSTYPE" in
+ darwin*)
+ CpuType=`ioreg -l -p IODeviceTree | grep firmware-abi | cut -d "\"" -f 4`
+ if [[ "$CpuType" == EFI32 ]] ; then
+ Platform="ia32"
+ else
+ Platform="x64"
+ fi
+ ;;
+ linux*)
+ CpuType=`uname -m`
+ case "$CpuType" in
+ aarch64)
+ Platform="aa64"
+ ;;
+ x86_64)
+ Platform="x64"
+ ;;
+ i?86)
+ Platform="ia32"
+ # If we're in EFI mode, do some sanity checks, and alert the user or even
+ # abort. Not in BIOS mode, though, since that could be used on an emergency
+ # disc to try to recover a troubled Linux installation.
+ if [[ -d /sys/firmware/efi ]] ; then
+ if [[ "$ShimSource" != "none" && "$TargetDir" != "/BOOT/EFI" ]] ; then
+ echo ""
+ echo "CAUTION: shim does not currently supports 32-bit systems, so you should not"
+ echo "use the --shim option to install on such systems. Aborting!"
+ echo ""
+ exit 1
+ fi
+ echo
+ echo "CAUTION: This Linux installation uses a 32-bit kernel. 32-bit EFI-based"
+ echo "computers are VERY RARE. If you've installed a 32-bit version of Linux"
+ echo "on a 64-bit computer, you should manually install the 64-bit version of"
+ echo "rEFInd. If you're positive you want to continue with this installation,"
+ echo "answer 'Y' to the following question..."
+ echo
+ echo -n "Are you sure you want to continue (Y/N)? "
+ ReadYesNo
+ if [[ $YesNo == "Y" || $YesNo == "y" ]] ; then
+ echo "OK; continuing with the installation..."
+ else
+ exit 0
+ fi
+ fi # In EFI mode
+ ;;
+ *)
+ echo "Unknown CPU type '$CpuType'; aborting!"
+ exit 1
+ ;;
+ esac # case "$CpuType"....
+ ;;
+ *)
+ echo "Unknown OS; aborting!"
+ exit 1
+ ;;
+ esac # case "$OSTYPE"....
+} # DeterminePlatform()
+