Beispiel #1
0
def deb_factory(name=None, repourl=None, ppabranch=None, branch='master', distribution='trusty', architecture='i386'):
    factory = BuildFactory()

    for step in [
        Git(
            haltOnFailure = True,
            logEnviron = False,
            repourl=repourl,
            branch=branch,
            mode='full',
            method='copy',
            retry=(5, 3)
        ),

        # Set snapshot property for Launchpad versioning
        SetProperty(
            description="setting snapshot",
            descriptionDone="set snapshot",
            name="set-snapshot",
            property="snapshot",
            value=Interpolate("+%(prop:buildnumber)s%(kw:snapshot)s%(kw:distribution)s", snapshot=(dev_snapshot if branch=='develop' else ""), distribution=distribution)
        )
    ]: factory.addStep(step)

    # Run 'go get' for go-ethereum
    if name == 'ethereum':
        for step in [
            ShellCommand(
                haltOnFailure = True,
                logEnviron = False,
                name = "move-src",
                command=_go_cmds(branch=branch),
                description="moving src",
                descriptionDone="move src",
                env={"GOPATH": Interpolate("%(prop:workdir)s/go")}
            ),
            ShellCommand(
                logEnviron = False,
                name="source-tarball",
                description="creating source tarball",
                descriptionDone="create source tarball",
                command=Interpolate("tar --exclude .git --exclude pkg --exclude bin -czf ../%(kw:name)s_%(prop:version)s%(prop:snapshot)s.orig.tar.gz .", name=name),
                workdir=Interpolate("%(prop:workdir)s/go")
            ),
            # clean up the Git checkout for debuild
            ShellCommand(
                logEnviron = False,
                name = "clean-build",
                command="rm -rf build && mkdir build",
                description="cleaning build",
                descriptionDone="clean build",
                workdir=Interpolate("%(prop:workdir)s")
            )
        ]: factory.addStep(step)
    # Get qtwebengine-opensource-src tarball
    elif name == 'qtwebengine-opensource-src':
        for step in [
            ShellCommand(
                logEnviron = False,
                name="source-tarball",
                description="getting source tarball",
                descriptionDone="get source tarball",
                command=Interpolate("wget -c https://download.qt.io/official_releases/qt/5.4/%(kw:version)s/submodules/qtwebengine-opensource-src-%(kw:version)s.tar.xz -O ../%(kw:name)s_%(prop:version)s%(prop:snapshot)s.orig.tar.xz", name=name, version=branch)
            ),
            # clean up the Git checkout for debuild
            ShellCommand(
                logEnviron = False,
                name = "clean-build",
                command="rm -rf build && mkdir build",
                description="cleaning build",
                descriptionDone="clean build",
                workdir=Interpolate("%(prop:workdir)s")
            )
        ]: factory.addStep(step)
    # Just create the source tarball for others
    else:
        factory.addStep(ShellCommand(
            logEnviron = False,
            name="source-tarball",
            description="creating source tarball",
            descriptionDone="create source tarball",
            command=Interpolate("tar --exclude .git -czf ../%(kw:name)s_%(kw:version)s%(prop:snapshot)s.orig.tar.gz .", name=name, version=deb_version)
        ))

    for step in [
        # Get debian/ directory
        ShellCommand(
            logEnviron = False,
            name="get-debian",
            description="getting debian folder",
            descriptionDone="get debian folder",
            command=Interpolate("wget https://github.com/ethereum/ethereum-ppa/archive/%(kw:ppabranch)s.tar.gz -O- | tar -zx --exclude package.sh --exclude README.md --strip-components=1", ppabranch=ppabranch)
        ),

        # Bump version
        ShellCommand(
            logEnviron = False,
            name="bump-debian",
            description="bumping %s deb version" % distribution,
            descriptionDone="bump %s deb version" % distribution,
            command=Interpolate("EMAIL='caktux (Buildserver key) <*****@*****.**>' dch -v %(prop:version)s%(prop:snapshot)s-0ubuntu1 'git build of %(prop:got_revision)s'", dist=distribution)
        ),

        # Build a source package
        ShellCommand(
            logEnviron = False,
            name="source-package",
            description="debuilding %s" % distribution,
            descriptionDone="debuild %s" % distribution,
            command="debuild -S -sa -us -uc"
        ),
    ]: factory.addStep(step)

    # Source only packages for dependencies, build local deb packages otherwise
    if name in ['ethereum', 'cpp-ethereum']:
        # Add pbuilderrc with ccache config
        # factory.addStep(FileDownload(
        #     mastersrc="pbuilderrc",
        #     slavedest="~/.pbuilderrc"
        # ))
        main_ppa = "http://ppa.launchpad.net/ethereum/ethereum/ubuntu"
        dev_ppa = "http://ppa.launchpad.net/ethereum/ethereum-dev/ubuntu"
        qt_ppa = "http://ppa.launchpad.net/ethereum/ethereum-qt/ubuntu"

        # Set othermirror for pbuilder
        if name == 'ethereum':
            factory.addStep(ShellCommand(
                logEnviron = False,
                name="pbuilder-opts",
                description="setting pbuilderrc",
                descriptionDone="set pbuilderrc",
                command="echo 'OTHERMIRROR=\"deb [trusted=yes] %s %s main|deb-src [trusted=yes] %s %s main|deb [trusted=yes] %s %s main|deb-src [trusted=yes] %s %s main\"' > ~/.pbuilderrc" % (
                        main_ppa, distribution,
                        main_ppa, distribution,
                        qt_ppa, distribution,
                        qt_ppa, distribution),
            ))
        elif name == 'cpp-ethereum':
            if branch == 'develop':
                factory.addStep(ShellCommand(
                    logEnviron = False,
                    name="pbuilder-opts",
                    description="setting pbuilderrc",
                    descriptionDone="set pbuilderrc",
                    command="echo 'OTHERMIRROR=\"deb [trusted=yes] %s %s main|deb-src [trusted=yes] %s %s main|deb [trusted=yes] %s %s main|deb-src [trusted=yes] %s %s main|deb [trusted=yes] %s %s main|deb-src [trusted=yes] %s %s main\"' > ~/.pbuilderrc" % (
                            main_ppa, distribution,
                            main_ppa, distribution,
                            dev_ppa, distribution,
                            dev_ppa, distribution,
                            qt_ppa, distribution,
                            qt_ppa, distribution),
                ))
            else:
                factory.addStep(ShellCommand(
                    logEnviron = False,
                    name="pbuilder-opts",
                    description="setting pbuilderrc",
                    descriptionDone="set pbuilderrc",
                    command="echo 'OTHERMIRROR=\"deb [trusted=yes] %s %s main|deb-src [trusted=yes] %s %s main|deb [trusted=yes] %s %s main|deb-src [trusted=yes] %s %s main\"' > ~/.pbuilderrc" % (
                            main_ppa, distribution,
                            main_ppa, distribution,
                            qt_ppa, distribution,
                            qt_ppa, distribution),
                ))

        for step in [
            # Package that thing already
            UbuCowbuilder(
                logEnviron = False,
                architecture=architecture,
                distribution=distribution,
                basetgz="/var/cache/pbuilder/%s-%s-ethereum.cow" % (distribution, architecture),
                keyring="/usr/share/keyrings/ubuntu-archive-keyring.gpg"
            )
        ]: factory.addStep(step)

    for step in [
        # Run Lintian
        # DebLintian(
        #     fileloc=Interpolate("%(prop:deb-changes)s")
        # ),
        # Prepare .changes file for Launchpad
        ShellCommand(
            name='prepare-changes',
            description='preparing changes',
            descriptionDone='prepare changes',
            command=Interpolate('sed -i -e s/UNRELEASED/%(kw:dist)s/ -e s/urgency=medium/urgency=low/ ../*.changes', dist=distribution)
        ),

        # Gather artefacts
        ShellCommand(
            haltOnFailure=True,
            logEnviron = False,
            name="move-packages",
            description='moving packages',
            descriptionDone='move packages',
            command="mkdir result; mv %s../*.changes ../*.dsc ../*.gz %sresult/" % ("*.deb *.changes " if name in ['ethereum', 'cpp-ethereum'] else "", "../*.xz " if name == 'qtwebengine-opensource-src' else ""),
        ),

        # Upload result folder
        DirectoryUpload(
            slavesrc="result",
            masterdest=Interpolate("public_html/builds/%(prop:buildername)s/%(prop:buildnumber)s"),
            url=Interpolate("/builds/%(prop:buildername)s/%(prop:buildnumber)s"),
        ),

        # Clean latest link
        MasterShellCommand(
            name='clean-latest',
            description='cleaning latest link',
            descriptionDone='clean latest link',
            command=['rm', '-f', Interpolate("public_html/builds/%(prop:buildername)s/latest")]
        ),

        # Link latest
        MasterShellCommand(
            name='link-latest',
            description='linking latest',
            descriptionDone='link latest',
            command=['ln', '-sf', Interpolate("%(prop:buildnumber)s"), Interpolate("public_html/builds/%(prop:buildername)s/latest")]
        ),

        # Create source changes folders
        MasterShellCommand(
            name='mkdir-changes',
            description='mkdir',
            descriptionDone='mkdir',
            command=['mkdir', '-p', Interpolate("changes/%(kw:dist)s/%(kw:arch)s/%(kw:name)s", dist=distribution, arch=architecture, name=name)]
        ),

        # Link source changes
        MasterShellCommand(
            name='link-changes',
            description='linking changes',
            descriptionDone='link changes',
            command=['ln', '-sf', Interpolate("../../../../public_html/builds/%(prop:buildername)s/%(prop:buildnumber)s"), Interpolate("changes/%(kw:dist)s/%(kw:arch)s/%(kw:name)s", dist=distribution, arch=architecture, name=name)]
        )
    ]: factory.addStep(step)

    # Use ethereum-dev ppa for snapshots, only dput one source pkg
    if architecture == 'amd64':
        for step in [
            # debsign
            MasterShellCommand(
                haltOnFailure=False,
                flunkOnFailure=False,
                name='debsign',
                description='debsigning',
                descriptionDone='debsign',
                command=['debsign', Interpolate("changes/%(kw:dist)s/%(kw:arch)s/%(kw:name)s/%(prop:buildnumber)s/%(kw:name)s_%(kw:version)s%(prop:snapshot)s-0ubuntu1_source.changes", dist=distribution, arch=architecture, name=name, version=deb_version)]
            ),
            # dput
            MasterShellCommand(
                name='dput',
                description='dputting',
                descriptionDone='dput',
                command=['dput', 'ppa:ethereum/ethereum%s' % ("-dev" if branch=='develop' or (name == 'libjson-rpc-cpp' and jsonrpc_for_develop) else ("-qt" if name == 'qtwebengine-opensource-src' else "")), Interpolate("changes/%(kw:dist)s/%(kw:arch)s/%(kw:name)s/%(prop:buildnumber)s/%(kw:name)s_%(kw:version)s%(prop:snapshot)s-0ubuntu1_source.changes", dist=distribution, arch=architecture, name=name, version=deb_version)]
            )
        ]: factory.addStep(step)

    return factory
