Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-release-src > by-pkgid > 704c9bb6db073f89f2ef10e5e8f97fd3 > files > 3

os-prober-1.65-9.mga5.src.rpm

diff -ur os-prober_o/os-probes/common/50mounted-tests os-prober/os-probes/common/50mounted-tests
--- os-prober_o/os-probes/common/50mounted-tests	2015-04-06 12:18:32.272913799 +0100
+++ os-prober/os-probes/common/50mounted-tests	2015-04-06 12:29:10.689714831 +0100
@@ -85,10 +85,43 @@
             rmdir "$tmpmnt" || true
             exit 1
         fi
-	if [ -z "$subvols" ]; then
-		debug "no subvols found on btrfs volume $UUID"
-		exit 1
-	fi
+        mounted=
+# Check master volume
+			if [ ! -d "$tmpmnt" ]; then
+			      mkdir "$tmpmnt"
+			fi
+			mpoint="$tmpmnt"
+			if [ -n "$mpoint" ]; then
+			        if [ "x$mpoint" = "x/" ]; then
+					exit 1  # this is the root for the running system
+				fi
+				if mount -t btrfs -U "$UUID" "$tmpmnt"  2>/dev/null; then
+					debug "btrfs master volume $UUID mounted"
+					mpoint="$tmpmnt"
+					test="/usr/lib/os-probes/mounted/90linux-distro"
+						if [ -f "$test" ] && [ -x "$test" ]; then
+							debug "running test $test on master vol"
+							if "$test" "$partition" "$mpoint" btrfs "UUID=$UUID" ; then
+								debug "os found by test $test on master $UUID"
+								found=1
+							fi
+						fi
+						if [ -z "$mounted" ]; then
+							if ! umount "$tmpmnt"; then
+			    				warn "failed to umount $tmpmnt"
+							fi
+						fi
+				fi
+		
+			fi
+			rmdir "$tmpmnt" || true
+			if [ "$found" ]; then
+				exit 0
+			else
+				exit 1
+			fi
+	
+# Check subvols
 	found=
         for subvol in $subvols; do
 		debug "begin btrfs processing for $UUID subvol=$subvol"
@@ -100,6 +133,7 @@
 		fi
 		mounted=
 		mpoint="$(grep btrfs /proc/self/mountinfo | grep "$partition " | grep "/$subvol " | cut -d ' ' -f 5)"
+		debug "mpoint=$mpoint partition=$partition"
 		if [ -n "$mpoint" ]; then
 			if [ "x$mpoint" = "x/" ]; then
 				continue # this is the root for the running system
@@ -109,10 +143,12 @@
 			# again, do not mount btrfs ro
 			mount -t btrfs -o subvol="$subvol" -U "$UUID" "$tmpmnt"
 			mpoint="$tmpmnt"
+			debug "mpoint=$mpoint partition=$partition"
 		fi
 		test="/usr/lib/os-probes/mounted/90linux-distro"
 		if [ -f "$test" ] && [ -x "$test" ]; then
 			debug "running subtest $test"
+			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
@@ -130,6 +166,7 @@
 	else
 		exit 1
 	fi
+#	fi  #End of subvols
 fi
 
 if type grub-mount >/dev/null 2>&1 && \
@@ -177,3 +214,4 @@
 
 # No tests found anything.
 exit 1
+
diff -ur os-prober_o/os-probes/mounted/common/90linux-distro os-prober/os-probes/mounted/common/90linux-distro
--- os-prober_o/os-probes/mounted/common/90linux-distro	2015-04-06 12:18:32.275913836 +0100
+++ os-prober/os-probes/mounted/common/90linux-distro	2015-04-06 14:46:11.433970154 +0100
@@ -27,7 +27,7 @@
 	# mandrake-release, so check their files first.
 	elif [ -e "$dir/etc/mageia-release" ]; then
 		short="Mageia"
-		long="$(cat "$dir/etc/mageia-release")"
+		long=$(. /etc/os-release; echo $PRETTY_NAME)
 	elif [ -e "$dir/etc/altlinux-release" ]; then
 		short="ALTLinux"
 		long="$(cat "$dir/etc/altlinux-release")"