]> git.proxmox.com Git - grub2.git/blob - debian/patches/mkconfig_loopback.patch
grub2 (2.02+dfsg1-20) unstable; urgency=medium
[grub2.git] / debian / patches / mkconfig_loopback.patch
1 From 67aeec648cc3b3439d65f331adc5f757de3b1c78 Mon Sep 17 00:00:00 2001
2 From: Colin Watson <cjwatson@debian.org>
3 Date: Mon, 13 Jan 2014 12:13:00 +0000
4 Subject: Handle filesystems loop-mounted on file images
5
6 Improve prepare_grub_to_access_device to emit appropriate commands for
7 such filesystems, and ignore them in Linux grub.d scripts.
8
9 This is needed for Ubuntu's Wubi installation method.
10
11 This patch isn't inherently Debian/Ubuntu-specific. losetup and
12 /proc/mounts are Linux-specific, though, so we might need to refine this
13 before sending it upstream. The changes to the Linux grub.d scripts
14 might be better handled by integrating 10_lupin properly instead.
15
16 Patch-Name: mkconfig_loopback.patch
17 ---
18 util/grub-mkconfig_lib.in | 24 ++++++++++++++++++++++++
19 util/grub.d/10_linux.in | 5 +++++
20 util/grub.d/20_linux_xen.in | 5 +++++
21 3 files changed, 34 insertions(+)
22
23 diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in
24 index 3a4684e78..9ee60d5fa 100644
25 --- a/util/grub-mkconfig_lib.in
26 +++ b/util/grub-mkconfig_lib.in
27 @@ -133,6 +133,22 @@ prepare_grub_to_access_device ()
28 esac
29 done
30
31 + loop_file=
32 + case $1 in
33 + /dev/loop/*|/dev/loop[0-9])
34 + grub_loop_device="${1#/dev/}"
35 + loop_file=`losetup "$1" | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
36 + case $loop_file in
37 + /dev/*) ;;
38 + *)
39 + loop_device="$1"
40 + shift
41 + set -- `"${grub_probe}" --target=device "${loop_file}"` "$@"
42 + ;;
43 + esac
44 + ;;
45 + esac
46 +
47 # Abstraction modules aren't auto-loaded.
48 abstraction="`"${grub_probe}" --device $@ --target=abstraction`"
49 for module in ${abstraction} ; do
50 @@ -165,6 +181,14 @@ prepare_grub_to_access_device ()
51 echo "fi"
52 fi
53 IFS="$old_ifs"
54 +
55 + if [ "x${loop_file}" != x ]; then
56 + loop_mountpoint="$(awk '"'${loop_file}'" ~ "^"$2 && $2 != "/" { print $2 }' /proc/mounts | tail -n1)"
57 + if [ "x${loop_mountpoint}" != x ]; then
58 + echo "loopback ${grub_loop_device} ${loop_file#$loop_mountpoint}"
59 + echo "set root=(${grub_loop_device})"
60 + fi
61 + fi
62 }
63
64 grub_get_device_id ()
65 diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
66 index c34d470c9..5ff76f59a 100644
67 --- a/util/grub.d/10_linux.in
68 +++ b/util/grub.d/10_linux.in
69 @@ -40,6 +40,11 @@ fi
70 case ${GRUB_DEVICE} in
71 /dev/loop/*|/dev/loop[0-9])
72 GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
73 + # We can't cope with devices loop-mounted from files here.
74 + case ${GRUB_DEVICE} in
75 + /dev/*) ;;
76 + *) exit 0 ;;
77 + esac
78 ;;
79 esac
80
81 diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
82 index c48af948d..af05bd276 100644
83 --- a/util/grub.d/20_linux_xen.in
84 +++ b/util/grub.d/20_linux_xen.in
85 @@ -40,6 +40,11 @@ fi
86 case ${GRUB_DEVICE} in
87 /dev/loop/*|/dev/loop[0-9])
88 GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
89 + # We can't cope with devices loop-mounted from files here.
90 + case ${GRUB_DEVICE} in
91 + /dev/*) ;;
92 + *) exit 0 ;;
93 + esac
94 ;;
95 esac
96