[elbe-devel] [PATCH] elbeproject: dbsfed: add ssh-key support to the pbuilder project description
Köry Maincent
kory.maincent at bootlin.com
Wed Jul 8 11:03:41 CEST 2020
Actually the pbuilder git repository could only be public.
This patch add support to a private and dedicated ssh-key for those git
repositories.
A small hack, there should be a better way to do it.
Signed-off-by: Kory Maincent <kory.maincent at bootlin.com>
---
elbepack/elbeproject.py | 12 ++++++++++++
schema/dbsfed.xsd | 8 ++++++++
2 files changed, 20 insertions(+)
diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
index b51101a..0c5e212 100644
--- a/elbepack/elbeproject.py
+++ b/elbepack/elbeproject.py
@@ -14,6 +14,8 @@ import io
import logging
import sys
+from urlparse import urlparse
+
from elbepack.shellhelper import CommandError, system, do, chroot
from elbepack.elbexml import (ElbeXML, NoInitvmNode,
@@ -416,12 +418,22 @@ class ElbeProject (object):
do("cd %s; rm sdk.txz" % self.builddir)
def pbuild(self, p):
+ if p.tag == 'ssh-key':
+ key = p.text('.').strip()
+ do('[ ! -d /root/.ssh ] && mkdir /root/.ssh; echo -n "%s" >
/root/.ssh/id_rsa; chmod 0600 /root/.ssh/id_rsa' % (key))
+ return
+
self.pdebuild_init()
src_path = os.path.join(self.builddir, "pdebuilder", "current")
src_uri = p.text('.').replace("LOCALMACHINE", "10.0.2.2").strip()
logging.info("Retrieve pbuild sources: %s", src_uri)
if p.tag == 'git':
+ git_url_scheme = urlparse(src_uri).scheme
+ if git_url_scheme == '':
+ git_url_hostname = urlparse("xx://" + src_uri).hostname
+ do("[ -d /root/.ssh ] && { ssh-keygen -F %s ||
ssh-keyscan %s >> /root/.ssh/known_hosts; }" % (git_url_hostname,
git_url_hostname))
+
do("git clone %s %s" % (src_uri, src_path))
try:
do("cd %s; git reset --hard %s" %
diff --git a/schema/dbsfed.xsd b/schema/dbsfed.xsd
index de64974..a2864d2 100644
--- a/schema/dbsfed.xsd
+++ b/schema/dbsfed.xsd
@@ -2331,6 +2331,14 @@
</documentation>
</annotation>
<sequence>
+ <element name="ssh-key" type="rfs:string" minOccurs="0"
maxOccurs="unbounded">
+ <annotation>
+ <documentation>
+ add a ssh private key to the initvm. add this before the
git package.
+ support only empty passphrase.
+ </documentation>
+ </annotation>
+ </element>
<element name="src-pkg" type="rfs:string" minOccurs="0"
maxOccurs="unbounded">
<annotation>
<documentation>
--
2.17.1
More information about the elbe-devel
mailing list