def osx_go_factory(branch='develop', isPullRequest=False, headless=True):
    factory = BuildFactory()

    env = {
        "GOPATH": Interpolate("%(prop:workdir)s/go:%(prop:workdir)s/build/Godeps/_workspace"),
        "PKG_CONFIG_PATH": "/usr/local/opt/qt5/lib/pkgconfig",
        "CGO_CPPFLAGS": "-I/usr/local/opt/qt5/include/QtCore",
        "LD_LIBRARY_PATH": "/usr/local/opt/qt5/lib",
        'PATH': [Interpolate("%(prop:workdir)s/go/bin"), "${PATH}"]
    }

    for step in [
        Git(
            haltOnFailure=True,
            logEnviron=False,
            repourl='https://github.com/ethereum/go-ethereum.git',
            branch=branch,
            mode='full',
            method='copy',
            codebase='go-ethereum',
            retry=(5, 3)
        ),
        Git(
            haltOnFailure=True,
            logEnviron=False,
            repourl='https://github.com/ethereum/go-build.git',
            branch='master',
            mode='incremental',
            codebase='go-build',
            retry=(5, 3),
            workdir='go-build-%s' % branch
        ),
        SetPropertyFromCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="update-protocol",
            command='gsed -ne "s/.*ProtocolVersion    = \(.*\)/\\1/p" eth/protocol.go',
            property="protocol"
        ),
        SetPropertyFromCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="update-p2p",
            command='gsed -ne "s/.*baseProtocolVersion.*= \(.*\)/\\1/p" p2p/peer.go',
            property="p2p"
        ),
        SetPropertyFromCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="update-version",
            command='gsed -ne "s/.*Version.*=\s*[^0-9]\([0-9]*\.[0-9]*\.[0-9]*\).*/\\1/p" cmd/geth/main.go',
            property="version"
        ),
        ShellCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="go-cleanup",
            command=Interpolate("rm -rf %(prop:workdir)s/go"),
            description="cleaning up",
            descriptionDone="clean up",
            env={"GOPATH": Interpolate("%(prop:workdir)s/go")}
        ),
        ShellCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="move-src",
            description="moving src",
            descriptionDone="move src",
            command=_go_cmds(branch=branch),
            env={"GOPATH": Interpolate("%(prop:workdir)s/go")}
        ),
        ShellCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="install-geth",
            description="installing geth",
            descriptionDone="install geth",
            command="go install -v github.com/ethereum/go-ethereum/cmd/geth",
            env=env
        )
    ]: factory.addStep(step)

    if not headless:
        for step in [
            ShellCommand(
                haltOnFailure=True,
                logEnviron=False,
                name="install-mist",
                description="installing mist",
                descriptionDone="install mist",
                command="go install -v github.com/ethereum/go-ethereum/cmd/mist",
                env=env
            )
        ]: factory.addStep(step)

    if not isPullRequest and headless:
        for step in [
            Trigger(
                schedulerNames=["go-ethereum-%s-brew" % branch],
                waitForFinish=False,
                set_properties={
                    "p2p": Interpolate("%(prop:p2p)s"),
                    "protocol": Interpolate("%(prop:protocol)s"),
                    "version": Interpolate("%(prop:version)s")
                }
            )
        ]: factory.addStep(step)

    for step in [
        ShellCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="go-test",
            description="go testing",
            descriptionDone="go test",
            command="go test github.com/ethereum/go-ethereum/...",
            env=env,
            maxTime=900
        )
    ]: factory.addStep(step)

    if not isPullRequest and not headless:
        for step in [
            ShellCommand(
                haltOnFailure=True,
                logEnviron=False,
                name="go-build",
                description='go build',
                descriptionDone='go build',
                command=['python', 'build.py'],
                workdir='go-build-%s/osx' % branch,
                decodeRC={0:SUCCESS,1:WARNINGS,2:WARNINGS},
                env={"GOPATH": Interpolate("%(prop:workdir)s/go")}
            ),
            SetPropertyFromCommand(
                haltOnFailure=True,
                logEnviron=False,
                name="set-sha1sum",
                command=Interpolate('sha1sum osx/Mist.dmg | grep -o -w "\w\{40\}"'),
                property='sha1sum',
                workdir='go-build-%s' % branch
            ),
            SetProperty(
                description="setting filename",
                descriptionDone="set filename",
                name="set-filename",
                property="filename",
                value=Interpolate("Mist-OSX-%(kw:time_string)s-%(prop:version)s-%(prop:protocol)s-%(kw:short_revision)s.dmg", time_string=get_time_string, short_revision=get_short_revision_go)
            ),
            FileUpload(
                haltOnFailure=True,
                name='upload-mist',
                slavesrc="osx/Mist.dmg",
                masterdest=Interpolate("public_html/builds/%(prop:buildername)s/%(prop:filename)s"),
                url=Interpolate("/builds/%(prop:buildername)s/%(prop:filename)s"),
                workdir='go-build-%s' % branch
            ),
            MasterShellCommand(
                name="clean-latest-link",
                description='cleaning latest link',
                descriptionDone= 'clean latest link',
                command=['rm', '-f', Interpolate("public_html/builds/%(prop:buildername)s/Mist-OSX-latest.dmg")]
            ),
            MasterShellCommand(
                haltOnFailure=True,
                name="link-latest",
                description='linking latest',
                descriptionDone='link latest',
                command=['ln', '-sf', Interpolate("%(prop:filename)s"), Interpolate("public_html/builds/%(prop:buildername)s/Mist-OSX-latest.dmg")]
            )
        ]: factory.addStep(step)

    return factory
