phase1: add ability to clone feeds via SSH
authorJo-Philipp Wich <[email protected]>
Mon, 24 Jun 2019 04:12:12 +0000 (06:12 +0200)
committerJo-Philipp Wich <[email protected]>
Mon, 24 Jun 2019 04:12:12 +0000 (06:12 +0200)
Signed-off-by: Jo-Philipp Wich <[email protected]>
phase1/config.ini.example
phase1/master.cfg

index 47e454d78bfa6519c55908181fc8a2d170459429..f1b677cf3a3356e998732bd5632578492bcc2c3a 100644 (file)
@@ -6,6 +6,7 @@ homedir = .
 expire = 1209600
 port = 9989
 cc_version = le 4.9
+git_ssh = true
 
 [status]
 bind = tcp:8010:interface=127.0.0.1
index d94b888ed3fe7f5c0547bb4a5a33dbf563b20a8b..51c0262abbca6a3dfae930823a111eddc262ef75 100644 (file)
@@ -101,6 +101,8 @@ cc_version = None
 cc_command = "gcc"
 cxx_command = "g++"
 
+git_ssh = False
+
 if ini.has_option("general", "expire"):
        tree_expire = ini.getint("general", "expire")
 
@@ -112,6 +114,9 @@ if ini.has_option("general", "cc_version"):
        if len(cc_version) == 1:
                cc_version = ["eq", cc_version[0]]
 
+if ini.has_option("general", "git_ssh"):
+       git_ssh = ini.getboolean("general", "git_ssh")
+
 repo_url = ini.get("repo", "url")
 repo_branch = "master"
 
@@ -605,15 +610,40 @@ for target in targets:
                mode = 0755,
        ))
 
+       # Git SSH
+       if git_ssh:
+               factory.addStep(FileDownload(
+                       name = "dlgitclonekey",
+                       mastersrc = "git-clone.key",
+                       slavedest = "../git-clone.key",
+                       mode = 0600,
+               ))
+
+               factory.addStep(ShellCommand(
+                       name = "patchfeedsconf",
+                       description = "Patching feeds.conf",
+                       command="sed -e 's#https://#ssh://git@#g' feeds.conf.default > feeds.conf",
+                       haltOnFailure = True
+               ))
+
        # feed
        factory.addStep(ShellCommand(
                name = "updatefeeds",
                description = "Updating feeds",
                command=["./scripts/feeds", "update"],
-               env = MakeEnv(tryccache=True),
+               env = MakeEnv(tryccache=True, overrides={'GIT_SSH_COMMAND': Interpolate("ssh -o IdentitiesOnly=yes -o IdentityFile=%(kw:cwd)s/git-clone.key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no", cwd=GetCwd)} if git_ssh else {}),
                haltOnFailure = True
        ))
 
+       # Git SSH
+       if git_ssh:
+               factory.addStep(ShellCommand(
+                       name = "rmfeedsconf",
+                       description = "Removing feeds.conf",
+                       command=["rm", "feeds.conf"],
+                       haltOnFailure = True
+               ))
+
        # feed
        factory.addStep(ShellCommand(
                name = "installfeeds",