phase2: compute checksums
[buildbot.git] / phase2 / master.cfg
index eb9c37fc5d73b294c650dfa356d87fef3cd4c48f..774f1a637055c9996ae3862556302fe143bc9899 100644 (file)
@@ -5,7 +5,6 @@ import os
 import re
 import sys
 import base64
-import random
 import subprocess
 import configparser
 
@@ -26,11 +25,12 @@ from buildbot.plugins import util
 from buildbot.process import results
 from buildbot.process.factory import BuildFactory
 from buildbot.process.properties import Property
-from buildbot.process.properties import WithProperties
+from buildbot.process.properties import Interpolate
+from buildbot.process import properties
 from buildbot.schedulers.basic import SingleBranchScheduler
 from buildbot.schedulers.forcesched import ForceScheduler
 from buildbot.steps.master import MasterShellCommand
-from buildbot.steps.shell import SetProperty
+from buildbot.steps.shell import SetPropertyFromCommand
 from buildbot.steps.shell import ShellCommand
 from buildbot.steps.transfer import FileDownload
 from buildbot.steps.transfer import FileUpload
@@ -62,7 +62,6 @@ c = BuildmasterConfig = {}
 
 worker_port = 9990
 persistent = False
-other_builds = 0
 tree_expire = 0
 git_ssh = False
 git_ssh_key = None
@@ -73,9 +72,6 @@ if ini.has_option("phase2", "port"):
 if ini.has_option("phase2", "persistent"):
        persistent = ini.getboolean("phase2", "persistent")
 
-if ini.has_option("phase2", "other_builds"):
-       other_builds = ini.getint("phase2", "other_builds")
-
 if ini.has_option("phase2", "expire"):
        tree_expire = ini.getint("phase2", "expire")
 
@@ -93,7 +89,7 @@ max_builds = dict()
 for section in ini.sections():
        if section.startswith("worker "):
                if ini.has_option(section, "name") and ini.has_option(section, "password") and \
-                  ini.has_option(section, "phase") and ini.getint(section, "phase") == 2:
+                       ini.has_option(section, "phase") and ini.getint(section, "phase") == 2:
                        name = ini.get(section, "name")
                        password = ini.get(section, "password")
                        sl_props = { 'shared_wd': False }
@@ -154,6 +150,8 @@ if ini.has_option("rsync", "sdk_password"):
 if ini.has_option("rsync", "sdk_pattern"):
        rsync_sdk_pat = ini.get("rsync", "sdk_pattern")
 
+rsync_defopts = ["-4", "-v", "--timeout=120"]
+
 repo_url = ini.get("repo", "url")
 repo_branch = "master"
 
