aboutsummaryrefslogtreecommitdiffstats
path: root/lib/python2.7/site-packages/autobuilder/buildsteps/CheckOutLayers.py
blob: b3278625909b474b5e9d4fca5b54f098355933e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# This file is part of Buildbot.  Buildbot is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
#
#
'''
Created on Jan 14, 2012

__copyright__ = "Copyright Buildbot Team Members"
__credits__ = ["Elizabeth Flanagan"]
__license__ = "GPL"
__version__ = "2.0"
__maintainer__ = "Elizabeth Flanagan"
__email__ = "pidge@toganlabs.com"
'''
from twisted.python import log
from twisted.internet import defer

import os
from buildbot.steps.source.yoctogit import YoctoGit
from buildbot import config
from buildbot.status import build
from buildbot.process import buildstep

class CheckOutLayers(YoctoGit):
    def __init__(self, factory, scheduler=None, layername=None, mode='full',  storedir=None, mirrordir=None,
                method='clobber', submodules=False, shallow=False, workdir='build',
                timeout=100000, progress=True, retryFetch=True, clobberOnFailure=False,
                getDescription=True, argdict=None,
                 **kwargs):
        self.scheduler = scheduler
        self.workdir=workdir
        self.branch = ""
        self.commit = ""
        self.method = method
        self.prog = progress
        self.repourl = ""
        self.retryFetch = retryFetch
        self.submodules = submodules
        self.shallow = shallow
        self.storedir=storedir
        self.mirrordir=mirrordir
        self.fetchcount = 0
        self.clobberOnFailure = clobberOnFailure
        self.mode = mode
        self.timeout = 100000
        self.getDescription = getDescription
        self.layername = layername
        self.name="Git checkout of " + layername
        kwargs['timeout']=self.timeout
        for k, v in argdict.iteritems():
            setattr(self, k, v)
        YoctoGit.__init__(self, repourl=self.repourl, branch=self.branch, mode=self.mode,
                 method=self.method, storedir=self.storedir, mirrordir=mirrordir, submodules=self.submodules,
                 workdir=self.workdir, shallow=self.shallow, progress=self.progress,
                 retryFetch=self.retryFetch, clobberOnFailure=self.clobberOnFailure,
                 getDescription=self.getDescription, layername=self.layername, **kwargs)

    def startVC(self, branch, revision, patch):
        if self.getProperty('branch_'+self.layername):
            self.branch = self.getProperty('branch_'+self.layername)
        else:
            self.branch = "master"
        if self.getProperty('repo_'+self.layername):
            self.repourl = self.getProperty('repo_'+self.layername)
        else:
            self.repourl = "git://git.yoctoproject.org/poky"

        if self.getProperty('commit_'+self.layername) == "HEAD" and \
           self.getProperty('commit_resolvedhead_'+self.layername) is not None:
            log.msg("Using Resolved HEAD")
            self.commit = self.getProperty('commit_resolvedhead_'+self.layername)
        elif self.getProperty('commit_'+self.layername):
            self.commit = self.getProperty('commit_'+self.layername)
        else:
            self.commit = "HEAD"

        self.setProperty('repourl_' + self.layername, self.repourl, "CheckOutLayers")
        self.setProperty('branch_' + self.layername, self.branch, "CheckOutLayers")
        self.setProperty('commit_' + self.layername, self.commit, "CheckOutLayers")

        # Store non-core (and non-eclipse) layer names in a variable for use
        # by other buildsteps
        if self.layername not in ["poky", "oecore", "eclipse", "bitbake"]:
            layers = self.getProperty('cloned_layers', default='')
            if len(layers) == 0:
                layers = self.layername
            else:
                layers = layers + ' ' + self.layername
            self.setProperty("cloned_layers", layers, "CheckOutLayers")

        if self.layername == "poky" or self.layername == "oecore" or "eclipse" in self.layername:
            self.setProperty('repository', self.repourl, "CheckOutLayers")
            self.setProperty('branch', self.branch, "CheckOutLayers")
            self.setProperty('revision', self.commit, "CheckOutLayers")
        YoctoGit.startVC(self, branch=self.branch, patch=None, revision=self.commit)

    @defer.inlineCallbacks
    def parseGotRevision(self, _=None):
        self.workdir = "source/" + self.repourl
        stdout = yield self._dovccmd(['rev-parse', self.commit], collectStdout=True)
        revision = stdout.strip()
        if len(revision) != 40:
            raise buildstep.BuildStepFailed()
        if self.layername == "poky":
            self.updateSourceProperty('got_revision', revision)
        self.updateSourceProperty('got_revision_' + self.layername, revision)
        defer.returnValue(0)