+ try_fail_repeat(umount, mpoint)
+
+ def _to_exclude(self):
+ excluded = ['/tmp', '/var/tmp']
+ if self.tmp is not None:
+ excluded.append(self.tmp)
+ local_filesystems = MKFS_OPTS.keys() + ['rootfs']
+ for entry in self._read_fstable('/proc/mounts'):
+ if entry.fs in local_filesystems:
+ continue
+
+ mpoint = entry.mpoint
+ if mpoint in excluded:
+ continue
+
+ descendants = filter(
+ lambda p: p.startswith(mpoint + '/'), excluded)
+ if len(descendants):
+ for d in descendants:
+ excluded.remove(d)
+ excluded.append(mpoint)
+ continue
+
+ dirname = mpoint
+ basename = ''
+ found_ancestor = False
+ while dirname != '/':
+ (dirname, basename) = os.path.split(dirname)
+ if dirname in excluded:
+ found_ancestor = True
+ break
+
+ if not found_ancestor:
+ excluded.append(mpoint)
+
+ return excluded
+
+ def _replace_uuids(self, target, new_uuid):
+
+ files = ['/etc/fstab',
+ '/boot/grub/grub.cfg',
+ '/boot/grub/menu.lst',
+ '/boot/grub/grub.conf']
+
+ orig = dict(map(
+ lambda p: (
+ p.number,
+ blkid('-s', 'UUID', '-o', 'value', p.path).stdout.strip()),
+ self.disk.partitions))
+
+ for f in map(lambda f: target + f, files):
+
+ if not os.path.exists(f):
+ continue
+
+ with open(f, 'r') as src:
+ lines = src.readlines()
+ with open(f, 'w') as dest:
+ for line in lines:
+ for i, uuid in new_uuid.items():
+ line = re.sub(orig[i], uuid, line)
+ dest.write(line)