def _deprecated_cleanbuild(project_options, remote, config, tar_filename): if remote and not lxd._remote_is_valid(remote): raise errors.InvalidContainerRemoteError(remote) lxd.Cleanbuilder(source=tar_filename, project_options=project_options, metadata=config.get_metadata(), remote=remote).execute()
def _deprecated_cleanbuild(project: Project, remote: str, tar_filename: str) -> str: if remote and not lxd._remote_is_valid(remote): raise errors.InvalidContainerRemoteError(remote) builder = lxd.Cleanbuilder(source=tar_filename, project=project, remote=remote) builder.execute() return builder.snap_filename
def _deprecated_cleanbuild(project_options, remote, config, tar_filename): if remote and not lxd._remote_is_valid(remote): raise errors.InvalidContainerRemoteError(remote) lxd.Cleanbuilder( source=tar_filename, project_options=project_options, metadata=config.get_metadata(), remote=remote, ).execute()
def cleanbuild(project_options, remote=''): if remote and not lxd._remote_is_valid(remote): raise errors.InvalidContainerRemoteError(remote) config = snapcraft.internal.load_config(project_options) tar_filename = '{}_{}_source.tar.bz2'.format( config.data['name'], config.data['version']) with tarfile.open(tar_filename, 'w:bz2') as t: t.add(os.path.curdir, filter=_create_tar_filter(tar_filename)) lxd.Cleanbuilder(source=tar_filename, project_options=project_options, metadata=config.get_metadata(), remote=remote).execute()
def cleanbuild(project_options, remote=''): if remote and not lxd._remote_is_valid(remote): raise errors.InvalidContainerRemoteError(remote) config = load_config(project_options) tar_filename = '{}_{}_source.tar.bz2'.format( config.data['name'], config.data['version']) with tarfile.open(tar_filename, 'w:bz2') as t: t.add(os.path.curdir, filter=_create_tar_filter(tar_filename)) lxd.Cleanbuilder(source=tar_filename, project_options=project_options, metadata=config.get_metadata(), remote=remote).execute()
def __init__(self): """ Determines if a container should be used and which remote to choose Checks the environment variable SNAPCRAFT_CONTAINER_BUILDS: 1. SNAPCRAFT_CONTAINER_BUILDS=1 enables local containers 2. SNAPCRAFT_CONTAINER_BUILDS=foobar uses the value as a remote 3. SNAPCRAFT_CONTAINER_BUILDS=0 or unset, no container is used """ container_builds = os.environ.get('SNAPCRAFT_CONTAINER_BUILDS', '0') # Default remote if it's a truthy value - otherwise it's a remote name try: self._use_container = util.strtobool(container_builds) self._remote = None except ValueError: self._use_container = True # Verbatim name of a remote if not lxd._remote_is_valid(container_builds): raise errors.InvalidContainerRemoteError(container_builds) self._remote = container_builds