This repository has been archived by the owner on Jun 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
factory.py
8105 lines (7466 loc) · 324 KB
/
factory.py
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from __future__ import absolute_import
from datetime import datetime
import os.path, re
import urllib
import random
from twisted.python import log
from buildbot.process.buildstep import regex_log_evaluator
from buildbot.process.factory import BuildFactory
from buildbot.steps.shell import WithProperties
from buildbot.steps.transfer import FileDownload, JSONPropertiesDownload, JSONStringDownload
from buildbot.steps.dummy import Dummy
from buildbot import locks
from buildbot.status.builder import worst_status
import buildbotcustom.common
import buildbotcustom.status.errors
import buildbotcustom.steps.base
import buildbotcustom.steps.misc
import buildbotcustom.steps.release
import buildbotcustom.steps.source
import buildbotcustom.steps.test
import buildbotcustom.steps.transfer
import buildbotcustom.steps.updates
import buildbotcustom.steps.talos
import buildbotcustom.steps.unittest
import buildbotcustom.steps.signing
import buildbotcustom.env
import buildbotcustom.misc_scheduler
import build.paths
import release.info
import release.paths
reload(buildbotcustom.common)
reload(buildbotcustom.status.errors)
reload(buildbotcustom.steps.base)
reload(buildbotcustom.steps.misc)
reload(buildbotcustom.steps.release)
reload(buildbotcustom.steps.source)
reload(buildbotcustom.steps.test)
reload(buildbotcustom.steps.transfer)
reload(buildbotcustom.steps.updates)
reload(buildbotcustom.steps.talos)
reload(buildbotcustom.steps.unittest)
reload(buildbotcustom.steps.signing)
reload(buildbotcustom.env)
reload(build.paths)
reload(release.info)
reload(release.paths)
from buildbotcustom.status.errors import purge_error, global_errors, \
upload_errors, talos_hgweb_errors
from buildbotcustom.steps.base import ShellCommand, SetProperty, Mercurial, \
Trigger, RetryingShellCommand, RetryingSetProperty
from buildbotcustom.steps.misc import TinderboxShellCommand, SendChangeStep, \
GetBuildID, MozillaClobberer, FindFile, DownloadFile, UnpackFile, \
SetBuildProperty, DisconnectStep, OutputStep, MockCommand, \
RepackPartners, UnpackTest, FunctionalStep, setBuildIDProps, \
RetryingMockProperty, MockInit, MockInstall
from buildbotcustom.steps.release import UpdateVerify, SnippetComparison
from buildbotcustom.steps.source import MercurialCloneCommand
from buildbotcustom.steps.test import AliveTest, \
CompareLeakLogs, Codesighs, GraphServerPost
from buildbotcustom.steps.updates import CreateCompleteUpdateSnippet, \
CreatePartialUpdateSnippet
from buildbotcustom.steps.signing import SigningServerAuthenication
from buildbotcustom.env import MozillaEnvironments
from buildbotcustom.common import getSupportedPlatforms, getPlatformFtpDir, \
genBuildID, reallyShort
import buildbotcustom.steps.unittest as unittest_steps
import buildbotcustom.steps.talos as talos_steps
from buildbot.status.builder import SUCCESS, FAILURE
from release.paths import makeCandidatesDir
# limit the number of clones of the try repository so that we don't kill
# dm-vcview04 if the master is restarted, or there is a large number of pushes
hg_try_lock = locks.MasterLock("hg_try_lock", maxCount=20)
hg_l10n_lock = locks.MasterLock("hg_l10n_lock", maxCount=20)
# Limit ourselves to uploading 4 things at a time
upload_lock = locks.MasterLock("upload_lock", maxCount=4)
SIGNING_SERVER_CERT = os.path.join(
os.path.dirname(build.paths.__file__),
'../../../release/signing/host.cert')
class DummyFactory(BuildFactory):
def __init__(self, delay=5, triggers=None):
BuildFactory.__init__(self)
self.addStep(Dummy(delay))
if triggers:
self.addStep(Trigger(
schedulerNames=triggers,
waitForFinish=False,
))
def makeDummyBuilder(name, slaves, category=None, delay=0, triggers=None, properties=None):
properties = properties or {}
builder = {
'name': name,
'factory': DummyFactory(delay, triggers),
'builddir': name,
'slavenames': slaves,
'properties': properties,
}
if category:
builder['category'] = category
return builder
def postUploadCmdPrefix(upload_dir=None,
branch=None,
product=None,
revision=None,
version=None,
who=None,
builddir=None,
buildid=None,
buildNumber=None,
to_tinderbox_dated=False,
to_tinderbox_builds=False,
to_dated=False,
to_latest=False,
to_try=False,
to_shadow=False,
to_candidates=False,
to_mobile_candidates=False,
nightly_dir=None,
as_list=True,
signed=False,
):
"""Returns a post_upload.py command line for the given arguments.
If as_list is True (the default), the command line will be returned as a
list of arguments. Some arguments may be WithProperties instances.
If as_list is False, the command will be returned as a WithProperties
instance representing the entire command line as a single string.
It is expected that the returned value is augmented with the list of files
to upload, and where to upload it.
"""
cmd = ["post_upload.py"]
if upload_dir:
cmd.extend(["--tinderbox-builds-dir", upload_dir])
if branch:
cmd.extend(["-b", branch])
if product:
cmd.extend(["-p", product])
if buildid:
cmd.extend(['-i', buildid])
if buildNumber:
cmd.extend(['-n', buildNumber])
if version:
cmd.extend(['-v', version])
if revision:
cmd.extend(['--revision', revision])
if who:
cmd.extend(['--who', who])
if builddir:
cmd.extend(['--builddir', builddir])
if to_tinderbox_dated:
cmd.append('--release-to-tinderbox-dated-builds')
if to_tinderbox_builds:
cmd.append('--release-to-tinderbox-builds')
if to_try:
cmd.append('--release-to-try-builds')
if to_latest:
cmd.append("--release-to-latest")
if to_dated:
cmd.append("--release-to-dated")
if to_shadow:
cmd.append("--release-to-shadow-central-builds")
if to_candidates:
cmd.append("--release-to-candidates-dir")
if to_mobile_candidates:
cmd.append("--release-to-mobile-candidates-dir")
if nightly_dir:
cmd.append("--nightly-dir=%s" % nightly_dir)
if signed:
cmd.append("--signed")
if as_list:
return cmd
else:
# Remove WithProperties instances and replace them with their fmtstring
for i,a in enumerate(cmd):
if isinstance(a, WithProperties):
cmd[i] = a.fmtstring
return WithProperties(' '.join(cmd))
def parse_make_upload(rc, stdout, stderr):
''' This function takes the output and return code from running
the upload make target and returns a dictionary of important
file urls.'''
retval = {}
for m in re.findall("^(https?://.*?\.(?:tar\.bz2|dmg|zip|apk|rpm|mar))$",
"\n".join([stdout, stderr]), re.M):
if 'devel' in m and m.endswith('.rpm'):
retval['develRpmUrl'] = m
elif 'tests' in m and m.endswith('.rpm'):
retval['testsRpmUrl'] = m
elif m.endswith('.rpm'):
retval['packageRpmUrl'] = m
elif m.endswith("crashreporter-symbols.zip"):
retval['symbolsUrl'] = m
elif m.endswith("tests.tar.bz2") or m.endswith("tests.zip"):
retval['testsUrl'] = m
elif m.endswith('apk') and 'unsigned-unaligned' in m:
retval['unsignedApkUrl'] = m
elif m.endswith('apk') and 'robocop' in m:
retval['robocopApkUrl'] = m
elif 'jsshell-' in m and m.endswith('.zip'):
retval['jsshellUrl'] = m
elif m.endswith('.complete.mar'):
retval['completeMarUrl'] = m
elif m.endswith('.mar') and '.partial.' in m:
retval['partialMarUrl'] = m
else:
retval['packageUrl'] = m
return retval
def short_hash(rc, stdout, stderr):
''' This function takes an hg changeset id and returns just the first 12 chars'''
retval = {}
retval['got_revision'] = stdout[:12]
return retval
def get_signing_cmd(signingServers, python):
if not python:
python = 'python'
cmd = [
python,
'%(toolsdir)s/release/signing/signtool.py',
'--cachedir', '%(basedir)s/signing_cache',
'-t', '%(basedir)s/token',
'-n', '%(basedir)s/nonce',
'-c', '%(toolsdir)s/release/signing/host.cert',
]
for ss, user, passwd in signingServers:
cmd.extend(['-H', ss])
return ' '.join(cmd)
class BootstrapFactory(BuildFactory):
def __init__(self, automation_tag, logdir, bootstrap_config,
cvsroot="pserver:anonymous@cvs-mirror.mozilla.org",
cvsmodule="mozilla"):
"""
@type cvsroot: string
@param cvsroot: The CVSROOT to use for checking out Bootstrap.
@type cvsmodule: string
@param cvsmodule: The CVS module to use for checking out Bootstrap.
@type automation_tag: string
@param automation_tag: The CVS Tag to use for checking out Bootstrap.
@type logdir: string
@param logdir: The log directory for Bootstrap to use.
Note - will be created if it does not already exist.
@type bootstrap_config: string
@param bootstrap_config: The location of the bootstrap.cfg file on the
slave. This will be copied to "bootstrap.cfg"
in the builddir on the slave.
"""
BuildFactory.__init__(self)
self.addStep(ShellCommand(
name='rm_builddir',
description='clean checkout',
workdir='.',
command=['rm', '-rf', 'build'],
haltOnFailure=1))
self.addStep(RetryingShellCommand(
name='checkout',
description='checkout',
workdir='.',
command=['cvs', '-d', cvsroot, 'co', '-r', automation_tag,
'-d', 'build', cvsmodule],
haltOnFailure=1,
))
self.addStep(ShellCommand(
name='copy_bootstrap',
description='copy bootstrap.cfg',
command=['cp', bootstrap_config, 'bootstrap.cfg'],
haltOnFailure=1,
))
self.addStep(ShellCommand(
name='echo_bootstrap',
description='echo bootstrap.cfg',
command=['cat', 'bootstrap.cfg'],
haltOnFailure=1,
))
self.addStep(ShellCommand(
name='create_logdir',
description='(re)create logs area',
command=['bash', '-c', 'mkdir -p ' + logdir],
haltOnFailure=1,
))
self.addStep(ShellCommand(
name='rm_old_logs',
description='clean logs area',
command=['bash', '-c', 'rm -rf ' + logdir + '/*.log'],
haltOnFailure=1,
))
self.addStep(ShellCommand(
name='make_test',
description='unit tests',
command=['make', 'test'],
haltOnFailure=1,
))
def getPlatformMinidumpPath(platform):
platform_minidump_path = {
'linux': WithProperties('%(toolsdir:-)s/breakpad/linux/minidump_stackwalk'),
'linuxqt': WithProperties('%(toolsdir:-)s/breakpad/linux/minidump_stackwalk'),
'linux32_gecko': WithProperties('%(toolsdir:-)s/breakpad/linux/minidump_stackwalk'),
'linux64': WithProperties('%(toolsdir:-)s/breakpad/linux64/minidump_stackwalk'),
'win32': WithProperties('%(toolsdir:-)s/breakpad/win32/minidump_stackwalk.exe'),
'win32_gecko': WithProperties('%(toolsdir:-)s/breakpad/win32/minidump_stackwalk.exe'),
'win64': WithProperties('%(toolsdir:-)s/breakpad/win64/minidump_stackwalk.exe'),
'macosx': WithProperties('%(toolsdir:-)s/breakpad/osx/minidump_stackwalk'),
'macosx64': WithProperties('%(toolsdir:-)s/breakpad/osx64/minidump_stackwalk'),
'macosx64_gecko': WithProperties('%(toolsdir:-)s/breakpad/osx/minidump_stackwalk'),
# Android uses OSX because the Foopies are OSX.
'linux-android': WithProperties('%(toolsdir:-)s/breakpad/osx/minidump_stackwalk'),
'android': WithProperties('%(toolsdir:-)s/breakpad/osx/minidump_stackwalk'),
'android-xul': WithProperties('%(toolsdir:-)s/breakpad/osx/minidump_stackwalk'),
}
return platform_minidump_path[platform]
class RequestSortingBuildFactory(BuildFactory):
"""Base class used for sorting build requests according to buildid.
In most cases the buildid of the request is calculated at the time when the
build is scheduled. For tests, the buildid of the sendchange corresponds
to the buildid of the build. Sorting the test requests by buildid allows us
to order them according to the order in which the builds were scheduled.
This avoids the problem where build A of revision 1 completes (and triggers
tests) after build B of revision 2. Without the explicit sorting done here,
the test requests would be sorted [r2, r1], and buildbot would choose the
latest of the set to run.
We sort according to the following criteria:
* If the request looks like a rebuild, use the request's submission time
* If the request or any of the changes contains a 'buildid' property,
use the greatest of these property values
* Otherwise use the request's submission time
"""
def newBuild(self, requests):
def sortkey(request):
# Ignore any buildids if we're rebuilding
# Catch things like "The web-page 'rebuild' ...", or self-serve
# messages, "Rebuilt by ..."
if 'rebuil' in request.reason.lower():
return int(genBuildID(request.submittedAt))
buildids = []
props = [request.properties] + [c.properties for c in request.source.changes]
for p in props:
try:
buildids.append(int(p['buildid']))
except:
pass
if buildids:
return max(buildids)
return int(genBuildID(request.submittedAt))
try:
sorted_requests = sorted(requests, key=sortkey)
return BuildFactory.newBuild(self, sorted_requests)
except:
# Something blew up!
# Return the orginal list
log.msg("Error sorting build requests")
log.err()
return BuildFactory.newBuild(self, requests)
class MozillaBuildFactory(RequestSortingBuildFactory):
ignore_dirs = [ 'info', 'rel-*']
def __init__(self, hgHost, repoPath, buildToolsRepoPath, buildSpace=0,
clobberURL=None, clobberBranch=None, clobberTime=None,
buildsBeforeReboot=None, branchName=None, baseWorkDir='build',
hashType='sha512', baseMirrorUrls=None, baseBundleUrls=None,
signingServers=None, enableSigning=True, env={},
balrog_api_root=None, balrog_credentials_file=None, **kwargs):
BuildFactory.__init__(self, **kwargs)
if hgHost.endswith('/'):
hgHost = hgHost.rstrip('/')
self.hgHost = hgHost
self.repoPath = repoPath
self.buildToolsRepoPath = buildToolsRepoPath
self.buildToolsRepo = self.getRepository(buildToolsRepoPath)
self.buildSpace = buildSpace
self.clobberURL = clobberURL
self.clobberTime = clobberTime
self.buildsBeforeReboot = buildsBeforeReboot
self.baseWorkDir = baseWorkDir
self.hashType = hashType
self.baseMirrorUrls = baseMirrorUrls
self.baseBundleUrls = baseBundleUrls
self.signingServers = signingServers
self.enableSigning = enableSigning
self.env = env.copy()
self.balrog_api_root = balrog_api_root
self.balrog_credentials_file = balrog_credentials_file
self.repository = self.getRepository(repoPath)
if branchName:
self.branchName = branchName
else:
self.branchName = self.getRepoName(self.repository)
if not clobberBranch:
self.clobberBranch = self.branchName
else:
self.clobberBranch = clobberBranch
if self.signingServers and self.enableSigning:
self.signing_command = get_signing_cmd(
self.signingServers, self.env.get('PYTHON26'))
self.env['MOZ_SIGN_CMD'] = WithProperties(self.signing_command)
self.addStep(OutputStep(
name='get_buildername',
data=WithProperties('Building on: %(slavename)s'),
))
self.addStep(OutputStep(
name='tinderboxprint_buildername',
data=WithProperties('TinderboxPrint: s: %(slavename)s'),
))
self.addStep(OutputStep(
name='tinderboxsummarymessage_buildername',
data=WithProperties('TinderboxSummaryMessage: s: %(slavename)s'),
))
self.addInitialSteps()
def addInitialSteps(self):
self.addStep(SetProperty(
name='set_basedir',
command=['bash', '-c', 'pwd'],
property='basedir',
workdir='.',
))
self.addStep(SetProperty(
name='set_hashType',
command=['echo', self.hashType],
property='hashType',
workdir='.',
))
# We need the basename of the current working dir so we can
# ignore that dir when purging builds later.
self.addStep(SetProperty(
name='set_builddir',
command=['bash', '-c', 'basename "$PWD"'],
property='builddir',
workdir='.',
))
self.addStep(ShellCommand(
name='rm_buildtools',
command=['rm', '-rf', 'tools'],
description=['clobber', 'build tools'],
workdir='.'
))
self.addStep(MercurialCloneCommand(
name='clone_buildtools',
command=['hg', 'clone', self.buildToolsRepo, 'tools'],
description=['clone', 'build tools'],
workdir='.',
retry=False
))
self.addStep(SetProperty(
name='set_toolsdir',
command=['bash', '-c', 'pwd'],
property='toolsdir',
workdir='tools',
))
if self.clobberURL is not None:
self.addStep(MozillaClobberer(
name='checking_clobber_times',
branch=self.clobberBranch,
clobber_url=self.clobberURL,
clobberer_path=WithProperties('%(builddir)s/tools/clobberer/clobberer.py'),
clobberTime=self.clobberTime
))
if self.buildSpace > 0:
command = ['python', 'tools/buildfarm/maintenance/purge_builds.py',
'-s', str(self.buildSpace)]
for i in self.ignore_dirs:
command.extend(["-n", i])
# These are the base_dirs that get passed to purge_builds.py.
# The mock dir is only present on linux slaves, but since
# not all classes that inherit from MozillaBuildFactory provide
# a platform property we can use for limiting the base_dirs, it
# is easier to include mock by default and simply have
# purge_builds.py skip the dir when it isn't present.
command.extend(["..","/mock/users/cltbld/home/cltbld/build"])
def parse_purge_builds(rc, stdout, stderr):
properties = {}
for stream in (stdout, stderr):
m = re.search('unable to free (?P<size>[.\d]+) (?P<unit>\w+) ', stream, re.M)
if m:
properties['purge_target'] = '%s%s' % (m.group('size'), m.group('unit'))
m = None
m = re.search('space only (?P<size>[.\d]+) (?P<unit>\w+)', stream, re.M)
if m:
properties['purge_actual'] = '%s%s' % (m.group('size'), m.group('unit'))
m = None
m = re.search('(?P<size>[.\d]+) (?P<unit>\w+) of space available', stream, re.M)
if m:
properties['purge_actual'] = '%s%s' % (m.group('size'), m.group('unit'))
if not properties.has_key('purge_target'):
properties['purge_target'] = '%sGB' % str(self.buildSpace)
return properties
self.addStep(SetProperty(
name='clean_old_builds',
command=command,
description=['cleaning', 'old', 'builds'],
descriptionDone=['clean', 'old', 'builds'],
haltOnFailure=True,
workdir='.',
timeout=3600, # One hour, because Windows is slow
extract_fn=parse_purge_builds,
log_eval_func=lambda c,s: regex_log_evaluator(c, s, purge_error),
env=self.env,
))
def addPeriodicRebootSteps(self):
def do_disconnect(cmd):
try:
if 'SCHEDULED REBOOT' in cmd.logs['stdio'].getText():
return True
except:
pass
return False
self.addStep(DisconnectStep(
name='maybe_rebooting',
command=['python', 'tools/buildfarm/maintenance/count_and_reboot.py',
'-f', '../reboot_count.txt',
'-n', str(self.buildsBeforeReboot),
'-z'],
description=['maybe rebooting'],
force_disconnect=do_disconnect,
warnOnFailure=False,
flunkOnFailure=False,
alwaysRun=True,
workdir='.'
))
def getRepoName(self, repo):
return repo.rstrip('/').split('/')[-1]
def getRepository(self, repoPath, hgHost=None, push=False):
assert repoPath
for prefix in ('http://', 'ssh://'):
if repoPath.startswith(prefix):
return repoPath
if repoPath.startswith('/'):
repoPath = repoPath.lstrip('/')
if not hgHost:
hgHost = self.hgHost
proto = 'ssh' if push else 'http'
return '%s://%s/%s' % (proto, hgHost, repoPath)
def getPackageFilename(self, platform, platform_variation):
if 'android-armv6' in self.complete_platform:
packageFilename = '*arm-armv6.apk'
elif 'android' in self.complete_platform:
packageFilename = '*arm.apk' #the arm.apk is to avoid
#unsigned/unaligned apks
elif 'maemo' in self.complete_platform:
packageFilename = '*.linux-*-arm.tar.*'
elif platform.startswith("linux64"):
packageFilename = '*.linux-x86_64.tar.bz2'
elif platform.startswith("linux"):
packageFilename = '*.linux-i686.tar.bz2'
elif platform.startswith("macosx"):
packageFilename = '*.dmg'
elif platform.startswith("win32"):
packageFilename = '*.win32.zip'
elif platform.startswith("win64"):
packageFilename = '*.win64-x86_64.zip'
else:
return False
return packageFilename
def parseFileSize(self, propertyName):
def getSize(rv, stdout, stderr):
stdout = stdout.strip()
return {propertyName: stdout.split()[4]}
return getSize
def parseFileHash(self, propertyName):
def getHash(rv, stdout, stderr):
stdout = stdout.strip()
return {propertyName: stdout.split(' ',2)[1]}
return getHash
def unsetFilepath(self, rv, stdout, stderr):
return {'filepath': None}
def addFilePropertiesSteps(self, filename, directory, fileType,
doStepIf=True, maxDepth=1, haltOnFailure=False):
self.addStep(FindFile(
name='find_filepath',
description=['find', 'filepath'],
doStepIf=doStepIf,
filename=filename,
directory=directory,
filetype='file',
max_depth=maxDepth,
property_name='filepath',
workdir='.',
haltOnFailure=haltOnFailure
))
self.addStep(SetProperty(
description=['set', fileType.lower(), 'filename'],
doStepIf=doStepIf,
command=['basename', WithProperties('%(filepath)s')],
property=fileType+'Filename',
workdir='.',
name='set_'+fileType.lower()+'_filename',
haltOnFailure=haltOnFailure
))
self.addStep(SetProperty(
description=['set', fileType.lower(), 'size',],
doStepIf=doStepIf,
command=['bash', '-c',
WithProperties("ls -l %(filepath)s")],
workdir='.',
name='set_'+fileType.lower()+'_size',
extract_fn = self.parseFileSize(propertyName=fileType+'Size'),
haltOnFailure=haltOnFailure
))
self.addStep(SetProperty(
description=['set', fileType.lower(), 'hash',],
doStepIf=doStepIf,
command=['bash', '-c',
WithProperties('openssl ' + 'dgst -' + self.hashType +
' %(filepath)s')],
workdir='.',
name='set_'+fileType.lower()+'_hash',
extract_fn=self.parseFileHash(propertyName=fileType+'Hash'),
haltOnFailure=haltOnFailure
))
self.addStep(SetProperty(
description=['unset', 'filepath',],
doStepIf=doStepIf,
name='unset_filepath',
command='echo "filepath:"',
workdir=directory,
extract_fn = self.unsetFilepath,
))
def makeHgtoolStep(self, name='hg_update', repo_url=None, wc=None,
mirrors=None, bundles=None, env=None,
clone_by_revision=False, rev=None, workdir='build',
use_properties=True, locks=None):
if not env:
env = self.env
if use_properties:
env = env.copy()
env['PROPERTIES_FILE'] = 'buildprops.json'
cmd = ['python', WithProperties("%(toolsdir)s/buildfarm/utils/hgtool.py")]
if clone_by_revision:
cmd.append('--clone-by-revision')
if mirrors is None and self.baseMirrorUrls:
mirrors = ["%s/%s" % (url, self.repoPath) for url in self.baseMirrorUrls]
if mirrors:
for mirror in mirrors:
cmd.extend(["--mirror", mirror])
if bundles is None and self.baseBundleUrls:
bundles = ["%s/%s.hg" % (url, self.getRepoName(self.repository)) for url in self.baseBundleUrls]
if bundles:
for bundle in bundles:
cmd.extend(["--bundle", bundle])
if not repo_url:
repo_url = self.repository
if rev:
cmd.extend(["--rev", rev])
cmd.append(repo_url)
if wc:
cmd.append(wc)
if locks is None:
locks = []
return RetryingShellCommand(
name=name,
command=cmd,
timeout=60*60,
env=env,
workdir=workdir,
haltOnFailure=True,
flunkOnFailure=True,
locks=locks,
)
def addGetTokenSteps(self):
token = "token"
nonce = "nonce"
self.addStep(ShellCommand(
command=['rm', '-f', nonce],
workdir='.',
name='rm_nonce',
description=['remove', 'old', 'nonce'],
))
self.addStep(SigningServerAuthenication(
servers=self.signingServers,
server_cert=SIGNING_SERVER_CERT,
slavedest=token,
workdir='.',
name='download_token',
))
class MercurialBuildFactory(MozillaBuildFactory):
def __init__(self, objdir, platform, configRepoPath, configSubDir,
profiledBuild, mozconfig, srcMozconfig=None,
use_mock=False, productName=None,
mock_target='mozilla-f16-x86_64', android_signing=False,
buildRevision=None, stageServer=None, stageUsername=None,
stageGroup=None, stageSshKey=None, stageBasePath=None,
stageProduct=None, post_upload_include_platform=False,
ausBaseUploadDir=None, updatePlatform=None,
downloadBaseURL=None, ausUser=None, ausSshKey=None,
ausHost=None, nightly=False, leakTest=False, leakTarget=None,
checkTest=False, valgrindCheck=False, codesighs=True,
graphServer=None, graphSelector=None, graphBranch=None,
baseName=None, uploadPackages=True, uploadSymbols=True,
createSnippet=False, createPartial=False, doCleanup=True,
packageSDK=False, packageTests=False, mozillaDir=None,
enable_ccache=False, stageLogBaseUrl=None,
triggeredSchedulers=None, triggerBuilds=False,
mozconfigBranch="production", useSharedCheckouts=False,
stagePlatform=None, testPrettyNames=False, l10nCheckTest=False,
doBuildAnalysis=False,
downloadSubdir=None,
multiLocale=False,
multiLocaleMerge=True,
compareLocalesRepoPath=None,
compareLocalesTag='RELEASE_AUTOMATION',
mozharnessRepoPath=None,
mozharnessTag='default',
multiLocaleScript=None,
multiLocaleConfig=None,
mozharnessMultiOptions=None,
mock_packages=[],
tooltool_manifest_src=None,
tooltool_bootstrap="setup.sh",
tooltool_url_list=None,
tooltool_script='/tools/tooltool.py',
enablePackaging=True,
runAliveTests=True,
enableInstaller=False,
**kwargs):
MozillaBuildFactory.__init__(self, **kwargs)
# Make sure we have a buildid and builduid
self.addStep(FunctionalStep(
name='set_buildids',
func=setBuildIDProps,
))
self.objdir = objdir
self.platform = platform
self.configRepoPath = configRepoPath
self.configSubDir = configSubDir
self.profiledBuild = profiledBuild
self.mozconfig = mozconfig
self.srcMozconfig = srcMozconfig
self.productName = productName
self.buildRevision = buildRevision
self.stageServer = stageServer
self.stageUsername = stageUsername
self.stageGroup = stageGroup
self.stageSshKey = stageSshKey
self.stageBasePath = stageBasePath
if stageBasePath and not stageProduct:
self.stageProduct = productName
else:
self.stageProduct = stageProduct
self.doBuildAnalysis = doBuildAnalysis
self.ausBaseUploadDir = ausBaseUploadDir
self.updatePlatform = updatePlatform
self.downloadBaseURL = downloadBaseURL
self.downloadSubdir = downloadSubdir
self.ausUser = ausUser
self.ausSshKey = ausSshKey
self.ausHost = ausHost
self.nightly = nightly
self.leakTest = leakTest
self.leakTarget = leakTarget
self.checkTest = checkTest
self.valgrindCheck = valgrindCheck
self.codesighs = codesighs
self.graphServer = graphServer
self.graphSelector = graphSelector
self.graphBranch = graphBranch
self.baseName = baseName
self.uploadPackages = uploadPackages
self.uploadSymbols = uploadSymbols
self.createSnippet = createSnippet
self.createPartial = createPartial
self.doCleanup = doCleanup
self.packageSDK = packageSDK
self.enablePackaging = enablePackaging
self.enableInstaller = enableInstaller
self.packageTests = packageTests
self.enable_ccache = enable_ccache
if self.enable_ccache:
self.env['CCACHE_BASEDIR'] = WithProperties('%(basedir:-)s')
self.triggeredSchedulers = triggeredSchedulers
self.triggerBuilds = triggerBuilds
self.mozconfigBranch = mozconfigBranch
self.use_mock = use_mock
self.mock_target = mock_target
self.mock_packages = mock_packages
self.android_signing = android_signing
self.post_upload_include_platform = post_upload_include_platform
self.useSharedCheckouts = useSharedCheckouts
self.testPrettyNames = testPrettyNames
self.l10nCheckTest = l10nCheckTest
self.tooltool_manifest_src = tooltool_manifest_src
self.tooltool_url_list = tooltool_url_list or []
self.tooltool_script = tooltool_script
self.tooltool_bootstrap = tooltool_bootstrap
self.runAliveTests = runAliveTests
assert len(self.tooltool_url_list) <= 1, "multiple urls not currently supported by tooltool"
if self.uploadPackages:
assert productName and stageServer and stageUsername
assert stageBasePath
if self.createSnippet:
if 'android' in platform: #happens before we trim platform
assert downloadSubdir
assert ausBaseUploadDir and updatePlatform and downloadBaseURL
assert ausUser and ausSshKey and ausHost
# To preserve existing behavior, we need to set the
# ausFullUploadDir differently for when we are create all the
# mars (complete+partial) ourselves.
if self.createPartial:
# e.g.:
# /opt/aus2/incoming/2/Firefox/mozilla-central/WINNT_x86-msvc
self.ausFullUploadDir = '%s/%s' % (self.ausBaseUploadDir,
self.updatePlatform)
else:
# this is a tad ugly because we need python interpolation
# as well as WithProperties, e.g.:
# /opt/aus2/build/0/Firefox/mozilla-central/WINNT_x86-msvc/2008010103/en-US
self.ausFullUploadDir = '%s/%s/%%(buildid)s/en-US' % \
(self.ausBaseUploadDir,
self.updatePlatform)
self.complete_platform = self.platform
# we don't need the extra cruft in 'platform' anymore
self.platform = platform.split('-')[0]
self.stagePlatform = stagePlatform
# it turns out that the cruft is useful for dealing with multiple types
# of builds that are all done using the same self.platform.
# Examples of what happens:
# platform = 'linux' sets self.platform_variation to []
# platform = 'linux-opt' sets self.platform_variation to ['opt']
# platform = 'linux-opt-rpm' sets self.platform_variation to ['opt','rpm']
platform_chunks = self.complete_platform.split('-', 1)
if len(platform_chunks) > 1:
self.platform_variation = platform_chunks[1].split('-')
else:
self.platform_variation = []
assert self.platform in getSupportedPlatforms(), "%s not in %s" % (self.platform, getSupportedPlatforms())
if self.graphServer is not None:
self.tbPrint = False
else:
self.tbPrint = True
# SeaMonkey/Thunderbird make use of mozillaDir. Firefox does not.
if mozillaDir:
self.mozillaDir = '/%s' % mozillaDir
self.mozillaObjdir = '%s%s' % (self.objdir, self.mozillaDir)
else:
self.mozillaDir = ''
self.mozillaObjdir = self.objdir
# These following variables are useful for sharing build steps (e.g.
# update generation) with subclasses that don't use object dirs (e.g.
# l10n repacks).
#
# We also concatenate the baseWorkDir at the outset to avoid having to
# do that everywhere.
self.mozillaSrcDir = '.%s' % self.mozillaDir
self.absMozillaSrcDir = '%s%s' % (self.baseWorkDir, self.mozillaDir)
self.absMozillaObjDir = '%s/%s' % (self.baseWorkDir, self.mozillaObjdir)
self.latestDir = '/pub/mozilla.org/%s' % self.stageProduct + \
'/nightly/latest-%s' % self.branchName
if self.post_upload_include_platform:
self.latestDir += '-%s' % self.stagePlatform
self.stageLogBaseUrl = stageLogBaseUrl
if self.stageLogBaseUrl:
# yes, the branchName is needed twice here so that log uploads work for all
self.logUploadDir = '%s/%s-%s/' % (self.branchName, self.branchName,
self.stagePlatform)
self.logBaseUrl = '%s/%s' % (self.stageLogBaseUrl, self.logUploadDir)
else:
self.logUploadDir = 'tinderbox-builds/%s-%s/' % (self.branchName,
self.stagePlatform)
self.logBaseUrl = 'http://%s/pub/mozilla.org/%s/%s' % \
( self.stageServer, self.stageProduct, self.logUploadDir)
# Need to override toolsdir as set by MozillaBuildFactory because
# we need Windows-style paths.
if self.platform.startswith('win'):
self.addStep(SetProperty(
command=['bash', '-c', 'pwd -W'],
property='toolsdir',
workdir='tools'
))
if self.use_mock:
self.addStep(MockInit(
target=self.mock_target,
))
# This is needed for the builds to start
self.addStep(MockCommand(
command=WithProperties("mkdir -p %(basedir)s" + "/%s" % self.baseWorkDir),
target=self.mock_target,
mock=True,
workdir='/',
))
if self.mock_packages:
self.addStep(MockInstall(
target=self.mock_target,
packages=self.mock_packages,
))
if self.enable_ccache:
self.addStep(ShellCommand(command=['ccache', '-z'],
name="clear_ccache_stats", warnOnFailure=False,
flunkOnFailure=False, haltOnFailure=False, env=self.env))
if multiLocale:
assert compareLocalesRepoPath and compareLocalesTag
assert mozharnessRepoPath and mozharnessTag
assert multiLocaleScript and multiLocaleConfig
self.compareLocalesRepoPath = compareLocalesRepoPath
self.compareLocalesTag = compareLocalesTag
self.mozharnessRepoPath = mozharnessRepoPath
self.mozharnessTag = mozharnessTag
self.multiLocaleScript = multiLocaleScript
self.multiLocaleConfig = multiLocaleConfig
self.multiLocaleMerge = multiLocaleMerge
if mozharnessMultiOptions:
self.mozharnessMultiOptions = mozharnessMultiOptions
else:
self.mozharnessMultiOptions = ['--only-pull-locale-source',
'--only-add-locales',
'--only-package-multi']
self.addMultiLocaleRepoSteps()
self.multiLocale = multiLocale
self.addBuildSteps()
if self.uploadSymbols or self.packageTests or self.leakTest:
self.addBuildSymbolsStep()
if self.uploadSymbols:
self.addUploadSymbolsStep()
if self.enablePackaging or self.uploadPackages: