forked from pool/os-prober
8f472cc59a
- Version bump to 1.74: * Add support for Mageia * Improve logging of mounting and setting partitions to ro/rw * Use a read-only device-mapper entry if possible rather than setting the underlying device to read-only. Note that this introduces a dependency on dmsetup on Linux architectures. * Remove the "blockdev --setro" code path entirely, since the read-only device-mapper arrangement supersedes it and should be safer * Make the yaboot parser more tolerant about the syntax of "append" options * Disable debugging if OS_PROBER_DISABLE_DEBUG is set * Replace basename/dirname with shell string processing * Fix typos in README * Add Devuan detection * Work harder to avoid trying to mount extended partitions * Drop " (loader)" suffixes on Microsoft operating systems * Add support for 4MLinux * Use HTTPS for Vcs-* URLs, and link to cgit rather than gitweb. - Rediff * os-prober-1.49-grub2-mount.patch * os-prober-EFI-openSUSEfy.patch * os-prober-btrfs-always-detect-default.patch * os-prober-btrfsfix.patch * os-prober-dont-load-all-fs-module-and-dont-test-mount.patch * os-prober-fix-btrfs-subvol-mounted-tests.patch * os-prober-linux-distro-avoid-expensive-ld-file-test.patch * os-prober-linux-distro-parse-os-release.patch - Remove patches; fixed on upstream release * os-prober-call-dmraid-once.patch * os-prober-1.49-skip-LVM2_member.patch OBS-URL: https://build.opensuse.org/request/show/459143 OBS-URL: https://build.opensuse.org/package/show/Base:System/os-prober?expand=0&rev=73
132 lines
3.7 KiB
Diff
132 lines
3.7 KiB
Diff
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
|
|
@@ -113,6 +113,47 @@ if [ "$mounted" ]; then
|
|
fi
|
|
do_unmount
|
|
|
|
+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
|
|
@@ -135,45 +176,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
|