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
|
'''
Created on Dec 25, 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.status.results import SUCCESS, WARNINGS, FAILURE, SKIPPED, \
EXCEPTION, RETRY, worst_status
import os, datetime
import cPickle as pickle
from autobuilder.config import *
from twisted.python import log
from buildbot.steps.shell import ShellCommand
class SetDest(ShellCommand):
name = "SetDest"
haltOnFailure = True
flunkOnFailure = True
name = "Destination"
description = ["Setting %s" % name]
descriptionDone = [name]
def __init__(self, factory, argdict=None, **kwargs):
self.target=""
for k, v in argdict.iteritems():
setattr(self, k, v)
self.workerworkdir=os.path.join(os.path.join(YOCTO_ABBASE, "yocto-worker"))
self.description = ["Setting", "Destination"]
for k, v in argdict.iteritems():
setattr(self, k, v)
self.description = "Setting Destination"
# Timeout needs to be passed to LoggingBuildStep as a kwarg
self.timeout = 100
kwargs['timeout']=self.timeout
ShellCommand.__init__(self, **kwargs)
def start(self):
DEST = self.getProperty("DEST")
snapshot = ""
if DEST is not None:
self.finished(SUCCESS)
else:
buildername=self.getProperty("buildername")
self.workdir=os.path.join(self.workerworkdir, buildername)
if str(self.getProperty("custom_release_me")) == "True":
is_milestone = self.getProperty("custom_is_milestone")
milestone_number = self.getProperty("custom_milestone_number")
rc_number = self.getProperty("custom_rc_number")
if is_milestone == "False":
snapshot = "."+rc_number
elif is_milestone == "True" and milestone_number is not "" and rc_number is not "":
snapshot = "_"+milestone_number+"."+rc_number
else:
snapshot = ""
prefix = snapshot
poky_name = self.getProperty("custom_poky_name")+prefix
poky_number = self.getProperty("custom_poky_number")+prefix
yocto_number = self.getProperty("custom_yocto_number")+prefix
rel_name = 'yocto-'+ yocto_number
if not rel_name or rel_name == "":
rel_name = self.getProperty(commit-description)
DEST=os.path.normpath(os.path.join(
os.environ.get("RELEASE_PUBLISH_DIR"),rel_name))
if os.environ.get("RELEASE_PUBLISH_DIR") not in DEST:
self.step_status.setText(["Failed Setting Destination:", "Bad Release Name."])
self.finished(FAILURE)
else:
DEST = os.path.normpath(os.path.join(
os.environ.get("BUILD_PUBLISH_DIR"), buildername))
if os.environ.get("BUILD_PUBLISH_DIR") not in DEST:
self.step_status.setText(["Failed Setting Destination:", "Bad Release Name."])
self.finished(FAILURE)
DEST_DATE=datetime.datetime.now().strftime("%Y%m%d")
DATA_FILE = os.path.join(YOCTO_ABBASE, self.target + "_dest.dat")
try:
pfile = open(DATA_FILE, 'rb')
data = pickle.load(pfile)
except:
pfile = open(DATA_FILE, 'wb')
data = {}
pickle.dump(data, pfile)
pfile.close()
# we can't os.path.exists here as we don't neccessarily have
# access to the worker dest from controller. So we keep a cpickle of
# the dests.
try:
# if the dictionary entry exists, we increment value by one, then repickle
REV=data[os.path.join(DEST, DEST_DATE)]
REV=int(REV) + 1
except:
REV=1
data[os.path.join(DEST, DEST_DATE)] = REV
pfile = open(DATA_FILE, 'wb')
pickle.dump(data, pfile)
pfile.close()
DEST = os.path.join(DEST, DEST_DATE + "-" + str(REV))
self.setProperty("DEST", DEST)
self.finished(SUCCESS)
|