[elbe-devel] [PATCH 2/3] Download project repo (elbe prjrepo download <build_dir>)
Philipp Arras
philipp.arras at linutronix.de
Mon May 8 18:18:16 CEST 2017
`elbe prjrepo download <build_dir>` creates a tarball of the project's Debian
repository and downloads it from initvm to host.
Signed-off-by: Philipp Arras <philipp.arras at linutronix.de>
---
elbepack/daemons/soap/esoap.py | 10 ++++++++++
elbepack/soapclient.py | 30 ++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/elbepack/daemons/soap/esoap.py b/elbepack/daemons/soap/esoap.py
index 5c7fd24..995f08b 100644
--- a/elbepack/daemons/soap/esoap.py
+++ b/elbepack/daemons/soap/esoap.py
@@ -20,6 +20,8 @@
import binascii
import os
+import tarfile
+import fnmatch
from tempfile import NamedTemporaryFile
@@ -326,3 +328,11 @@ class ESoap (ServiceBase):
for filename in fnmatch.filter(filenames, '*.deb'):
s += filename +'\n'
return s
+
+ @rpc (String, String)
+ @authenticated_uid
+ @soap_faults
+ def tar_prjrepo (self, uid, builddir, filename):
+ self.app.pm.open_project (uid, builddir)
+ with tarfile.open(os.path.join(builddir, filename), "w:gz") as tar:
+ tar.add(os.path.join(builddir, "repo"), arcname=os.path.basename(os.path.join(builddir, "repo")))
diff --git a/elbepack/soapclient.py b/elbepack/soapclient.py
index 5bcf29a..437bf00 100644
--- a/elbepack/soapclient.py
+++ b/elbepack/soapclient.py
@@ -29,6 +29,8 @@ import time
import sys
import os
+from datetime import datetime
+
from elbepack.filesystem import Filesystem
from elbepack.elbexml import ElbeXML, ValidationMode
@@ -624,3 +626,31 @@ class ListPackagesAction(RepoAction):
print(client.service.list_packages (builddir))
RepoAction.register(ListPackagesAction)
+
+
+class DownloadAction(RepoAction):
+
+ tag = 'download'
+
+ def __init__(self, node):
+ RepoAction.__init__(self, node)
+
+ def execute(self, client, opt, args):
+ if len (args) != 1:
+ print ("usage: elbe prjrepo download <project_dir>", file=sys.stderr)
+ sys.exit(20)
+
+ builddir = args[0]
+ filename = "repo.tar.gz"
+ client.service.tar_prjrepo (builddir, filename)
+
+ dst_fname = os.path.join(".", "elbe-projectrepo-" + datetime.now().strftime("%Y%m%d-%H%M%S") + ".tar.gz")
+
+ client.download_file (builddir, filename, dst_fname)
+ print (dst_fname + " saved", file=sys.stderr)
+
+ client.service.rm (builddir, filename)
+ print (filename + " deleted on initvm.")
+
+
+RepoAction.register(DownloadAction)
--
2.1.4
More information about the elbe-devel
mailing list