@@ -212,9 +210,9 @@ make = subprocess.Popen(['make', '--no-print-directory', '-C', work_dir+'/source
 
 line = make.stdout.readline()
 if line:
-       parse_feed_entry(line)
+       parse_feed_entry(str(line, 'utf-8'))
 
-with open(work_dir+'/source.git/feeds.conf.default', 'r') as f:
+with open(work_dir+'/source.git/feeds.conf.default', 'r', encoding='utf-8') as f:
        for line in f:
                parse_feed_entry(line)
 
@@ -284,6 +282,7 @@ c['schedulers'].append(ForceScheduler(
 # what steps, and which workers can execute them.  Note that any particular build will
 # only take place on one worker.
 
+@properties.renderer
 def GetDirectorySuffix(props):
        verpat = re.compile(r'^([0-9]{2})\.([0-9]{2})(?:\.([0-9]+)(?:-rc([0-9]+))?|-(SNAPSHOT))$')
        if props.hasProperty("release_version"):
@@ -292,12 +291,14 @@ def GetDirectorySuffix(props):
                        return "-%02d.%02d" %(int(m.group(1)), int(m.group(2)))
        return ""
 
+@properties.renderer
 def GetNumJobs(props):
        if props.hasProperty("workername") and props.hasProperty("nproc"):
-               return ((int(props["nproc"]) / (max_builds[props["workername"]] + other_builds)) + 1)
+               return str(int(props["nproc"]) / max_builds[props["workername"]])
        else:
-               return 1
+               return "1"
 
+@properties.renderer
 def GetCwd(props):
        if props.hasProperty("builddir"):
                return props["builddir"]
@@ -324,7 +325,7 @@ def IsArchitectureSelected(target):
 def UsignSec2Pub(seckey, comment="untrusted comment: secret key"):
        try:
                seckey = base64.b64decode(seckey)
-       except:
+       except Exception:
                return None
 
        return "{}\n{}".format(re.sub(r"\bsecret key$", "public key", comment),
@@ -367,7 +368,7 @@ def getNewestCompleteTime(bldr):
        if last_build and last_build[0]:
                last_complete_at = last_build[0]['complete_at']
                if last_complete_at and (last_complete_at > complete_at):
-                   return last_complete_at
+                       return last_complete_at
 
        return complete_at
 
@@ -440,7 +441,7 @@ for arch in arches:
                doStepIf = IsSharedWorkdir))
 
        # find number of cores
-       factory.addStep(SetProperty(
+       factory.addStep(SetPropertyFromCommand(
                name = "nproc",
                property = "nproc",
                description = "Finding number of CPUs",
@@ -456,7 +457,7 @@ for arch in arches:
                factory.addStep(ShellCommand(
                        name = "cleanold",
                        description = "Cleaning previous builds",
-                       command = ["./cleanup.sh", buildbot_url, WithProperties("%(workername)s"), WithProperties("%(buildername)s"), "full"],
+                       command = ["./cleanup.sh", buildbot_url, Interpolate("%(prop:workername)s"), Interpolate("%(prop:buildername)s"), "full"],
                        workdir = ".",
                        haltOnFailure = True,
                        timeout = 2400))
@@ -464,7 +465,7 @@ for arch in arches:
                factory.addStep(ShellCommand(
                        name = "cleanup",
                        description = "Cleaning work area",
-                       command = ["./cleanup.sh", buildbot_url, WithProperties("%(workername)s"), WithProperties("%(buildername)s"), "single"],
+                       command = ["./cleanup.sh", buildbot_url, Interpolate("%(prop:workername)s"), Interpolate("%(prop:buildername)s"), "single"],
                        workdir = ".",
                        haltOnFailure = True,
                        timeout = 2400))
@@ -493,7 +494,7 @@ for arch in arches:
        factory.addStep(ShellCommand(
                name = "downloadsdk",
                description = "Downloading SDK archive",
-               command = ["rsync", "-4", "-va", "%s/%s/%s/%s" %(rsync_sdk_url, ts[0], ts[1], rsync_sdk_pat), "sdk.archive"],
+               command = ["rsync"] + rsync_defopts + ["-a", "%s/%s/%s/%s" %(rsync_sdk_url, ts[0], ts[1], rsync_sdk_pat), "sdk.archive"],
                env={'RSYNC_PASSWORD': rsync_sdk_key},
                haltOnFailure = True,
                logEnviron = False))
@@ -507,7 +508,7 @@ for arch in arches:
        factory.addStep(ShellCommand(
                name = "updatesdk",
                description = "Updating SDK",
-               command = "rsync --checksum -av sdk_update/ sdk/ && rm -rf sdk_update",
+               command = "rsync " + (" ").join(rsync_defopts) + " --checksum -a sdk_update/ sdk/ && rm -rf sdk_update",
                haltOnFailure = True))
 
        factory.addStep(ShellCommand(
@@ -522,7 +523,7 @@ for arch in arches:
                workerdest = "sdk/getversion.mk",
                mode = 0o755))
 
-       factory.addStep(SetProperty(
+       factory.addStep(SetPropertyFromCommand(
                name = "getversion",
                property = "release_version",
                description = "Finding SDK release version",
@@ -573,13 +574,6 @@ for arch in arches:
                command = ["./ccache.sh"],
                haltOnFailure = True))
 
-       factory.addStep(ShellCommand(
-               name = "patchfeedsconfgitfull",
-               description = "Patching feeds.conf to use src-git-full",
-               workdir = "build/sdk",
-               command = "sed -e 's#^src-git #src-git-full #g' feeds.conf.default > feeds.conf",
-               haltOnFailure = True))
-
        if git_ssh:
                factory.addStep(StringDownload(
                        name = "dlgitclonekey",
@@ -589,9 +583,9 @@ for arch in arches:
 
                factory.addStep(ShellCommand(
                        name = "patchfeedsconf",
-                       description = "Patching feeds.conf to use SSH cloning",
+                       description = "Patching feeds.conf",
                        workdir = "build/sdk",
-                       command = "sed -i -e 's#https://#ssh://git@#g' feeds.conf",
+                       command = "sed -e 's#https://#ssh://git@#g' feeds.conf.default > feeds.conf",
                        haltOnFailure = True))
 
        factory.addStep(ShellCommand(
@@ -599,7 +593,7 @@ for arch in arches:
                description = "Updating feeds",
                workdir = "build/sdk",
                command = ["./scripts/feeds", "update", "-f"],
-               env = {'GIT_SSH_COMMAND': WithProperties("ssh -o IdentitiesOnly=yes -o IdentityFile=%(cwd)s/git-clone.key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no", cwd=GetCwd)} if git_ssh else {},
+               env = {'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))
 
        if git_ssh:
@@ -632,8 +626,8 @@ for arch in arches:
                description = "Building packages",
                workdir = "build/sdk",
                timeout = 3600,
-               command = ["make", WithProperties("-j%(jobs)d", jobs=GetNumJobs), "IGNORE_ERRORS=n m y", "BUILD_LOG=1", "CONFIG_AUTOREMOVE=y", "CONFIG_SIGNED_PACKAGES="],
-               env = {'CCACHE_BASEDIR': WithProperties("%(cwd)s", cwd=GetCwd)},
+               command = ["make", Interpolate("-j%(kw:jobs)s", jobs=GetNumJobs), "IGNORE_ERRORS=n m y", "BUILD_LOG=1", "CONFIG_AUTOREMOVE=y", "CONFIG_SIGNED_PACKAGES="],
+               env = {'CCACHE_BASEDIR': Interpolate("%(kw:cwd)s", cwd=GetCwd)},
                haltOnFailure = True))
 
        factory.addStep(ShellCommand(
@@ -642,6 +636,15 @@ for arch in arches:
                workdir = "build/sdk",
                command = "./scripts/feeds list -s -f > bin/packages/%s/feeds.conf" %(arch[0])))
 
+       factory.addStep(ShellCommand(
+               name = "checksums",
+               description = "Calculating checksums",
+               descriptionDone="Checksums calculated",
+               workdir = "build/sdk",
+               command = "cd bin/packages/%s; " %(arch[0]) + "find . -type f -not -name 'sha256sums' -printf \"%P\n\" | sort | xargs -r ../../../staging_dir/host/bin/mkhash -n sha256 | sed -ne 's!^\(.*\) \(.*\)$!\1 *\2!p' > sha256sums)",
+               haltOnFailure = True
+       ))
+
        if ini.has_option("gpg", "key") or usign_key is not None:
                factory.addStep(MasterShellCommand(
                        name = "signprepare",
@@ -686,11 +689,18 @@ for arch in arches:
                        haltOnFailure = True
                ))
 
+       factory.addStep(FileDownload(
+               name="dlrsync.sh",
+               mastersrc = scripts_dir + "/rsync.sh",
+               workerdest = "../rsync.sh",
+               mode = 0o755
+       ))
+
        factory.addStep(ShellCommand(
                name = "uploadprepare",
                description = "Preparing package directory",
                workdir = "build/sdk",
-               command = ["rsync", "-4", "-av", "--include", "/%s/" %(arch[0]), "--exclude", "/*", "--exclude", "/%s/*" %(arch[0]), "bin/packages/", WithProperties("%s/packages%%(suffix)s/" %(rsync_bin_url), suffix=GetDirectorySuffix)],
+               command = ["rsync"] + rsync_defopts + ["-a", "--include", "/%s/" %(arch[0]), "--exclude", "/*", "--exclude", "/%s/*" %(arch[0]), "bin/packages/", Interpolate("%(kw:rsyncbinurl)s/packages%(kw:suffix)s/", rsyncbinurl=rsync_bin_url, suffix=GetDirectorySuffix)],
                env={'RSYNC_PASSWORD': rsync_bin_key},
                haltOnFailure = True,
                logEnviron = False
@@ -700,7 +710,7 @@ for arch in arches:
                name = "packageupload",
                description = "Uploading package files",
                workdir = "build/sdk",
-               command = ["rsync", "-4", "--progress", "--delete", "--checksum", "--delay-updates", "--partial-dir=.~tmp~%s" %(arch[0]), "-avz", "bin/packages/%s/" %(arch[0]), WithProperties("%s/packages%%(suffix)s/%s/" %(rsync_bin_url, arch[0]), suffix=GetDirectorySuffix)],
+               command = ["../../../rsync.sh"] + rsync_defopts + ["--delete", "--checksum", "--delay-updates", "--partial-dir=.~tmp~%s" %(arch[0]), "-a", "bin/packages/%s/" %(arch[0]), Interpolate("%(kw:rsyncbinurl)s/packages%(kw:suffix)s/%(kw:archname)s/", rsyncbinurl=rsync_bin_url, suffix=GetDirectorySuffix, archname=arch[0])],
                env={'RSYNC_PASSWORD': rsync_bin_key},
                haltOnFailure = True,
                logEnviron = False
@@ -710,7 +720,7 @@ for arch in arches:
                name = "logprepare",
                description = "Preparing log directory",
                workdir = "build/sdk",
-               command = ["rsync", "-4", "-av", "--include", "/%s/" %(arch[0]), "--exclude", "/*", "--exclude", "/%s/*" %(arch[0]), "bin/packages/", WithProperties("%s/faillogs%%(suffix)s/" %(rsync_bin_url), suffix=GetDirectorySuffix)],
+               command = ["rsync"] + rsync_defopts + ["-a", "--include", "/%s/" %(arch[0]), "--exclude", "/*", "--exclude", "/%s/*" %(arch[0]), "bin/packages/", Interpolate("%(kw:rsyncbinurl)s/faillogs%(kw:suffix)s/", rsyncbinurl=rsync_bin_url, suffix=GetDirectorySuffix)],
                env={'RSYNC_PASSWORD': rsync_bin_key},
                haltOnFailure = True,
                logEnviron = False
@@ -730,7 +740,7 @@ for arch in arches:
                name = "logcollect",
                description = "Collecting failure logs",
                workdir = "build/sdk",
-               command = ["rsync", "-av", "--files-from=logs.txt", "logs/package/feeds/", "faillogs/"],
+               command = ["rsync"] + rsync_defopts + ["-a", "--files-from=logs.txt", "logs/package/feeds/", "faillogs/"],
                haltOnFailure = False,
                flunkOnFailure = False,
                warnOnFailure = True,
@@ -740,7 +750,7 @@ for arch in arches:
                name = "logupload",
                description = "Uploading failure logs",
                workdir = "build/sdk",
-               command = ["rsync", "-4", "--progress", "--delete", "--delay-updates", "--partial-dir=.~tmp~%s" %(arch[0]), "-avz", "faillogs/", WithProperties("%s/faillogs%%(suffix)s/%s/" %(rsync_bin_url, arch[0]), suffix=GetDirectorySuffix)],
+               command = ["../../../rsync.sh"] + rsync_defopts + ["--delete", "--delay-updates", "--partial-dir=.~tmp~%s" %(arch[0]), "-az", "faillogs/", Interpolate("%(kw:rsyncbinurl)s/faillogs%(kw:suffix)s/%(kw:archname)s/", rsyncbinurl=rsync_bin_url, suffix=GetDirectorySuffix, archname=arch[0])],
                env={'RSYNC_PASSWORD': rsync_bin_key},
                haltOnFailure = False,
                flunkOnFailure = False,
@@ -761,8 +771,8 @@ for arch in arches:
                        name = "sourceupload",
                        description = "Uploading source archives",
                        workdir = "build/sdk",
-                       command = ["rsync", "--files-from=sourcelist", "-4", "--progress", "--checksum", "--delay-updates",
-                                  WithProperties("--partial-dir=.~tmp~%s~%%(workername)s" %(arch[0])), "-avz", "dl/", "%s/" %(rsync_src_url)],
+                       command = ["../../../rsync.sh"] + rsync_defopts + ["--files-from=sourcelist", "--checksum", "--delay-updates",
+                                       Interpolate("--partial-dir=.~tmp~%(kw:archname)s~%(prop:workername)s", archname=arch[0]), "-a", "dl/", "%s/" %(rsync_src_url)],
                        env={'RSYNC_PASSWORD': rsync_src_key},
                        haltOnFailure = False,
                        flunkOnFailure = False,
@@ -792,6 +802,17 @@ for arch in arches:
                alwaysRun = True
        ))
 
+       factory.addStep(ShellCommand(
+               name = "ccachestat",
+               description = "Reporting ccache stats",
+               command=["ccache", "-s"],
+               want_stderr = False,
+               haltOnFailure = False,
+               flunkOnFailure = False,
+               warnOnFailure = False,
+               alwaysRun = True,
+       ))
+
        c['builders'].append(BuilderConfig(name=arch[0], workernames=workerNames, factory=factory))
 
        c['schedulers'].append(schedulers.Triggerable(name="trigger_%s" % arch[0], builderNames=[ arch[0] ]))