+ self._mount(target, devs)
+
+ excluded = self._to_exclude()
+
+ rsync = Rsync(self.out)
+
+ for excl in excluded + [image]:
+ rsync.exclude(excl)
+
+ rsync.archive().hard_links().xattrs().sparse().acls()
+ rsync.run('/', target, 'host', 'temporary image')
+
+ # Create missing mountpoints. Since they are mountpoints, we
+ # cannot determine the ownership and the mode of the real
+ # directory. Make them inherit those properties from their
+ # parent dir
+ for excl in excluded:
+ dirname = os.path.dirname(excl)
+ stat = os.stat(dirname)
+ os.mkdir(target + excl)
+ os.chmod(target + excl, stat.st_mode)
+ os.chown(target + excl, stat.st_uid, stat.st_gid)
+
+ # /tmp and /var/tmp are special cases. We exclude then even if
+ # they aren't mountpoints. Restore their permissions.
+ for excl in ('/tmp', '/var/tmp'):
+ if self._is_mpoint(excl):
+ os.chmod(target + excl, 041777)
+ os.chown(target + excl, 0, 0)
+ else:
+ stat = os.stat(excl)
+ os.chmod(target + excl, stat.st_mode)
+ os.chown(target + excl, stat.st_uid, stat.st_gid)
+
+ # We need to replace the old UUID referencies with the new
+ # ones in grub configuration files and /etc/fstab for file
+ # systems that have been recreated.
+ self._replace_uuids(target, new_uuid)