forked from pool/os-prober
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
This commit is contained in:
parent
447fa20feb
commit
81111d8d75
70
05efi
Normal file
70
05efi
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#!/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
|
25
efi-10elilo
Normal file
25
efi-10elilo
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Detects ELILO bootloader on a EFI System Partition
|
||||||
|
|
||||||
|
. /usr/share/os-prober/common.sh
|
||||||
|
|
||||||
|
efi="$1"
|
||||||
|
|
||||||
|
found=
|
||||||
|
|
||||||
|
elilo=`find $1 -name "elilo.efi"`
|
||||||
|
if [ -n "$elilo" ]; then
|
||||||
|
bdir=`dirname $elilo`
|
||||||
|
bdir=`basename $bdir`
|
||||||
|
vendor=$(echo $bdir | sed 's|SuSE|SUSE|')
|
||||||
|
long="${vendor} ELILO Boot Manager"
|
||||||
|
short="ELILO"
|
||||||
|
path=${bdir}/elilo.efi
|
||||||
|
found=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$found" ]; then
|
||||||
|
label="$(count_next_label "$short")"
|
||||||
|
result "${path}:${long}:${label}"
|
||||||
|
fi
|
||||||
|
exit 0
|
28
efi-20microsoft
Normal file
28
efi-20microsoft
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Detects Microsoft bootloader on a EFI System Partition
|
||||||
|
|
||||||
|
. /usr/share/os-prober/common.sh
|
||||||
|
|
||||||
|
efi="$1"
|
||||||
|
|
||||||
|
found=
|
||||||
|
for microsoft in $(item_in_dir microsoft "$efi"); do
|
||||||
|
for boot in $(item_in_dir boot "$efi/$microsoft"); do
|
||||||
|
bcd=$(item_in_dir bcd "$efi/$microsoft/$boot")
|
||||||
|
bootmgfw=$(item_in_dir bootmgfw.efi "$efi/$microsoft/$boot")
|
||||||
|
if [ -n "$bcd" -a -n "$bootmgfw" ]; then
|
||||||
|
long="Windows Boot Manager"
|
||||||
|
short=Windows
|
||||||
|
path="$microsoft/$boot/$bootmgfw"
|
||||||
|
found=true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
if [ -n "$found" ]; then
|
||||||
|
label="$(count_next_label "$short")"
|
||||||
|
result "${path}:${long}:${label}"
|
||||||
|
fi
|
||||||
|
exit 0
|
31
os-prober-skip-MS-legacy-on-UEFI.patch
Normal file
31
os-prober-skip-MS-legacy-on-UEFI.patch
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
From: Andrey Borzenkov <arvidjaar@gmail.com>
|
||||||
|
Date: Fri Jan 4 09:46:56 UTC 2013
|
||||||
|
Subject: skip legacy Microsoft bootloader on UEFI system
|
||||||
|
|
||||||
|
References: bnc#775610
|
||||||
|
Patch-Mainline: no
|
||||||
|
|
||||||
|
Sometimes Windows installs both legacy BIOS and UEFI bootloaders.
|
||||||
|
Attempt to chainload legacy bootloader on UEFI system fails. Skip
|
||||||
|
adding legacy bootloader in this case.
|
||||||
|
|
||||||
|
TODO: this probably should be implemented as runtime check. But it
|
||||||
|
does the right thing in majority of cases. If mixed legacy/UEFI
|
||||||
|
boot will be used frequently, it can be revisited.
|
||||||
|
Index: os-prober/os-probes/mounted/x86/20microsoft
|
||||||
|
===================================================================
|
||||||
|
--- os-prober.orig/os-probes/mounted/x86/20microsoft
|
||||||
|
+++ os-prober/os-probes/mounted/x86/20microsoft
|
||||||
|
@@ -7,6 +7,12 @@ partition="$1"
|
||||||
|
mpoint="$2"
|
||||||
|
type="$3"
|
||||||
|
|
||||||
|
+# This script looks for legacy BIOS bootloaders only. Skip if running UEFI
|
||||||
|
+if [ -d /sys/firmware/efi ]; then
|
||||||
|
+ debug "Skipping legacy bootloaders on UEFI system"
|
||||||
|
+ exit 1
|
||||||
|
+fi
|
||||||
|
+
|
||||||
|
# Weed out stuff that doesn't apply to us
|
||||||
|
case "$type" in
|
||||||
|
ntfs|ntfs-3g) debug "$1 is a NTFS partition" ;;
|
@ -1,3 +1,12 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Fri Jan 4 11:18:01 UTC 2013 - arvidjaar@gmail.com
|
||||||
|
|
||||||
|
- 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)
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Mon Dec 19 11:13:44 UTC 2011 - aj@suse.de
|
Mon Dec 19 11:13:44 UTC 2011 - aj@suse.de
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# spec file for package os-prober
|
# spec file for package os-prober
|
||||||
#
|
#
|
||||||
# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||||
#
|
#
|
||||||
# All modifications and additions to the file contributed by third parties
|
# All modifications and additions to the file contributed by third parties
|
||||||
# remain the property of their copyright owners, unless otherwise agreed
|
# remain the property of their copyright owners, unless otherwise agreed
|
||||||
@ -16,7 +16,6 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Name: os-prober
|
Name: os-prober
|
||||||
Version: 1.49
|
Version: 1.49
|
||||||
Release: 0
|
Release: 0
|
||||||
@ -27,11 +26,16 @@ Group: System/Boot
|
|||||||
Url: http://kitenet.net/~joey/code/os-prober/
|
Url: http://kitenet.net/~joey/code/os-prober/
|
||||||
Source0: http://ftp.de.debian.org/debian/pool/main/o/os-prober/%{name}_%{version}.tar.gz
|
Source0: http://ftp.de.debian.org/debian/pool/main/o/os-prober/%{name}_%{version}.tar.gz
|
||||||
Source1: COPYING-note.txt
|
Source1: COPYING-note.txt
|
||||||
|
Source2: 05efi
|
||||||
|
Source3: efi-20microsoft
|
||||||
|
Source4: efi-10elilo
|
||||||
# move newns binary outside of os-prober subdirectory, so that debuginfo
|
# move newns binary outside of os-prober subdirectory, so that debuginfo
|
||||||
# can be automatically generated for it
|
# can be automatically generated for it
|
||||||
Patch0: os-prober-newnsdirfix.patch
|
Patch0: os-prober-newnsdirfix.patch
|
||||||
# PATCH-FIX-OPENSUSE: Fix spelling of SUSE aj@suse.de
|
# PATCH-FIX-OPENSUSE: Fix spelling of SUSE aj@suse.de
|
||||||
Patch1: os-prober-SUSE.patch
|
Patch1: os-prober-SUSE.patch
|
||||||
|
# PATCH-FIX-OPENSUSE: Skip legacy Microsoft bootloader on UEFI [bnc#775610]
|
||||||
|
Patch2: os-prober-skip-MS-legacy-on-UEFI.patch
|
||||||
|
|
||||||
Requires: /bin/grep
|
Requires: /bin/grep
|
||||||
Requires: /bin/sed
|
Requires: /bin/sed
|
||||||
@ -52,6 +56,7 @@ distributions can be added easily.
|
|||||||
cp %SOURCE1 .
|
cp %SOURCE1 .
|
||||||
%patch0 -p1
|
%patch0 -p1
|
||||||
%patch1 -p1
|
%patch1 -p1
|
||||||
|
%patch2 -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
make %{?_smp_mflags} CC="%__cc" CFLAGS="%{optflags}"
|
make %{?_smp_mflags} CC="%__cc" CFLAGS="%{optflags}"
|
||||||
@ -88,6 +93,12 @@ done
|
|||||||
if [ "$ARCH" = x86 ]; then
|
if [ "$ARCH" = x86 ]; then
|
||||||
install -m 755 -p os-probes/mounted/powerpc/20macosx \
|
install -m 755 -p os-probes/mounted/powerpc/20macosx \
|
||||||
%{buildroot}%{_libexecdir}/os-probes/mounted
|
%{buildroot}%{_libexecdir}/os-probes/mounted
|
||||||
|
install -m 755 -p %SOURCE2 %{buildroot}%{_libexecdir}/os-probes/mounted
|
||||||
|
install -m 755 -d %{buildroot}%{_libexecdir}/os-probes/mounted/efi
|
||||||
|
install -m 755 -p %SOURCE3 \
|
||||||
|
%{buildroot}%{_libexecdir}/os-probes/mounted/efi/20microsoft
|
||||||
|
install -m 755 -p %SOURCE4 \
|
||||||
|
%{buildroot}%{_libexecdir}/os-probes/mounted/efi/10elilo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
%files
|
%files
|
||||||
|
Loading…
Reference in New Issue
Block a user