def arm_go_factory(branch="develop", isPullRequest=False):
    factory = BuildFactory()

    env = {
        "GOPATH": Interpolate("%(prop:workdir)s/go:%(prop:workdir)s/build/Godeps/_workspace"),
        "CC": "arm-linux-gnueabi-gcc",
        "GOOS": "linux",
        "GOARCH": "arm",
        "CGO_ENABLED": "1",
        "GOARM": "5",
        "PATH": [Interpolate("%(prop:workdir)s/go/bin"), "${PATH}"],
    }

    for step in [
        Git(
            haltOnFailure=True,
            logEnviron=False,
            repourl="https://github.com/ethereum/go-ethereum.git",
            branch=branch,
            mode="full",
            method="copy",
            codebase="go-ethereum",
            retry=(5, 3),
        ),
        SetPropertyFromCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="set-version",
            command='sed -ne "s/^\([0-9]*\.[0-9]*\.[0-9]*\).*/\\1/p" VERSION',
            property="version",
        ),
        ShellCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="go-cleanup",
            command=Interpolate("rm -rf %(prop:workdir)s/go"),
            description="cleaning up",
            descriptionDone="clean up",
            env={"GOPATH": Interpolate("%(prop:workdir)s/go")},
        ),
        ShellCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="move-src",
            command=_go_cmds(branch=branch),
            description="moving src",
            descriptionDone="move src",
            env={"GOPATH": Interpolate("%(prop:workdir)s/go")},
        ),
        ShellCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="build-geth",
            description="building geth",
            descriptionDone="build geth",
            command="go build -v github.com/ethereum/go-ethereum/cmd/geth",
            env=env,
        ),
    ]:
        factory.addStep(step)

    # for step in [
    #     ShellCommand(
    #         haltOnFailure=True,
    #         name="go-test",
    #         description="go testing",
    #         descriptionDone="go test",
    #         command="go test github.com/ethereum/go-ethereum/...",
    #         env=env,
    #         maxTime=900
    #     )
    # ]: factory.addStep(step)

    if not isPullRequest:
        for step in [
            ShellCommand(
                haltOnFailure=True,
                logEnviron=False,
                name="tar-geth",
                description="packing",
                descriptionDone="pack",
                command=["tar", "-cjf", "geth.tar.bz2", "geth"],
            ),
            SetPropertyFromCommand(
                haltOnFailure=True,
                logEnviron=False,
                name="set-sha256sum",
                command=Interpolate('sha256sum geth.tar.bz2 | grep -o -w "\w\{64\}"'),
                property="sha256sum",
            ),
            SetProperty(
                description="setting filename",
                descriptionDone="set filename",
                name="set-filename",
                property="filename",
                value=Interpolate(
                    "geth-ARM-%(kw:time_string)s-%(prop:version)s-%(kw:short_revision)s.tar.bz2",
                    time_string=get_time_string,
                    short_revision=get_short_revision_go,
                ),
            ),
            FileUpload(
                haltOnFailure=True,
                name="upload-geth",
                slavesrc="geth.tar.bz2",
                masterdest=Interpolate("public_html/builds/%(prop:buildername)s/%(prop:filename)s"),
                url=Interpolate("/builds/%(prop:buildername)s/%(prop:filename)s"),
            ),
            MasterShellCommand(
                name="clean-latest-link",
                description="cleaning latest link",
                descriptionDone="clean latest link",
                command=["rm", "-f", Interpolate("public_html/builds/%(prop:buildername)s/geth-ARM-latest.tar.bz2")],
            ),
            MasterShellCommand(
                haltOnFailure=True,
                name="link-latest",
                description="linking latest",
                descriptionDone="link latest",
                command=[
                    "ln",
                    "-sf",
                    Interpolate("%(prop:filename)s"),
                    Interpolate("public_html/builds/%(prop:buildername)s/geth-ARM-latest.tar.bz2"),
                ],
            ),
        ]:
            factory.addStep(step)

    return factory
