summaryrefslogtreecommitdiff
path: root/sys-boot/os-prober
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2021-10-08 23:06:07 +0100
committerV3n3RiX <venerix@koprulu.sector>2021-10-08 23:06:07 +0100
commite23a08d0c97a0cc415aaa165da840b056f93c997 (patch)
tree4c5f7db60483518201fef36f8cc0712789a08db2 /sys-boot/os-prober
parent391b5b359a346aff490103da7dddc85047f83830 (diff)
gentoo resync : 08.10.2021
Diffstat (limited to 'sys-boot/os-prober')
-rw-r--r--sys-boot/os-prober/Manifest12
-rw-r--r--sys-boot/os-prober/files/os-prober-1.79-btrfs-subvolume-detection.patch505
-rw-r--r--sys-boot/os-prober/files/os-prober-1.79-efi-chroot-blkid-fallback.patch24
-rw-r--r--sys-boot/os-prober/files/os-prober-1.79-fix-busy-umount-message.patch21
-rw-r--r--sys-boot/os-prober/files/os-prober-1.79-handle-multiple-initrd-paths.patch35
-rw-r--r--sys-boot/os-prober/files/os-prober-1.79-mdraid-detection.patch28
-rw-r--r--sys-boot/os-prober/files/os-prober-1.79-mounted-boot-partition-fix.patch17
-rw-r--r--sys-boot/os-prober/files/os-prober-1.79-use-fstab-name.patch34
-rw-r--r--sys-boot/os-prober/os-prober-1.78-r1.ebuild (renamed from sys-boot/os-prober/os-prober-1.78.ebuild)0
-rw-r--r--sys-boot/os-prober/os-prober-1.79.ebuild104
-rw-r--r--sys-boot/os-prober/os-prober-9999.ebuild103
11 files changed, 882 insertions, 1 deletions
diff --git a/sys-boot/os-prober/Manifest b/sys-boot/os-prober/Manifest
index 4ce549eefb67..ce14b440e277 100644
--- a/sys-boot/os-prober/Manifest
+++ b/sys-boot/os-prober/Manifest
@@ -1,5 +1,15 @@
AUX os-prober-1.76-exherbo.patch 905 BLAKE2B e8d78b730d33b5760128eaf910f20ac01dc7db3e2b3a271279859869e3c8451e7c8dd72ed5b2784a0dfbf3f31747a81509445d3793a8ed8070a1a721b1b84186 SHA512 0c3c2e4cde868e186131b08268e6344841f0830be5bf4131e5a7ded93a222097599b0a011168e4b7bd0bc97b69ece194df1d46d98eac2c921f16b3e76d004cc8
AUX os-prober-1.78-btrfsfix.patch 14379 BLAKE2B 5aff7aad1957966355748eafb7b1b426e81428c1de9d1053e708cccb271efe97c8728887a7dbc969a78e4ff3d92cbb0b1badf7551532030b585c5211a7308323 SHA512 deefcd22ac50b9a5cdc4609eda6cc5c58f40989c17e56a8f098f529bacfef7bb65fca9775e7ea85540b850eecfd1380d9474388644f13c47459c14bc6cbe681f
+AUX os-prober-1.79-btrfs-subvolume-detection.patch 14719 BLAKE2B 94d2c67eac4d17fee345f046a147c8f9d2f12446e07b651a0ddd8245fc6791589bf38603c02dfbbeba05f7ab63a1bd996692ca6b066bc568d33b63c396571d5d SHA512 588f68ab64547d3f854879ec65c74067fe0a3068a0e2f5e2c8bb461e08e4fe3a2be7dcfb10a5d7b44033ad46419e9ef6e8af28c59085fea06f77d6885a11bb35
+AUX os-prober-1.79-efi-chroot-blkid-fallback.patch 1025 BLAKE2B 86a4b2fee4ac16f0e454cd244f7c27ea40b5115c0a4945b2b0f69be683854853e5f9ae9ed9844821c22e0dd0604f2fb6947a97d2640fc6b1f5e7c723f3b424b7 SHA512 36bc04c07182a83dac3c0e0328a046a665cb535c8719a934756a0f0575122897c3f5542aef0052709aace3a1d4331d7486b5bd993e8d412da5f4b7afe2d48d1b
+AUX os-prober-1.79-fix-busy-umount-message.patch 435 BLAKE2B 547286075651f19518a4a8815a920604e8c31190fdcea9ef8a0ec2a607d126f2181e51fb77ef1585dac5551e990e6a07aca81004b0fa4fc8ed39559866a0d005 SHA512 b68352f1a7f3607ca853de42bd589600cf310abe34dd7ab99fdb12eebbe1a50b7b5a6b208a8902f2cdb61ce7acff12f6d616311d704ba4ee5347120d44adc37a
+AUX os-prober-1.79-handle-multiple-initrd-paths.patch 1008 BLAKE2B b66a9e9e2f2ab3a2e1a092efa5eba519c71d2b48ffde010d260a704a225da39e72a09bc1ed609ad0ccdf738b54f3b25536fa340a973d553d82d6625944a81231 SHA512 266c896c80e36a779502f4f7a10c64d9778bff5d914df1f191f55dd39c2f2d4f4cdcd957ce396d21b486d5d8d48bb353704379ee0eda43ff3c8e0791a5a2f6f6
+AUX os-prober-1.79-mdraid-detection.patch 848 BLAKE2B 11ec43662f174d7f12f09b9b46f57ea7519d45aa1560ef31fc9c75b2684d1f549b3a679aa3f6dff855fc79c72757f0814ea147e75536f6503fc76f3426f8c648 SHA512 a4d68ea8cb6dcc2fc452a15ed983cb911e6a6097ec48515511b94c7f0096c6f611ffb4bf8af3c373cc5774f94e398ef74e1e2a8fe68669ace31bed134e839697
+AUX os-prober-1.79-mounted-boot-partition-fix.patch 555 BLAKE2B 9b98506f986ceb509271a8a1ce0cc357fb25402ec1059d16411c79e96c727ef40182b5d9f362f16ae4ddab95a45155380cc5742ad1f15ac2cd39fdf273fc9a90 SHA512 fa66356859001d15823c3dbe8143e905e25ee937c236c787965b2a9a50493b55006e0fc9190b076fe106f942ea6074ef7556a443a237d0108b6b936106186061
+AUX os-prober-1.79-use-fstab-name.patch 1101 BLAKE2B 37353efa899fd72e68d297325218be5a81abc2eee50bda5607e87c0eb799924fff0f510b4f13c681213e5e4be864a62fec9d5c98e539a61e9cd4036315eeabc5 SHA512 25236c935559398a4c37cdec04c358787f6178a016a6d0d4780c7dcd9eb7e18f308f4a89a1ddbb37d6c7dd17d334d879961029afb4463cef5e9029eab58fdc5c
DIST os-prober_1.78.tar.xz 26848 BLAKE2B eee68ab9be36807d86e8bda831cfd490a01d20d9cc3f84ca50d5e1143e5a2dd66e47d3bdf2b4780cf73cc692f0ffc9497c6cbf13ce7aa0057e996b13d706c8f7 SHA512 7a0425130d17ce8554e7d0797b53e3a984f63a2fdcf8e668c83d357418d8c68259ada25bc350b199adece2e683d9014f234e3a83ce5ab7485be2e69c45874640
-EBUILD os-prober-1.78.ebuild 2233 BLAKE2B 7fa1535d0b90ec18c1ec2a49759915a786f35657a1bbed560239fed784e87d8517b2754c315017013f72398d6159faff5178f9976963443fd42ac52c6210f4db SHA512 54cb1e72251533af64b65675b1fb5833c699f9f91c6d20586268e5300a7977e2d95dcd3e8d32629ac6aaf45a9fecc434151aff4d7e656f577ae42f17c15b2f14
+DIST os-prober_1.79.tar.xz 27028 BLAKE2B b3efacce9d7fce3708f5ec727a219e872e8d1de6dea15540cfbc0a0e8372c1033098230d3ddb9066fb5474d44e5584ee28631e0e5ab981e8fb1dc29ee3cbd89d SHA512 89b827b9b90a1d3bc11e0090ec04d808502cc1883ab10997b6d9edbe6005dcf8a0acdd7d200102c9dccde56297bda6087d68fb6dec419f0920090c2655c9c7d8
+EBUILD os-prober-1.78-r1.ebuild 2233 BLAKE2B 7fa1535d0b90ec18c1ec2a49759915a786f35657a1bbed560239fed784e87d8517b2754c315017013f72398d6159faff5178f9976963443fd42ac52c6210f4db SHA512 54cb1e72251533af64b65675b1fb5833c699f9f91c6d20586268e5300a7977e2d95dcd3e8d32629ac6aaf45a9fecc434151aff4d7e656f577ae42f17c15b2f14
+EBUILD os-prober-1.79.ebuild 2543 BLAKE2B 350e41f8141b46037344bee7f16ef0fb63c40e4d50a70f026d0a39abf24b1d6908620abd8db184261f4e03223738138438b591bdf94a870c5e4f1485d05c20db SHA512 b6e8b8380b1c2a430a4cade4d9489eebca7f3e469467f417717b2fd9dc052de364dc1f6b8bebc9cefeeb312076f365b7719828923a39b1602c423037c227a6d8
+EBUILD os-prober-9999.ebuild 2482 BLAKE2B c59a755ba75807f6bdc3f9437ea319ee55600658997a23168f586eb19c4ea1012a9dfc0d637ae18bce2d972f8533e81360249c1af4157e67dad4de242c8dbe1b SHA512 62c4eb2541c01148e715eebf2b65d4ebaa0435a431839360e06509935706cfee3c1c5afc444333e94921f43d767d0964cedc118f9981bf4cb8cc01fcd7ed492c
MISC metadata.xml 384 BLAKE2B 98bf64680e61d1c0f0c9cbd73ce11be5a98fc7014517d263be8808064b1ab5b7ef200c243c472c3dedfad24176851007d9f4b03399e0970fd351f086b13d355c SHA512 dd391671666f17ce8e45093ff42c898c4bb0c685df9bb631c56089379d0825a15364656dedf4eec13c7652cfdbeb9c4f40f7bae0a8360cadd9b2cff136189bc3
diff --git a/sys-boot/os-prober/files/os-prober-1.79-btrfs-subvolume-detection.patch b/sys-boot/os-prober/files/os-prober-1.79-btrfs-subvolume-detection.patch
new file mode 100644
index 000000000000..14cd794530ee
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-1.79-btrfs-subvolume-detection.patch
@@ -0,0 +1,505 @@
+Fixes detection of multiple linux installations on different subvolumes of the
+same partition. Also contains changes from
+https://build.opensuse.org/package/view_file/openSUSE:Factory/os-prober/os-prober-btrfs-always-detect-default.patch
+to fix https://bugs.gentoo.org/790434.
+
+Bug: https://bugs.gentoo.org/790434
+ https://bugs.debian.org/688336
+ https://bugzilla.redhat.com/888341
+
+--- a/common.sh
++++ b/common.sh
+@@ -155,6 +155,7 @@
+ done
+ }
+
++# add forth parameter to pickup btrfs subvol info
+ parsefstab () {
+ while read -r line; do
+ case "$line" in
+@@ -165,12 +166,22 @@
+ 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'
+--- a/linux-boot-prober
++++ b/linux-boot-prober
+@@ -5,16 +5,148 @@
+
+ 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 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 [ -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
++ 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
+@@ -22,8 +154,8 @@
+
+ if ! grep -q "^$mapped " "$OS_PROBER_TMP/mounted-map"; then
+ for test in /usr/lib/linux-boot-probes/*; do
+- debug "running $test"
+ if [ -x $test ] && [ -f $test ]; then
++ debug "running $test"
+ if $test "$partition"; then
+ debug "linux detected by $test"
+ break
+--- a/linux-boot-probes/mounted/common/40grub2
++++ b/linux-boot-probes/mounted/common/40grub2
+@@ -2,17 +2,30 @@
+ . /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 "$partition" = "$bootpart" ]; then
++ # trim off the leading subvol
++ kernelfile=$(echo "$kernel" | cut -d '/' -f 2- | cut -d '/' -f 2-)
++ if [ "x$rootsv" != "x$bootsv" ]; then
++ kernelfile="/boot/$kernelfile"
++ fi
++ 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
+@@ -108,9 +121,9 @@
+ [ "$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/grub.cfg" ]; then
++elif [ -e "$mpoint/boot/grub/grub.cfg" ]; then
+ debug "parsing grub.cfg"
+- parse_grub_menu "$mpoint" "$partition" "$bootpart" < "$mpoint/boot/grub2/grub.cfg"
++ parse_grub_menu "$mpoint" "$partition" "$bootpart" < "$mpoint/boot/grub/grub.cfg"
+ fi
+
+ if [ "$found_item" = 0 ]; then
+--- a/os-prober
++++ b/os-prober
+@@ -76,9 +76,12 @@
+
+ # Also detect OSes on LVM volumes (assumes LVM is active)
+ if type lvs >/dev/null 2>&1; then
+- echo "$(LVM_SUPPRESS_FD_WARNINGS=1 log_output lvs --noheadings --separator : -o vg_name,lv_name |
++ echo "$(LVM_SUPPRESS_FD_WARNINGS=1 log_output lvs --noheadings --separator : -o vg_name,lv_name 2>/dev/null |
+ 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 'TYPE="btrfs"' | cut -d ':' -f 1
+ }
+
+ parse_proc_swaps () {
+@@ -136,6 +139,8 @@
+ grep "^md" /proc/mdstat | cut -d: -f2- | 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"
+@@ -154,7 +159,26 @@
+ 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"
+--- a/os-probes/common/50mounted-tests
++++ b/os-probes/common/50mounted-tests
+@@ -14,19 +14,31 @@
+ 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")" || types=NOT-DETECTED
++fi
++
+ if [ "$types" = NOT-DETECTED ]; then
+ debug "$1 type not recognised; skipping"
+- exit 0
++ exit 1
+ elif [ "$types" = swap ]; then
+ debug "$1 is a swap partition; skipping"
+- exit 0
++ exit 1
+ elif [ "$types" = crypto_LUKS ]; then
+ debug "$1 is a LUKS partition; skipping"
+- exit 0
++ exit 1
+ elif [ "$types" = LVM2_member ]; then
+ debug "$1 is an LVM member; skipping"
+- exit 0
++ exit 1
+ elif [ "$types" = ntfs ]; then
+ if type ntfs-3g >/dev/null 2>&1; then
+ types='ntfs-3g ntfs'
+@@ -35,7 +47,7 @@
+ if type cryptsetup >/dev/null 2>&1 && \
+ cryptsetup luksDump "$partition" >/dev/null 2>&1; then
+ debug "$1 is a LUKS partition; skipping"
+- exit 0
++ exit 1
+ fi
+ for type in $(grep -v nodev /proc/filesystems); do
+ # hfsplus filesystems are mountable as hfs. Try hfs last so
+@@ -58,6 +70,127 @@
+ fi
+
+ mounted=
++
++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
++ 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
++
++ found=
++ mounted=
++
++ mpoint="$(grep btrfs /proc/self/mountinfo | grep "$partition " | cut -d ' ' -f 5)"
++ if [ -n "$mpoint" -a "x$mpoint" = "x/" ]; then
++ debug "This is the root for the running system" #running system must be done elsewhere
++ else
++ #partition was not root of running system, so lets look for bootable subvols
++ if [ -n "$mpoint" ] ; then
++ mounted=1 #partition was already mounted,so lets not unmount it when done
++ else
++ # again, do not mount btrfs ro
++ mount -t btrfs -U "$UUID" "$tmpmnt"
++ mpoint="$tmpmnt"
++ fi
++
++ test="/usr/libexec/os-probes/mounted/90linux-distro"
++ if [ -f "$test" ] && [ -x "$test" ]; then
++ debug "running subtest $test"
++ if "$test" "$partition" "$mpoint" btrfs "UUID=$UUID"; then
++ debug "os found by subtest $test on $partition"
++ found=1
++ fi
++ fi
++ if [ -z "$mounted" ]; then
++ if ! umount "$tmpmnt"; then
++ warn "failed to umount $tmpmnt"
++ fi
++ fi
++ fi
++ found=
++ # 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
++ debug "begin btrfs processing for $UUID subvol=$subvol"
++ if probe_subvol "$subvol" "$partition" "$UUID" "$tmpmnt"; then
++ found=1
++ fi
++ done
++ rmdir "$tmpmnt" || true
++ if [ "$found" ]; then
++ exit 0
++ else
++ exit 1
++ fi
++fi
++
+ if type grub-mount >/dev/null 2>&1 && \
+ type grub-probe >/dev/null 2>&1 && \
+ grub-mount "$partition" "$tmpmnt" 2>/dev/null; then
+--- a/os-probes/mounted/common/90linux-distro
++++ b/os-probes/mounted/common/90linux-distro
+@@ -7,6 +7,8 @@
+ 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 @@
+ 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
diff --git a/sys-boot/os-prober/files/os-prober-1.79-efi-chroot-blkid-fallback.patch b/sys-boot/os-prober/files/os-prober-1.79-efi-chroot-blkid-fallback.patch
new file mode 100644
index 000000000000..b5b90b2214da
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-1.79-efi-chroot-blkid-fallback.patch
@@ -0,0 +1,24 @@
+Fixes missing entries when os-prober is run in a chroot environment by falling back
+to blkid if udev isn't available or if /run/udev isn't bind mounted. Modified from
+https://build.opensuse.org/package/view_file/Base:System/os-prober/os-prober-05efi-blkid.patch?rev=103
+
+Bug: https://bugs.gentoo.org/761475
+ https://bugzilla.opensuse.org/1076779
+
+--- a/os-probes/mounted/x86/05efi
++++ b/os-probes/mounted/x86/05efi
+@@ -46,6 +46,14 @@ if type udevinfo > /dev/null 2>&1; then
+ fi
+
+ eval "$(udevinfo -q property -n "$partition" | grep -E '^ID_PART_ENTRY_(TYPE|SCHEME)=')"
++
++ # 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.79-fix-busy-umount-message.patch b/sys-boot/os-prober/files/os-prober-1.79-fix-busy-umount-message.patch
new file mode 100644
index 000000000000..a9859f5005ab
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-1.79-fix-busy-umount-message.patch
@@ -0,0 +1,21 @@
+Fixes errors like "umount: /var/lib/os-prober/mount: target is busy."
+which can appear in some corner-cases.
+
+Bug: https://bugzilla.redhat.com/903906
+
+--- a/common.sh
++++ b/common.sh
+@@ -336,3 +336,13 @@ linux_mount_boot () {
+
+ mountboot="$bootpart $mounted"
+ }
++
++umount_exec=$(which umount)
++umount() {
++ if ! $umount_exec $@ 2> /dev/null; then
++ error "umount error, retrying after 1 sec"
++ sleep 1
++ $umount_exec $@
++ fi
++}
++
diff --git a/sys-boot/os-prober/files/os-prober-1.79-handle-multiple-initrd-paths.patch b/sys-boot/os-prober/files/os-prober-1.79-handle-multiple-initrd-paths.patch
new file mode 100644
index 000000000000..0b477c17c362
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-1.79-handle-multiple-initrd-paths.patch
@@ -0,0 +1,35 @@
+Backport handling of multiple initrd paths, like those needed by Manjaro
+installations. Note, it still requires resolution of
+https://savannah.gnu.org/bugs/index.php?47681 on grub's end.
+
+Commit: https://salsa.debian.org/installer-team/os-prober/-/commit/53b920e106f13acf87ef8a275161e20f94feeb8a
+
+--- a/linux-boot-probes/mounted/common/40grub2
++++ b/linux-boot-probes/mounted/common/40grub2
+@@ -78,11 +78,21 @@
+ fi
+ ;;
+ initrd)
+- initrd="$(echo "$2" | sed 's/(.*)//')"
+- # Initrd same.
+- if [ "$partition" != "$bootpart" ]; then
+- initrd="/boot$initrd"
+- fi
++ shift
++ initrd=""
++ for initrd_path in "$@"; do
++ # sed hack, as above
++ initrd_path="$(echo "$initrd_path" | sed 's/(.*)//')"
++ # Initrd same.
++ if [ "$partition" != "$bootpart" ]; then
++ initrd_path="/boot$initrd_path"
++ fi
++ if [ -z "$initrd" ]; then
++ initrd="$initrd_path"
++ else
++ initrd="$initrd $initrd_path"
++ fi
++ done
+ ;;
+ "}")
+ entry_result
diff --git a/sys-boot/os-prober/files/os-prober-1.79-mdraid-detection.patch b/sys-boot/os-prober/files/os-prober-1.79-mdraid-detection.patch
new file mode 100644
index 000000000000..15b9de5117a9
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-1.79-mdraid-detection.patch
@@ -0,0 +1,28 @@
+Fixes OS detection on mdraid devices
+
+Bug: https://bugs.debian.org/648251
+ https://bugzilla.redhat.com/752402
+
+--- a/os-prober
++++ b/os-prober
+@@ -64,6 +64,11 @@ partitions () {
+ exit 0
+ fi
+
++ # Add MD RAID devices
++ if [ -f /proc/mdstat ] ; then
++ awk '/^md/ {printf "/dev/"$1"\n"}' /proc/mdstat
++ fi
++
+ # Also detect OSes on LVM volumes (assumes LVM is active)
+ if type lvs >/dev/null 2>&1; then
+ echo "$(LVM_SUPPRESS_FD_WARNINGS=1 log_output lvs --noheadings --separator : -o vg_name,lv_name |
+@@ -123,7 +128,7 @@ if [ -f /proc/swaps ]; then
+ fi
+ : >"$OS_PROBER_TMP/raided-map"
+ if [ -f /proc/mdstat ] ; then
+- grep "^md" /proc/mdstat | parse_proc_mdstat >"$OS_PROBER_TMP/raided-map" || true
++ grep "^md" /proc/mdstat | cut -d: -f2- | parse_proc_mdstat >"$OS_PROBER_TMP/raided-map" || true
+ fi
+
+ for partition in $(partitions); do
diff --git a/sys-boot/os-prober/files/os-prober-1.79-mounted-boot-partition-fix.patch b/sys-boot/os-prober/files/os-prober-1.79-mounted-boot-partition-fix.patch
new file mode 100644
index 000000000000..1be8c810ddf5
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-1.79-mounted-boot-partition-fix.patch
@@ -0,0 +1,17 @@
+Fixes the problem of the root partition being returned instead of the boot
+partition when both are already mounted somewhere.
+
+Bug: https://bugs.debian.org/699840
+ https://bugzilla.redhat.com/906886
+
+--- a/linux-boot-prober
++++ b/linux-boot-prober
+@@ -167,7 +167,7 @@ else
+ bootpart="${mountboot%% *}"
+ bootmounted="${mountboot#* }"
+ else
+- bootpart="$partition"
++ bootpart="$(grep " $mpoint/boot " "$OS_PROBER_TMP/mounted-map" | head -n1 | cut -d " " -f 4)"
+ bootmounted=0
+ fi
+ for test in /usr/lib/linux-boot-probes/mounted/*; do
diff --git a/sys-boot/os-prober/files/os-prober-1.79-use-fstab-name.patch b/sys-boot/os-prober/files/os-prober-1.79-use-fstab-name.patch
new file mode 100644
index 000000000000..e38d85a77feb
--- /dev/null
+++ b/sys-boot/os-prober/files/os-prober-1.79-use-fstab-name.patch
@@ -0,0 +1,34 @@
+For symlinks to partions in fstab, returns the partition name from fstab instead
+of the name of its resolved destination, eg., for /dev/mapper/mylvmvol in fstab,
+linked to /dev/dm-2, return "mylvmvol" instead of "dm-2".
+
+Bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=699839
+ https://bugzilla.redhat.com/show_bug.cgi?id=893472
+
+--- a/common.sh
++++ b/common.sh
+@@ -269,7 +269,7 @@ linux_mount_boot () {
+ if [ "$bindfrom" != "$tmpmnt/boot" ]; then
+ if mount --bind "$bindfrom" "$tmpmnt/boot"; then
+ mounted=1
+- bootpart="$1"
++ bootpart="$tmppart"
+ else
+ debug "failed to bind-mount $bindfrom onto $tmpmnt/boot"
+ fi
+@@ -277,6 +277,15 @@ linux_mount_boot () {
+ fi
+ if [ "$mounted" ]; then
+ :
++ elif [ -e "$tmppart" ]; then
++ bootpart="$tmppart"
++ boottomnt="$tmppart"
++ elif [ -e "$tmpmnt/$tmppart" ]; then
++ bootpart="$tmppart"
++ boottomnt="$tmpmnt/$tmppart"
++ elif [ -e "/target/$tmppart" ]; then
++ bootpart="$tmppart"
++ boottomnt="/target/$tmppart"
+ elif [ -e "$1" ]; then
+ bootpart="$1"
+ boottomnt="$1"
diff --git a/sys-boot/os-prober/os-prober-1.78.ebuild b/sys-boot/os-prober/os-prober-1.78-r1.ebuild
index ba56852a216e..ba56852a216e 100644
--- a/sys-boot/os-prober/os-prober-1.78.ebuild
+++ b/sys-boot/os-prober/os-prober-1.78-r1.ebuild
diff --git a/sys-boot/os-prober/os-prober-1.79.ebuild b/sys-boot/os-prober/os-prober-1.79.ebuild
new file mode 100644
index 000000000000..811ad1fef51f
--- /dev/null
+++ b/sys-boot/os-prober/os-prober-1.79.ebuild
@@ -0,0 +1,104 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+inherit readme.gentoo-r1 toolchain-funcs
+
+DESCRIPTION="Utility to detect other OSs on a set of drives"
+HOMEPAGE="https://salsa.debian.org/installer-team/os-prober"
+
+if [[ ${PV} == 9999 ]]; then
+ inherit git-r3
+ EGIT_REPO_URI="https://salsa.debian.org/installer-team/${PN}.git"
+else
+ SRC_URI="mirror://debian/pool/main/${PN::1}/${PN}/${PN}_${PV}.tar.xz"
+ KEYWORDS="~amd64 ~x86"
+ S="${WORKDIR}"/${PN}
+fi
+
+LICENSE="GPL-3"
+SLOT="0"
+
+# grub-mount needed per bug #607518
+RDEPEND="sys-boot/grub:2[mount]"
+
+# bug 594250
+QA_MULTILIB_PATHS="usr/lib/os-prober/.*"
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-1.79-mdraid-detection.patch
+ "${FILESDIR}"/${PN}-1.79-handle-multiple-initrd-paths.patch
+ "${FILESDIR}"/${PN}-1.79-btrfs-subvolume-detection.patch
+ "${FILESDIR}"/${PN}-1.79-use-fstab-name.patch
+ "${FILESDIR}"/${PN}-1.79-mounted-boot-partition-fix.patch
+ "${FILESDIR}"/${PN}-1.79-fix-busy-umount-message.patch
+ "${FILESDIR}"/${PN}-1.79-efi-chroot-blkid-fallback.patch
+)
+
+DOC_CONTENTS="
+ If you intend for os-prober to detect versions of Windows installed on
+ NTFS-formatted partitions, your system must be capable of reading the
+ NTFS filesystem. One way to do this is by installing sys-fs/ntfs3g.
+
+ NOTE: Since sys-boot/grub-2.06-rc1, grub-mkconfig disables os-prober by default.
+ To enable it, add GRUB_DISABLE_OS_PROBER=false to /etc/default/grub.
+"
+
+src_prepare() {
+ default
+ # use default GNU rules
+ rm Makefile || die 'rm Makefile failed'
+}
+
+src_compile() {
+ tc-export CC
+ emake newns
+}
+
+src_install() {
+ dobin os-prober linux-boot-prober
+
+ # Note: as no shared libraries are installed, /usr/lib is correct
+ exeinto /usr/lib/os-prober
+ doexe newns
+
+ insinto /usr/share/os-prober
+ doins common.sh
+
+ keepdir /var/lib/os-prober
+
+ local debarch=${ARCH%-*} dir
+
+ case ${debarch} in
+ amd64) debarch=x86 ;;
+ ppc|ppc64) debarch=powerpc ;;
+ esac
+
+ for dir in os-probes{,/mounted,/init} linux-boot-probes{,/mounted}; do
+ exeinto /usr/lib/${dir}
+ doexe ${dir}/common/*
+ if [[ -d ${dir}/${debarch} ]]; then
+ for exe in ${dir}/${debarch}/*; do
+ [[ ! -d "${exe}" ]] && doexe "${exe}"
+ done
+ fi
+ if [[ -d ${dir}/${debarch}/efi ]]; then
+ exeinto /usr/lib/${dir}/efi
+ doexe ${dir}/${debarch}/efi/*
+ fi
+ done
+
+ if use amd64 || use x86; then
+ exeinto /usr/lib/os-probes/mounted
+ doexe os-probes/mounted/powerpc/20macosx
+ fi
+
+ einstalldocs
+ dodoc debian/changelog
+
+ readme.gentoo_create_doc
+}
+
+pkg_postinst() {
+ readme.gentoo_print_elog
+}
diff --git a/sys-boot/os-prober/os-prober-9999.ebuild b/sys-boot/os-prober/os-prober-9999.ebuild
new file mode 100644
index 000000000000..c854d403e4f0
--- /dev/null
+++ b/sys-boot/os-prober/os-prober-9999.ebuild
@@ -0,0 +1,103 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+inherit readme.gentoo-r1 toolchain-funcs
+
+DESCRIPTION="Utility to detect other OSs on a set of drives"
+HOMEPAGE="https://salsa.debian.org/installer-team/os-prober"
+
+if [[ ${PV} == 9999 ]]; then
+ inherit git-r3
+ EGIT_REPO_URI="https://salsa.debian.org/installer-team/${PN}.git"
+else
+ SRC_URI="mirror://debian/pool/main/${PN::1}/${PN}/${PN}_${PV}.tar.xz"
+ KEYWORDS="~amd64 ~x86"
+ S="${WORKDIR}"/${PN}
+fi
+
+LICENSE="GPL-3"
+SLOT="0"
+
+# grub-mount needed per bug #607518
+RDEPEND="sys-boot/grub:2[mount]"
+
+# bug 594250
+QA_MULTILIB_PATHS="usr/lib/os-prober/.*"
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-1.79-mdraid-detection.patch
+ "${FILESDIR}"/${PN}-1.79-btrfs-subvolume-detection.patch
+ "${FILESDIR}"/${PN}-1.79-use-fstab-name.patch
+ "${FILESDIR}"/${PN}-1.79-mounted-boot-partition-fix.patch
+ "${FILESDIR}"/${PN}-1.79-fix-busy-umount-message.patch
+ "${FILESDIR}"/${PN}-1.79-efi-chroot-blkid-fallback.patch
+)
+
+DOC_CONTENTS="
+ If you intend for os-prober to detect versions of Windows installed on
+ NTFS-formatted partitions, your system must be capable of reading the
+ NTFS filesystem. One way to do this is by installing sys-fs/ntfs3g.
+
+ NOTE: Since sys-boot/grub-2.06-rc1, grub-mkconfig disables os-prober by default.
+ To enable it, add GRUB_DISABLE_OS_PROBER=false to /etc/default/grub.
+"
+
+src_prepare() {
+ default
+ # use default GNU rules
+ rm Makefile || die 'rm Makefile failed'
+}
+
+src_compile() {
+ tc-export CC
+ emake newns
+}
+
+src_install() {
+ dobin os-prober linux-boot-prober
+
+ # Note: as no shared libraries are installed, /usr/lib is correct
+ exeinto /usr/lib/os-prober
+ doexe newns
+
+ insinto /usr/share/os-prober
+ doins common.sh
+
+ keepdir /var/lib/os-prober
+
+ local debarch=${ARCH%-*} dir
+
+ case ${debarch} in
+ amd64) debarch=x86 ;;
+ ppc|ppc64) debarch=powerpc ;;
+ esac
+
+ for dir in os-probes{,/mounted,/init} linux-boot-probes{,/mounted}; do
+ exeinto /usr/lib/${dir}
+ doexe ${dir}/common/*
+ if [[ -d ${dir}/${debarch} ]]; then
+ for exe in ${dir}/${debarch}/*; do
+ [[ ! -d "${exe}" ]] && doexe "${exe}"
+ done
+ fi
+ if [[ -d ${dir}/${debarch}/efi ]]; then
+ exeinto /usr/lib/${dir}/efi
+ doexe ${dir}/${debarch}/efi/*
+ fi
+ done
+
+ if use amd64 || use x86; then
+ exeinto /usr/lib/os-probes/mounted
+ doexe os-probes/mounted/powerpc/20macosx
+ fi
+
+ einstalldocs
+ dodoc debian/changelog
+
+ readme.gentoo_create_doc
+}
+
+pkg_postinst() {
+ readme.gentoo_print_elog
+}