summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys-boot/os-prober/files/Improve-btrfs-handling-on-os-probing-for-grub2.patch94
-rw-r--r--sys-boot/os-prober/files/os-prober-05efi-blkid.patch18
-rw-r--r--sys-boot/os-prober/files/os-prober-1.49-fix-grub2.cfg-parsing.patch55
-rw-r--r--sys-boot/os-prober/files/os-prober-1.49-grub2-mount.patch68
-rw-r--r--sys-boot/os-prober/files/os-prober-1.76-exherbo.patch26
-rw-r--r--sys-boot/os-prober/files/os-prober-40grub-check-grub2.patch19
-rw-r--r--sys-boot/os-prober/files/os-prober-EFI-openSUSEfy.patch34
-rw-r--r--sys-boot/os-prober/files/os-prober-SUSE.patch13
-rw-r--r--sys-boot/os-prober/files/os-prober-accept-ESP-on-IMSM.patch33
-rw-r--r--sys-boot/os-prober/files/os-prober-btrfs-absolute-subvol.patch41
-rw-r--r--sys-boot/os-prober/files/os-prober-btrfs-always-detect-default.patch131
-rw-r--r--sys-boot/os-prober/files/os-prober-btrfs-multiple-device.patch35
-rw-r--r--sys-boot/os-prober/files/os-prober-btrfs-snapshot-detection.patch31
-rw-r--r--sys-boot/os-prober/files/os-prober-btrfsfix.patch418
-rw-r--r--sys-boot/os-prober/files/os-prober-dont-load-all-fs-module-and-dont-test-mount.patch92
-rw-r--r--sys-boot/os-prober/files/os-prober-fix-btrfs-subvol-mounted-tests.patch84
-rw-r--r--sys-boot/os-prober/files/os-prober-linux-distro-avoid-expensive-ld-file-test.patch295
-rw-r--r--sys-boot/os-prober/files/os-prober-linux-distro-parse-os-release.patch24
-rw-r--r--sys-boot/os-prober/files/os-prober-linux-secure-boot.patch29
-rw-r--r--sys-boot/os-prober/files/os-prober-make-btrfsprogs-optional.patch30
-rw-r--r--sys-boot/os-prober/files/os-prober-multiple-initrd.patch32
-rw-r--r--sys-boot/os-prober/files/os-prober-newnsdirfix.patch10
-rw-r--r--sys-boot/os-prober/files/os-prober-probe-MD-devices.patch26
-rw-r--r--sys-boot/os-prober/files/os-prober-redcore.patch36
-rw-r--r--sys-boot/os-prober/files/os-prober-skip-part-on-multipath.patch42
-rw-r--r--sys-boot/os-prober/files/os-prober-use-tmp-over-var-lib-for-transient-files.patch276
-rw-r--r--sys-boot/os-prober/os-prober-1.77-r10.ebuild (renamed from sys-boot/os-prober/os-prober-1.77-r314.ebuild)31
27 files changed, 1975 insertions, 48 deletions
diff --git a/sys-boot/os-prober/files/Improve-btrfs-handling-on-os-probing-for-grub2.patch b/sys-boot/os-prober/files/Improve-btrfs-handling-on-os-probing-for-grub2.patch
new file mode 100644
index 00000000..ba6ceca7
--- /dev/null
+++ b/sys-boot/os-prober/files/Improve-btrfs-handling-on-os-probing-for-grub2.patch
@@ -0,0 +1,94 @@
+From: Egbert Eich <eich@suse.de>
+Date: Fri May 29 08:55:21 2015 +0200
+Subject: Improve btrfs handling on os-probing for grub2
+Patch-mainline: never
+
+References: bsc#892364
+Signed-off-by: Egbert Eich <eich@suse.com>
+
+Currently probing of a grub2 config file is broken if
+the root/boot fs is btrfs. This is due to a patch picked
+from Fedora which attempts to determine the location of
+the kernel and probe for it.
+This code has meanwhile changed on Fedora, however the
+new version works no better than the old one.
+It is possible that this code works under very special
+circumstances of the Fedora system, however it is by no
+means valid.
+Our goal is to
+a. determine the location of the kernel in the mounted fs
+ regardless whether the grub2 config specifies an absolute
+ or relative path to the kernel file.
+b. Prepend the correct prefix if grub2_btrfs expects an
+ absolute path (either because the current grub2 fs isn't
+ btrfs or absolute path addressing is explicitely requested).
+c. Attempt to handle the location of the kernel file correctly
+ if this lives on a separate btrfs subvolume.
+ (Currently this only works if the path to this subvolume is
+ identical to the fs path).
+
+Signed-off-by: Egbert Eich <eich@suse.de>
+
+v2:
+a. Fix missing linux16/initrd16 parsing in entry result
+b. Fix kernelfile path if separate boot partition on btrfs
+
+Signed-off-by: Michael Chang <mchang@suse.com>
+---
+ linux-boot-probes/mounted/common/40grub2 | 16 +++++++++++++---
+ 1 file changed, 13 insertions(+), 3 deletions(-)
+
+Index: os-prober-1.61/linux-boot-probes/mounted/common/40grub2
+===================================================================
+--- os-prober-1.61.orig/linux-boot-probes/mounted/common/40grub2
++++ os-prober-1.61/linux-boot-probes/mounted/common/40grub2
+@@ -14,9 +14,19 @@ bootsv="$6"
+ found_item=0
+
+ entry_result () {
+- if [ "x$type" = "xbtrfs" -a "$rootsv" = "$bootsv" ]; then
+- # trim off the leading subvol
+- kernelfile=$(echo "$kernel" | cut -d '/' -f 2- | cut -d '/' -f 2-)
++ if [ "x$type" = "xbtrfs" ]; then
++ bsv=${bootsv:+/}${bootsv}
++ # if path is not relative to subvolume make it relative
++ kernel=${kernel#${bsv}}
++ kernelfile=$kernel
++ initrd=${initrd#${bsv}}
++ if [ "x$GRUB_FS" != "xbtrfs" -o "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" != "xtrue" ]; then
++ # absolute path needed: prepend subvolume if $kernel isn't empty
++ kernel=${kernel:+${bsv}}${kernel}
++ initrd=${initrd:+${bsv}}${initrd}
++ fi
++ # assumed: rootsv != bootsv if rootsv isn't ancestor of bootsv
++ [ "$partition" != "$bootpart" -o "$rootsv" != "$bootsv" ] && kernelfile="/boot${kernelfile}"
+ else
+ kernelfile=$kernel
+ fi
+@@ -81,7 +91,7 @@ parse_grub_menu () {
+ ignore_item=1
+ fi
+ ;;
+- linux|linuxefi)
++ linux|linuxefi|linux16)
+ # Hack alert: sed off any (hdn,n) but
+ # assume the kernel is on the same
+ # partition.
+@@ -90,14 +100,14 @@ parse_grub_menu () {
+ parameters="$@"
+ # Systems with a separate /boot will not have
+ # the path to the kernel in grub.cfg.
+- if [ "$partition" != "$bootpart" ]; then
++ if [ "$partition" != "$bootpart" -a "$type" != "btrfs" ]; then
+ kernel="/boot$kernel"
+ fi
+ ;;
+- initrd|initrdefi)
++ initrd|initrdefi|initrd16)
+ initrd="$(echo "$2" | sed 's/(.*)//')"
+ # Initrd same.
+- if [ "$partition" != "$bootpart" ]; then
++ if [ "$partition" != "$bootpart" -a "$type" != "btrfs" ]; then
+ initrd="/boot$initrd"
+ fi
+ ;;
diff --git a/sys-boot/os-prober/files/os-prober-05efi-blkid.patch b/sys-boot/os-prober/files/os-prober-05efi-blkid.patch
new file mode 100644
index 00000000..d8a7113d
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-05efi-blkid.patch
@@ -0,0 +1,18 @@
+Index: os-prober/os-probes/mounted/x86/05efi
+===================================================================
+--- os-prober.orig/os-probes/mounted/x86/05efi
++++ os-prober/os-probes/mounted/x86/05efi
+@@ -46,6 +46,13 @@ if type udevinfo > /dev/null 2>&1; then
+ fi
+ fi
+
++ # udev may not work in chroot as its db may not be there, bailout that by blkid (bsc#1076779)
++ if [ -z "$ID_PART_ENTRY_TYPE" -a -z "$ID_PART_ENTRY_SCHEME" ] &&
++ type blkid > /dev/null 2>&1; then
++ debug "fallback to blkid"
++ eval "$(blkid -p -o udev "$partition" | grep -E '^(ID_PART_ENTRY_(TYPE|SCHEME))=')"
++ fi
++
+ debug "$partition partition scheme is $ID_PART_ENTRY_SCHEME"
+ debug "$partition partition type is $ID_PART_ENTRY_TYPE"
+
diff --git a/sys-boot/os-prober/files/os-prober-1.49-fix-grub2.cfg-parsing.patch b/sys-boot/os-prober/files/os-prober-1.49-fix-grub2.cfg-parsing.patch
new file mode 100644
index 00000000..afd0ff55
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-1.49-fix-grub2.cfg-parsing.patch
@@ -0,0 +1,55 @@
+From: Andrey Borzenkov <arvidjaar@gmail.com>
+Subject: fix parsing GRUB2 grub.cfg
+References: bnc#796919
+
+Fix several problems in parsing of grub.cfg by
+linux-boot-probes/mounted/40grub2
+
+1. Look for /boot/grub2-efi/grub.cfg as well (openSUSE 12.2)
+
+2. It checked for literal "(on /dev/.*)" to filter out menu entries
+added by another os-prober on target system. But grub.cfg now includes
+TRANSLATED strings, so this check will fail if grub.cfg was created in
+non-English locale. Use menu entry ID to check whether entry was added
+by os-prober (it always starts with osprober-). Suggested by Vladimir
+Serbienko.
+Index: os-prober-1.61/linux-boot-probes/mounted/common/40grub2
+===================================================================
+--- os-prober-1.61.orig/linux-boot-probes/mounted/common/40grub2
++++ os-prober-1.61/linux-boot-probes/mounted/common/40grub2
+@@ -43,6 +43,13 @@ parse_grub_menu () {
+ menuentry)
+ entry_result
+ shift 1
++ # Currently GRUB2 puts translated strings
++ # in grub.cfg, so checking for verbatim
++ # (on /dev/.*) will fail if target grub.cfg
++ # was created in non-English locale. Extract
++ # menu entry ID and check if it starts with
++ # "osprober-"
++ id="$(echo "$line" | sed -n 's/^.*[[:space:]]\+\(\$menuentry_id_option\|--id\)[[:space:]]\+\([^[:space:]]\+\).*$/\2/p')"
+ # The double-quoted string is the title.
+ # Make sure to look at the text of the line
+ # before 'set' mangled it.
+@@ -58,9 +65,9 @@ parse_grub_menu () {
+ fi
+ if [ -z "$title" ]; then
+ ignore_item=1
+- elif echo "$title" | grep -q '(on /dev/[^)]*)$'; then
++ elif echo "$title" | grep -q '(on /dev/[^)]*)$' || echo "$id" | grep -q "^\([\"']\|\)osprober-"; then
+ log "Skipping entry '$title':"
+- log "appears to be an automatic reference taken from another menu.lst"
++ log "appears to be an automatic reference taken from another grub.cfg"
+ ignore_item=1
+ fi
+ ;;
+@@ -98,6 +105,9 @@ if [ -e "$mpoint/boot/grub/grub.cfg" ] &
+ [ "$mpoint/boot/grub/grub.cfg" -nt "$mpoint/boot/grub/menu.lst" ]); then
+ debug "parsing grub.cfg"
+ parse_grub_menu "$mpoint" "$partition" "$bootpart" < "$mpoint/boot/grub/grub.cfg"
++elif [ -e "$mpoint/boot/grub2-efi/grub.cfg" ]; then
++ debug "parsing grub.cfg"
++ parse_grub_menu "$mpoint" "$partition" "$bootpart" < "$mpoint/boot/grub2-efi/grub.cfg"
+ elif [ -e "$mpoint/boot/grub2/grub.cfg" ]; then
+ debug "parsing grub.cfg"
+ parse_grub_menu "$mpoint" "$partition" "$bootpart" < "$mpoint/boot/grub2/grub.cfg"
diff --git a/sys-boot/os-prober/files/os-prober-1.49-grub2-mount.patch b/sys-boot/os-prober/files/os-prober-1.49-grub2-mount.patch
new file mode 100644
index 00000000..18c17546
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-1.49-grub2-mount.patch
@@ -0,0 +1,68 @@
+Index: os-prober-1.76/common.sh
+===================================================================
+--- os-prober-1.76.orig/common.sh
++++ os-prober-1.76/common.sh
+@@ -279,8 +279,8 @@ linux_mount_boot () {
+ debug "found boot partition $1 for linux system on $partition, but cannot map to existing device"
+ else
+ debug "found boot partition $bootpart for linux system on $partition"
+- if type grub-mount >/dev/null 2>&1 && \
+- grub-mount "$boottomnt" "$tmpmnt/boot" 2>/dev/null; then
++ if type grub2-mount >/dev/null 2>&1 && \
++ grub2-mount "$boottomnt" "$tmpmnt/boot" 2>/dev/null; then
+ mounted=1
+ fi
+ fi
+Index: os-prober-1.76/linux-boot-probes/common/50mounted-tests
+===================================================================
+--- os-prober-1.76.orig/linux-boot-probes/common/50mounted-tests
++++ os-prober-1.76/linux-boot-probes/common/50mounted-tests
+@@ -48,11 +48,11 @@ if [ ! -d "$tmpmnt" ]; then
+ fi
+
+ mounted=
+-if type grub-mount >/dev/null 2>&1 && \
+- type grub-probe >/dev/null 2>&1 && \
+- grub-mount "$partition" "$tmpmnt" 2>/dev/null; then
++if type grub2-mount >/dev/null 2>&1 && \
++ type grub2-probe >/dev/null 2>&1 && \
++ grub2-mount "$partition" "$tmpmnt" 2>/dev/null; then
+ mounted=1
+- type="$(grub-probe -d "$partition" -t fs)"
++ type="$(grub2-probe -d "$partition" -t fs)"
+ [ "$type" ] || type=fuseblk
+ fi
+
+Index: os-prober-1.76/os-probes/common/50mounted-tests
+===================================================================
+--- os-prober-1.76.orig/os-probes/common/50mounted-tests
++++ os-prober-1.76/os-probes/common/50mounted-tests
+@@ -58,11 +58,11 @@ if [ ! -d "$tmpmnt" ]; then
+ fi
+
+ mounted=
+-if type grub-mount >/dev/null 2>&1 && \
+- type grub-probe >/dev/null 2>&1 && \
+- grub-mount "$partition" "$tmpmnt" 2>/dev/null; then
++if type grub2-mount >/dev/null 2>&1 && \
++ type grub2-probe >/dev/null 2>&1 && \
++ grub2-mount "$partition" "$tmpmnt" 2>/dev/null; then
+ mounted=1
+- type="$(grub-probe -d "$partition" -t fs)" || true
++ type="$(grub2-probe -d "$partition" -t fs)" || true
+ if [ "$type" ]; then
+ debug "mounted using GRUB $type filesystem driver"
+ else
+Index: os-prober-1.76/os-probes/init/common/10filesystems
+===================================================================
+--- os-prober-1.76.orig/os-probes/init/common/10filesystems
++++ os-prober-1.76/os-probes/init/common/10filesystems
+@@ -3,7 +3,7 @@
+ set +e # ignore errors from modprobe
+
+ FILESYSTEMS='ext2 ext3 ext4 xfs jfs msdos vfat ntfs minix hfs hfsplus qnx4 ufs btrfs'
+-# fuse is needed to make grub-mount work.
++# fuse is needed to make grub2-mount work.
+ FILESYSTEMS="$FILESYSTEMS fuse"
+ # The Ubuntu kernel udebs put a number of filesystem modules in
+ # fs-{core,secondary}-modules. It's fairly cheap to check for these too.
diff --git a/sys-boot/os-prober/files/os-prober-1.76-exherbo.patch b/sys-boot/os-prober/files/os-prober-1.76-exherbo.patch
deleted file mode 100644
index 6ef83dca..00000000
--- a/sys-boot/os-prober/files/os-prober-1.76-exherbo.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From 09fefdb360b69c2de03a2f1c881db87f924d3c76 Mon Sep 17 00:00:00 2001
-From: Timo Gurr <timo.gurr@gmail.com>
-Date: Mon, 20 Feb 2017 17:33:14 +0100
-Subject: [PATCH] Add Exherbo Linux detection
-
----
- os-probes/mounted/common/90linux-distro | 3 +++
- 1 file changed, 3 insertions(+)
-
-diff --git a/os-probes/mounted/common/90linux-distro b/os-probes/mounted/common/90linux-distro
-index badfbb1..41a5553 100755
---- a/os-probes/mounted/common/90linux-distro
-+++ b/os-probes/mounted/common/90linux-distro
-@@ -137,6 +137,9 @@ if (ls "$dir"/lib*/ld*.so* && [ -d "$dir/boot" ] || ls "$dir"/usr/lib*/ld*.so*)
- elif [ -e "$dir/etc/devuan_version" ]; then
- short="Devuan"
- long="$(printf "Devuan GNU/Linux (%s)\n" "$(cat "$dir/etc/devuan_version")")"
-+ elif [ -e "$dir/etc/exherbo-release" ]; then
-+ short="Exherbo"
-+ long="Exherbo Linux"
- else
- short="Linux"
- long="unknown Linux distribution"
---
-2.11.1
-
diff --git a/sys-boot/os-prober/files/os-prober-40grub-check-grub2.patch b/sys-boot/os-prober/files/os-prober-40grub-check-grub2.patch
new file mode 100644
index 00000000..13bac3dd
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-40grub-check-grub2.patch
@@ -0,0 +1,19 @@
+From: Andrei Borzenkov <arvidjaar@gmail.com>
+Subject: Also skip legacy grub if grub2 is found
+
+Check for grub.cfg also in /boot/grub2, not only in /boot/grub.
+Index: os-prober/linux-boot-probes/mounted/x86/40grub
+===================================================================
+--- os-prober.orig/linux-boot-probes/mounted/x86/40grub
++++ os-prober/linux-boot-probes/mounted/x86/40grub
+@@ -95,7 +95,9 @@ fi
+
+ if [ "$grubconf" ] && \
+ ([ ! -e "$mpoint/boot/grub/grub.cfg" ] || \
+- [ "$mpoint/boot/grub/$grubconf" -nt "$mpoint/boot/grub/grub.cfg" ]); then
++ [ "$mpoint/boot/grub/$grubconf" -nt "$mpoint/boot/grub/grub.cfg" ]) && \
++ ([ ! -e "$mpoint/boot/grub2/grub.cfg" ] || \
++ [ "$mpoint/boot/grub/$grubconf" -nt "$mpoint/boot/grub2/grub.cfg" ]); then
+ debug "parsing $grubconf"
+ parse_grub_menu "$mpoint" "$partition" "$bootpart" < "$mpoint/boot/grub/$grubconf"
+ fi
diff --git a/sys-boot/os-prober/files/os-prober-EFI-openSUSEfy.patch b/sys-boot/os-prober/files/os-prober-EFI-openSUSEfy.patch
new file mode 100644
index 00000000..4cd9e485
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-EFI-openSUSEfy.patch
@@ -0,0 +1,34 @@
+From: Andrey Borzenkov <arvidjaar@gmail.com>
+Subject: keep UEFI scripts the same as they were in openSUSE
+
+Small cosmetic changes to ensure UEFI scripts keep content
+after upstream merged (slightly outdated) version of them.
+
+- retain ELILO vendor prefix in case someone is really using it
+
+- comment in 05efi is obviously wrong
+Index: os-prober/os-probes/mounted/x86/efi/10elilo
+===================================================================
+--- os-prober.orig/os-probes/mounted/x86/efi/10elilo
++++ os-prober/os-probes/mounted/x86/efi/10elilo
+@@ -11,7 +11,8 @@ elilo=`find $1 -name "elilo.efi"`
+ if [ -n "$elilo" ]; then
+ bdir="${elilo%/*}"
+ bdir="${elilo##*/}"
+- long="ELILO Boot Manager"
++ vendor=$(echo $bdir | sed 's|SuSE|SUSE|')
++ long="${vendor} ELILO Boot Manager"
+ short="ELILO"
+ path=${bdir}/elilo.efi
+ found=true
+Index: os-prober/os-probes/mounted/x86/05efi
+===================================================================
+--- os-prober.orig/os-probes/mounted/x86/05efi
++++ os-prober/os-probes/mounted/x86/05efi
+@@ -1,5 +1,5 @@
+ #!/bin/sh
+-# Detects all Microsoft OSes on a collection of partitions.
++# Detects all UEFI bootloaders on EFI System Partition
+
+ . /usr/share/os-prober/common.sh
+
diff --git a/sys-boot/os-prober/files/os-prober-SUSE.patch b/sys-boot/os-prober/files/os-prober-SUSE.patch
new file mode 100644
index 00000000..15b9e843
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-SUSE.patch
@@ -0,0 +1,13 @@
+Index: os-prober-1.57/os-probes/mounted/common/90linux-distro
+===================================================================
+--- os-prober-1.57.orig/os-probes/mounted/common/90linux-distro
++++ os-prober-1.57/os-probes/mounted/common/90linux-distro
+@@ -84,7 +84,7 @@ if (ls "$dir"/lib*/ld*.so* || ls "$dir"/
+ short="RedHat"
+ long="$(cat "$dir/etc/redhat-release")"
+ elif [ -e "$dir/etc/SuSE-release" ]; then
+- short="SuSE"
++ short="SUSE"
+ long="$(head -n 1 "$dir/etc/SuSE-release")"
+ elif [ -e "$dir/etc/gentoo-release" ]; then
+ short="Gentoo"
diff --git a/sys-boot/os-prober/files/os-prober-accept-ESP-on-IMSM.patch b/sys-boot/os-prober/files/os-prober-accept-ESP-on-IMSM.patch
new file mode 100644
index 00000000..bacf2065
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-accept-ESP-on-IMSM.patch
@@ -0,0 +1,33 @@
+Index: os-prober-1.76/os-probes/mounted/x86/05efi
+===================================================================
+--- os-prober-1.76.orig/os-probes/mounted/x86/05efi
++++ os-prober-1.76/os-probes/mounted/x86/05efi
+@@ -28,13 +28,24 @@ if type udevadm > /dev/null 2>&1; then
+ fi
+
+ if type udevinfo > /dev/null 2>&1; then
+- # Skip virtual devices
++ eval "$(udevinfo -q property -n "$partition" | grep -E '^(MD_CONTAINER|ID_PART_ENTRY_(TYPE|SCHEME))=')"
++ debug "$partition container is '$MD_CONTAINER'"
++
++ # Skip virtual devices unless they are known SW-RAID
+ if udevinfo -q path -n $partition | grep -q /virtual/; then
+- debug "$1 is virtual device: exiting"
+- exit 1
++ # Check for Intel Matrix array
++ if [ -n "$MD_CONTAINER" ]; then
++ eval "$(udevinfo -q property -n "$MD_CONTAINER" | grep -E '^MD_METADATA=')"
++ debug "$MD_CONTAINER metadata is '$MD_METADATA'"
++ fi
++ if [ "$MD_METADATA" = imsm ]; then
++ debug "$partition is on IMSM array"
++ else
++ debug "$1 is virtual device: exiting"
++ exit 1
++ fi
+ 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"
+
diff --git a/sys-boot/os-prober/files/os-prober-btrfs-absolute-subvol.patch b/sys-boot/os-prober/files/os-prober-btrfs-absolute-subvol.patch
new file mode 100644
index 00000000..5b8ff050
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-btrfs-absolute-subvol.patch
@@ -0,0 +1,41 @@
+Index: os-prober/os-probes/common/50mounted-tests
+===================================================================
+--- os-prober.orig/os-probes/common/50mounted-tests
++++ os-prober/os-probes/common/50mounted-tests
+@@ -72,9 +72,7 @@ mounted=
+
+ if [ "$types" = btrfs ]; then
+ partition="$BTRFSDEV"
+-fi
+-
+-if type grub2-mount >/dev/null 2>&1 && \
++elif type grub2-mount >/dev/null 2>&1 && \
+ type grub2-probe >/dev/null 2>&1 && \
+ grub2-mount "$partition" "$tmpmnt" 2>/dev/null; then
+ mounted=1
+@@ -110,7 +108,11 @@ if [ "$mounted" ]; then
+ fi
+ done
+ fi
+-do_unmount
++
++if [ "$types" != "btrfs" ]; then
++ do_unmount
++ exit 1
++fi
+
+ # all btrfs processing here. Handle both unmounted and
+ # mounted subvolumes.
+@@ -125,9 +127,9 @@ if [ "$types" = btrfs ]; then
+ exit 1
+ fi
+ # besides regular subvols, get ro and snapshot so thet can be excluded
+- subvols=$(btrfs subvolume list "$tmpmnt" | cut -d ' ' -f 9)
+- rosubvols=$(btrfs subvolume list -r "$tmpmnt" | cut -d ' ' -f 9)
+- sssubvols=$(btrfs subvolume list -s "$tmpmnt" | cut -d ' ' -f 14)
++ subvols=$(btrfs subvolume list -a "$tmpmnt" | cut -d ' ' -f 9 | sed -e s!^\<FS_TREE\>/!!)
++ rosubvols=$(btrfs subvolume list -r -a "$tmpmnt" | cut -d ' ' -f 9 | sed -e s!^\<FS_TREE\>/!!)
++ sssubvols=$(btrfs subvolume list -s -a "$tmpmnt" | cut -d ' ' -f 14 | sed -e s!^\<FS_TREE\>/!!)
+ if ! umount "$tmpmnt"; then
+ warn "failed to umount btrfs volume on $tmpmnt"
+ rmdir "$tmpmnt" || true
diff --git a/sys-boot/os-prober/files/os-prober-btrfs-always-detect-default.patch b/sys-boot/os-prober/files/os-prober-btrfs-always-detect-default.patch
new file mode 100644
index 00000000..d8ebe56f
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-btrfs-always-detect-default.patch
@@ -0,0 +1,131 @@
+Index: os-prober/linux-boot-prober
+===================================================================
+--- os-prober.orig/linux-boot-prober
++++ os-prober/linux-boot-prober
+@@ -67,7 +67,12 @@ if [ "$type" = btrfs ]; then
+ fi
+ if [ -z "$mpoint" ]; then
+ # mount the btrfs root
+- if ! mount -o subvol=$subvol -t btrfs -U $UUID "$tmpmnt" 2>/dev/null; then
++
++ if [ -n "$subvol" ]; then
++ opts="-o subvol=$subvol"
++ fi
++
++ if ! mount $opts -t btrfs -U $UUID "$tmpmnt" 2>/dev/null; then
+ warn "error mounting btrfs subvol=$subvol UUID=$UUID"
+ umount "$tmpmnt/boot" 2>/dev/null
+ umount "$tmpmnt" 2>/dev/null
+Index: os-prober/os-probes/common/50mounted-tests
+===================================================================
+--- os-prober.orig/os-probes/common/50mounted-tests
++++ os-prober/os-probes/common/50mounted-tests
+@@ -114,6 +114,47 @@ if [ "$types" != "btrfs" ]; then
+ exit 1
+ fi
+
++probe_subvol ()
++{
++ local subvol=$1
++ local partition=$2
++ local UUID=$3
++ local tmpmnt=$4
++
++ mounted=
++ mpoint="$(grep btrfs /proc/self/mountinfo | grep "$partition " | grep "/$subvol " | cut -d ' ' -f 5)"
++ ret=1
++
++ if [ -n "$subvol" ]; then
++ opts="-o subvol=$subvol"
++ fi
++
++ if [ -n "$mpoint" ]; then
++ if [ "x$mpoint" = "x/" ]; then
++ continue # this is the root for the running system
++ fi
++ mounted=1
++ else
++ # again, do not mount btrfs ro
++ mount -t btrfs $opts -U "$UUID" "$tmpmnt"
++ mpoint="$tmpmnt"
++ fi
++ test="/usr/lib/os-probes/mounted/90linux-distro"
++ if [ -f "$test" ] && [ -x "$test" ]; then
++ debug "running subtest $test"
++ if "$test" "$partition" "$mpoint" btrfs "UUID=$UUID" "subvol=$subvol"; then
++ debug "os found by subtest $test on subvol $subvol"
++ ret=0
++ fi
++ fi
++ if [ -z "$mounted" ]; then
++ if ! umount "$tmpmnt"; then
++ warn "failed to umount $tmpmnt"
++ fi
++ fi
++ return $ret
++}
++
+ # all btrfs processing here. Handle both unmounted and
+ # mounted subvolumes.
+ if [ "$types" = btrfs ]; then
+@@ -136,45 +177,23 @@ if [ "$types" = btrfs ]; then
+ rmdir "$tmpmnt" || true
+ exit 1
+ fi
+- if [ -z "$subvols" ]; then
+- debug "no subvols found on btrfs volume $UUID"
+- exit 1
+- fi
++
+ found=
+- for subvol in $subvols; do
+- debug "begin btrfs processing for $UUID subvol=$subvol"
+- if [ "$subvol" != "$defaultvol" ]; then
+- if echo "$rosubvols" | grep -q -x "$subvol"; then
+- continue
+- fi
+- if echo "$sssubvols" | grep -q -x "$subvol"; then
+- continue
+- fi
+- fi
+- mounted=
+- mpoint="$(grep btrfs /proc/self/mountinfo | grep "$partition " | grep "/$subvol " | cut -d ' ' -f 5)"
+- if [ -n "$mpoint" ]; then
+- if [ "x$mpoint" = "x/" ]; then
+- continue # this is the root for the running system
+- fi
+- mounted=1
+- else
+- # again, do not mount btrfs ro
+- mount -t btrfs -o subvol="$subvol" -U "$UUID" "$tmpmnt"
+- mpoint="$tmpmnt"
+- fi
+- test="/usr/lib/os-probes/mounted/90linux-distro"
+- if [ -f "$test" ] && [ -x "$test" ]; then
+- debug "running subtest $test"
+- if "$test" "$partition" "$mpoint" btrfs "UUID=$UUID" "subvol=$subvol"; then
+- debug "os found by subtest $test on subvol $subvol"
+- found=1
+- fi
++ # Always probe subvol or root set as default
++ if probe_subvol "$defaultvol" "$partition" "$UUID" "$tmpmnt"; then
++ found=1
++ fi
++
++ # Probe any other OS on subvol
++ for subvol in $subvols; do
++ if echo "$rosubvols" | grep -q -x "$subvol" ||
++ echo "$sssubvols" | grep -q -x "$subvol" ||
++ echo "$defaultvol" | grep -q -x "$subvol"; then
++ continue
+ fi
+- if [ -z "$mounted" ]; then
+- if ! umount "$tmpmnt"; then
+- warn "failed to umount $tmpmnt"
+- fi
++ debug "begin btrfs processing for $UUID subvol=$subvol"
++ if probe_subvol "$subvol" "$partition" "$UUID" "$tmpmnt"; then
++ found=1
+ fi
+ done
+ rmdir "$tmpmnt" || true
diff --git a/sys-boot/os-prober/files/os-prober-btrfs-multiple-device.patch b/sys-boot/os-prober/files/os-prober-btrfs-multiple-device.patch
new file mode 100644
index 00000000..8da09a1d
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-btrfs-multiple-device.patch
@@ -0,0 +1,35 @@
+Index: os-prober-1.76/os-prober
+===================================================================
+--- os-prober-1.76.orig/os-prober
++++ os-prober-1.76/os-prober
+@@ -161,6 +161,15 @@ fi
+
+ : >"$OS_PROBER_TMP/btrfs-vols"
+
++btrfsrootdev=$(sed -n -e 's!\([^\s]\+\)\s\+\(/\|/target/boot\|/target\)\s\+btrfs!\1!p;ta;b;:a;q' "$OS_PROBER_TMP/mounted-map")
++if [ -n "$btrfsrootdev" ] ; then
++ if btrfsrootdev="$(mapdevfs "$btrfsrootdev")"; then
++ btrfsrootdevuuid=$(blkid -o value -s UUID "$btrfsrootdev")
++ debug "btrfs is mounted as root, uuid: $btrfsrootdevuuid"
++ echo "$btrfsrootdevuuid" >>"$OS_PROBER_TMP/btrfs-vols"
++ fi
++fi
++
+ for partition in $(partitions); do
+ if ! mapped="$(mapdevfs "$partition")"; then
+ log "Device '$partition' does not exist; skipping"
+@@ -183,13 +192,9 @@ for partition in $(partitions); do
+ # be handled by 50mounted-tests so we can do a subvol only once.
+ type=$(blkid -o value -s TYPE $mapped || true)
+ if [ "$type" = btrfs ]; then
+- mpoint=$(grep "^$mapped " "$OS_PROBER_TMP/mounted-map" | head -n1 | cut -d " " -f 2)
+- mpoint="$(unescape_mount "$mpoint")"
+- if [ "$mpoint" = "/target/boot" ] || [ "$mpoint" = "/target" ] || [ "$mpoint" = "/" ]; then
+- continue
+- fi
+ uuid=$(blkid -o value -s UUID $mapped)
+ if grep -q "^$uuid" "$OS_PROBER_TMP/btrfs-vols" ; then
++ debug "skipped btrfs partition=$partition uuid=$uuid"
+ continue
+ fi
+ debug "btrfs volume uuid=$uuid partition=$partition"
diff --git a/sys-boot/os-prober/files/os-prober-btrfs-snapshot-detection.patch b/sys-boot/os-prober/files/os-prober-btrfs-snapshot-detection.patch
new file mode 100644
index 00000000..60c9a2f3
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-btrfs-snapshot-detection.patch
@@ -0,0 +1,31 @@
+Index: os-prober/os-probes/common/50mounted-tests
+===================================================================
+--- os-prober.orig/os-probes/common/50mounted-tests
++++ os-prober/os-probes/common/50mounted-tests
+@@ -115,6 +115,7 @@ if [ "$types" = btrfs ]; then
+ subvols=$(btrfs subvolume list -a "$tmpmnt" | cut -d ' ' -f 9 | sed -e s!^\<FS_TREE\>/!!)
+ rosubvols=$(btrfs subvolume list -r -a "$tmpmnt" | cut -d ' ' -f 9 | sed -e s!^\<FS_TREE\>/!!)
+ sssubvols=$(btrfs subvolume list -s -a "$tmpmnt" | cut -d ' ' -f 14 | sed -e s!^\<FS_TREE\>/!!)
++ defaultvol=$(btrfs subvolume get-default "$tmpmnt" | cut -d ' ' -f 9)
+ if ! umount "$tmpmnt"; then
+ warn "failed to umount btrfs volume on $tmpmnt"
+ rmdir "$tmpmnt" || true
+@@ -127,11 +128,13 @@ if [ "$types" = btrfs ]; then
+ found=
+ for subvol in $subvols; do
+ debug "begin btrfs processing for $UUID subvol=$subvol"
+- if echo "$rosubvols" | grep -q -x "$subvol"; then
+- continue
+- fi
+- if echo "$sssubvols" | grep -q -x "$subvol"; then
+- continue
++ if [ "$subvol" != "$defaultvol" ]; then
++ if echo "$rosubvols" | grep -q -x "$subvol"; then
++ continue
++ fi
++ if echo "$sssubvols" | grep -q -x "$subvol"; then
++ continue
++ fi
+ fi
+ mounted=
+ mpoint="$(grep btrfs /proc/self/mountinfo | grep "$partition " | grep "/$subvol " | cut -d ' ' -f 5)"
diff --git a/sys-boot/os-prober/files/os-prober-btrfsfix.patch b/sys-boot/os-prober/files/os-prober-btrfsfix.patch
new file mode 100644
index 00000000..bb5e6c03
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-btrfsfix.patch
@@ -0,0 +1,418 @@
+Index: os-prober/common.sh
+===================================================================
+--- os-prober.orig/common.sh
++++ os-prober/common.sh
+@@ -155,6 +155,7 @@ parse_proc_mounts () {
+ done
+ }
+
++# add forth parameter to pickup btrfs subvol info
+ parsefstab () {
+ while read -r line; do
+ case "$line" in
+@@ -165,12 +166,22 @@ parsefstab () {
+ set -f
+ set -- $line
+ set +f
+- printf '%s %s %s\n' "$1" "$2" "$3"
++ printf '%s %s %s %s\n' "$1" "$2" "$3" "$4"
+ ;;
+ esac
+ done
+ }
+
++#check_btrfs_mounted $bootsv $bootuuid)
++check_btrfs_mounted () {
++ bootsv="$1"
++ bootuuid="$2"
++ bootdev=$(blkid | grep "$bootuuid" | cut -d ':' -f 1)
++ bindfrom=$(grep " btrfs " /proc/self/mountinfo |
++ grep " $bootdev " | grep " /$bootsv " | cut -d ' ' -f 5)
++ printf "%s" "$bindfrom"
++}
++
+ unescape_mount () {
+ printf %s "$1" | \
+ sed 's/\\011/ /g; s/\\012/\n/g; s/\\040/ /g; s/\\134/\\/g'
+Index: os-prober/linux-boot-prober
+===================================================================
+--- os-prober.orig/linux-boot-prober
++++ os-prober/linux-boot-prober
+@@ -5,16 +5,143 @@ set -e
+
+ newns "$@"
+ require_tmpdir
++ERR="n"
++
++tmpmnt=/var/lib/os-prober/mount
++if [ ! -d "$tmpmnt" ]; then
++ mkdir "$tmpmnt"
++fi
++
++mounted=
++bootmnt=
++bootsv=
++bootuuid=
+
+ grep "^/dev/" /proc/mounts | parse_proc_mounts >"$OS_PROBER_TMP/mounted-map" || true
+
+-partition="$1"
++if [ -z "$1" ]; then
++ ERR=y
++elif [ "$1" = btrfs -a -z "$2" ]; then
++ ERR=y
++elif [ "$1" = btrfs -a -z "$3" ]; then
++ ERR=y
++elif [ "$1" = btrfs ]; then
++ type=btrfs
++ echo "$2" | grep -q "^UUID=" || ERR=y
++ echo "$3" | grep -q "^subvol=" || ERR=y
++ export "$2"
++ export "$3"
++ partition=$(blkid | grep "$UUID" | cut -d ':' -f 1 | tr '\n' ' ' | cut -d ' ' -f 1)
++ debug "btrfs: partition=$partition, UUID=$UUID, subvol=$subvol"
++else
++ partition="$1"
++ type=other
++fi
+
+-if [ -z "$partition" ]; then
++if [ "x$ERR" != xn ]; then
+ echo "usage: linux-boot-prober partition" >&2
++ echo " linux-boot-prober partition | btrfs UUID=<> subvol=<>" >&2
+ exit 1
+ fi
+
++if [ "$type" = btrfs ]; then
++ # handle all of the btrfs stuff here
++ if [ ! -e "/proc/self/mountinfo" ]; then
++ warn "/proc/self/mountinfo does not exist, exiting"
++ umount "$tmpmnt" 2>/dev/null
++ rmdir "$tmpmnt" 2>/dev/null
++ exit 1
++ fi
++ mpoint=$(grep "btrfs" /proc/self/mountinfo | grep " /$subvol " | grep " $partition " | cut -d ' ' -f 5)
++ if [ "$mpoint" = "/" ]; then
++ warn "specifying active root not valid, exiting"
++ umount "$tmpmnt" 2>/dev/null
++ rmdir "$tmpmnt" 2>/dev/null
++ exit 1
++ fi
++ if [ "$mpoint" = "$tmpmnt" ]; then
++ warn "btrfs subvol=$subvool, UUID=$UUID, already mounted on $tmpmnt **ERROR**"
++ umount "$tmpmnt" 2>/dev/null
++ rmdir "$tmpmnt" 2>/dev/null
++ exit 1
++ fi
++ if [ -z "$mpoint" ]; then
++ # mount the btrfs root
++ if ! mount -o subvol=$subvol -t btrfs -U $UUID "$tmpmnt" 2>/dev/null; then
++ warn "error mounting btrfs subvol=$subvol UUID=$UUID"
++ umount "$tmpmnt/boot" 2>/dev/null
++ umount "$tmpmnt" 2>/dev/null
++ rmdir "$tmpmnt" 2>/dev/null
++ exit 1
++ fi
++ else
++ # bind-mount
++ if ! mount -o bind "$mpoint" "$tmpmnt" 2>/dev/null; then
++ warn "error mounting btrfs bindfrom=$mpoint subvol=$subvol UUID=$UUID"
++ umount "$tmpmnt/boot" 2>/dev/null
++ umount "$tmpmnt" 2>/dev/null
++ rmdir "$tmpmnt" 2>/dev/null
++ exit 1
++ fi
++ fi
++ debug "mounted btrfs $partition, subvol=$subvol on $tmpmnt"
++ if [ ! -e "$tmpmnt/etc/fstab" ]; then
++ warn "btrfs subvol=$subvol not root"
++ umount "$tmpmnt" 2>/dev/null
++ rmdir "$tmpmnt" 2>/dev/null
++ exit 1
++ fi
++ bootmnt=$(parsefstab < "$tmpmnt/etc/fstab" | grep " /boot ") || true
++ if [ -z "$bootmnt" ]; then
++ # /boot is part of the root
++ bootpart="$partition"
++ bootsv="$subvol"
++ elif echo "$bootmnt" | cut -d ' ' -f 3 | grep -q "btrfs"; then
++ # separate btrfs /boot subvolume
++ bootsv=$(echo "$bootmnt" | cut -d ' ' -f 4 | grep "^subvol=" | sed "s/subvol=//" )
++ bootuuid=$(echo "$bootmnt" | cut -d ' ' -f 1 | grep "^UUID=" | sed "s/UUID=//" )
++ debug "mounting btrfs $tmpmnt/boot UUID=$bootuuid subvol=$bootsv"
++ bindfrom=$(check_btrfs_mounted $bootsv $bootuuid)
++ if [ -n "$bindfrom" ]; then
++ # already mounted some place
++ if ! mount -o bind $bindfrom "$tmpmnt/boot" 2>/dev/null; then
++ warn "error bind mounting btrfs boot subvol=$bootsv, from=$bindfrom"
++ umount "$tmpmnt/boot" 2>/dev/null
++ umount "$tmpmnt" 2>/dev/null
++ rmdir "$tmpmnt" 2>/dev/null
++ exit 1
++ fi
++ elif ! mount -o subvol=$bootsv -t btrfs -U $bootuuid "$tmpmnt/boot" 2>/dev/null; then
++ warn "error mounting btrfs boot partition subvol=$bootsv, UUID=$bootuuid"
++ umount "$tmpmnt/boot" 2>/dev/null
++ umount "$tmpmnt" 2>/dev/null
++ rmdir "$tmpmnt" 2>/dev/null
++ exit 1
++ fi
++ bootpart=$(grep " btrfs " /proc/self/mountinfo | grep " /$bootsv " | cut -d ' ' -f 10)
++ else
++ # non-btrfs partition or logical volume
++ linux_mount_boot $partition $tmpmnt
++ bootpart="${mountboot%% *}"
++ bootsv=
++ fi
++
++ test="/usr/lib/linux-boot-probes/mounted/40grub2"
++ if [ -f $test ] && [ -x $test ]; then
++ debug "running $test $partition $bootpart $tmpmnt $type $subvol $bootsv"
++ if $test "$partition" "$bootpart" "$tmpmnt" "$type" "$subvol" "$bootsv"; then
++ debug "$test succeeded"
++ fi
++ fi
++ umount "$tmpmnt/boot" 2>/dev/null || true
++ if ! umount "$tmpmnt" 2>/dev/null; then
++ warn "problem umount $tmpmnt"
++ fi
++ rmdir "$tmpmnt" 2>/dev/null || true
++
++ exit 0
++fi
++
+ if ! mapped="$(mapdevfs "$partition")"; then
+ log "Device '$partition' does not exist; skipping"
+ continue
+Index: os-prober/linux-boot-probes/mounted/common/40grub2
+===================================================================
+--- os-prober.orig/linux-boot-probes/mounted/common/40grub2
++++ os-prober/linux-boot-probes/mounted/common/40grub2
+@@ -2,17 +2,27 @@
+ . /usr/share/os-prober/common.sh
+ set -e
+
++# add support for btrfs with no separate /boot
++# that is, rootsv = bootsv
+ partition="$1"
+ bootpart="$2"
+ mpoint="$3"
+ type="$4"
++rootsv="$5"
++bootsv="$6"
+
+ found_item=0
+
+ entry_result () {
++ if [ "x$type" = "xbtrfs" -a "$rootsv" = "$bootsv" ]; then
++ # trim off the leading subvol
++ kernelfile=$(echo "$kernel" | cut -d '/' -f 2- | cut -d '/' -f 2-)
++ else
++ kernelfile=$kernel
++ fi
+ if [ "$ignore_item" = 0 ] && \
+ [ -n "$kernel" ] && \
+- [ -e "$mpoint/$kernel" ]; then
++ [ -e "$mpoint/$kernelfile" ]; then
+ result "$rootpart:$bootpart:$title:$kernel:$initrd:$parameters"
+ found_item=1
+ fi
+Index: os-prober/os-prober
+===================================================================
+--- os-prober.orig/os-prober
++++ os-prober/os-prober
+@@ -79,6 +79,9 @@ partitions () {
+ echo "$(LVM_SUPPRESS_FD_WARNINGS=1 log_output lvs --noheadings --separator : -o vg_name,lv_name |
+ sed "s|-|--|g;s|^[[:space:]]*\(.*\):\(.*\)$|/dev/mapper/\1-\2|")"
+ fi
++
++ # now lets make sure we got all of the btrfs partitions and disks
++ blkid | grep btrfs | cut -d ':' -f 1
+ }
+
+ parse_proc_swaps () {
+@@ -137,6 +140,8 @@ if [ -f /proc/mdstat ] ; then
+ grep "^md" /proc/mdstat | parse_proc_mdstat >"$OS_PROBER_TMP/raided-map" || true
+ fi
+
++: >"$OS_PROBER_TMP/btrfs-vols"
++
+ for partition in $(partitions); do
+ if ! mapped="$(mapdevfs "$partition")"; then
+ log "Device '$partition' does not exist; skipping"
+@@ -155,7 +160,26 @@ for partition in $(partitions); do
+ continue
+ fi
+
+- if ! grep -q "^$mapped " "$OS_PROBER_TMP/mounted-map" ; then
++ # do btrfs processing here; both mounted and unmounted will
++ # be handled by 50mounted-tests so we can do a subvol only once.
++ type=$(blkid -o value -s TYPE $mapped || true)
++ if [ "$type" = btrfs ]; then
++ uuid=$(blkid -o value -s UUID $mapped)
++ if grep -q "^$uuid" "$OS_PROBER_TMP/btrfs-vols" ; then
++ continue
++ fi
++ debug "btrfs volume uuid=$uuid partition=$partition"
++ echo "$uuid" >>"$OS_PROBER_TMP/btrfs-vols"
++ test="/usr/lib/os-probes/50mounted-tests"
++ if [ -f "$test" ] && [ -x "$test" ]; then
++ debug "running $test on btrfs $partition"
++ if "$test" btrfs "$uuid" "$partition"; then
++ debug "os detected by $test"
++ continue
++ fi
++ fi
++
++ elif ! grep -q "^$mapped " "$OS_PROBER_TMP/mounted-map" ; then
+ for test in /usr/lib/os-probes/*; do
+ if [ -f "$test" ] && [ -x "$test" ]; then
+ debug "running $test on $partition"
+Index: os-prober/os-probes/common/50mounted-tests
+===================================================================
+--- os-prober.orig/os-probes/common/50mounted-tests
++++ os-prober/os-probes/common/50mounted-tests
+@@ -19,7 +19,19 @@ do_unmount() {
+ rmdir "$tmpmnt" || true
+ }
+
+-types="$(fs_type "$partition")"
++if [ "x$1" = xbtrfs ]; then
++ types=btrfs
++ if [ -z "$2" -o -z "$3" ]; then
++ debug "missing btrfs parameters, exiting"
++ exit 1
++ fi
++ UUID="$2"
++ BTRFSDEV="$3"
++else
++ partition="$1"
++ types="$(fs_type "$partition")"
++fi
++
+ if [ "$types" = NOT-DETECTED ]; then
+ debug "$1 type not recognised; skipping"
+ exit 0
+@@ -66,6 +78,76 @@ if [ ! -d "$tmpmnt" ]; then
+ fi
+
+ mounted=
++
++# all btrfs processing here. Handle both unmounted and
++# mounted subvolumes.
++if [ "$types" = btrfs ]; then
++ partition="$BTRFSDEV"
++ debug "begin btrfs processing for $UUID"
++ # note that the btrfs volume must not be mounted ro
++ if mount -t btrfs -U "$UUID" "$tmpmnt" 2>/dev/null; then
++ debug "btrfs volume $UUID mounted"
++ else
++ warn "cannot mount btrfs volume $UUID, exiting"
++ rmdir "$tmpmnt" || true
++ exit 1
++ fi
++ # besides regular subvols, get ro and snapshot so thet can be excluded
++ subvols=$(btrfs subvolume list "$tmpmnt" | cut -d ' ' -f 9)
++ rosubvols=$(btrfs subvolume list -r "$tmpmnt" | cut -d ' ' -f 9)
++ sssubvols=$(btrfs subvolume list -s "$tmpmnt" | cut -d ' ' -f 14)
++ if ! umount "$tmpmnt"; then
++ warn "failed to umount btrfs volume on $tmpmnt"
++ rmdir "$tmpmnt" || true
++ exit 1
++ fi
++ if [ -z "$subvols" ]; then
++ debug "no subvols found on btrfs volume $UUID"
++ exit 1
++ fi
++ found=
++ for subvol in $subvols; do
++ debug "begin btrfs processing for $UUID subvol=$subvol"
++ if echo "$rosubvols" | grep -q -x "$subvol"; then
++ continue
++ fi
++ if echo "$sssubvols" | grep -q -x "$subvol"; then
++ continue
++ fi
++ mounted=
++ mpoint="$(grep btrfs /proc/self/mountinfo | grep "$partition " | grep "/$subvol " | cut -d ' ' -f 5)"
++ if [ -n "$mpoint" ]; then
++ if [ "x$mpoint" = "x/" ]; then
++ continue # this is the root for the running system
++ fi
++ mounted=1
++ else
++ # again, do not mount btrfs ro
++ mount -t btrfs -o subvol="$subvol" -U "$UUID" "$tmpmnt"
++ mpoint="$tmpmnt"
++ fi
++ test="/usr/lib/os-probes/mounted/90linux-distro"
++ if [ -f "$test" ] && [ -x "$test" ]; then
++ debug "running subtest $test"
++ if "$test" "$partition" "$mpoint" btrfs "UUID=$UUID" "subvol=$subvol"; then
++ debug "os found by subtest $test on subvol $subvol"
++ found=1
++ fi
++ fi
++ if [ -z "$mounted" ]; then
++ if ! umount "$tmpmnt"; then
++ warn "failed to umount $tmpmnt"
++ fi
++ fi
++ done
++ rmdir "$tmpmnt" || true
++ if [ "$found" ]; then
++ exit 0
++ else
++ exit 1
++ fi
++fi
++
+ if type grub2-mount >/dev/null 2>&1 && \
+ type grub2-probe >/dev/null 2>&1 && \
+ grub2-mount "$partition" "$tmpmnt" 2>/dev/null; then
+Index: os-prober/os-probes/mounted/common/90linux-distro
+===================================================================
+--- os-prober.orig/os-probes/mounted/common/90linux-distro
++++ os-prober/os-probes/mounted/common/90linux-distro
+@@ -7,6 +7,8 @@ set -e
+ partition="$1"
+ dir="$2"
+ type="$3"
++uuid="$4"
++subvol="$5"
+
+ # This test is inaccurate, but given separate / and /boot partitions and the
+ # fact that only some architectures have ld-linux.so, I can't see anything
+@@ -143,7 +145,11 @@ if (ls "$dir"/lib*/ld*.so* && [ -d "$dir
+ fi
+
+ label="$(count_next_label "$short")"
+- result "$partition:$long:$label:linux"
++ if [ "x$type" = "xbtrfs" -a "x$uuid" != "x" -a "x$subvol" != "x" ]; then
++ result "$partition:$long:$label:linux:$type:$uuid:$subvol"
++ else
++ result "$partition:$long:$label:linux"
++ fi
+ exit 0
+ else
+ exit 1
+Index: os-prober/README.btrfs
+===================================================================
+--- /dev/null
++++ os-prober/README.btrfs
+@@ -0,0 +1,15 @@
++BTRFS is a new filesystem which combines the filesystem with logical volume
++management (subvolumes). For further information, see:
++ https://btrfs.wiki.kernel.org/index.php/Main_Page
++ https://btrfs.wiki.kernel.org/index.php/FAQ
++
++In order to support BTRFS, a number of changes were necessary to os-prober,
++os-probes/common/50mounted-tests, os-probes/mounted/common/90linux-distro,
++linux-boot-prober, and linux-boot-probes/common/50mounted-tests.
++
++The biggest impact will be to grub2 where there is additional information
++output by os-prober and where, if a BTRFS subvolume is being used for root,
++the parameters for linux-boot-prober have changed.
++
++Sun 30 Dec 2012 11:49:52 AM EST Gene Czarcinski <gene@czarc.net>
++
diff --git a/sys-boot/os-prober/files/os-prober-dont-load-all-fs-module-and-dont-test-mount.patch b/sys-boot/os-prober/files/os-prober-dont-load-all-fs-module-and-dont-test-mount.patch
new file mode 100644
index 00000000..42e22692
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-dont-load-all-fs-module-and-dont-test-mount.patch
@@ -0,0 +1,92 @@
+Index: os-prober-1.76/os-probes/common/50mounted-tests
+===================================================================
+--- os-prober-1.76.orig/os-probes/common/50mounted-tests
++++ os-prober-1.76/os-probes/common/50mounted-tests
+@@ -49,19 +49,13 @@ elif [ -z "$types" ]; then
+ debug "$1 is a LUKS partition; skipping"
+ exit 0
+ fi
+- for type in $(grep -v nodev /proc/filesystems); do
+- # hfsplus filesystems are mountable as hfs. Try hfs last so
+- # that we can tell the difference.
+- if [ "$type" = hfs ]; then
+- delaytypes="${delaytypes:+$delaytypes }$type"
+- elif [ "$type" = fuseblk ]; then
+- if type ntfs-3g >/dev/null 2>&1; then
+- types="${types:+$types }ntfs-3g"
+- fi
+- else
+- types="${types:+$types }$type"
+- fi
+- done
++
++ # Simply skip such partition is better than trying to detect
++ # it by blinded test mounts with all kinds of kernel file system,
++ # that would lead to unwanted consequence like kernel oops and
++ # risk to corrupt your system and data.
++ debug "$1 is a partition without file system; skipping"
++ exit 0
+ fi
+
+ tmpmnt=/var/lib/os-prober/mount
+Index: os-prober-1.76/os-probes/init/common/10filesystems
+===================================================================
+--- os-prober-1.76.orig/os-probes/init/common/10filesystems
++++ os-prober-1.76/os-probes/init/common/10filesystems
+@@ -1,39 +1,19 @@
+ #!/bin/sh
+ # Make sure filesystems are available.
+-set +e # ignore errors from modprobe
+-
+-FILESYSTEMS='ext2 ext3 ext4 xfs jfs msdos vfat ntfs minix hfs hfsplus qnx4 ufs btrfs'
+-# fuse is needed to make grub2-mount work.
+-FILESYSTEMS="$FILESYSTEMS fuse"
+-# The Ubuntu kernel udebs put a number of filesystem modules in
+-# fs-{core,secondary}-modules. It's fairly cheap to check for these too.
+-FILESYSTEMS="$FILESYSTEMS fs-core fs-secondary"
+-
+-if [ ! -e /var/lib/os-prober/modules ]; then
+- # Check for anna-install to make it easier to use os-prober outside
+- # d-i.
+- if type anna-install >/dev/null 2>&1 && [ -d /lib/debian-installer ]; then
+- for fs in $FILESYSTEMS; do
+- ANNA_QUIET=1 DEBIAN_FRONTEND=none \
+- log-output -t os-prober \
+- anna-install "$fs-modules" || true
+- done
+- depmod -a >/dev/null 2>&1 || true
+- fi
+-
+- for fs in $FILESYSTEMS; do
+- case "$fs" in
+- fs-*)
+- ;;
+- *)
+- modprobe "$fs" 2>/dev/null | logger -t os-prober
+- ;;
+- esac
+- done
+-
+- # We only want to keep this state inside d-i, so this is as good a
+- # check as any.
+- if type anna-install >/dev/null 2>&1 && [ -d /lib/debian-installer ]; then
+- touch /var/lib/os-prober/modules
+- fi
+-fi
++set -e
++
++# Make sure fuse is available for grub2-mount
++# As long as we use grub2-mount, we use grub2's own file system modules
++# to mount the partitiion and the operation don't require kernel support
++# other than fuse.
++if ! cat /proc/filesystems | grep nodev | cut -f2 | grep -qw fuse; then
++ modprobe fuse 2>&1 | logger -t os-prober
++fi
++# Regarding file systems not supported by grub2, or systems simply don't
++# have grub2-mount, will use linux 'mount' utility. This will require
++# kernel file system module to work, but still we don't need to modprobe
++# all of them before mount, because mount() syscall will take care of it
++# by __request_module the needed kernel module and we should leave it do
++# that for us in order to have only needed modules get loaded.
++#
++# Still if you want any kernel module loaded, add them here.
diff --git a/sys-boot/os-prober/files/os-prober-fix-btrfs-subvol-mounted-tests.patch b/sys-boot/os-prober/files/os-prober-fix-btrfs-subvol-mounted-tests.patch
new file mode 100644
index 00000000..d56e0948
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-fix-btrfs-subvol-mounted-tests.patch
@@ -0,0 +1,84 @@
+Index: os-prober-1.76/os-probes/common/50mounted-tests
+===================================================================
+--- os-prober-1.76.orig/os-probes/common/50mounted-tests
++++ os-prober-1.76/os-probes/common/50mounted-tests
+@@ -65,10 +65,40 @@ fi
+
+ mounted=
+
++if [ "$types" = btrfs ]; then
++ partition="$BTRFSDEV"
++fi
++
++if type grub2-mount >/dev/null 2>&1 && \
++ type grub2-probe >/dev/null 2>&1 && \
++ grub2-mount "$partition" "$tmpmnt" 2>/dev/null; then
++ mounted=1
++ type="$(grub2-probe -d "$partition" -t fs)" || true
++ if [ "$type" ]; then
++ debug "mounted using GRUB $type filesystem driver"
++ else
++ debug "mounted using GRUB, but unknown filesystem?"
++ type=fuseblk
++ fi
++fi
++
++if [ "$mounted" ]; then
++ for test in /usr/lib/os-probes/mounted/*; do
++ debug "running subtest $test"
++ if [ -f "$test" ] && [ -x "$test" ]; then
++ if "$test" "$partition" "$tmpmnt" "$type"; then
++ debug "os found by subtest $test"
++ do_unmount
++ exit 0
++ fi
++ fi
++ done
++fi
++do_unmount
++
+ # all btrfs processing here. Handle both unmounted and
+ # mounted subvolumes.
+ if [ "$types" = btrfs ]; then
+- partition="$BTRFSDEV"
+ debug "begin btrfs processing for $UUID"
+ # note that the btrfs volume must not be mounted ro
+ if mount -t btrfs -U "$UUID" "$tmpmnt" 2>/dev/null; then
+@@ -129,37 +159,8 @@ if [ "$types" = btrfs ]; then
+ rmdir "$tmpmnt" || true
+ if [ "$found" ]; then
+ exit 0
+- else
+- exit 1
+- fi
+-fi
+-
+-if type grub2-mount >/dev/null 2>&1 && \
+- type grub2-probe >/dev/null 2>&1 && \
+- grub2-mount "$partition" "$tmpmnt" 2>/dev/null; then
+- mounted=1
+- type="$(grub2-probe -d "$partition" -t fs)" || true
+- if [ "$type" ]; then
+- debug "mounted using GRUB $type filesystem driver"
+- else
+- debug "mounted using GRUB, but unknown filesystem?"
+- type=fuseblk
+ fi
+ fi
+
+-if [ "$mounted" ]; then
+- for test in /usr/lib/os-probes/mounted/*; do
+- debug "running subtest $test"
+- if [ -f "$test" ] && [ -x "$test" ]; then
+- if "$test" "$partition" "$tmpmnt" "$type"; then
+- debug "os found by subtest $test"
+- do_unmount
+- exit 0
+- fi
+- fi
+- done
+-fi
+-do_unmount
+-
+ # No tests found anything.
+ exit 1
diff --git a/sys-boot/os-prober/files/os-prober-linux-distro-avoid-expensive-ld-file-test.patch b/sys-boot/os-prober/files/os-prober-linux-distro-avoid-expensive-ld-file-test.patch
new file mode 100644
index 00000000..7a6e8a8b
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-linux-distro-avoid-expensive-ld-file-test.patch
@@ -0,0 +1,295 @@
+Index: os-prober/os-probes/mounted/common/90linux-distro
+===================================================================
+--- os-prober.orig/os-probes/mounted/common/90linux-distro
++++ os-prober/os-probes/mounted/common/90linux-distro
+@@ -10,147 +10,133 @@ type="$3"
+ uuid="$4"
+ subvol="$5"
+
+-# This test is inaccurate, but given separate / and /boot partitions and the
+-# fact that only some architectures have ld-linux.so, I can't see anything
+-# better. Make sure this test has a high number so that more accurate tests
+-# can come first.
+-# Unless volumes to checked are already mounted, they will be mounted using
+-# GRUB's own filesystems through FUSE. Since these ATM doesn't support
+-# symlinks we need to also check in $dir/usr/lib* for distributions that
+-# moved /lib* to /usr and only left symlinks behind.
+-# TODO: look for ld-linux.so on arches that have it
+-if (ls "$dir"/lib*/ld*.so* && [ -d "$dir/boot" ] || ls "$dir"/usr/lib*/ld*.so*) >/dev/null 2>/dev/null; then
+- if [ -e "$dir/etc/os-release" ]; then
+- short="$(grep ^NAME= "$dir/etc/os-release" | sed 's/^[^=]*=//; s/^['\''"]\(.*\)['\''"]$/\1/; s/\\\(.\)/\1/g; s/[[:space:]].*//')"
+- long="$(grep ^PRETTY_NAME= "$dir/etc/os-release" | sed 's/^[^=]*=//; s/^['\''"]\(.*\)['\''"]$/\1/; s/\\\(.\)/\1/g')"
+- elif [ -e "$dir/etc/debian_version" ]; then
+- short="Debian"
+- long="$(printf "Debian GNU/Linux (%s)\n" "$(cat "$dir/etc/debian_version")")"
+- # RPM derived distributions may also have a redhat-release or
+- # mandrake-release, so check their files first.
+- elif [ -e "$dir/etc/altlinux-release" ]; then
+- short="ALTLinux"
+- long="$(cat "$dir/etc/altlinux-release")"
+- elif [ -e "$dir/etc/magic-release" ]; then
+- short="Magic"
+- long="$(cat "$dir/etc/magic-release")"
+- elif [ -e "$dir/etc/blackPanther-release" ]; then
+- short="blackPanther"
+- long="$(cat "$dir/etc/blackPanther-release")"
+- elif [ -e "$dir/etc/ark-release" ]; then
+- short="Ark"
+- long="$(cat "$dir/etc/ark-release")"
+- elif [ -e "$dir/etc/arch-release" ]; then
+- short="Arch"
+- long="$(cat "$dir/etc/arch-release")"
+- elif [ -e "$dir/etc/asplinux-release" ]; then
+- short="ASPLinux"
+- long="$(cat "$dir/etc/asplinux-release")"
+- elif [ -e "$dir/etc/lvr-release" ]; then
+- short="LvR"
+- long="$(cat "$dir/etc/lvr-release")"
+- elif [ -e "$dir/etc/caos-release" ]; then
+- short="cAos"
+- long="$(cat "$dir/etc/caos-release")"
+- elif [ -e "$dir/etc/aurox-release" ]; then
+- short="Aurox"
+- long="$(cat "$dir/etc/aurox-release")"
+- elif [ -e "$dir/etc/engarde-release" ]; then
+- short="EnGarde"
+- long="$(cat "$dir/etc/engarde-release")"
+- elif [ -e "$dir/etc/vine-release" ]; then
+- short="Vine"
+- long="$(cat "$dir/etc/vine-release")"
+- elif [ -e "$dir/etc/whitebox-release" ]; then
+- short="WhiteBox"
+- long="$(cat "$dir/etc/whitebox-release")"
+- elif [ -e "$dir/etc/pld-release" ]; then
+- short="PLD"
+- long="$(cat "$dir/etc/pld-release")"
+- elif [ -e "$dir/etc/startcom-release" ]; then
+- short="StartCom"
+- long="$(cat "$dir/etc/startcom-release")"
+- elif [ -e "$dir/etc/trustix-release" ]; then
+- short="Trustix"
+- long="$(cat "$dir/etc/trustix-release")"
+- elif [ -e "$dir/etc/openna-release" ]; then
+- short="OpenNA"
+- long="$(cat "$dir/etc/openna-release")"
+- elif [ -e "$dir/etc/mageia-release" ]; then
+- short="Mageia"
+- long="$(cat "$dir/etc/mageia-release")"
+- elif [ -e "$dir/etc/conectiva-release" ]; then
+- short="Conectiva"
+- long="$(cat "$dir/etc/conectiva-release")"
+- elif [ -e "$dir/etc/mandrake-release" ]; then
+- short="Mandrake"
+- long="$(cat "$dir/etc/mandrake-release")"
+- elif [ -e "$dir/etc/fedora-release" ]; then
+- short="Fedora"
+- long="$(cat "$dir/etc/fedora-release")"
+- elif [ -e "$dir/etc/redhat-release" ]; then
+- short="RedHat"
+- long="$(cat "$dir/etc/redhat-release")"
+- elif [ -e "$dir/etc/SuSE-release" ]; then
+- short="SUSE"
+- long="$(head -n 1 "$dir/etc/SuSE-release")"
+- elif [ -e "$dir/etc/gentoo-release" ]; then
+- short="Gentoo"
+- long="$(cat "$dir/etc/gentoo-release")"
+- elif [ -e "$dir/etc/cobalt-release" ]; then
+- short="Cobalt"
+- long="$(cat "$dir/etc/cobalt-release")"
+- elif [ -e "$dir/etc/yellowdog-release" ]; then
+- short="YellowDog"
+- long="$(cat "$dir/etc/yellowdog-release")"
+- elif [ -e "$dir/etc/turbolinux-release" ]; then
+- short="Turbolinux"
+- long="$(cat "$dir/etc/turbolinux-release")"
+- elif [ -e "$dir/etc/pardus-release" ]; then
+- short="Pardus"
+- long="$(cat "$dir/etc/pardus-release")"
+- elif [ -e "$dir/etc/kanotix-version" ]; then
+- short="Kanotix"
+- long="$(cat "$dir/etc/kanotix-version")"
+- elif [ -e "$dir/etc/slackware-version" ]; then
+- short="Slackware"
+- long="$(printf "Slackware Linux (%s)\n" "$(cat "$dir/etc/slackware-version")")"
+- elif [ -e "$dir/sbin/pkgtool" ]; then
+- short="Slackware"
+- long="Slackware Linux"
+- elif grep -qs OpenLinux "$dir/etc/issue"; then
+- short="Caldera"
+- long="Caldera OpenLinux"
+- elif [ -e "$dir/etc/frugalware-release" ]; then
+- short="Frugalware Linux"
+- long="$(cat "$dir/etc/frugalware-release")"
+- elif [ -e "$dir/etc/kdemar-release" ]; then
+- short="K-DEMar"
+- long="$(printf "K-DEMar GNU/Linux (%s)\n" "$(cat "$dir/etc/kdemar-release")")"
+- elif [ -e "$dir/etc/lfs-release" ]; then
+- short="LFS"
+- long="$(printf "Linux From Scratch (%s)\n" "$(cat "$dir/etc/lfs-release")")"
+- elif [ -e "$dir/etc/meego-release" ]; then
+- short="MeeGo"
+- long="$(head -1 "$dir/etc/meego-release")"
+- elif [ -e "$dir/etc/4MLinux-version" ]; then
+- short="4MLinux"
+- long="4MLinux $(head -1 "$dir/etc/4MLinux-version")"
+- elif [ -e "$dir/etc/devuan_version" ]; then
+- short="Devuan"
+- long="$(printf "Devuan GNU/Linux (%s)\n" "$(cat "$dir/etc/devuan_version")")"
+- else
+- short="Linux"
+- long="unknown Linux distribution"
+- fi
+-
+- label="$(count_next_label "$short")"
+- if [ "x$type" = "xbtrfs" -a "x$uuid" != "x" -a "x$subvol" != "x" ]; then
+- result "$partition:$long:$label:linux:$type:$uuid:$subvol"
+- else
+- result "$partition:$long:$label:linux"
+- fi
+- exit 0
++if [ -e "$dir/etc/os-release" ]; then
++ short="$(grep ^NAME= "$dir/etc/os-release" | sed 's/^[^=]*=//; s/^['\''"]\(.*\)['\''"]$/\1/; s/\\\(.\)/\1/g; s/[[:space:]].*//')"
++ long="$(grep ^PRETTY_NAME= "$dir/etc/os-release" | sed 's/^[^=]*=//; s/^['\''"]\(.*\)['\''"]$/\1/; s/\\\(.\)/\1/g')"
++elif [ -e "$dir/etc/debian_version" ]; then
++ short="Debian"
++ long="$(printf "Debian GNU/Linux (%s)\n" "$(cat "$dir/etc/debian_version")")"
++# RPM derived distributions may also have a redhat-release or
++# mandrake-release, so check their files first.
++elif [ -e "$dir/etc/altlinux-release" ]; then
++ short="ALTLinux"
++ long="$(cat "$dir/etc/altlinux-release")"
++elif [ -e "$dir/etc/magic-release" ]; then
++ short="Magic"
++ long="$(cat "$dir/etc/magic-release")"
++elif [ -e "$dir/etc/blackPanther-release" ]; then
++ short="blackPanther"
++ long="$(cat "$dir/etc/blackPanther-release")"
++elif [ -e "$dir/etc/ark-release" ]; then
++ short="Ark"
++ long="$(cat "$dir/etc/ark-release")"
++elif [ -e "$dir/etc/arch-release" ]; then
++ short="Arch"
++ long="$(cat "$dir/etc/arch-release")"
++elif [ -e "$dir/etc/asplinux-release" ]; then
++ short="ASPLinux"
++ long="$(cat "$dir/etc/asplinux-release")"
++elif [ -e "$dir/etc/lvr-release" ]; then
++ short="LvR"
++ long="$(cat "$dir/etc/lvr-release")"
++elif [ -e "$dir/etc/caos-release" ]; then
++ short="cAos"
++ long="$(cat "$dir/etc/caos-release")"
++elif [ -e "$dir/etc/aurox-release" ]; then
++ short="Aurox"
++ long="$(cat "$dir/etc/aurox-release")"
++elif [ -e "$dir/etc/engarde-release" ]; then
++ short="EnGarde"
++ long="$(cat "$dir/etc/engarde-release")"
++elif [ -e "$dir/etc/vine-release" ]; then
++ short="Vine"
++ long="$(cat "$dir/etc/vine-release")"
++elif [ -e "$dir/etc/whitebox-release" ]; then
++ short="WhiteBox"
++ long="$(cat "$dir/etc/whitebox-release")"
++elif [ -e "$dir/etc/pld-release" ]; then
++ short="PLD"
++ long="$(cat "$dir/etc/pld-release")"
++elif [ -e "$dir/etc/startcom-release" ]; then
++ short="StartCom"
++ long="$(cat "$dir/etc/startcom-release")"
++elif [ -e "$dir/etc/trustix-release" ]; then
++ short="Trustix"
++ long="$(cat "$dir/etc/trustix-release")"
++elif [ -e "$dir/etc/openna-release" ]; then
++ short="OpenNA"
++ long="$(cat "$dir/etc/openna-release")"
++elif [ -e "$dir/etc/mageia-release" ]; then
++ short="Mageia"
++ long="$(cat "$dir/etc/mageia-release")"
++elif [ -e "$dir/etc/conectiva-release" ]; then
++ short="Conectiva"
++ long="$(cat "$dir/etc/conectiva-release")"
++elif [ -e "$dir/etc/mandrake-release" ]; then
++ short="Mandrake"
++ long="$(cat "$dir/etc/mandrake-release")"
++elif [ -e "$dir/etc/fedora-release" ]; then
++ short="Fedora"
++ long="$(cat "$dir/etc/fedora-release")"
++elif [ -e "$dir/etc/redhat-release" ]; then
++ short="RedHat"
++ long="$(cat "$dir/etc/redhat-release")"
++elif [ -e "$dir/etc/SuSE-release" ]; then
++ short="SUSE"
++ long="$(head -n 1 "$dir/etc/SuSE-release")"
++elif [ -e "$dir/etc/gentoo-release" ]; then
++ short="Gentoo"
++ long="$(cat "$dir/etc/gentoo-release")"
++elif [ -e "$dir/etc/cobalt-release" ]; then
++ short="Cobalt"
++ long="$(cat "$dir/etc/cobalt-release")"
++elif [ -e "$dir/etc/yellowdog-release" ]; then
++ short="YellowDog"
++ long="$(cat "$dir/etc/yellowdog-release")"
++elif [ -e "$dir/etc/turbolinux-release" ]; then
++ short="Turbolinux"
++ long="$(cat "$dir/etc/turbolinux-release")"
++elif [ -e "$dir/etc/pardus-release" ]; then
++ short="Pardus"
++ long="$(cat "$dir/etc/pardus-release")"
++elif [ -e "$dir/etc/kanotix-version" ]; then
++ short="Kanotix"
++ long="$(cat "$dir/etc/kanotix-version")"
++elif [ -e "$dir/etc/slackware-version" ]; then
++ short="Slackware"
++ long="$(printf "Slackware Linux (%s)\n" "$(cat "$dir/etc/slackware-version")")"
++elif [ -e "$dir/sbin/pkgtool" ]; then
++ short="Slackware"
++ long="Slackware Linux"
++elif grep -qs OpenLinux "$dir/etc/issue"; then
++ short="Caldera"
++ long="Caldera OpenLinux"
++elif [ -e "$dir/etc/frugalware-release" ]; then
++ short="Frugalware Linux"
++ long="$(cat "$dir/etc/frugalware-release")"
++elif [ -e "$dir/etc/kdemar-release" ]; then
++ short="K-DEMar"
++ long="$(printf "K-DEMar GNU/Linux (%s)\n" "$(cat "$dir/etc/kdemar-release")")"
++elif [ -e "$dir/etc/lfs-release" ]; then
++ short="LFS"
++ long="$(printf "Linux From Scratch (%s)\n" "$(cat "$dir/etc/lfs-release")")"
++elif [ -e "$dir/etc/meego-release" ]; then
++ short="MeeGo"
++ long="$(head -1 "$dir/etc/meego-release")"
++elif [ -e "$dir/etc/4MLinux-version" ]; then
++ short="4MLinux"
++ long="4MLinux $(head -1 "$dir/etc/4MLinux-version")"
++elif [ -e "$dir/etc/devuan_version" ]; then
++ short="Devuan"
++ long="$(printf "Devuan GNU/Linux (%s)\n" "$(cat "$dir/etc/devuan_version")")"
+ else
+ exit 1
+ fi
++
++label="$(count_next_label "$short")"
++if [ "x$type" = "xbtrfs" -a "x$uuid" != "x" -a "x$subvol" != "x" ]; then
++ result "$partition:$long:$label:linux:$type:$uuid:$subvol"
++else
++ result "$partition:$long:$label:linux"
++fi
++exit 0
+Index: os-prober/os-prober
+===================================================================
+--- os-prober.orig/os-prober
++++ os-prober/os-prober
+@@ -186,6 +186,11 @@ for partition in $(partitions); do
+ # be handled by 50mounted-tests so we can do a subvol only once.
+ type=$(blkid -o value -s TYPE $mapped || true)
+ if [ "$type" = btrfs ]; then
++ mpoint=$(grep "^$mapped " "$OS_PROBER_TMP/mounted-map" | head -n1 | cut -d " " -f 2)
++ mpoint="$(unescape_mount "$mpoint")"
++ if [ "$mpoint" = "/target/boot" ] || [ "$mpoint" = "/target" ] || [ "$mpoint" = "/" ]; then
++ continue
++ fi
+ uuid=$(blkid -o value -s UUID $mapped)
+ if grep -q "^$uuid" "$OS_PROBER_TMP/btrfs-vols" ; then
+ continue
diff --git a/sys-boot/os-prober/files/os-prober-linux-distro-parse-os-release.patch b/sys-boot/os-prober/files/os-prober-linux-distro-parse-os-release.patch
new file mode 100644
index 00000000..2aa2b316
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-linux-distro-parse-os-release.patch
@@ -0,0 +1,24 @@
+Index: os-prober/os-probes/mounted/common/90linux-distro
+===================================================================
+--- os-prober.orig/os-probes/mounted/common/90linux-distro
++++ os-prober/os-probes/mounted/common/90linux-distro
+@@ -10,7 +10,18 @@ type="$3"
+ uuid="$4"
+ subvol="$5"
+
+-if [ -e "$dir/etc/os-release" ]; then
++if [ -L "$dir/etc/os-release" ]; then
++ RELPATH=$(readlink -f "$dir/etc/os-release")
++ if readlink "$dir/etc/os-release" | grep -q '^/'; then
++ RELPATH="$dir$RELPATH"
++ fi
++ if [ -f "$RELPATH" ]; then
++ short="$(grep ^NAME= "$RELPATH" | sed 's/^[^=]*=//; s/^['\''"]\(.*\)['\''"]$/\1/; s/\\\(.\)/\1/g; s/[[:space:]].*//')"
++ long="$(grep ^PRETTY_NAME= "$RELPATH" | sed 's/^[^=]*=//; s/^['\''"]\(.*\)['\''"]$/\1/; s/\\\(.\)/\1/g')"
++ else
++ exit 1
++ fi
++elif [ -e "$dir/etc/os-release" ]; then
+ short="$(grep ^NAME= "$dir/etc/os-release" | sed 's/^[^=]*=//; s/^['\''"]\(.*\)['\''"]$/\1/; s/\\\(.\)/\1/g; s/[[:space:]].*//')"
+ long="$(grep ^PRETTY_NAME= "$dir/etc/os-release" | sed 's/^[^=]*=//; s/^['\''"]\(.*\)['\''"]$/\1/; s/\\\(.\)/\1/g')"
+ elif [ -e "$dir/etc/debian_version" ]; then
diff --git a/sys-boot/os-prober/files/os-prober-linux-secure-boot.patch b/sys-boot/os-prober/files/os-prober-linux-secure-boot.patch
new file mode 100644
index 00000000..2810f728
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-linux-secure-boot.patch
@@ -0,0 +1,29 @@
+From: Andrey Borzenkov <arvidjaar@gmail.com>
+Subject: detect linuxefi/initrdefi secure bootloaders too
+Reference: bnc#810912
+
+Recognize initrdefi and linuxefi too. Whether linux/initrd or
+linuxefi/initrdefi will be emitted is controlled by SECURE_BOOT
+setting in /etc/sysconfig/bootloader.
+Index: os-prober-1.61/linux-boot-probes/mounted/common/40grub2
+===================================================================
+--- os-prober-1.61.orig/linux-boot-probes/mounted/common/40grub2
++++ os-prober-1.61/linux-boot-probes/mounted/common/40grub2
+@@ -71,7 +71,7 @@ parse_grub_menu () {
+ ignore_item=1
+ fi
+ ;;
+- linux)
++ linux|linuxefi)
+ # Hack alert: sed off any (hdn,n) but
+ # assume the kernel is on the same
+ # partition.
+@@ -84,7 +84,7 @@ parse_grub_menu () {
+ kernel="/boot$kernel"
+ fi
+ ;;
+- initrd)
++ initrd|initrdefi)
+ initrd="$(echo "$2" | sed 's/(.*)//')"
+ # Initrd same.
+ if [ "$partition" != "$bootpart" ]; then
diff --git a/sys-boot/os-prober/files/os-prober-make-btrfsprogs-optional.patch b/sys-boot/os-prober/files/os-prober-make-btrfsprogs-optional.patch
new file mode 100644
index 00000000..5053e115
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-make-btrfsprogs-optional.patch
@@ -0,0 +1,30 @@
+Index: os-prober-1.76/os-probes/common/50mounted-tests
+===================================================================
+--- os-prober-1.76.orig/os-probes/common/50mounted-tests
++++ os-prober-1.76/os-probes/common/50mounted-tests
+@@ -151,11 +151,20 @@ if [ "$types" = btrfs ]; then
+ rmdir "$tmpmnt" || true
+ exit 1
+ fi
+- # besides regular subvols, get ro and snapshot so thet can be excluded
+- subvols=$(btrfs subvolume list -a "$tmpmnt" | cut -d ' ' -f 9 | sed -e s!^\<FS_TREE\>/!!)
+- rosubvols=$(btrfs subvolume list -r -a "$tmpmnt" | cut -d ' ' -f 9 | sed -e s!^\<FS_TREE\>/!!)
+- sssubvols=$(btrfs subvolume list -s -a "$tmpmnt" | cut -d ' ' -f 14 | sed -e s!^\<FS_TREE\>/!!)
+- defaultvol=$(btrfs subvolume get-default "$tmpmnt" | cut -d ' ' -f 9)
++
++ if type btrfs >/dev/null 2>&1; then
++ # besides regular subvols, get ro and snapshot so thet can be excluded
++ subvols=$(btrfs subvolume list -a "$tmpmnt" | cut -d ' ' -f 9 | sed -e s!^\<FS_TREE\>/!!)
++ rosubvols=$(btrfs subvolume list -r -a "$tmpmnt" | cut -d ' ' -f 9 | sed -e s!^\<FS_TREE\>/!!)
++ sssubvols=$(btrfs subvolume list -s -a "$tmpmnt" | cut -d ' ' -f 14 | sed -e s!^\<FS_TREE\>/!!)
++ defaultvol=$(btrfs subvolume get-default "$tmpmnt" | cut -d ' ' -f 9)
++ else
++ subvols=""
++ rosubvols=""
++ sssubvols=""
++ defaultvol=""
++ fi
++
+ if ! umount "$tmpmnt"; then
+ warn "failed to umount btrfs volume on $tmpmnt"
+ rmdir "$tmpmnt" || true
diff --git a/sys-boot/os-prober/files/os-prober-multiple-initrd.patch b/sys-boot/os-prober/files/os-prober-multiple-initrd.patch
new file mode 100644
index 00000000..57c89e19
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-multiple-initrd.patch
@@ -0,0 +1,32 @@
+Index: os-prober/linux-boot-probes/mounted/common/40grub2
+===================================================================
+--- os-prober.orig/linux-boot-probes/mounted/common/40grub2
++++ os-prober/linux-boot-probes/mounted/common/40grub2
+@@ -19,11 +19,11 @@ entry_result () {
+ # if path is not relative to subvolume make it relative
+ kernel=${kernel#${bsv}}
+ kernelfile=$kernel
+- initrd=${initrd#${bsv}}
++ initrd=`echo $initrd | sed -e "s!^${bsv}!!" -e "s!\\(\\s\\)${bsv}!\\1!g"`
+ if [ "x$GRUB_FS" != "xbtrfs" -o "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" != "xtrue" ]; then
+ # absolute path needed: prepend subvolume if $kernel isn't empty
+ kernel=${kernel:+${bsv}}${kernel}
+- initrd=${initrd:+${bsv}}${initrd}
++ initrd=`echo $initrd | sed -e "s!\\(\\S\\+\\)!${bsv}\\1!g"`
+ fi
+ # assumed: rootsv != bootsv if rootsv isn't ancestor of bootsv
+ [ "$partition" != "$bootpart" -o "$rootsv" != "$bootsv" ] && kernelfile="/boot${kernelfile}"
+@@ -105,10 +105,11 @@ parse_grub_menu () {
+ fi
+ ;;
+ initrd|initrdefi|initrd16)
+- initrd="$(echo "$2" | sed 's/(.*)//')"
++ shift
++ initrd="$(echo "$@" | sed 's/(\S*)//g')"
+ # Initrd same.
+ if [ "$partition" != "$bootpart" -a "$type" != "btrfs" ]; then
+- initrd="/boot$initrd"
++ initrd=`echo $initrd | sed -e 's!\(\S\+\)!/boot\1!g'`
+ fi
+ ;;
+ "}")
diff --git a/sys-boot/os-prober/files/os-prober-newnsdirfix.patch b/sys-boot/os-prober/files/os-prober-newnsdirfix.patch
new file mode 100644
index 00000000..4adcc7a0
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-newnsdirfix.patch
@@ -0,0 +1,10 @@
+diff -up os-prober-1.46/common.sh.newnsmove os-prober-1.46/common.sh
+--- os-prober-1.46/common.sh.newnsmove 2011-04-10 05:30:57.000000000 +0430
++++ os-prober-1.46/common.sh 2011-05-04 04:08:09.603020037 +0430
+@@ -1,5 +1,5 @@
+ newns () {
+- [ "$OS_PROBER_NEWNS" ] || exec /usr/lib/os-prober/newns "$0" "$@"
++ [ "$OS_PROBER_NEWNS" ] || exec /usr/lib/newns "$0" "$@"
+ }
+
+ cleanup_tmpdir=false
diff --git a/sys-boot/os-prober/files/os-prober-probe-MD-devices.patch b/sys-boot/os-prober/files/os-prober-probe-MD-devices.patch
new file mode 100644
index 00000000..61122da1
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-probe-MD-devices.patch
@@ -0,0 +1,26 @@
+Index: os-prober-1.61/os-prober
+===================================================================
+--- os-prober-1.61.orig/os-prober
++++ os-prober-1.61/os-prober
+@@ -39,6 +39,11 @@ partitions () {
+ fi
+ done
+
++ # Add Linux MD unpartioned devices. Linux MD partitions are already covered above
++ [ -f /proc/mdstat ] && grep '^md' /proc/mdstat | while read md line; do
++ [ -e "/dev/$md" ] && echo "/dev/$md"
++ done
++
+ # Add Serial ATA RAID devices
+ if type dmraid >/dev/null 2>&1 && \
+ dmraid -s -c >/dev/null 2>&1; then
+@@ -79,7 +84,8 @@ parse_proc_mdstat () {
+ udevadm info "$@"
+ }
+ fi
+- while read line; do
++ # Only add MD slaves to the list
++ while read md line; do
+ for word in $line; do
+ dev="${word%%\[*}"
+ # TODO: factor this out to something in di-utils if
diff --git a/sys-boot/os-prober/files/os-prober-redcore.patch b/sys-boot/os-prober/files/os-prober-redcore.patch
index 5ce141bd..501d2784 100644
--- a/sys-boot/os-prober/files/os-prober-redcore.patch
+++ b/sys-boot/os-prober/files/os-prober-redcore.patch
@@ -1,19 +1,19 @@
diff -Nur a/os-probes/mounted/common/90linux-distro b/os-probes/mounted/common/90linux-distro
---- a/os-probes/mounted/common/90linux-distro 2014-09-28 22:04:17.000000000 +0100
-+++ b/os-probes/mounted/common/90linux-distro 2016-11-06 12:16:59.285765508 +0000
-@@ -89,6 +89,15 @@
- elif [ -e "$dir/etc/gentoo-release" ]; then
- short="Gentoo"
- long="$(cat "$dir/etc/gentoo-release")"
-+ elif [ -e "$dir/etc/redcore-release" ]; then
-+ short="Redcore"
-+ long="$(cat "$dir/etc/redcore-release")"
-+ elif [ -e "$dir/etc/kogaion-release" ]; then
-+ short="Kogaion"
-+ long="$(cat "$dir/etc/kogaion-release")"
-+ elif [ -e "$dir/etc/argent-release" ]; then
-+ short="Argent"
-+ long="$(cat "$dir/etc/argent-release")"
- elif [ -e "$dir/etc/cobalt-release" ]; then
- short="Cobalt"
- long="$(cat "$dir/etc/cobalt-release")"
+--- a/os-probes/mounted/common/90linux-distro 2021-01-28 00:23:50.827441813 +0000
++++ b/os-probes/mounted/common/90linux-distro 2021-01-28 00:27:33.379716742 +0000
+@@ -98,6 +98,15 @@
+ elif [ -e "$dir/etc/gentoo-release" ]; then
+ short="Gentoo"
+ long="$(cat "$dir/etc/gentoo-release")"
++elif [ -e "$dir/etc/redcore-release" ]; then
++ short="Redcore"
++ long="$(cat "$dir/etc/redcore-release")"
++elif [ -e "$dir/etc/kogaion-release" ]; then
++ short="Kogaion"
++ long="$(cat "$dir/etc/kogaion-release")"
++elif [ -e "$dir/etc/argent-release" ]; then
++ short="Argent"
++ long="$(cat "$dir/etc/argent-release")"
+ elif [ -e "$dir/etc/cobalt-release" ]; then
+ short="Cobalt"
+ long="$(cat "$dir/etc/cobalt-release")"
diff --git a/sys-boot/os-prober/files/os-prober-skip-part-on-multipath.patch b/sys-boot/os-prober/files/os-prober-skip-part-on-multipath.patch
new file mode 100644
index 00000000..c813750a
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-skip-part-on-multipath.patch
@@ -0,0 +1,42 @@
+Index: os-prober-1.61/os-prober
+===================================================================
+--- os-prober-1.61.orig/os-prober
++++ os-prober-1.61/os-prober
+@@ -23,6 +23,28 @@
+ fi
+ return 1
+ }
++mp_disks="UNDEF"
++on_multipath () {
++ type multipath >/dev/null 2>&1 || return 1
++ local parent="${1%/*}"
++ local device="${parent##*/}"
++
++ if [ "$mp_disks" = "UNDEF" ]; then
++ mp_disks=`multipath -d -l | sed -n -e 's/^.\+[0-9]\+:[0-9]\+:[0-9]\+:[0-9]\+ \([^ ]\+\) .*/\1/p'`
++ fi
++
++ if [ -z "$mp_disks" ]; then
++ return 1
++ fi
++
++ for i in $mp_disks; do
++ if [ "$device" = "$i" ]; then
++ debug "$1: part of multipath disk $i"
++ return 0
++ fi
++ done
++ return 1
++}
+
+ partitions () {
+ os_name="$(uname -s)"
+@@ -31,7 +54,7 @@ partitions () {
+ # Serial ATA RAID disk.
+ for part in /sys/block/*/*[0-9]; do
+ if [ -f "$part/start" ] && \
+- [ ! -f "$part/whole_disk" ] && ! on_sataraid $part; then
++ [ ! -f "$part/whole_disk" ] && ! on_sataraid $part && ! on_multipath $part; then
+ name="$(echo "${part##*/}" | sed 's,[!.],/,g')"
+ if [ -e "/dev/$name" ]; then
+ echo "/dev/$name"
diff --git a/sys-boot/os-prober/files/os-prober-use-tmp-over-var-lib-for-transient-files.patch b/sys-boot/os-prober/files/os-prober-use-tmp-over-var-lib-for-transient-files.patch
new file mode 100644
index 00000000..cce5cb6b
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-use-tmp-over-var-lib-for-transient-files.patch
@@ -0,0 +1,276 @@
+From 2ed7c3ae98aa671d504eba254fdd89ea26fe15c8 Mon Sep 17 00:00:00 2001
+From: Michael Chang <mchang@suse.com>
+Date: Thu, 7 Mar 2019 16:31:19 +0800
+Subject: [PATCH] Use /tmp over /var/lib for transient files
+
+Create transient mount point in directory /tmp rather than /var/lib
+which is not available during transactional update. Also clean up the
+count_last_label function for not relying on /var/lib/os-prober/labels
+file for the caculation.
+
+https://en.opensuse.org/openSUSE:Packaging_for_transactional-updates
+
+v2:
+- Fix accidental deletion of btrfs subvolume (boo#1130669).
+- Fix detection of btrfs boot subvolume if its /etc/fstab entry contains
+ leading slash for subvol= mount option.
+
+---
+ common.sh | 37 ++++++++++++++------------------
+ linux-boot-prober | 2 +-
+ linux-boot-probes/common/50mounted-tests | 2 +-
+ os-prober | 3 ---
+ os-probes/common/50mounted-tests | 2 +-
+ 5 files changed, 19 insertions(+), 27 deletions(-)
+
+Index: os-prober-1.76/common.sh
+===================================================================
+--- os-prober-1.76.orig/common.sh
++++ os-prober-1.76/common.sh
+@@ -21,31 +21,26 @@ require_tmpdir() {
+ fi
+ }
+
+-count_for() {
+- _labelprefix="$1"
+- _result=$(grep "^${_labelprefix} " /var/lib/os-prober/labels 2>/dev/null || true)
+-
+- if [ -z "$_result" ]; then
+- return
+- else
+- echo "$_result" | cut -d' ' -f2
+- fi
+-}
+-
++OS_PROBER_LABELS=""
+ count_next_label() {
+- require_tmpdir
+-
+ _labelprefix="$1"
+- _cfor="$(count_for "${_labelprefix}")"
+-
+- if [ -z "$_cfor" ]; then
+- echo "${_labelprefix} 1" >> /var/lib/os-prober/labels
++ _count=""
++ _labels=""
++ for i in $OS_PROBER_LABELS; do
++ _label="`echo $i | cut -d: -f1`"
++ if [ x"$_labelprefix" = x"$_label" ]; then
++ _count=`echo $i | cut -d: -f2`
++ _labels="$_labels $_label:`expr $_count + 1`"
++ else
++ _labels="$_labels $i"
++ fi
++ done
++ if [ -z "$_count" ]; then
++ OS_PROBER_LABELS="$OS_PROBER_LABELS $_labelprefix:1"
+ else
+- sed "s/^${_labelprefix} ${_cfor}/${_labelprefix} $(($_cfor + 1))/" /var/lib/os-prober/labels > "$OS_PROBER_TMP/os-prober.tmp"
+- mv "$OS_PROBER_TMP/os-prober.tmp" /var/lib/os-prober/labels
++ OS_PROBER_LABELS="$_labels"
+ fi
+-
+- echo "${_labelprefix}${_cfor}"
++ echo "${_labelprefix}${_count}"
+ }
+
+ progname=
+Index: os-prober-1.76/linux-boot-prober
+===================================================================
+--- os-prober-1.76.orig/linux-boot-prober
++++ os-prober-1.76/linux-boot-prober
+@@ -7,11 +7,6 @@ newns "$@"
+ require_tmpdir
+ ERR="n"
+
+-tmpmnt=/var/lib/os-prober/mount
+-if [ ! -d "$tmpmnt" ]; then
+- mkdir "$tmpmnt"
+-fi
+-
+ mounted=
+ bootmnt=
+ bootsv=
+@@ -45,23 +40,21 @@ if [ "x$ERR" != xn ]; then
+ fi
+
+ if [ "$type" = btrfs ]; then
++ tmpmnt="$(mktemp -d /tmp/linux-boot-prober.XXXXXX)"
+ # handle all of the btrfs stuff here
+ if [ ! -e "/proc/self/mountinfo" ]; then
+ warn "/proc/self/mountinfo does not exist, exiting"
+- umount "$tmpmnt" 2>/dev/null
+ rmdir "$tmpmnt" 2>/dev/null
+ exit 1
+ fi
+ mpoint=$(grep "btrfs" /proc/self/mountinfo | grep " /$subvol " | grep " $partition " | cut -d ' ' -f 5)
+ if [ "$mpoint" = "/" ]; then
+ warn "specifying active root not valid, exiting"
+- umount "$tmpmnt" 2>/dev/null
+ rmdir "$tmpmnt" 2>/dev/null
+ exit 1
+ fi
+ if [ "$mpoint" = "$tmpmnt" ]; then
+ warn "btrfs subvol=$subvool, UUID=$UUID, already mounted on $tmpmnt **ERROR**"
+- umount "$tmpmnt" 2>/dev/null
+ rmdir "$tmpmnt" 2>/dev/null
+ exit 1
+ fi
+@@ -74,8 +67,6 @@ if [ "$type" = btrfs ]; then
+
+ if ! mount $opts -t btrfs -U $UUID "$tmpmnt" 2>/dev/null; then
+ warn "error mounting btrfs subvol=$subvol UUID=$UUID"
+- umount "$tmpmnt/boot" 2>/dev/null
+- umount "$tmpmnt" 2>/dev/null
+ rmdir "$tmpmnt" 2>/dev/null
+ exit 1
+ fi
+@@ -83,8 +74,6 @@ if [ "$type" = btrfs ]; then
+ # bind-mount
+ if ! mount -o bind "$mpoint" "$tmpmnt" 2>/dev/null; then
+ warn "error mounting btrfs bindfrom=$mpoint subvol=$subvol UUID=$UUID"
+- umount "$tmpmnt/boot" 2>/dev/null
+- umount "$tmpmnt" 2>/dev/null
+ rmdir "$tmpmnt" 2>/dev/null
+ exit 1
+ fi
+@@ -103,27 +92,34 @@ if [ "$type" = btrfs ]; then
+ bootsv="$subvol"
+ elif echo "$bootmnt" | cut -d ' ' -f 3 | grep -q "btrfs"; then
+ # separate btrfs /boot subvolume
+- bootsv=$(echo "$bootmnt" | cut -d ' ' -f 4 | grep "^subvol=" | sed "s/subvol=//" )
+- bootuuid=$(echo "$bootmnt" | cut -d ' ' -f 1 | grep "^UUID=" | sed "s/UUID=//" )
++ bootsv=$(echo "$bootmnt" | cut -d ' ' -f 4 | sed -n 's!\(^subvol=\|.*,subvol=\)\([^,]\+\).*!\2!p')
++ if [ -z "$bootsv" ]; then
++ warn "no subvolume in entry: $bootmnt"
++ umount "$tmpmnt" 2>/dev/null
++ rmdir "$tmpmnt" 2>/dev/null
++ exit 1
++ fi
++ bootuuid=$(echo "$bootmnt" | cut -d ' ' -f 1 | sed -n 's/UUID=\("\(.*\)"\|\(.*\)\)/\2\3/p')
+ debug "mounting btrfs $tmpmnt/boot UUID=$bootuuid subvol=$bootsv"
+ bindfrom=$(check_btrfs_mounted $bootsv $bootuuid)
+ if [ -n "$bindfrom" ]; then
+ # already mounted some place
+ if ! mount -o bind $bindfrom "$tmpmnt/boot" 2>/dev/null; then
+ warn "error bind mounting btrfs boot subvol=$bootsv, from=$bindfrom"
+- umount "$tmpmnt/boot" 2>/dev/null
+ umount "$tmpmnt" 2>/dev/null
+ rmdir "$tmpmnt" 2>/dev/null
+ exit 1
+ fi
+ elif ! mount -o subvol=$bootsv -t btrfs -U $bootuuid "$tmpmnt/boot" 2>/dev/null; then
+ warn "error mounting btrfs boot partition subvol=$bootsv, UUID=$bootuuid"
+- umount "$tmpmnt/boot" 2>/dev/null
+ umount "$tmpmnt" 2>/dev/null
+ rmdir "$tmpmnt" 2>/dev/null
+ exit 1
+ fi
+- bootpart=$(grep " btrfs " /proc/self/mountinfo | grep " /$bootsv " | cut -d ' ' -f 10)
++ bootpart=$(grep " btrfs " /proc/self/mountinfo | grep " `echo /$bootsv | tr -s /` " | cut -d ' ' -f 10)
++ if [ -z "$bootpart" ]; then
++ warn "no bootpart for $bootsv in /proc/self/mountinfo"
++ fi
+ else
+ # non-btrfs partition or logical volume
+ linux_mount_boot $partition $tmpmnt
+Index: os-prober-1.76/linux-boot-probes/common/50mounted-tests
+===================================================================
+--- os-prober-1.76.orig/linux-boot-probes/common/50mounted-tests
++++ os-prober-1.76/linux-boot-probes/common/50mounted-tests
+@@ -42,10 +42,7 @@ elif [ -z "$types" ]; then
+ types="$(grep -v nodev /proc/filesystems)"
+ fi
+
+-tmpmnt=/var/lib/os-prober/mount
+-if [ ! -d "$tmpmnt" ]; then
+- mkdir "$tmpmnt"
+-fi
++tmpmnt="$(mktemp -d /tmp/linux-boot-probes-50mounted-tests.XXXXXX)"
+
+ mounted=
+ if type grub2-mount >/dev/null 2>&1 && \
+Index: os-prober-1.76/os-prober
+===================================================================
+--- os-prober-1.76.orig/os-prober
++++ os-prober-1.76/os-prober
+@@ -141,9 +141,6 @@ parse_proc_mdstat () {
+ done
+ }
+
+-# Needed for idempotency
+-rm -f /var/lib/os-prober/labels
+-
+ for prog in /usr/lib/os-probes/init/*; do
+ if [ -x "$prog" ] && [ -f "$prog" ]; then
+ "$prog" || true
+Index: os-prober-1.76/os-probes/common/50mounted-tests
+===================================================================
+--- os-prober-1.76.orig/os-probes/common/50mounted-tests
++++ os-prober-1.76/os-probes/common/50mounted-tests
+@@ -58,10 +58,7 @@ elif [ -z "$types" ]; then
+ exit 0
+ fi
+
+-tmpmnt=/var/lib/os-prober/mount
+-if [ ! -d "$tmpmnt" ]; then
+- mkdir "$tmpmnt"
+-fi
++tmpmnt="$(mktemp -d /tmp/os-probes-50mounted-tests.XXXXXX)"
+
+ mounted=
+
+@@ -105,7 +102,7 @@ probe_subvol ()
+ local UUID=$3
+ local tmpmnt=$4
+
+- mounted=
++ local mounted=
+ mpoint="$(grep btrfs /proc/self/mountinfo | grep "$partition " | grep "/$subvol " | cut -d ' ' -f 5)"
+ ret=1
+
+@@ -115,13 +112,18 @@ probe_subvol ()
+
+ if [ -n "$mpoint" ]; then
+ if [ "x$mpoint" = "x/" ]; then
+- continue # this is the root for the running system
++ return 1
+ fi
+- mounted=1
+ else
+ # again, do not mount btrfs ro
+- mount -t btrfs $opts -U "$UUID" "$tmpmnt"
+- mpoint="$tmpmnt"
++ if mount -t btrfs $opts -U "$UUID" "$tmpmnt" 2>/dev/null; then
++ debug "btrfs volume $UUID mounted with $opt"
++ mpoint="$tmpmnt"
++ mounted=1
++ else
++ warn "cannot mount btrfs volume $UUID with $opt"
++ return 1
++ fi
+ fi
+ test="/usr/lib/os-probes/mounted/90linux-distro"
+ if [ -f "$test" ] && [ -x "$test" ]; then
+@@ -131,7 +133,7 @@ probe_subvol ()
+ ret=0
+ fi
+ fi
+- if [ -z "$mounted" ]; then
++ if [ "$mounted" ]; then
+ if ! umount "$tmpmnt"; then
+ warn "failed to umount $tmpmnt"
+ fi
+Index: os-prober-1.76/linux-boot-probes/mounted/common/40grub2
+===================================================================
+--- os-prober-1.76.orig/linux-boot-probes/mounted/common/40grub2
++++ os-prober-1.76/linux-boot-probes/mounted/common/40grub2
+@@ -15,7 +15,7 @@ found_item=0
+
+ entry_result () {
+ if [ "x$type" = "xbtrfs" ]; then
+- bsv=${bootsv:+/}${bootsv}
++ bsv=`echo ${bootsv:+/}${bootsv} | tr -s /`
+ # if path is not relative to subvolume make it relative
+ kernel=${kernel#${bsv}}
+ kernelfile=$kernel
diff --git a/sys-boot/os-prober/os-prober-1.77-r314.ebuild b/sys-boot/os-prober/os-prober-1.77-r10.ebuild
index 8010ba3f..9ab62e33 100644
--- a/sys-boot/os-prober/os-prober-1.77-r314.ebuild
+++ b/sys-boot/os-prober/os-prober-1.77-r10.ebuild
@@ -21,9 +21,32 @@ DEPEND=""
QA_MULTILIB_PATHS="usr/lib/os-prober/.*"
# start : Redcore Linux Project tweaks
-PATCHES=(
- "${FILESDIR}"/${PN}-1.76-exherbo.patch
- "${FILESDIR}"/os-prober-redcore.patch
+PATCHES=(
+ ${FILESDIR}/${PN}-newnsdirfix.patch
+ ${FILESDIR}/${PN}-SUSE.patch
+ ${FILESDIR}/${PN}-1.49-fix-grub2.cfg-parsing.patch
+ ${FILESDIR}/${PN}-1.49-grub2-mount.patch
+ ${FILESDIR}/${PN}-probe-MD-devices.patch
+ ${FILESDIR}/${PN}-linux-secure-boot.patch
+ ${FILESDIR}/${PN}-btrfsfix.patch
+ ${FILESDIR}/${PN}-EFI-openSUSEfy.patch
+ ${FILESDIR}/${PN}-accept-ESP-on-IMSM.patch
+ ${FILESDIR}/${PN}-dont-load-all-fs-module-and-dont-test-mount.patch
+ ${FILESDIR}/${PN}-fix-btrfs-subvol-mounted-tests.patch
+ ${FILESDIR}/${PN}-skip-part-on-multipath.patch
+ ${FILESDIR}/Improve-btrfs-handling-on-os-probing-for-grub2.patch
+ ${FILESDIR}/${PN}-btrfs-absolute-subvol.patch
+ ${FILESDIR}/${PN}-40grub-check-grub2.patch
+ ${FILESDIR}/${PN}-btrfs-snapshot-detection.patch
+ ${FILESDIR}/${PN}-btrfs-always-detect-default.patch
+ ${FILESDIR}/${PN}-linux-distro-avoid-expensive-ld-file-test.patch
+ ${FILESDIR}/${PN}-linux-distro-parse-os-release.patch
+ ${FILESDIR}/${PN}-05efi-blkid.patch
+ ${FILESDIR}/${PN}-multiple-initrd.patch
+ ${FILESDIR}/${PN}-make-btrfsprogs-optional.patch
+ ${FILESDIR}/${PN}-use-tmp-over-var-lib-for-transient-files.patch
+ ${FILESDIR}/${PN}-btrfs-multiple-device.patch
+ ${FILESDIR}/${PN}-redcore.patch
)
# stop : Redcore Linux Project tweaks
@@ -48,7 +71,7 @@ src_install() {
dobin os-prober linux-boot-prober
# Note: as no shared libraries are installed, /usr/lib is correct
- exeinto /usr/lib/os-prober
+ exeinto /usr/lib
doexe newns
insinto /usr/share/os-prober