--- xen-4.1.2/tools/pygrub/src/pygrub.orig 2011-10-13 18:56:41.000000000 +0100
+++ xen-4.1.2/tools/pygrub/src/pygrub 2011-10-13 20:46:58.000000000 +0100
@@ -78,9 +78,17 @@
def get_fs_offset_gpt(file):
fd = os.open(file, os.O_RDONLY)
# assume the first partition is an EFI system partition.
- os.lseek(fd, SECTOR_SIZE * 2, 0)
+ os.lseek(fd, SECTOR_SIZE, 0)
buf = os.read(fd, 512)
- return struct.unpack("<Q", buf[32:40])[0] * SECTOR_SIZE
+ partcount = struct.unpack("<L", buf[80:84])[0]
+ partsize = struct.unpack("<L", buf[84:88])[0]
+ i = partcount
+ offsets = []
+ while i>0:
+ buf = os.read(fd, partsize)
+ offsets.append(struct.unpack("<Q", buf[32:40])[0] * SECTOR_SIZE)
+ i -= 1
+ return offsets
FDISK_PART_SOLARIS=0xbf
FDISK_PART_SOLARIS_OLD=0x82
@@ -116,7 +124,9 @@
continue # no solaris magic at that offset, ignore partition
if type == FDISK_PART_GPT:
- offset = get_fs_offset_gpt(file)
+ for offset in get_fs_offset_gpt(file):
+ part_offs.append(offset)
+ break
# Active partition has 0x80 as the first byte.
# If active, prepend to front of list, otherwise append to back.
@@ -394,7 +404,8 @@
["/boot/grub/menu.lst", "/boot/grub/grub.conf",
"/grub/menu.lst", "/grub/grub.conf"]) + \
map(lambda x: (x,grub.GrubConf.Grub2ConfigFile),
- ["/boot/grub/grub.cfg", "/grub/grub.cfg"]) + \
+ ["/boot/grub/grub.cfg", "/grub/grub.cfg",
+ "/boot/grub2/grub.cfg", "/grub2/grub.cfg"]) + \
map(lambda x: (x,grub.ExtLinuxConf.ExtLinuxConfigFile),
["/boot/isolinux/isolinux.cfg",
"/boot/extlinux.conf"])
--- xen-4.1.2/tools/pygrub/src/GrubConf.py.orig 2011-10-08 19:42:10.000000000 +0100
+++ xen-4.1.2/tools/pygrub/src/GrubConf.py 2011-10-14 21:08:44.000000000 +0100
@@ -79,6 +79,8 @@
val = val.replace("(", "").replace(")", "")
if val[:5] == "msdos":
val = val[5:]
+ if val[:3] == "gpt":
+ val = val[3:]
self._part = int(val)
part = property(get_part, set_part)
@@ -368,6 +370,7 @@
in_function = False
img = None
title = ""
+ menu_level=0
for l in lines:
l = l.strip()
# skip blank lines
@@ -394,10 +397,18 @@
img = []
title = title_match.group(1)
continue
-
+
+ if l.startswith("submenu"):
+ menu_level += 1
+ continue
+
if l.startswith("}"):
if img is None:
- raise RuntimeError, "syntax error: closing brace without menuentry"
+ if menu_level > 0:
+ menu_level -= 1
+ continue
+ else:
+ raise RuntimeError, "syntax error: closing brace without menuentry"
self.add_image(Grub2Image(title, img))
img = None
@@ -414,6 +425,8 @@
if self.commands.has_key(com):
if self.commands[com] is not None:
+ if arg.strip() == "${saved_entry}":
+ arg = "0"
setattr(self, self.commands[com], arg.strip())
else:
logging.info("Ignored directive %s" %(com,))