summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Dawson <phil.dawson@codethink.co.uk>2018-11-19 09:33:17 +0000
committerPhil Dawson <phil.dawson@codethink.co.uk>2018-12-12 14:43:40 +0000
commit85c61894d8871f6096fbd164280eb529981b40c6 (patch)
treecdbf5f7a621478d6043834939ce47c6aee7c8d9f
parentc2efeba064f30c9bdbb4e370b1911dc50a78ff9b (diff)
downloadbuildstream-85c61894d8871f6096fbd164280eb529981b40c6.tar.gz
Remove source bundle command
This is part of the work towards #672
-rw-r--r--buildstream/_frontend/cli.py31
-rw-r--r--buildstream/_stream.py81
-rw-r--r--doc/source/using_commands.rst7
-rw-r--r--tests/completions/completions.py1
-rw-r--r--tests/frontend/help.py1
-rw-r--r--tests/frontend/source_bundle.py48
6 files changed, 0 insertions, 169 deletions
diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index 46d598837..f2f87e721 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -915,34 +915,3 @@ def workspace_list(app):
with app.initialized():
app.stream.workspace_list()
-
-
-##################################################################
-# Source Bundle Command #
-##################################################################
-@cli.command(name="source-bundle", short_help="Produce a build bundle to be manually executed")
-@click.option('--except', 'except_', multiple=True,
- type=click.Path(readable=False),
- help="Elements to except from the tarball")
-@click.option('--compression', default='gz',
- type=click.Choice(['none', 'gz', 'bz2', 'xz']),
- help="Compress the tar file using the given algorithm.")
-@click.option('--track', 'track_', default=False, is_flag=True,
- help="Track new source references before bundling")
-@click.option('--force', '-f', default=False, is_flag=True,
- help="Overwrite an existing tarball")
-@click.option('--directory', default=os.getcwd(),
- help="The directory to write the tarball to")
-@click.argument('element',
- type=click.Path(readable=False))
-@click.pass_obj
-def source_bundle(app, element, force, directory,
- track_, compression, except_):
- """Produce a source bundle to be manually executed
- """
- with app.initialized():
- app.stream.source_bundle(element, directory,
- track_first=track_,
- force=force,
- compression=compression,
- except_targets=except_)
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
diff --git a/doc/source/using_commands.rst b/doc/source/using_commands.rst
index 18affc6e5..90d86dcbb 100644
--- a/doc/source/using_commands.rst
+++ b/doc/source/using_commands.rst
@@ -86,13 +86,6 @@ project's main directory.
----
-.. _invoking_source_bundle:
-
-.. click:: buildstream._frontend.cli:source_bundle
- :prog: bst source bundle
-
-----
-
.. _invoking_workspace:
.. click:: buildstream._frontend.cli:workspace
diff --git a/tests/completions/completions.py b/tests/completions/completions.py
index af35fb23a..9b32baadd 100644
--- a/tests/completions/completions.py
+++ b/tests/completions/completions.py
@@ -16,7 +16,6 @@ MAIN_COMMANDS = [
'shell ',
'show ',
'source-checkout ',
- 'source-bundle ',
'track ',
'workspace '
]
diff --git a/tests/frontend/help.py b/tests/frontend/help.py
index bdafe851b..2a0c502e3 100644
--- a/tests/frontend/help.py
+++ b/tests/frontend/help.py
@@ -25,7 +25,6 @@ def test_help_main(cli):
('push'),
('shell'),
('show'),
- ('source-bundle'),
('track'),
('workspace')
])
diff --git a/tests/frontend/source_bundle.py b/tests/frontend/source_bundle.py
deleted file mode 100644
index f72e80a3b..000000000
--- a/tests/frontend/source_bundle.py
+++ /dev/null
@@ -1,48 +0,0 @@
-#
-# Copyright (C) 2018 Bloomberg Finance LP
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library. If not, see <http://www.gnu.org/licenses/>.
-#
-# Authors: Chandan Singh <csingh43@bloomberg.net>
-#
-
-import os
-import tarfile
-
-import pytest
-
-from tests.testutils import cli
-
-# Project directory
-DATA_DIR = os.path.join(
- os.path.dirname(os.path.realpath(__file__)),
- "project",
-)
-
-
-@pytest.mark.datafiles(DATA_DIR)
-def test_source_bundle(cli, tmpdir, datafiles):
- project_path = os.path.join(datafiles.dirname, datafiles.basename)
- element_name = 'source-bundle/source-bundle-hello.bst'
- normal_name = 'source-bundle-source-bundle-hello'
-
- # Verify that we can correctly produce a source-bundle
- args = ['source-bundle', element_name, '--directory', str(tmpdir)]
- result = cli.run(project=project_path, args=args)
- result.assert_success()
-
- # Verify that the source-bundle contains our sources and a build script
- with tarfile.open(os.path.join(str(tmpdir), '{}.tar.gz'.format(normal_name))) as bundle:
- assert os.path.join(normal_name, 'source', normal_name, 'llamas.txt') in bundle.getnames()
- assert os.path.join(normal_name, 'build.sh') in bundle.getnames()