[(mapped[i], filesystem[i].mpoint)
for i in mapped.keys()])
exclude = self._to_exclude() + [image]
- rsync = Rsync('/', target,
- map(lambda p: os.path.relpath(p, '/'), exclude))
- rsync.archive().run(self.out)
+
+ rsync = Rsync(self.out)
+
+ # Excluded paths need to be relative to the source
+ for excl in map(lambda p: os.path.relpath(p, '/'), exclude):
+ rsync.exclude(excl)
+
+ rsync.archive().hard_links().xattrs().sparse().acls()
+ rsync.run('/', target, 'host', 'tmp image')
# We need to replace the old UUID referencies with the new
# ones in grub configuration files and /etc/fstab for file
end_sector = self._shrink_partitions(image)
+ size = (end_sector + 1) * self.disk.device.sectorSize
+
+ # Truncate image to the new size.
+ fd = os.open(image, os.O_RDWR)
+ try:
+ os.ftruncate(fd, size)
+ finally:
+ os.close(fd)
+
# Check if the available space is enough to host the image
dirname = os.path.dirname(image)
- size = (end_sector + 1) * self.disk.device.sectorSize
self.out.output("Examining available space in %s ..." % dirname, False)
stat = os.statvfs(dirname)
available = stat.f_bavail * stat.f_frsize
self._create_filesystems(image)
- # Truncate image to the new size. I counldn't find a better way to do
- # this. It seems that python's high level functions work in a different
- # way.
- fd = os.open(image, os.O_RDWR)
- try:
- os.ftruncate(fd, size)
- finally:
- os.close(fd)
-
return image
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :