summaryrefslogtreecommitdiff
path: root/buildstream/_ostree.py
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2017-05-29 15:23:33 +0200
committerJürg Billeter <j@bitron.ch>2017-06-27 10:30:29 +0200
commite33ed2ff1450efc0b8e459d58d5d1a768884423e (patch)
treed6df91cefd3ad7050a12e42a5c0ec34023e03da3 /buildstream/_ostree.py
parent6c1186b6273924abfb8cba4231f40a589450fdd2 (diff)
downloadbuildstream-e33ed2ff1450efc0b8e459d58d5d1a768884423e.tar.gz
_ostree.py: Add SSH artifact push support
Diffstat (limited to 'buildstream/_ostree.py')
-rw-r--r--buildstream/_ostree.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/buildstream/_ostree.py b/buildstream/_ostree.py
index dbff2d28e..fdb37eb91 100644
--- a/buildstream/_ostree.py
+++ b/buildstream/_ostree.py
@@ -23,6 +23,9 @@
# Code based on Jürg's artifact cache and Andrew's ostree plugin
#
import os
+import subprocess
+from . import _site
+from . import utils
from .exceptions import _BstError
import gi
@@ -267,6 +270,28 @@ def fetch(repo, remote="origin", ref=None, progress=None):
raise OSTreeError("Failed to fetch from '{}': {}".format(remote, e.message)) from e
+# push()
+#
+# Pushes a ref to a remote repository
+#
+# Args:
+# repo (OSTree.Repo): The repo
+# remote (str): The url of the remote ostree repo
+# ref (str): A ref to push
+#
+def push(repo, remote, ref):
+ exit_code, output = utils._call([
+ _site.ostree_push,
+ '--repo=' + repo.get_path().get_path(),
+ remote,
+ ref],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+
+ if exit_code:
+ raise OSTreeError("Failed to push artifact to remote SSH repository:\n{}".format(output))
+
+
# configure_remote():
#
# Ensures a remote is setup to a given url.