aboutsummaryrefslogtreecommitdiffstats
path: root/lib/python2.7/site-packages/autobuilder/buildsteps/CreateAutoConf.py
blob: 92bcfaa0dccd470763187f988ad4302c31809068 (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
196
197
'''
Created on Dec 26, 2012

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

from buildbot.steps.shell import ShellCommand
import os
from twisted.python import log
import ast, json

class CreateAutoConf(ShellCommand):
    haltOnFailure = False
    flunkOnFailure = True
    name = "CreateAutoConf"
    def __init__(self, factory, argdict=None, **kwargs):
        self.machine=""
        self.buildapp=""
        self.distro="poky"
        self.packages=None
        self.buildhistory=False
        self.gplv3=True
        self.multilib=False
        self.swabber=False
        self.x32=False
        self.atext=None
        self.emgd=False
        self.pvr=False
        self.atextprepend=None
        self.atextappend=None
        self.SDKMACHINE="i686"
        self.adtdev=False
        self.factory = factory
        self.buildappsrcrev = "${AUTOREV}"
        self.initmgr=None
        self.nosstate=False
        self.kwargs = kwargs
        self.devkernel = True
        for k, v in argdict.iteritems():
            if type(v) is bool:
                setattr(self, k, str(v))
            else:
                setattr(self, k, v)
        self.description = "Create Auto Configuration"
        ShellCommand.__init__(self, **kwargs)

    def start(self):
        buildername=self.getProperty("buildername")
        buildername=self.getProperty("devkernel")
        distroversion=self.getProperty("distroversion")
        layerversion = self.getProperty("layerversion_yoctobsp")
        layerversionoe = self.getProperty("layerversion_core")
        fout = ""
        #check to see if we have a prepend
        if self.atextprepend:
            fout = fout + self.atextprepend
        #check to see if we have text override
        if self.atext:
            fout = fout+self.atext
        else:
            if layerversionoe is not None and os.environ.get('ERROR_REPORT_COLLECT') is not None:
                if str(os.environ.get('ERROR_REPORT_COLLECT')) == "True" and int(layerversionoe) > 3:
                        fout += 'INHERIT += "report-error"\n'
            if self.distro != "oecore":
                fout = fout + 'DISTRO = "' + self.distro + '"\n'
            if self.packages:
                self.classes = [ "package_%s" % p for p in self.packages.split() ]
                fout = fout + 'PACKAGE_CLASSES = "' + " ".join(self.classes) + '"\n'
            else:
                fout = fout + 'PACKAGE_CLASSES = "package_rpm package_deb package_ipk"\n'
            repo=self.getProperty("repository")
            if os.environ.get('DEVKERNEL_MUT_REPO') is not None:
                mut_repos=ast.literal_eval(os.environ.get('DEVKERNEL_MUT_REPO').encode('utf-8'))
                if mut_repos is not None and repo in mut_repos.keys():
                    if self.getProperty("branch") in mut_repos[self.getProperty("repository")] and self.devkernel is not "False":
                        fout = fout + 'PREFERRED_PROVIDER_virtual/kernel = "' + os.environ.get('DEVKERNEL') + '"\n'
                    elif self.getProperty("custom_prefered_kernel") is not None:
                        fout = fout + 'PREFERRED_PROVIDER_virtual/kernel = "' + self.getProperty("custom_prefered_kernel") +'"\n'
            fout = fout + 'BB_NUMBER_THREADS = "' + os.environ.get('BB_NUMBER_THREADS') + '"\n'
            fout = fout + 'PARALLEL_MAKE = "-j ' + os.environ.get('PARALLEL_MAKE') + '"\n'
            fout = fout + 'SDKMACHINE ?= "' + self.SDKMACHINE + '"\n'
            fout = fout + 'BB_TASK_NICE_LEVEL = "5"\n'
            if os.environ.get('IMAGE_FSTYPES') is not None:
                fout = fout + 'IMAGE_FSTYPES_append = " ' + os.environ.get('IMAGE_FSTYPES') +'"\n'
            if os.environ.get('TMP_DIR'):
                fout = fout + 'TMPDIR = "' + os.environ.get('TMP_DIR') + '"\n'
            fout = fout + 'BB_TASK_NICE_LEVEL_task-testimage = "0"\n'
            buildprops = self.getProperties().asDict()
            for k, v in buildprops.iteritems():
                if "buildappsrcrev" in k:
                    self.buildappsrcrev=v[0]
            if self.buildapp == "True":
                if self.buildappsrcrev == "AUTOREV":
                    self.buildappsrcrev="${AUTOREV}"
                fout = fout + 'DL_DIR ?= "${TOPDIR}/downloads"\n'
                fout = fout + 'INHERIT += "own-mirrors"\n'
                fout = fout + 'SOURCE_MIRROR_URL = "file:///' + os.environ.get('DL_DIR') +'"\n'
                if self.buildappsrcrev != "DEFAULT":
                    fout = fout + 'SRCREV_pn-build-appliance-image = "' + self.buildappsrcrev + '"\n'
            else:
                fout = fout + 'DL_DIR = "' + os.environ.get('DL_DIR')+'"\n'
            if self.emgd == "True":
                fout = fout + 'LICENSE_FLAGS_WHITELIST += "license_emgd-driver-bin" \n'
            if self.pvr == "True":
                fout = fout + 'LICENSE_FLAGS_WHITELIST += "license_cdv-pvr-driver" \n'
                fout = fout + 'PVR_LICENSE = "yes" \n'
            if self.multilib and self.multilib != "False":
                if self.multilib == "True" or self.multilib == "lib32":
                    fout = fout + 'require conf/multilib.conf \n'
                    fout = fout + 'MULTILIBS = "multilib:lib32" \n'
                    fout = fout + 'DEFAULTTUNE_virtclass-multilib-lib32 = "x86" \n'
                elif self.multilib == "lib64":
                    fout = fout + 'require conf/multilib.conf \n'
                    fout = fout + 'MULTILIBS = "multilib:lib64" \n'
                    fout = fout + 'DEFAULTTUNE_virtclass-multilib-lib64 = "x86-64" \n'
                if not self.nosstate:
                    fout = fout + 'SSTATE_DIR ?= "' + os.environ.get("SSTATE_DIR") + '/multilib" \n'
            else:
                if not self.nosstate:
                    fout = fout + 'SSTATE_DIR ?= "' + os.environ.get("SSTATE_DIR") + '/" \n'
            if self.gplv3 == "False":
                    fout = fout + 'INCOMPATIBLE_LICENSE = "GPLv3" \n'
            if self.x32 == "True":
                    fout = fout + 'DEFAULTTUNE = "x86-64-x32"\n'
                    fout = fout + 'baselib = \\042${@d.getVar(\\047BASE_LIB_tune-\\047 + (d.getVar(\\047DEFAULTTUNE\\047, True) or \\047INVALID\\047), True) or \\047lib\\047}\\042 \n'
            if self.distro == "poky-rt":
                fout = fout + 'PREFERRED_PROVIDER_virtual/kernel="linux-yocto-rt" \n'
            machine=self.machine
            if layerversion is not None and int(layerversion) > 1:
                if self.machine == "atom-pc":
                    machine = self.machine.replace("atom-pc", "genericx86")
            else:
                if self.machine == "genericx86":
                    machine = self.machine.replace("genericx86", "atom-pc")
            if layerversion is not None and int(layerversion) > 2:
                if self.machine == "beagleboard":
                    machine = self.machine.replace("beagleboard", "beaglebone")
                elif self.machine == "routerstationpro":
                    machine = self.machine.replace("routerstationpro", "edgerouter")
            else:
                if self.machine == "beaglebone":
                    machine = self.machine.replace("beaglebone", "beagleboard")
                elif self.machine == "edgerouter":
                    machine = self.machine.replace("edgerouter", "routerstationpro")
            self.setProperty('MACHINE', machine, "Setting Layer Version")
            fout = fout + 'MACHINE = "' + machine + '"\n'
            fout = fout + 'PREMIRRORS = ""\n'
            if "imx" in self.machine and "danny" in self.getProperty("branch_poky"):
                fout = fout + 'BBMASK = "udev_.*\.bbappend$"\n'
            if self.swabber == "True":
                fout = fout + 'USER_CLASSES += "image-prelink image-swab"\n'
            if os.environ.get("PUBLISH_SOURCE_MIRROR") == "True":
                fout = fout + 'BB_GENERATE_MIRROR_TARBALLS = "1"\n'
            if self.buildhistory == True and os.environ.get("BUILD_HISTORY_COLLECT") == "True" and self.getProperty("branch_poky") == "master":
                fout = fout + 'INHERIT += "buildhistory"\n'
                fout = fout + 'BUILDHISTORY_COMMIT = "1"\n'
                fout = fout + 'BUILDHISTORY_DIR = "' + os.environ.get('BUILD_HISTORY_DIR') + '/' + self.getProperty("buildername") + '/poky-buildhistory"\n'
                fout = fout + 'BUILDHISTORY_PUSH_REPO = "' + os.environ.get('BUILD_HISTORY_REPO') + ' ' + self.getProperty("buildername") + ':' + self.getProperty("buildername") + '"\n'
            if self.getProperty("branch_poky"):
                if "danny" not in self.getProperty("branch_poky") and distroversion is not None:
                    if self.adtdev == "True":
                        adtrepo_url=os.environ.get("ADTREPO_DEV_URL")
                        fout=fout+'ADTREPO = "' + adtrepo_url + '/' + self.getProperty("distroversion") + '-' + self.getProperty("got_revision_poky") + '-' + self.getProperty("branch_poky") + '"\n'
                    else:
                        adtrepo_url=os.environ.get("ADTREPO_URL")
                        fout=fout+'ADTREPO = "' + adtrepo_url + '/' + self.getProperty("distroversion") + '"\n'
            if self.initmgr and "danny" not in self.getProperty("branch_poky"):
                # we don't neet to test sysvinit only, because that's the default
                if self.initmgr == "systemd":
                    fout = fout + 'DISTRO_FEATURES_append = " systemd"\n'
                    fout = fout + 'VIRTUAL-RUNTIME_init_manager = "systemd"\n'
                    fout = fout + 'DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"\n'
                if self.initmgr == "systemd sysvinit":
                    fout = fout + 'DISTRO_FEATURES_append = " systemd"\n'
                    fout = fout + 'VIRTUAL-RUNTIME_init_manager = "systemd"\n'
                if self.initmgr == "sysvinit systemd":
                    fout = fout + 'DISTRO_FEATURES_append = " systemd"\n'
                    fout = fout + 'VIRTUAL-RUNTIME_init_manager = "sysvinit"\n'
        if self.atextappend:
            fout = fout + self.atextappend

        # We have to pass command in as a list due to some weird issue where
        # build progress will throw an assert error in stepFinished. This does
        # not happen all the time but when it does happen, just break command
        # up into a list.
        self.setProperty("LOCALCONF", fout)
        self.command = ["sh", "-c", "rm -rf ./build/conf/auto.conf; printf '" + fout + "'>> ./build/conf/auto.conf"]
        ShellCommand.start(self)