Beispiel #4
0
def deb_factory(name=None,
                repourl=None,
                ppabranch=None,
                branch='master',
                distribution='trusty',
                architecture='i386',
                testdeb=False):
    factory = BuildFactory()

    for step in [
            Git(haltOnFailure=True,
                logEnviron=False,
                repourl=repourl,
                branch=branch,
                mode='full',
                method='copy',
                retry=(5, 3)),

            # Set snapshot property for Launchpad versioning
            SetProperty(
                description="setting snapshot",
                descriptionDone="set snapshot",
                name="set-snapshot",
                property="snapshot",
                value=Interpolate(
                    "+%(prop:buildnumber)s%(kw:snapshot)s%(kw:distribution)s",
                    snapshot=(dev_snapshot
                              if branch == 'develop' or testdeb else ""),
                    distribution=distribution))
    ]:
        factory.addStep(step)

    # Run 'go get' for go-ethereum
    if name == 'ethereum':
        for step in [
                ShellCommand(
                    haltOnFailure=True,
                    logEnviron=False,
                    name="move-src",
                    command=_go_cmds(branch=branch),
                    description="moving src",
                    descriptionDone="move src",
                    env={"GOPATH": Interpolate("%(prop:workdir)s/go")}),
                ShellCommand(
                    logEnviron=False,
                    name="source-tarball",
                    description="creating source tarball",
                    descriptionDone="create source tarball",
                    command=Interpolate(
                        "tar --exclude .git --exclude pkg --exclude bin -czf "
                        "../%(kw:name)s_%(prop:version)s%(prop:snapshot)s.orig.tar.gz .",
                        name=name),
                    workdir=Interpolate("%(prop:workdir)s/go")),
                # clean up the Git checkout for debuild
                ShellCommand(logEnviron=False,
                             name="clean-build",
                             command="rm -rf build && mkdir build",
                             description="cleaning build",
                             descriptionDone="clean build",
                             workdir=Interpolate("%(prop:workdir)s"))
        ]:
            factory.addStep(step)
    # Get qtwebengine-opensource-src tarball
    elif name == 'qtwebengine-opensource-src':
        for step in [
                ShellCommand(
                    logEnviron=False,
                    name="source-tarball",
                    description="getting source tarball",
                    descriptionDone="get source tarball",
                    command=Interpolate(
                        "wget -c https://download.qt.io/official_releases/qt/5.4/%(kw:version)s/submodules/"
                        "qtwebengine-opensource-src-%(kw:version)s.tar.xz "
                        "-O ../%(kw:name)s_%(prop:version)s%(prop:snapshot)s.orig.tar.xz",
                        name=name,
                        version=branch)),
                # clean up the Git checkout for debuild
                ShellCommand(logEnviron=False,
                             name="clean-build",
                             command="rm -rf build && mkdir build",
                             description="cleaning build",
                             descriptionDone="clean build",
                             workdir=Interpolate("%(prop:workdir)s"))
        ]:
            factory.addStep(step)
    # Just create the source tarball for others
    else:
        factory.addStep(
            ShellCommand(
                logEnviron=False,
                name="source-tarball",
                description="creating source tarball",
                descriptionDone="create source tarball",
                command=Interpolate(
                    "tar --exclude .git -czf "
                    "../%(kw:name)s_%(kw:version)s%(prop:snapshot)s.orig.tar.gz .",
                    name=name,
                    version=deb_version)))

    for step in [
            # Get debian/ directory
            ShellCommand(
                logEnviron=False,
                name="get-debian",
                description="getting debian folder",
                descriptionDone="get debian folder",
                command=Interpolate(
                    "wget https://github.com/ethereum/ethereum-ppa/archive/%(kw:ppabranch)s.tar.gz -O- |"
                    " tar -zx --exclude package.sh --exclude README.md --strip-components=1",
                    ppabranch=ppabranch)),

            # Bump version
            ShellCommand(
                logEnviron=False,
                name="bump-debian",
                description="bumping %s deb version" % distribution,
                descriptionDone="bump %s deb version" % distribution,
                command=Interpolate(
                    "EMAIL='caktux (Buildserver key) <*****@*****.**>' "
                    "dch -v %(prop:version)s%(prop:snapshot)s-0ubuntu1 "
                    "'git build of %(prop:got_revision)s'",
                    dist=distribution)),

            # Build a source package
            ShellCommand(logEnviron=False,
                         name="source-package",
                         description="debuilding %s" % distribution,
                         descriptionDone="debuild %s" % distribution,
                         command="debuild -S -sa -us -uc"),
    ]:
        factory.addStep(step)

    # Source only packages for dependencies, build local deb packages otherwise
    if name in ['ethereum', 'cpp-ethereum']:
        # Add pbuilderrc with ccache config
        # factory.addStep(FileDownload(
        #     mastersrc="pbuilderrc",
        #     slavedest="~/.pbuilderrc"
        # ))
        main_ppa = "http://ppa.launchpad.net/ethereum/ethereum/ubuntu"
        dev_ppa = "http://ppa.launchpad.net/ethereum/ethereum-dev/ubuntu"
        qt_ppa = "http://ppa.launchpad.net/ethereum/ethereum-qt/ubuntu"

        if name is not 'ethereum' or distribution is not 'wily':
            for step in [
                    # Set PPA dependencies for pbuilder
                    ShellCommand(
                        logEnviron=False,
                        name="pbuilder-opts",
                        description="setting pbuilderrc",
                        descriptionDone="set pbuilderrc",
                        command="echo 'OTHERMIRROR=\""
                        "deb [trusted=yes] {1} {0} main|deb-src [trusted=yes] {1} {0} main|"
                        "deb [trusted=yes] {2} {0} main|deb-src [trusted=yes] {2} {0} main|"
                        "deb [trusted=yes] {3} {0} main|deb-src [trusted=yes] {3} {0} main\"' > ~/.pbuilderrc"
                        .format(distribution, main_ppa, dev_ppa, qt_ppa))
            ]:
                factory.addStep(step)

        for step in [
                # Package that thing already
                UbuCowbuilder(
                    logEnviron=False,
                    architecture=architecture,
                    distribution=distribution,
                    basetgz="/var/cache/pbuilder/%s-%s-ethereum.cow" %
                    (distribution, architecture),
                    keyring="/usr/share/keyrings/ubuntu-archive-keyring.gpg")
        ]:
            factory.addStep(step)

    for step in [
            # Run Lintian
            # DebLintian(
            #     fileloc=Interpolate("%(prop:deb-changes)s")
            # ),
            # Prepare .changes file for Launchpad
            ShellCommand(name='prepare-changes',
                         description='preparing changes',
                         descriptionDone='prepare changes',
                         command=Interpolate(
                             "sed -i -e s/UNRELEASED/%(kw:dist)s/ "
                             "-e s/urgency=medium/urgency=low/ ../*.changes",
                             dist=distribution)),

            # Gather artefacts
            ShellCommand(
                haltOnFailure=True,
                logEnviron=False,
                name="move-packages",
                description='moving packages',
                descriptionDone='move packages',
                command=
                "mkdir result; mv %s../*.changes ../*.dsc ../*.gz %sresult/" %
                ("*.deb *.changes "
                 if name in ['ethereum', 'cpp-ethereum'] else "",
                 "../*.xz " if name == 'qtwebengine-opensource-src' else ""),
            ),

            # Upload result folder
            DirectoryUpload(
                slavesrc="result",
                masterdest=Interpolate(
                    "public_html/builds/%(prop:buildername)s/%(prop:buildnumber)s"
                ),
                url=Interpolate(
                    "/builds/%(prop:buildername)s/%(prop:buildnumber)s"),
            ),

            # Clean latest link
            MasterShellCommand(
                name='clean-latest',
                description='cleaning latest link',
                descriptionDone='clean latest link',
                command=[
                    'rm', '-f',
                    Interpolate(
                        "public_html/builds/%(prop:buildername)s/latest")
                ]),

            # Link latest
            MasterShellCommand(
                name='link-latest',
                description='linking latest',
                descriptionDone='link latest',
                command=[
                    'ln', '-sf',
                    Interpolate("%(prop:buildnumber)s"),
                    Interpolate(
                        "public_html/builds/%(prop:buildername)s/latest")
                ]),

            # Create source changes folders
            MasterShellCommand(
                name='mkdir-changes',
                description='mkdir',
                descriptionDone='mkdir',
                command=[
                    'mkdir', '-p',
                    Interpolate("changes/%(kw:dist)s/%(kw:arch)s/%(kw:name)s",
                                dist=distribution,
                                arch=architecture,
                                name=name)
                ]),

            # Link source changes
            MasterShellCommand(
                name='link-changes',
                description='linking changes',
                descriptionDone='link changes',
                command=[
                    'ln', '-sf',
                    Interpolate(
                        "../../../../public_html/builds/%(prop:buildername)s/%(prop:buildnumber)s"
                    ),
                    Interpolate("changes/%(kw:dist)s/%(kw:arch)s/%(kw:name)s",
                                dist=distribution,
                                arch=architecture,
                                name=name)
                ])
    ]:
        factory.addStep(step)

    # Use ethereum-dev ppa for snapshots, only dput one source pkg
    ppa_suffix = ""
    if branch == 'develop' or (name == 'libjson-rpc-cpp'
                               and jsonrpc_for_develop):
        ppa_suffix = "-dev"
    elif name == 'qtwebengine-opensource-src':
        ppa_suffix = "-qt"

    if architecture == 'amd64':
        for step in [
                # debsign
                MasterShellCommand(
                    haltOnFailure=False,
                    flunkOnFailure=False,
                    name='debsign',
                    description='debsigning',
                    descriptionDone='debsign',
                    command=[
                        'debsign',
                        Interpolate(
                            "changes/%(kw:dist)s/%(kw:arch)s/"
                            "%(kw:name)s/%(prop:buildnumber)s/"
                            "%(kw:name)s_%(kw:version)s%(prop:snapshot)s-"
                            "0ubuntu1_source.changes",
                            dist=distribution,
                            arch=architecture,
                            name=name,
                            version=deb_version)
                    ]),
                # dput
                MasterShellCommand(
                    name='dput',
                    description='dputting',
                    descriptionDone='dput',
                    command=[
                        'dput',
                        'ppa:%s%s' %
                        ("caktux/ppa" if testdeb else "ethereum/ethereum",
                         ppa_suffix),
                        Interpolate(
                            "changes/%(kw:dist)s/%(kw:arch)s/%(kw:name)s/"
                            "%(prop:buildnumber)s/%(kw:name)s_%(kw:version)s%(prop:snapshot)s-"
                            "0ubuntu1_source.changes",
                            dist=distribution,
                            arch=architecture,
                            name=name,
                            version=deb_version)
                    ])
        ]:
            factory.addStep(step)

    return factory
