aboutsummaryrefslogtreecommitdiffstats
path: root/lib/python2.7/site-packages/autobuilder/buildsteps/BuildImages.py
blob: 23527c97145a0e1f25b3f9946fd98a4cf09dd3cd (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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
'''
Created on Jan 6, 2013

__author__ = "Elizabeth 'pidge' Flanagan"
__copyright__ = "Copyright 2012-2013, Intel Corp."
__credits__ = ["Elizabeth Flanagan"]
__license__ = "GPL"
__version__ = "2.0"
__maintainer__ = "Elizabeth Flanagan"
__email__ = "pidge@toganlabs.com"
'''


from buildbot.steps.shell import ShellCommand
from buildbot.process.buildstep import LogLineObserver
from distutils.version import StrictVersion
from buildbot.status.results import SUCCESS, SKIPPED
import os, datetime

from lib.buildsteps import BitbakeShellCommand

class BuildImages(BitbakeShellCommand):
    haltOnFailure = False
    flunkOnFailure = True
    name = "BuildImages"
    def __init__(self, factory, argdict=None, **kwargs):
        self.layerversion_yoctobsp=0
        self.machine=""
        self.images=""
        self.oeinit = "oe-init-build-env"
        self.overrideenv = []
        self._pendingLogObservers = []
        self.factory = factory
        for k, v in argdict.iteritems():
            setattr(self, k, v)
        # Timeout needs to be passed to LoggingBuildStep as a kwarg
        self.timeout = 100000
        kwargs['timeout']=self.timeout
        super(BuildImages, self).__init__(factory, argdict=None,
                **kwargs)

    def start(self):
        self.localconf = self.getProperty("LOCALCONF")
        self.layerversion_yoctobsp = \
            int(self.getProperty("layerversion_yoctobsp", "0"))
        self.layerversion_core = \
            int(self.getProperty("layerversion_core", "0"))
        self.machine = self.getProperty("MACHINE", "")
        self.minnowExists = self.getProperty("minnowExists")
        try:
            self.deploycheck = self.getProperty('custom_deploy_artifacts')
        except:
            self.deploycheck = "True"

        builddir = os.path.join(self.getProperty('builddir'), 'build')
        if self.overrideenv:
            for i, e in enumerate(self.overrideenv):
                self.overrideenv[i] = e.replace('#YPDIR', builddir)

        # the eventlog capability exists only in bitbake 1.25 and newer
        self.create_eventlog = "False"
        if self.getProperty('bitbakeversion') \
           and StrictVersion(self.getProperty('bitbakeversion')) >= StrictVersion("1.25"):
            try:
                self.create_eventlog = self.getProperty("custom_create_eventlog")
                if self.create_eventlog == "True":
                    timestamp = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
                    self.eventlog_name = "tmp/log/bitbake_eventlog-%s.json" % timestamp
            except:
                pass

        env = ''
        if self.overrideenv:
            env = ' '.join(self.overrideenv) + ' '

        # Refkit builds should only happen for non-releases on master,
        # master-next or ross/mut* branches
        branch = self.getProperty('branch')
        masterish = False
        if self.getProperty('is_release') != 'True' \
           and (branch in ['master', 'master-next'] \
                or branch.startswith('ross/mut')):
            masterish = True

        if self.images == "#SCRAPEDTARGETS":
            self.images = self.getProperty("scraped_targets")

        if self.images == "#TOASTER":
            bitbakeflags = "-k "
            if self.create_eventlog == "True":
                bitbakeflags += "-w '" + self.eventlog_name + "' "
            self.images=self.getProperty("custom_images")
            self.command = env + ". ./" + self.oeinit + "; bitbake " + bitbakeflags + self.images
            self.description = ["Building " + str(self.images)]
        elif self.images == "package-index" and str(self.deploycheck) == "False":
            self.skipStep('Skipping build as the required artifacts are not there')
        elif not masterish and 'refkit' in self.images:
            # Refkit tracks OE-Core master, skip it for named branches
            self.skipStep('Skipping refkit build, not supported for releases.')
        # core-image-basic rename
        # See: http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=b7f1cca517bbd4191828c6bae32e0c5041f1ff19
        # I hate making people change their configs, so support both.
        else:
            if self.layerversion_core < 4:
                self.images=self.images.replace("core-image-full-cmdline", "core-image-basic")
            else:
                self.images=self.images.replace("core-image-basic", "core-image-full-cmdline")

            if self.layerversion_core < 8:
                self.images=self.images.replace("core-image-sato-sdk-ptest", "")

            if self.layerversion_core > 6:
                self.images=self.images.replace("LSB-QT-IMAGES", "")
            else:
                self.images=self.images.replace("LSB-QT-IMAGES", "core-image-lsb-qt3")

            # Releases older than Rocko didn't build
            # core-image-sato-sdk with musl.
            if self.layerversion_core < 11 \
               and "musl" in self.localconf:
                self.images = self.images.replace("core-image-sato-sdk", "core-image-sato")

            # Releases older than Pyro need to build an image before
            # invoking oe-selfest
            if self.layerversion_core < 10:
                self.images = self.images.replace("SELFTEST-PRE", "core-image-minimal")
            else:
                self.images = self.images.replace("SELFTEST-PRE", "")

            # The switch to recipe-specific-sysroots during the Pyro release forced us
            # to change how we build the native dependencies for wic and introduce
            # wic-tools. As we've traditionally made efforts in the AB to not break
            # existing buildset we should handle both wic-tools and the full list
            # of native dependencies correctly.
            wicNativeDeps = ("syslinux syslinux-native parted-native "
                             "gptfdisk-native dosfstools-native mtools-native")
            if self.layerversion_core > 9:
                self.images = self.images.replace(wicNativeDeps, "wic-tools")
            else:
                self.images = self.images.replace("wic-tools", wicNativeDeps)

            if "minnow" in self.machine:

                if self.minnowExists is "False":
                    self.skipStep("Minnowboard layer does not build for 1.8")

            '''
            Various images/builds/features do not work in earlier versions of
            oe-core/other layers. This excludes certain builds from building.

            While we could do something like:

            if <some condition is met>:
                self.finished(SUCCESS)
                self.description = ["Skipping Build"]
                self.build.allStepsDone()

            we really don't want to do this as other bits later in the build
            set may in fact be needed.
            '''
            if self.layerversion_core > 7 \
               and "adt-installer" in self.images:
                self.skipStep('Skipping adt-installer.')
            elif self.layerversion_core < 8 \
               and 'DISTRO_FEATURES_remove="x11"' in self.localconf.replace(" ", ""):
                self.skipStep('Skipping no-x11 Build.')
            elif self.layerversion_core != 8 \
               and 'uclibc' in self.localconf:
                self.skipStep('Skipping uclib Build.')
            elif self.layerversion_core < 8 \
               and 'musl' in self.localconf:
                self.skipStep('Skipping musl Build.')
            elif self.layerversion_core < 7 \
               and "populate_sdk_ext" in self.images:
                self.skipStep('Skipping eSDK Build.')
            elif self.layerversion_yoctobsp < 2 \
               and self.machine == "genericx86-64":
                self.skipStep("Skipping genericx86-64 Build")
            elif self.images == "":
                self.skipStep("Skipping Build. No Images to be built")
            else:
                bitbakeflags = "-k "
                if self.create_eventlog == "True":
                    bitbakeflags += "-w '" + self.eventlog_name + "' "
                if self.minnowExists is None or self.minnowExists == "True":
                    self.command = env + ". ./" + self.oeinit + "; bitbake " + bitbakeflags + self.images
                    self.description = ["Building " + str(self.images)]

        self.setProperty("BuildImages", self.images, "BuildImages")

        ShellCommand.start(self)

    def describe(self, done=False):
        description = ShellCommand.describe(self, done)
        return description