mkconfig_loopback.patch: Use different GRUB loop devices for different

OS loop devices (thanks, bcbc; LP: #888281).
This commit is contained in:
Colin Watson 2012-03-08 15:39:05 +00:00
parent dcf0754eaf
commit c25fcec2d1
3 changed files with 8 additions and 5 deletions

2
debian/changelog vendored
View File

@ -2,6 +2,8 @@ grub2 (1.99-18) UNRELEASED; urgency=low
* Ensure that /sbin and /usr/sbin are in $PATH when running tests (closes:
#662916).
* mkconfig_loopback.patch: Use different GRUB loop devices for different
OS loop devices (thanks, bcbc; LP: #888281).
-- Colin Watson <cjwatson@debian.org> Wed, 07 Mar 2012 10:06:22 +0000

View File

@ -13,13 +13,14 @@ Index: b/util/grub-mkconfig_lib.in
===================================================================
--- a/util/grub-mkconfig_lib.in
+++ b/util/grub-mkconfig_lib.in
@@ -105,6 +105,20 @@
@@ -105,6 +105,21 @@
{
device="$1"
+ loop_file=
+ case ${device} in
+ /dev/loop/*|/dev/loop[0-9])
+ grub_loop_device="${device#/dev/}"
+ loop_file=`losetup "${device}" | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
+ case $loop_file in
+ /dev/*) ;;
@ -34,7 +35,7 @@ Index: b/util/grub-mkconfig_lib.in
if dmsetup status $device 2>/dev/null | grep -q 'crypt[[:space:]]$'; then
grub_warn \
"$device is a crypto device, which GRUB cannot read directly. Some" \
@@ -141,6 +155,14 @@
@@ -141,6 +156,14 @@
if fs_uuid="`"${grub_probe}" --device "${device}" --target=fs_uuid 2> /dev/null`" ; then
echo "search --no-floppy --fs-uuid --set=root ${fs_uuid}"
fi
@ -42,8 +43,8 @@ Index: b/util/grub-mkconfig_lib.in
+ if [ "x${loop_file}" != x ]; then
+ loop_mountpoint="$(awk '"'${loop_file}'" ~ "^"$2 && $2 != "/" { print $2 }' /proc/mounts | tail -n1)"
+ if [ "x${loop_mountpoint}" != x ]; then
+ echo "loopback loop0 ${loop_file#$loop_mountpoint}"
+ echo "set root=(loop0)"
+ echo "loopback ${grub_loop_device} ${loop_file#$loop_mountpoint}"
+ echo "set root=(${grub_loop_device})"
+ fi
+ fi
}

View File

@ -9,7 +9,7 @@ Index: b/util/grub-mkconfig_lib.in
===================================================================
--- a/util/grub-mkconfig_lib.in
+++ b/util/grub-mkconfig_lib.in
@@ -170,7 +170,7 @@
@@ -171,7 +171,7 @@
if test -f "$1" ; then
case "$1" in
*.dpkg-*) return 1 ;; # debian dpkg