def arm_go_factory(branch='develop', isPullRequest=False):
    factory = BuildFactory()

    env = {
        "GOPATH": Interpolate("%(prop:workdir)s/go:%(prop:workdir)s/build/Godeps/_workspace"),
        "CC": "arm-linux-gnueabi-gcc",
        "GOOS": "linux",
        "GOARCH": "arm",
        "CGO_ENABLED": "1",
        "GOARM": "5",
        'PATH': [Interpolate("%(prop:workdir)s/go/bin"), "${PATH}"]
    }

    for step in [
        Git(
            haltOnFailure = True,
            logEnviron = False,
            repourl='https://github.com/ethereum/go-ethereum.git',
            branch=branch,
            mode='full',
            method='copy',
            codebase='go-ethereum',
            retry=(5, 3)
        ),
        SetPropertyFromCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="set-protocol",
            command='sed -ne "s/.*ProtocolVersion    = \(.*\)/\\1/p" eth/protocol.go',
            property="protocol"
        ),
        SetPropertyFromCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="set-p2p",
            command='sed -ne "s/.*baseProtocolVersion.*= \(.*\)/\\1/p" p2p/peer.go',
            property="p2p"
        ),
        SetPropertyFromCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="set-version",
            command='sed -ne "s/.*Version.*=\s*[^0-9]\([0-9]*\.[0-9]*\.[0-9]*\).*/\\1/p" cmd/geth/main.go',
            property="version"
        ),
        ShellCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="go-cleanup",
            command=Interpolate("rm -rf %(prop:workdir)s/go"),
            description="cleaning up",
            descriptionDone="clean up",
            env={"GOPATH": Interpolate("%(prop:workdir)s/go")}
        ),
        ShellCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="move-src",
            command=_go_cmds(branch=branch),
            description="moving src",
            descriptionDone="move src",
            env={"GOPATH": Interpolate("%(prop:workdir)s/go")}
        ),
        ShellCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="build-geth",
            description="building geth",
            descriptionDone="build geth",
            command="go build -v github.com/ethereum/go-ethereum/cmd/geth",
            env=env
        )
    ]: factory.addStep(step)

    # for step in [
    #     ShellCommand(
    #         haltOnFailure=True,
    #         name="go-test",
    #         description="go testing",
    #         descriptionDone="go test",
    #         command="go test github.com/ethereum/go-ethereum/...",
    #         env=env,
    #         maxTime=900
    #     )
    # ]: factory.addStep(step)

    if not isPullRequest:
        for step in [
            ShellCommand(
                haltOnFailure=True,
                logEnviron=False,
                name="tar-geth",
                description='packing',
                descriptionDone='pack',
                command=['tar', '-cjf', 'geth.tar.bz2', 'geth']
            ),
            SetPropertyFromCommand(
                haltOnFailure=True,
                logEnviron=False,
                name="set-sha256sum",
                command=Interpolate('sha256sum geth.tar.bz2 | grep -o -w "\w\{64\}"'),
                property='sha256sum'
            ),
            SetProperty(
                description="setting filename",
                descriptionDone="set filename",
                name="set-filename",
                property="filename",
                value=Interpolate("geth-ARM-%(kw:time_string)s-%(prop:version)s-%(prop:protocol)s-%(kw:short_revision)s.tar.bz2", time_string=get_time_string, short_revision=get_short_revision_go)
            ),
            FileUpload(
                haltOnFailure=True,
                name='upload-geth',
                slavesrc="geth.tar.bz2",
                masterdest=Interpolate("public_html/builds/%(prop:buildername)s/%(prop:filename)s"),
                url=Interpolate("/builds/%(prop:buildername)s/%(prop:filename)s")
            ),
            MasterShellCommand(
                name="clean-latest-link",
                description='cleaning latest link',
                descriptionDone= 'clean latest link',
                command=['rm', '-f', Interpolate("public_html/builds/%(prop:buildername)s/geth-ARM-latest.tar.bz2")]
            ),
            MasterShellCommand(
                haltOnFailure=True,
                name="link-latest",
                description='linking latest',
                descriptionDone='link latest',
                command=['ln', '-sf', Interpolate("%(prop:filename)s"), Interpolate("public_html/builds/%(prop:buildername)s/geth-ARM-latest.tar.bz2")]
            )
        ]: factory.addStep(step)

    return factory
