Implement GPG signing support
[buildbot.git] / phase1 / master.cfg
index 6ae57d9004437e3a132734b4c98f14110a4a888f..ea6d47164885e75619878c34533385ed3ea837b9 100644 (file)
@@ -61,6 +61,20 @@ if ini.has_option("rsync", "source_url"):
        rsync_src_url = ini.get("rsync", "source_url")
        rsync_src_key = ini.get("rsync", "source_password")
 
+gpg_keyid = None
+gpg_comment = "Unattended build signature"
+gpg_passfile = "/dev/null"
+
+if ini.has_option("gpg", "keyid"):
+       gpg_keyid = ini.get("gpg", "keyid")
+
+if ini.has_option("gpg", "comment"):
+       gpg_comment = ini.get("gpg", "comment")
+
+if ini.has_option("gpg", "passfile"):
+       gpg_passfile = ini.get("gpg", "passfile")
+
+
 # find targets
 targets = [ ]
 
@@ -114,7 +128,9 @@ from buildbot.process.factory import BuildFactory
 from buildbot.steps.source import Git
 from buildbot.steps.shell import ShellCommand
 from buildbot.steps.shell import SetProperty
+from buildbot.steps.transfer import FileUpload
 from buildbot.steps.transfer import FileDownload
+from buildbot.steps.master import MasterShellCommand
 from buildbot.process.properties import WithProperties
 
 
@@ -422,6 +438,48 @@ EOT''' %(ts[0], ts[0], ts[1]) ))
                haltOnFailure = True
        ))
 
+       # sign
+       if gpg_keyid is not None:
+               factory.addStep(MasterShellCommand(
+                       name = "signprepare",
+                       description = "Preparing temporary signing directory",
+                       command = ["mkdir", "-p", "%s/signing" %(home_dir)],
+                       haltOnFailure = True
+               ))
+
+               factory.addStep(ShellCommand(
+                       name = "signpack",
+                       description = "Packing files to sign",
+                       command = ["sh", "-c", WithProperties("find bin/targets/%s/%s%%(libc)s/ -mindepth 1 -maxdepth 2 -type f -name sha256sums -or -name Packages -print0 | xargs -0 tar -czf sign.tar.gz" %(ts[0], ts[1]))],
+                       haltOnFailure = True
+               ))
+
+               factory.addStep(FileUpload(
+                       slavesrc = "sign.tar.gz",
+                       masterdest = "%s/signing/%s.%s.tar.gz" %(home_dir, ts[0], ts[1]),
+                       haltOnFailure = True
+               ))
+
+               factory.addStep(MasterShellCommand(
+                       name = "signfiles",
+                       description = "Signing files",
+                       command = ["%s/signall.sh" %(home_dir), "%s/signing/%s.%s.tar.gz" %(home_dir, ts[0], ts[1]), gpg_keyid, gpg_passfile, gpg_comment],
+                       haltOnFailure = True
+               ))
+
+               factory.addStep(FileDownload(
+                       mastersrc = "%s/signing/%s.%s.tar.gz" %(home_dir, ts[0], ts[1]),
+                       slavedest = "sign.tar.gz",
+                       haltOnFailure = True
+               ))
+
+               factory.addStep(ShellCommand(
+                       name = "signunpack",
+                       description = "Unpacking signed files",
+                       command = ["tar", "-xzf", "sign.tar.gz"],
+                       haltOnFailure = True
+               ))
+
        # upload
        factory.addStep(ShellCommand(
                name = "uploadprepare",
@@ -524,12 +582,12 @@ if ini.has_option("irc", "host") and ini.has_option("irc", "nickname") and ini.h
                irc_pass = ini.get("irc", "password")
 
        irc = words.IRC(irc_host, irc_nick, port = irc_port, password = irc_pass,
-                       channels = [{ "channel": irc_chan }],
-                       notify_events = {
-                         'exception': 1,
-                         'successToFailure': 1,
-                         'failureToSuccess': 1
-                       }
+                       channels = [{ "channel": irc_chan }],
+                       notify_events = {
+                         'exception': 1,
+                         'successToFailure': 1,
+                         'failureToSuccess': 1
+                       }
        )
 
        c['status'].append(irc)