summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin David <valentin.david@codethink.co.uk>2018-04-26 10:14:53 +0200
committerValentin David <valentin.david@codethink.co.uk>2018-06-06 14:57:34 +0200
commit061fc2864181ed13e16a27c0370bf3cb99190c98 (patch)
treef96009f90cbf644ce33a60996c123a32f490179c
parente0ba2b91cfd6d5378c4b05ec13b42106a7f7c767 (diff)
downloadbuildstream-valentindavid/update_mirror.tar.gz
buildstream/_frontend/cli.py: Add mirror command.valentindavid/update_mirror
tests/completions/completions.py: Add mirror command.
-rw-r--r--buildstream/_frontend/cli.py48
-rw-r--r--tests/completions/completions.py1
2 files changed, 49 insertions, 0 deletions
diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index 41e97cb0e..73c94ba04 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -6,6 +6,7 @@ from .. import _yaml
from .._exceptions import BstError, LoadError, AppError
from .._versions import BST_FORMAT_VERSION
from .complete import main_bashcomplete, complete_path, CompleteUnhandled
+from .. import utils
##################################################################
@@ -330,6 +331,53 @@ def track(app, elements, deps, except_, cross_junctions):
##################################################################
+# Mirror Command #
+##################################################################
+@cli.command(short_help="Mirror new source references")
+@click.option('--except', 'except_', multiple=True,
+ type=click.Path(dir_okay=False, readable=True),
+ help="Except certain dependencies from mirroring")
+@click.option('--deps', '-d', default='none',
+ type=click.Choice(['none', 'all']),
+ help='The dependencies to mirror (default: none)')
+@click.argument('elements', nargs=-1,
+ required=False,
+ type=click.Path(dir_okay=False, readable=True))
+@click.pass_obj
+def mirror(app, elements, deps, except_):
+ """Mirror all sources.
+
+ This will download everything available from sources. For
+ repositories, it will download all commits/revisions. For files,
+ it will download the latest version even if the source is already
+ cached. Previously mirrored/fetched downloads will still be
+ accessible.
+
+ If no element is given as parameters, all elements found in
+ `element_path` will be used.
+
+ Specify `--deps` to control which sources to track:
+
+ \b
+ none: No dependencies, just the specified elements
+ all: All dependencies of all specified elements
+
+ """
+ if not elements:
+ with app.partially_initialized():
+ elements = []
+ for element in utils.list_relative_paths(app.project.element_path):
+ if element.endswith('.bst'):
+ elements.append(element)
+ elements = tuple(elements)
+
+ with app.initialized(session_name="Mirror"):
+ app.stream.mirror(elements,
+ selection=deps,
+ except_targets=except_)
+
+
+##################################################################
# Pull Command #
##################################################################
@cli.command(short_help="Pull a built artifact")
diff --git a/tests/completions/completions.py b/tests/completions/completions.py
index cc98cb940..47b13dc55 100644
--- a/tests/completions/completions.py
+++ b/tests/completions/completions.py
@@ -10,6 +10,7 @@ MAIN_COMMANDS = [
'checkout ',
'fetch ',
'init ',
+ 'mirror ',
'pull ',
'push ',
'shell ',