def osx_go_factory(branch='develop', isPullRequest=False):
    factory = BuildFactory()

    env = {
        "GOPATH": Interpolate("%(prop:workdir)s/go:%(prop:workdir)s/build/Godeps/_workspace"),
        'PATH': [Interpolate("%(prop:workdir)s/go/bin"), "${PATH}"]
    }

    for step in [
        Git(
            haltOnFailure=True,
            logEnviron=False,
            repourl='https://github.com/expanse-project/go-expanse.git',
            branch=branch,
            mode='full',
            method='copy',
            codebase='go-expanse',
            retry=(5, 3)
        ),
        SetPropertyFromCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="update-version",
            command='gsed -ne "s/.*Version.*=\s*[^0-9]\([0-9]*\.[0-9]*\.[0-9]*\).*/\\1/p" cmd/gexp/main.go',
            property="version"
        ),
        ShellCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="go-cleanup",
            command=Interpolate("rm -rf %(prop:workdir)s/go"),
            description="cleaning up",
            descriptionDone="clean up",
            env={"GOPATH": Interpolate("%(prop:workdir)s/go")}
        ),
        ShellCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="move-src",
            description="moving src",
            descriptionDone="move src",
            command=_go_cmds(branch=branch),
            env={"GOPATH": Interpolate("%(prop:workdir)s/go")}
        ),
        ShellCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="install-gexp",
            description="installing gexp",
            descriptionDone="install gexp",
            command="go install -v github.com/expanse-project/go-expanse/cmd/gexp",
            env=env
        )
    ]: factory.addStep(step)

    for step in [
        ShellCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="go-test",
            description="go testing",
            descriptionDone="go test",
            command="go test github.com/expanse-project/go-expanse/...",
            env=env,
            maxTime=900
        )
    ]: factory.addStep(step)

    if not isPullRequest:
        for step in [
            Trigger(
                schedulerNames=["go-expanse-%s-brew" % branch],
                waitForFinish=False,
                set_properties={
                    "version": Interpolate("%(prop:version)s")
                }
            )
        ]: factory.addStep(step)

    return factory
