aboutsummaryrefslogtreecommitdiffstats
path: root/backend/raw_write.py
diff options
context:
space:
mode:
Diffstat (limited to 'backend/raw_write.py')
-rwxr-xr-xbackend/raw_write.py43
1 files changed, 29 insertions, 14 deletions
diff --git a/backend/raw_write.py b/backend/raw_write.py
index 4428d67..87f17a5 100755
--- a/backend/raw_write.py
+++ b/backend/raw_write.py
@@ -215,7 +215,6 @@ class Dumper(object):
sha512func.update(block)
sha512sumcalc=sha512func.hexdigest().upper()
f.close()
- logging.info(_('SHA3 sum: {}').format(sha512sumcalc))
if self.signature_found and not self.signature_checked:
#, keep the pourcent, this is the place for source file name
self.return_message = _('Invalid signature for %s')%self.source_file
@@ -242,6 +241,24 @@ class Dumper(object):
self.return_state = True
self.finished.set()
+ def udev_wait(self, operation):
+ wait = Popen(["udevadm","settle","--timeout=15"], stderr=PIPE)
+ outs, errs = wait.communicate()
+ working=True
+ while working:
+ time.sleep(0.5)
+ wait.poll()
+ rc=wait.returncode
+ if not (rc is None):
+ wait = None
+ working= False
+ if rc != 0:
+ self.return_state = False
+ self.return_message = _("Timeout reached when {}".format(operation))
+ return False
+ return True
+
+
def _do_persistence(self, target, label, key):
logging.debug("Start doing persistence partition")
p = Popen(["fdisk",target], stdin = PIPE, stderr=PIPE)
@@ -264,19 +281,7 @@ class Dumper(object):
self._progress = 33
# Wait for propagation of the info of new partition table
- wait = Popen(["udevadm","settle","--timeout=15"], stderr=PIPE)
- outs, errs = wait.communicate()
- working=True
- while working:
- time.sleep(0.5)
- wait.poll()
- rc=wait.returncode
- if not (rc is None):
- wait = None
- working= False
- if rc != 0:
- self.return_state = False
- self.return_message = _("Timeout reached when creating a new partition table")
+ if not self.udev_wait("creating a new partition table"):
return
self._progress = 50
if key == "":
@@ -303,6 +308,8 @@ class Dumper(object):
self.finished.set()
return
logging.info("Persistent partition done")
+ if not self.udev_wait(_("formatting partition")):
+ return
else:
# example cryptsetup luksFormat /dev/sdb3
print("Crypt key provided",file=sys.stderr)
@@ -327,6 +334,8 @@ class Dumper(object):
return
self._progress = 75
# cryptsetup open /dev/sdb3 crypt_sdb3
+ if not self.udev_wait("creating encrypted partition"):
+ return
process = Popen(['cryptsetup','luksOpen', target + "3", 'crypt_' + base_target ,'-d','-'],stdin=PIPE, stderr=PIPE)
outs, errs = process.communicate(input=key.encode('utf-8'))
@@ -347,6 +356,8 @@ class Dumper(object):
self.finished.set()
return
+ if not self.udev_wait(_("opening encrypted partition")):
+ return
# mkfs.ext4 -L mgalive-persist /dev/mapper/crypt_sdb3
process = Popen(['mkfs.ext4','-q','-F','-L', label, '/dev/mapper/crypt_' + base_target],stderr=PIPE)
outs, errs = process.communicate()
@@ -368,6 +379,8 @@ class Dumper(object):
return
# cryptsetup close crypt_sdb3
+ if not self.udev_wait(_("formatting encrypted partition")):
+ return
process = Popen(['cryptsetup','luksClose', 'crypt_' + base_target ])
outs, errs = process.communicate()
working=True
@@ -388,6 +401,8 @@ class Dumper(object):
self.return_state = True
self.return_message = _("Persistent partition done")
logging.info("Persistent partition done")
+ if not self.udev_wait(_("closing encrypted partition")):
+ return
self._progress = 100
self.finished.set()
logging.debug("Finished")