-
Notifications
You must be signed in to change notification settings - Fork 27
/
ros_deb.py
172 lines (170 loc) · 7.2 KB
/
ros_deb.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
from buildbot.config import BuilderConfig
from buildbot.process.factory import BuildFactory
from buildbot.process.properties import Interpolate
from buildbot.steps.source.git import Git
from buildbot.steps.shell import ShellCommand, SetPropertyFromCommand
from buildbot.steps.transfer import FileUpload, FileDownload
from buildbot.steps.trigger import Trigger
from buildbot.steps.master import MasterShellCommand
from buildbot.steps.slave import RemoveDirectory
from buildbot.schedulers import triggerable
from helpers import success
## @brief Debbuilds are used for building sourcedebs & binaries out of gbps and uploading to an APT repository
## @param c The Buildmasterconfig
## @param job_name Name for this job (typically the metapackage name)
## @param packages List of packages to build.
## @param url URL of the BLOOM repository.
## @param distro Ubuntu distro to build for (for instance, 'precise')
## @param arch Architecture to build for (for instance, 'amd64')
## @param rosdistro ROS distro (for instance, 'groovy')
## @param version Release version to build (for instance, '0.8.1-0')
## @param machines List of machines this can build on.
## @param othermirror Cowbuilder othermirror parameter
## @param keys List of keys that cowbuilder will need
## @param trigger_pkgs List of packages names to trigger after our build is done.
def ros_debbuild(c, job_name, packages, url, distro, arch, rosdistro, version, machines, othermirror, keys, trigger_pkgs = None):
gbp_args = ['-uc', '-us', '--git-ignore-branch', '--git-ignore-new',
'--git-verbose', '--git-dist='+distro, '--git-arch='+arch]
f = BuildFactory()
# Remove the build directory.
f.addStep(
RemoveDirectory(
name = job_name+'-clean',
dir = Interpolate('%(prop:workdir)s'),
hideStepIf = success,
)
)
# Check out the repository master branch, since releases are tagged and not branched
f.addStep(
Git(
repourl = url,
branch = 'master',
alwaysUseLatest = True, # this avoids broken builds when schedulers send wrong tag/rev
mode = 'full' # clean out old versions
)
)
# Update the cowbuilder
f.addStep(
ShellCommand(
command = ['cowbuilder-update.py', distro, arch] + keys,
hideStepIf = success
)
)
# Need to build each package in order
for package in packages:
debian_pkg = 'ros-'+rosdistro+'-'+package.replace('_','-') # debian package name (ros-groovy-foo)
branch_name = 'debian/'+debian_pkg+'_%(prop:release_version)s_'+distro # release branch from bloom
deb_name = debian_pkg+'_%(prop:release_version)s'+distro
final_name = debian_pkg+'_%(prop:release_version)s-%(prop:datestamp)s'+distro+'_'+arch+'.deb'
# Check out the proper tag. Use --force to delete changes from previous deb stamping
f.addStep(
ShellCommand(
haltOnFailure = True,
name = package+'-checkout',
command = ['git', 'checkout', Interpolate(branch_name), '--force'],
hideStepIf = success
)
)
# Build the source deb
f.addStep(
ShellCommand(
haltOnFailure = True,
name = package+'-buildsource',
command = ['git-buildpackage', '-S'] + gbp_args,
descriptionDone = ['sourcedeb', package]
)
)
# Upload sourcedeb to master (currently we are not actually syncing these with a public repo)
f.addStep(
FileUpload(
name = package+'-uploadsource',
slavesrc = Interpolate('%(prop:workdir)s/'+deb_name+'.dsc'),
masterdest = Interpolate('sourcedebs/'+deb_name+'.dsc'),
hideStepIf = success
)
)
# Stamp the changelog, in a similar fashion to the ROS buildfarm
f.addStep(
SetPropertyFromCommand(
command="date +%Y%m%d-%H%M-%z", property="datestamp",
name = package+'-getstamp',
hideStepIf = success
)
)
f.addStep(
ShellCommand(
haltOnFailure = True,
name = package+'-stampdeb',
command = ['git-dch', '-a', '--ignore-branch', '--verbose',
'-N', Interpolate('%(prop:release_version)s-%(prop:datestamp)s'+distro)],
descriptionDone = ['stamped changelog', Interpolate('%(prop:release_version)s'),
Interpolate('%(prop:datestamp)s')]
)
)
# download hooks
f.addStep(
FileDownload(
name = package+'-grab-hooks',
mastersrc = 'hooks/D05deps',
slavedest = Interpolate('%(prop:workdir)s/hooks/D05deps'),
hideStepIf = success,
mode = 0777 # make this executable for the cowbuilder
)
)
# build the binary from the git working copy
f.addStep(
ShellCommand(
haltOnFailure = True,
name = package+'-buildbinary',
command = ['git-buildpackage', '--git-pbuilder', '--git-export=WC',
Interpolate('--git-export-dir=%(prop:workdir)s')] + gbp_args,
env = {'DIST': distro,
'GIT_PBUILDER_OPTIONS': Interpolate('--hookdir %(prop:workdir)s/hooks --override-config'),
'OTHERMIRROR': othermirror },
descriptionDone = ['binarydeb', package]
)
)
# Upload binarydeb to master
f.addStep(
FileUpload(
name = package+'-uploadbinary',
slavesrc = Interpolate('%(prop:workdir)s/'+final_name),
masterdest = Interpolate('binarydebs/'+final_name),
hideStepIf = success
)
)
# Add the binarydeb using reprepro updater script on master
f.addStep(
MasterShellCommand(
name = package+'includedeb',
command = ['reprepro-include.bash', debian_pkg, Interpolate(final_name), distro, arch],
descriptionDone = ['updated in apt', package]
)
)
# Trigger if needed
if trigger_pkgs != None:
f.addStep(
Trigger(
schedulerNames = [t.replace('_','-')+'-'+rosdistro+'-'+distro+'-'+arch+'-debtrigger' for t in trigger_pkgs],
waitForFinish = False,
alwaysRun=True
)
)
# Create trigger
c['schedulers'].append(
triggerable.Triggerable(
name = job_name.replace('_','-')+'-'+rosdistro+'-'+distro+'-'+arch+'-debtrigger',
builderNames = [job_name+'_'+rosdistro+'_'+distro+'_'+arch+'_debbuild',]
)
)
# Add to builders
c['builders'].append(
BuilderConfig(
name = job_name+'_'+rosdistro+'_'+distro+'_'+arch+'_debbuild',
properties = {'release_version' : version},
slavenames = machines,
factory = f
)
)
# return name of builder created
return job_name+'_'+rosdistro+'_'+distro+'_'+arch+'_debbuild'