def osx_go_factory(branch='develop', isPullRequest=False):
    factory = BuildFactory()

    env = {
        "GOPATH":
        Interpolate(
            "%(prop:workdir)s/go:%(prop:workdir)s/build/Godeps/_workspace"),
        'PATH': [Interpolate("%(prop:workdir)s/go/bin"), "${PATH}"]
    }

    for step in [
            Git(haltOnFailure=True,
                logEnviron=False,
                repourl='https://github.com/ethereum/go-ethereum.git',
                branch=branch,
                mode='full',
                method='copy',
                codebase='go-ethereum',
                retry=(5, 3)),
            SetPropertyFromCommand(
                haltOnFailure=True,
                logEnviron=False,
                name="update-version",
                command=
                'gsed -ne "s/^\([0-9]*\.[0-9]*\.[0-9]*\).*/\\1/p" VERSION',
                property="version"),
            ShellCommand(haltOnFailure=True,
                         logEnviron=False,
                         name="go-cleanup",
                         command=Interpolate("rm -rf %(prop:workdir)s/go"),
                         description="cleaning up",
                         descriptionDone="clean up",
                         env={"GOPATH": Interpolate("%(prop:workdir)s/go")}),
            ShellCommand(haltOnFailure=True,
                         logEnviron=False,
                         name="move-src",
                         description="moving src",
                         descriptionDone="move src",
                         command=_go_cmds(branch=branch),
                         env={"GOPATH": Interpolate("%(prop:workdir)s/go")}),
            ShellCommand(
                haltOnFailure=True,
                logEnviron=False,
                name="install-geth",
                description="installing geth",
                descriptionDone="install geth",
                command=
                "go install -v github.com/ethereum/go-ethereum/cmd/geth",
                env=env)
    ]:
        factory.addStep(step)

    for step in [
            ShellCommand(haltOnFailure=True,
                         logEnviron=False,
                         name="go-test",
                         description="go testing",
                         descriptionDone="go test",
                         command="go test github.com/ethereum/go-ethereum/...",
                         env=env,
                         maxTime=900)
    ]:
        factory.addStep(step)

    if not isPullRequest:
        for step in [
                Trigger(name='brew-el-capitan',
                        schedulerNames=["go-ethereum-%s-el-capitan" % branch],
                        waitForFinish=False,
                        set_properties={
                            "version": Interpolate("%(prop:version)s")
                        })
        ]:
            factory.addStep(step)

    return factory
