~vorlon/ubuntu/precise/grub2/lp.942846

« back to all changes in this revision

Viewing changes to debian/patches/mkconfig_loopback.patch

  • Committer: Colin Watson
  • Date: 2011-05-16 22:43:37 UTC
  • mfrom: (1892.1.515 grub)
  • Revision ID: cjwatson@canonical.com-20110516224337-27u9u9wef4gc8ibj
merge from Debian 1.99-1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Description: Handle filesystems loop-mounted on file images
 
2
 Improve prepare_grub_to_access_device to emit appropriate commands for such
 
3
 filesystems, and ignore them in Linux grub.d scripts.
 
4
 .
 
5
 This is needed for Ubuntu's Wubi installation method.
 
6
 .
 
7
 This patch isn't inherently Debian/Ubuntu-specific.  losetup and
 
8
 /proc/mounts are Linux-specific, though, so we might need to refine this
 
9
 before sending it upstream.  The changes to the Linux grub.d scripts might
 
10
 be better handled by integrating 10_lupin properly instead.
 
11
 
 
12
Index: b/util/grub-mkconfig_lib.in
 
13
===================================================================
 
14
--- a/util/grub-mkconfig_lib.in
 
15
+++ b/util/grub-mkconfig_lib.in
 
16
@@ -105,6 +105,20 @@
 
17
 {
 
18
   device="$1"
 
19
 
 
20
+  loop_file=
 
21
+  case ${device} in
 
22
+    /dev/loop/*|/dev/loop[0-9])
 
23
+      loop_file=`losetup "${device}" | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
 
24
+      case $loop_file in
 
25
+        /dev/*) ;;
 
26
+        *)
 
27
+          loop_device="${device}"
 
28
+          device=`"${grub_probe}" --target=device "${loop_file}"`
 
29
+        ;;
 
30
+      esac
 
31
+    ;;
 
32
+  esac
 
33
+
 
34
   if dmsetup status $device 2>/dev/null | grep -q 'crypt[[:space:]]$'; then
 
35
     grub_warn \
 
36
       "$device is a crypto device, which GRUB cannot read directly.  Some" \
 
37
@@ -141,6 +155,14 @@
 
38
   if fs_uuid="`"${grub_probe}" --device "${device}" --target=fs_uuid 2> /dev/null`" ; then
 
39
     echo "search --no-floppy --fs-uuid --set=root ${fs_uuid}"
 
40
   fi
 
41
+
 
42
+  if [ "x${loop_file}" != x ]; then
 
43
+    loop_mountpoint="$(awk '"'${loop_file}'" ~ "^"$2 && $2 != "/" { print $2 }' /proc/mounts | tail -n1)"
 
44
+    if [ "x${loop_mountpoint}" != x ]; then
 
45
+      echo "loopback loop0 ${loop_file#$loop_mountpoint}"
 
46
+      echo "set root=(loop0)"
 
47
+    fi
 
48
+  fi
 
49
 }
 
50
 
 
51
 grub_file_is_not_garbage ()
 
52
Index: b/util/grub.d/10_linux.in
 
53
===================================================================
 
54
--- a/util/grub.d/10_linux.in
 
55
+++ b/util/grub.d/10_linux.in
 
56
@@ -40,6 +40,11 @@
 
57
 case ${GRUB_DEVICE} in
 
58
   /dev/loop/*|/dev/loop[0-9])
 
59
     GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
 
60
+    # We can't cope with devices loop-mounted from files here.
 
61
+    case ${GRUB_DEVICE} in
 
62
+      /dev/*) ;;
 
63
+      *) exit 0 ;;
 
64
+    esac
 
65
   ;;
 
66
 esac
 
67
 
 
68
Index: b/util/grub.d/20_linux_xen.in
 
69
===================================================================
 
70
--- a/util/grub.d/20_linux_xen.in
 
71
+++ b/util/grub.d/20_linux_xen.in
 
72
@@ -40,6 +40,11 @@
 
73
 case ${GRUB_DEVICE} in
 
74
   /dev/loop/*|/dev/loop[0-9])
 
75
     GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
 
76
+    # We can't cope with devices loop-mounted from files here.
 
77
+    case ${GRUB_DEVICE} in
 
78
+      /dev/*) ;;
 
79
+      *) exit 0 ;;
 
80
+    esac
 
81
   ;;
 
82
 esac
 
83