os-prober/05efi
Marcus Meissner 81111d8d75 Accepting request 147193 from home:arvidjaar:bnc775610
- add support for chainloading another UEFI bootloader (bnc#775610)
  * 05efi - top level driver to search ESP
  * efi-20microsoft - support Microsoft UEFI bootloader
  * efi-10elilo - support ELILO UEFI bootloader (Agnelo de la Crotche)
- skip legacy Microsoft bootloader on UEFI (bnc#775610)

OBS-URL: https://build.opensuse.org/request/show/147193
OBS-URL: https://build.opensuse.org/package/show/Base:System/os-prober?expand=0&rev=9
2013-01-05 14:42:18 +00:00

71 lines
1.8 KiB
Bash

#!/bin/sh
# Detects all UEFI bootloaders on EFI System Partition
. /usr/share/os-prober/common.sh
partition="$1"
mpoint="$2"
type="$3"
# This file is for UEFI platform only
if [ ! -d /sys/firmware/efi ]; then
debug "Not on UEFI platform"
exit 1
fi
# Weed out stuff that doesn't apply to us
case "$type" in
vfat) debug "$1 is a FAT32 partition" ;;
msdos) debug "$1 is a FAT16 partition" ;;
*) debug "$1 is $type partition: exiting"; exit 1 ;;
esac
if type udevadm > /dev/null 2>&1; then
udevinfo () {
udevadm info "$@"
}
fi
if type udevinfo > /dev/null 2>&1; then
# Skip virtual devices
if udevinfo -q path -n $partition | grep -q /virtual/; then
debug "$1 is virtual device: exiting"
exit 1
fi
eval "$(udevinfo -q property -n "$partition" | grep -E '^ID_PART_ENTRY_(TYPE|SCHEME)=')"
debug "$partition partition scheme is $ID_PART_ENTRY_SCHEME"
debug "$partition partition type is $ID_PART_ENTRY_TYPE"
if [ -z "$ID_PART_ENTRY_TYPE" -o -z "$ID_PART_ENTRY_SCHEME" -o \
\( "$ID_PART_ENTRY_SCHEME" != gpt -a "$ID_PART_ENTRY_SCHEME" != msdos \) -o \
\( "$ID_PART_ENTRY_SCHEME" = gpt -a "$ID_PART_ENTRY_TYPE" != c12a7328-f81f-11d2-ba4b-00a0c93ec93b \) -o \
\( "$ID_PART_ENTRY_SCHEME" = msdos -a "$ID_PART_ENTRY_TYPE" != 0xef \) ]; then
debug "$partition is not a ESP partition: exiting"
exit 1
fi
else
debug "udevinfo and udevadm missing - cannot check partition type"
fi
efi=$(item_in_dir efi "$mpoint")
if [ -z "$efi" ]; then
debug "$mpoint does not have /EFI directory: exiting"
exit 1
fi
ret=1
for test in /usr/lib/os-probes/mounted/efi/*; do
debug "running subtest $test"
if [ -f "$test" ] && [ -x "$test" ]; then
entry=$("$test" "$mpoint/$efi")
if [ -n "$entry" ]; then
debug "bootloader $entry found by subtest $test"
ret=0
result "${partition}@/$efi/${entry}:efi"
fi
fi
done
exit $ret