From 85c61894d8871f6096fbd164280eb529981b40c6 Mon Sep 17 00:00:00 2001 From: Phil Dawson Date: Mon, 19 Nov 2018 09:33:17 +0000 Subject: Remove source bundle command This is part of the work towards #672 --- buildstream/_stream.py | 81 -------------------------------------------------- 1 file changed, 81 deletions(-) (limited to 'buildstream/_stream.py') diff --git a/buildstream/_stream.py b/buildstream/_stream.py index 059b7f653..04eb409a5 100644 --- a/buildstream/_stream.py +++ b/buildstream/_stream.py @@ -732,87 +732,6 @@ class Stream(): 'workspaces': workspaces }) - # source_bundle() - # - # Create a host buildable tarball bundle for the given target. - # - # Args: - # target (str): The target element to bundle - # directory (str): The directory to output the tarball - # track_first (bool): Track new source references before bundling - # compression (str): The compression type to use - # force (bool): Overwrite an existing tarball - # - def source_bundle(self, target, directory, *, - track_first=False, - force=False, - compression="gz", - except_targets=()): - - if track_first: - track_targets = (target,) - else: - track_targets = () - - elements, track_elements = self._load((target,), track_targets, - selection=PipelineSelection.ALL, - except_targets=except_targets, - track_selection=PipelineSelection.ALL, - fetch_subprojects=True) - - # source-bundle only supports one target - target = self.targets[0] - - self._message(MessageType.INFO, "Bundling sources for target {}".format(target.name)) - - # Find the correct filename for the compression algorithm - tar_location = os.path.join(directory, target.normal_name + ".tar") - if compression != "none": - tar_location += "." + compression - - # Attempt writing a file to generate a good error message - # early - # - # FIXME: A bit hackish - try: - open(tar_location, mode="x") - os.remove(tar_location) - except IOError as e: - raise StreamError("Cannot write to {0}: {1}" - .format(tar_location, e)) from e - - # Fetch and possibly track first - # - self._fetch(elements, track_elements=track_elements) - - # We don't use the scheduler for this as it is almost entirely IO - # bound. - - # Create a temporary directory to build the source tree in - builddir = self._context.builddir - os.makedirs(builddir, exist_ok=True) - prefix = "{}-".format(target.normal_name) - - with tempfile.TemporaryDirectory(prefix=prefix, dir=builddir) as tempdir: - source_directory = os.path.join(tempdir, 'source') - try: - os.makedirs(source_directory) - except OSError as e: - raise StreamError("Failed to create directory: {}" - .format(e)) from e - - # Any elements that don't implement _write_script - # should not be included in the later stages. - elements = [ - element for element in elements - if self._write_element_script(source_directory, element) - ] - - self._write_element_sources(os.path.join(tempdir, "source"), elements) - self._write_master_build_script(tempdir, elements) - self._collect_sources(tempdir, tar_location, - target.normal_name, compression) - # redirect_element_names() # # Takes a list of element names and returns a list where elements have been -- cgit v1.2.1