def arm_go_factory(branch='develop', isPullRequest=False):
    factory = BuildFactory()

    env = {
        "GOPATH": Interpolate("%(prop:workdir)s/go:%(prop:workdir)s/build/Godeps/_workspace"),
        "CC": "arm-linux-gnueabi-gcc",
        "GOOS": "linux",
        "GOARCH": "arm",
        "CGO_ENABLED": "1",
        "GOARM": "5",
        'PATH': [Interpolate("%(prop:workdir)s/go/bin"), "${PATH}"]
    }

    for step in [
        Git(
            haltOnFailure=True,
            logEnviron=False,
            repourl='https://github.com/ethereum/go-ethereum.git',
            branch=branch,
            mode='full',
            method='copy',
            codebase='go-ethereum',
            retry=(5, 3)
        ),
        SetPropertyFromCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="set-version",
            command='sed -ne "s/^\([0-9]*\.[0-9]*\.[0-9]*\).*/\\1/p" VERSION',
            property="version"
        ),
        ShellCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="go-cleanup",
            command=Interpolate("rm -rf %(prop:workdir)s/go"),
            description="cleaning up",
            descriptionDone="clean up",
            env={"GOPATH": Interpolate("%(prop:workdir)s/go")}
        ),
        ShellCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="move-src",
            command=_go_cmds(branch=branch),
            description="moving src",
            descriptionDone="move src",
            env={"GOPATH": Interpolate("%(prop:workdir)s/go")}
        ),
        ShellCommand(
            haltOnFailure=True,
            logEnviron=False,
            name="build-geth",
            description="building geth",
            descriptionDone="build geth",
            command="go build -v github.com/ethereum/go-ethereum/cmd/geth",
            env=env
        )
    ]: factory.addStep(step)

    # for step in [
    #     ShellCommand(
    #         haltOnFailure=True,
    #         name="go-test",
    #         description="go testing",
    #         descriptionDone="go test",
    #         command="go test github.com/ethereum/go-ethereum/...",
    #         env=env,
    #         maxTime=900
    #     )
    # ]: factory.addStep(step)

    if not isPullRequest:
        for step in [
            ShellCommand(
                haltOnFailure=True,
                logEnviron=False,
                name="tar-geth",
                description='packing',
                descriptionDone='pack',
                command=['tar', '-cjf', 'geth.tar.bz2', 'geth']
            ),
            SetPropertyFromCommand(
                haltOnFailure=True,
                logEnviron=False,
                name="set-sha256sum",
                command=Interpolate('sha256sum geth.tar.bz2 | grep -o -w "\w\{64\}"'),
                property='sha256sum'
            ),
            SetProperty(
                description="setting filename",
                descriptionDone="set filename",
                name="set-filename",
                property="filename",
                value=Interpolate("geth-ARM-%(kw:time_string)s-%(prop:version)s-%(kw:short_revision)s.tar.bz2",
                                  time_string=get_time_string,
                                  short_revision=get_short_revision_go)
            ),
            FileUpload(
                haltOnFailure=True,
                name='upload-geth',
                slavesrc="geth.tar.bz2",
                masterdest=Interpolate("public_html/builds/%(prop:buildername)s/%(prop:filename)s"),
                url=Interpolate("/builds/%(prop:buildername)s/%(prop:filename)s")
            ),
            MasterShellCommand(
                name="clean-latest-link",
                description='cleaning latest link',
                descriptionDone='clean latest link',
                command=['rm', '-f', Interpolate("public_html/builds/%(prop:buildername)s/geth-ARM-latest.tar.bz2")]
            ),
            MasterShellCommand(
                haltOnFailure=True,
                name="link-latest",
                description='linking latest',
                descriptionDone='link latest',
                command=['ln', '-sf', Interpolate("%(prop:filename)s"), Interpolate("public_html/builds/%(prop:buildername)s/geth-ARM-latest.tar.bz2")]
            )
        ]: factory.addStep(step)

    return factory