sys.stdout.write('\n')
sys.exit(2)
+def choice(msg, choices, default=0):
+ if default >= len(choices):
+ return None
+ _general_print('\rQ', ASK_COLOR, '')
+ try:
+ msg += " [%s] " % '/'.join(choices)
+ if INTERACTIVE:
+ while True:
+ repl = raw_input(msg)
+ if repl in choices:
+ return repl
+ elif not repl.strip():
+ return choices[default]
+ else:
+ msg += choices[default]
+ _general_print('', NO_COLOR, msg)
+
+ return choices[default]
+ except KeyboardInterrupt:
+ sys.stdout.write('\n')
+ sys.exit(2)
+
def pause(msg=None):
if INTERACTIVE:
_general_print('\rQ', ASK_COLOR, '')
imgloop = PartitionedMount({'/dev/sdb':disk}, imgmnt, skipformat = True)
img_fstype = "ext3"
+ msger.info("Partition Table:")
+ partnum = []
+ for line in runner.outs([partedcmd, "-s", img, "print"]).splitlines():
+ # no use strip to keep line output here
+ if "Number" in line:
+ msger.raw(line)
+ if line.strip() and line.strip()[0].isdigit():
+ partnum.append(line.strip()[0])
+ msger.raw(line)
+
+ rootpart = None
+ if len(partnum) > 1:
+ rootpart = msger.choice("please choose root partition", partnum)
+
# Check the partitions from raw disk.
root_mounted = False
partition_mounts = 0
else:
raise errors.CreatorError("Could not recognize partition fs type '%s'." % partition_info[5])
- if not root_mounted and fstype in ["ext2","ext3","ext4","btrfs"]:
+ if rootpart == line[0]:
+ mountpoint = '/'
+ root_mounted = True
+ elif not root_mounted and fstype in ["ext2","ext3","ext4","btrfs"]:
# TODO: Check that this is actually the valid root partition from /etc/fstab
mountpoint = "/"
root_mounted = True