sys.exit(1)
return [self.binaries.get(binary, None)]
+ def ensure_parttable(self):
+ logging.notice(f"Verifying that partition table on {Device} matches target specification")
+ for partnum, part in enumerate(self.part_table, 1):
+ bo = subprocess.check_output(["blkid", "-o", "export", Device + str(partnum)]).decode('utf-8')
+ if "PARTLABEL=" in bo and f"PARTLABEL={part['name']}" not in bo:
+ logging.error(f'On-device partition label mismatch with selected target: partlabel={part["name"]}, on-device:\n{bo}')
+ sys.exit(1)
+ if part['fstype'] not in 'raw' and f"TYPE={part['fstype']}" not in bo:
+ logging.error(f'On-device partition mismatch with selected target: fstype={part["fstype"]}, on-device:\n{bo}')
+ sys.exit(1)
+
def initialize_parameters(self):
pass
if not Format:
logging.info(f"Skip formatting of {Device}".format(Device))
+ target.ensure_parttable()
return
logging.info(f"Start formatting of {Device}")
mkpart(args, target)