def mount_shared_directory(self, host_dir=None): """ Bind mount shared location The shared location is a directory which shares data from the image buildsystem host with the image root system. It is used for the repository setup and the package manager cache to allow chroot operations without being forced to duplicate this data :param str host_dir: directory to share between image root and build system root :raises KiwiMountSharedDirectoryError: if mount fails """ if not host_dir: host_dir = self.shared_location try: Path.create(self.root_dir + host_dir) Path.create('/' + host_dir) shared_mount = MountManager( device=host_dir, mountpoint=self.root_dir + host_dir ) shared_mount.bind_mount() self.mount_stack.append(shared_mount) self.dir_stack.append(host_dir) except Exception as e: self.cleanup() raise KiwiMountSharedDirectoryError( '%s: %s' % (type(e).__name__, format(e)) )
def test_shared_directory_raises_error( self, mock_cleanup, mock_path, mock_mount ): mock_mount.side_effect = KiwiMountSharedDirectoryError( 'mount-error' ) self.bind_root.mount_shared_directory() mock.cleanup.assert_called_once_with()