diff --git a/Improve-btrfs-handling-on-os-probing-for-grub2.patch b/Improve-btrfs-handling-on-os-probing-for-grub2.patch index f0557ea..c64b260 100644 --- a/Improve-btrfs-handling-on-os-probing-for-grub2.patch +++ b/Improve-btrfs-handling-on-os-probing-for-grub2.patch @@ -28,14 +28,20 @@ c. Attempt to handle the location of the kernel file correctly identical to the fs path). Signed-off-by: Egbert Eich + +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 --- linux-boot-probes/mounted/common/40grub2 | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) -diff --git a/linux-boot-probes/mounted/common/40grub2 b/linux-boot-probes/mounted/common/40grub2 -index b548585..ccdbebb 100755 ---- a/linux-boot-probes/mounted/common/40grub2 -+++ b/linux-boot-probes/mounted/common/40grub2 +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 @@ -59,3 +65,30 @@ index b548585..ccdbebb 100755 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/os-prober-btrfs-always-detect-default.patch b/os-prober-btrfs-always-detect-default.patch new file mode 100644 index 0000000..8930e95 --- /dev/null +++ b/os-prober-btrfs-always-detect-default.patch @@ -0,0 +1,132 @@ +Index: os-prober-1.61/linux-boot-prober +=================================================================== +--- os-prober-1.61.orig/linux-boot-prober ++++ os-prober-1.61/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-1.61/os-probes/common/50mounted-tests +=================================================================== +--- os-prober-1.61.orig/os-probes/common/50mounted-tests ++++ os-prober-1.61/os-probes/common/50mounted-tests +@@ -99,6 +99,48 @@ if [ "$mounted" ]; then + fi + 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 subvol processing here. Handle both unmounted and + # mounted subvolumes. + if [ "$types" = btrfs ]; then +@@ -121,45 +163,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 + if [ "$found" ]; then diff --git a/os-prober-linux-distro-avoid-expensive-ld-file-test.patch b/os-prober-linux-distro-avoid-expensive-ld-file-test.patch new file mode 100644 index 0000000..facb6c6 --- /dev/null +++ b/os-prober-linux-distro-avoid-expensive-ld-file-test.patch @@ -0,0 +1,272 @@ +Index: os-prober-1.70/os-probes/mounted/common/90linux-distro +=================================================================== +--- os-prober-1.70.orig/os-probes/mounted/common/90linux-distro ++++ os-prober-1.70/os-probes/mounted/common/90linux-distro +@@ -10,6 +10,113 @@ type="$3" + uuid="$4" + subvol="$5" + ++if [ -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/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")" + # 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 +@@ -19,126 +126,17 @@ subvol="$5" + # 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* || ls "$dir"/usr/lib*/ld*.so*) >/dev/null 2>/dev/null; then +- if [ -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/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")" +- 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 ++elif (ls "$dir"/lib*/ld*.so* || ls "$dir"/usr/lib*/ld*.so*) >/dev/null 2>/dev/null; then ++ short="Linux" ++ long="unknown Linux distribution" + 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-1.70/os-prober +=================================================================== +--- os-prober-1.70.orig/os-prober ++++ os-prober-1.70/os-prober +@@ -187,6 +187,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/os-prober.changes b/os-prober.changes index 854ba89..e595c5f 100644 --- a/os-prober.changes +++ b/os-prober.changes @@ -1,3 +1,16 @@ +------------------------------------------------------------------- +Thu Dec 17 10:14:04 UTC 2015 - mchang@suse.com + +- The ld file tests cost too much as it transversed all files in + the given wildcard directory and path, we should avoid when not + necessary. (bsc#953987) + * added os-prober-linux-distro-avoid-expensive-ld-file-test.patch +- Fix missing linux16/initrd16 parsing in entry result +- Fix kernelfile path if separate boot partition on btrfs + * modified Improve-btrfs-handling-on-os-probing-for-grub2.patch +- fix os-prober failed to detect os in btrfs root tree (bsc#957018) + * added os-prober-btrfs-always-detect-default.patch + ------------------------------------------------------------------- Tue Nov 10 00:32:40 UTC 2015 - p.drouand@gmail.com diff --git a/os-prober.spec b/os-prober.spec index 5c60d8b..fc1f00a 100644 --- a/os-prober.spec +++ b/os-prober.spec @@ -62,6 +62,10 @@ Patch18: os-prober-btrfs-absolute-subvol.patch Patch19: os-prober-40grub-check-grub2.patch # PATCH-FIX-OPENSUSE: detect os on default subvolume in snapshot (bsc#954225) Patch21: os-prober-btrfs-snapshot-detection.patch +# PATCH-FIX-OPENSUSE: os-prober update broke Linux detection (bsc#957018) +Patch22: os-prober-btrfs-always-detect-default.patch +# PATCH-FIX-OPENSUSE: y2base runs at 100% cpu busy from beginning in installation of files to completion (bsc#953987) +Patch23: os-prober-linux-distro-avoid-expensive-ld-file-test.patch Requires: /bin/grep Requires: /bin/sed Requires: /sbin/modprobe @@ -102,6 +106,8 @@ cp %{SOURCE1} . %patch18 -p1 %patch19 -p1 %patch21 -p1 +%patch22 -p1 +%patch23 -p1 find . -name \*.orig -delete %build