packages: xen/pygrubfix.patch (NEW), xen/pygrubfix2.patch (NEW)=?UTF-8?Q?=20?=- make pygr...
baggins
baggins at pld-linux.org
Wed Feb 29 21:52:43 CET 2012
Author: baggins Date: Wed Feb 29 20:52:43 2012 GMT
Module: packages Tag: HEAD
---- Log message:
- make pygrub work better with GPT partitions and grub2 on guest
---- Files affected:
packages/xen:
pygrubfix.patch (NONE -> 1.1) (NEW), pygrubfix2.patch (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: packages/xen/pygrubfix.patch
diff -u /dev/null packages/xen/pygrubfix.patch:1.1
--- /dev/null Wed Feb 29 21:52:43 2012
+++ packages/xen/pygrubfix.patch Wed Feb 29 21:52:38 2012
@@ -0,0 +1,28 @@
+--- xen-4.1.0/tools/pygrub/src/pygrub.orig 2010-12-31 15:24:11.000000000 +0000
++++ xen-4.1.0/tools/pygrub/src/pygrub 2011-01-30 18:58:17.000000000 +0000
+@@ -96,6 +96,7 @@
+
+ fd = os.open(file, os.O_RDONLY)
+ buf = os.read(fd, 512)
++ offzerocount = 0
+ for poff in (446, 462, 478, 494): # partition offsets
+
+ # MBR contains a 16 byte descriptor per partition
+@@ -105,6 +106,7 @@
+
+ # offset == 0 implies this partition is not enabled
+ if offset == 0:
++ offzerocount += 1
+ continue
+
+ if type == FDISK_PART_SOLARIS or type == FDISK_PART_SOLARIS_OLD:
+@@ -123,6 +125,9 @@
+ else:
+ part_offs.append(offset)
+
++ if offzerocount == 4:
++ # Might be a grub boot sector pretending to be an MBR
++ part_offs.append(0)
+ return part_offs
+
+ class GrubLineEditor(curses.textpad.Textbox):
================================================================
Index: packages/xen/pygrubfix2.patch
diff -u /dev/null packages/xen/pygrubfix2.patch:1.1
--- /dev/null Wed Feb 29 21:52:43 2012
+++ packages/xen/pygrubfix2.patch Wed Feb 29 21:52:38 2012
@@ -0,0 +1,92 @@
+--- 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,))
================================================================
More information about the pld-cvs-commit
mailing list