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
|
'''
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__ = "pidge@toganlabs.com"
'''
from buildbot.steps.shell import ShellCommand
from buildbot.status import progress
from buildbot.status.results import SUCCESS, FAILURE, WARNINGS
from buildbot.process.properties import WithProperties
from twisted.python import log
from autobuilder.config import *
class GetDistroVersion(ShellCommand):
haltOnFailure = True
flunkOnFailure = True
name = "GetDistroVersion"
def __init__(self, factory, argdict=None, **kwargs):
for k, v in argdict.iteritems():
setattr(self, k, v)
self.description = "Get Distro Version"
self.distroversion = None
self.workerworkdir=os.path.join(os.path.join(YOCTO_ABBASE, "yocto-worker"))
for k, v in argdict.iteritems():
setattr(self, k, v)
ShellCommand.__init__(self, **kwargs)
def start(self):
self.buildername=self.getProperty("buildername")
layerversionyocto = int(self.getProperty("layerversion_yocto", "0"))
self.distroconf=self.workerworkdir + "/" + self.buildername
if 'poky' in self.distro or 'clanton' in self.distro:
if layerversionyocto < 3:
self.distroconf+="/build/meta-yocto/conf/distro/poky.conf|grep 'DISTRO_VERSION = \"'"
else:
self.distroconf+="/build/meta-poky/conf/distro/poky.conf|grep 'DISTRO_VERSION = \"'"
elif 'oecore' in self.distro:
self.distroconf+="/build/meta/conf/distro/include/default-distrovars.inc|grep 'DISTRO_VERSION '"
elif 'angstrom' in self.distro:
self.distroconf+="/build/meta-angstrom/conf/distro/angstrom-*.conf|grep 'DISTRO_VERSION = \"'"
elif 'refkit' in self.distro:
self.distroconf += "/build/*/meta-refkit/conf/distro/refkit*.conf|grep 'DISTRO_VERSION ?= \"'"
else:
logmsg = 'distro %s is not recognised by the yocto-autobuilder.' \
% self.distro
self.addCompleteLog("failure", logmsg)
self.finished(FAILURE)
return None
cmd = 'cat ' + self.distroconf
self.command = cmd
ShellCommand.start(self)
def commandComplete(self, cmd):
if cmd.didFail():
return
result = cmd.logs['stdio'].getText()
distroversion = result.replace("DISTRO_VERSION = ", "").replace("-${DATE}","").replace('"','').strip()
self.setProperty('distroversion', distroversion, "Setting Distro Version")
is_milestone = self.getProperty("custom_is_milestone")
milestone_number = self.getProperty("custom_milestone_number")
rc_number = self.getProperty("custom_rc_number")
if str(self.getProperty("custom_release_me")) == "True":
yocto_number = self.getProperty("custom_yocto_number")
if is_milestone == "True":
distroversion = distroversion.replace('+snapshot', '')
# If distroversion has more than one . and can't be coerced
# into a float we can't easily do our automatic version
# bumping for milestone releases.
if len(distroversion.split('.')) > 2:
logmsg = 'Unexpectedly long DISTRO_VERSION="%s"' \
% distroversion
logmsg = logmsg + ' only expected 2 components, '
logmsg = logmsg + 'i.e. 2.2 not 2.2.1'
self.addCompleteLog("failure", logmsg)
self.finished(FAILURE)
self.build.allStepsDone()
else:
try:
distroversion = str(float(distroversion)+0.1)
except ValueError:
# If the distro version can't be coerced into a float
# fail early and tell the user something went wrong.
logmsg = 'Unexpected DISTRO_VERSION="%s"' \
% distroversion
self.addCompleteLog("failure", logmsg)
self.finished(FAILURE)
self.build.allStepsDone()
self.setProperty('distroversion', distroversion, "Setting Distro Version")
if distroversion == yocto_number and "poky" in self.distro:
self.finished(SUCCESS)
elif "poky" not in self.distro:
self.finished(SUCCESS)
else:
logmsg = 'Failed to get distroversion. DISTRO_VERSION="%s"' \
% distroversion
logmsg = logmsg + ' is not the same as specified Yocto Project'
logmsg = logmsg + ' release number %s' % yocto_number
self.addCompleteLog("failure", logmsg)
self.finished(FAILURE)
self.build.allStepsDone()
else:
self.finished(SUCCESS)
def getText(self, cmd, results):
return ShellCommand.getText(self, cmd, results)
|