2 # ex: set syntax=python:
9 from buildbot import locks
11 ini = ConfigParser.ConfigParser()
12 ini.read("./config.ini")
14 # This is a sample buildmaster config file. It must be installed as
15 # 'master.cfg' in your buildmaster's base directory.
17 # This is the dictionary that the buildmaster pays attention to. We also use
18 # a shorter alias to save typing.
19 c = BuildmasterConfig = {}
23 # The 'slaves' list defines the set of recognized buildslaves. Each element is
24 # a BuildSlave object, specifying a unique slave name and password. The same
25 # slave name and password must be configured on the slave.
26 from buildbot.buildslave import BuildSlave
30 if ini.has_option("general", "port"):
31 slave_port = ini.getint("general", "port")
35 for section in ini.sections():
36 if section.startswith("slave "):
37 if ini.has_option(section, "name") and ini.has_option(section, "password"):
38 name = ini.get(section, "name")
39 password = ini.get(section, "password")
41 if ini.has_option(section, "builds"):
42 max_builds = ini.getint(section, "builds")
43 c['slaves'].append(BuildSlave(name, password, max_builds = max_builds))
45 # 'slavePortnum' defines the TCP port to listen on for connections from slaves.
46 # This must match the value configured into the buildslaves (with their
48 c['slavePortnum'] = slave_port
51 c['mergeRequests'] = True
55 home_dir = os.path.abspath(ini.get("general", "homedir"))
57 rsync_bin_url = ini.get("rsync", "binary_url")
58 rsync_bin_key = ini.get("rsync", "binary_password")
63 if ini.has_option("rsync", "source_url"):
64 rsync_src_url = ini.get("rsync", "source_url")
65 rsync_src_key = ini.get("rsync", "source_password")
68 gpg_comment = "Unattended build signature"
69 gpg_passfile = "/dev/null"
71 if ini.has_option("gpg", "keyid"):
72 gpg_keyid = ini.get("gpg", "keyid")
74 if ini.has_option("gpg", "comment"):
75 gpg_comment = ini.get("gpg", "comment")
77 if ini.has_option("gpg", "passfile"):
78 gpg_passfile = ini.get("gpg", "passfile")
85 findarches = subprocess.Popen([home_dir+'/dumpinfo.pl', 'architectures'],
86 stdout = subprocess.PIPE, cwd = home_dir+'/source.git')
89 line = findarches.stdout.readline()
92 at = line.strip().split()
94 archnames.append(at[0])
100 from buildbot.changes.gitpoller import GitPoller
101 c['change_source'] = []
103 with open(home_dir+'/source.git/feeds.conf.default', 'r') as f:
105 parts = line.strip().split()
106 if parts[0] == "src-git":
108 c['change_source'].append(GitPoller(parts[2], workdir='%s/%s.git' %(os.getcwd(), parts[1]), branch='master', pollinterval=300))
113 # Configure the Schedulers, which decide how to react to incoming changes. In this
114 # case, just kick off a 'basebuild' build
116 from buildbot.schedulers.basic import SingleBranchScheduler
117 from buildbot.schedulers.forcesched import ForceScheduler
118 from buildbot.changes import filter
120 c['schedulers'].append(SingleBranchScheduler(
122 change_filter=filter.ChangeFilter(branch='master'),
124 builderNames=archnames))
126 c['schedulers'].append(ForceScheduler(
128 builderNames=archnames))
132 # The 'builders' list defines the Builders, which tell Buildbot how to perform a build:
133 # what steps, and which slaves can execute them. Note that any particular build will
134 # only take place on one slave.
136 from buildbot.process.factory import BuildFactory
137 from buildbot.steps.source import Git
138 from buildbot.steps.shell import ShellCommand
139 from buildbot.steps.shell import SetProperty
140 from buildbot.steps.transfer import FileUpload
141 from buildbot.steps.transfer import FileDownload
142 from buildbot.steps.master import MasterShellCommand
143 from buildbot.process.properties import WithProperties
147 dlLock = locks.SlaveLock("slave_dl")
151 for slave in c['slaves']:
152 slaveNames.append(slave.slavename)
155 ts = arch[1].split('/')
157 factory = BuildFactory()
159 # find number of cores
160 factory.addStep(SetProperty(
163 description = "Finding number of CPUs",
164 command = ["nproc"]))
167 factory.addStep(FileDownload(mastersrc="cleanup.sh", slavedest="cleanup.sh", mode=0755))
169 factory.addStep(ShellCommand(
171 description = "Cleaning previous builds",
172 command = ["./cleanup.sh", WithProperties("%(slavename)s"), WithProperties("%(buildername)s"), "full"],
173 haltOnFailure = True,
176 factory.addStep(ShellCommand(
178 description = "Cleaning work area",
179 command = ["./cleanup.sh", WithProperties("%(slavename)s"), WithProperties("%(buildername)s"), "single"],
180 haltOnFailure = True,
183 factory.addStep(ShellCommand(
185 description = "Preparing SDK directory",
186 command = ["mkdir", "sdk"],
187 haltOnFailure = True))
189 factory.addStep(ShellCommand(
190 name = "downloadsdk",
191 description = "Downloading SDK archive",
192 command = ["rsync", "-va", "downloads.lede-project.org::downloads/snapshots/targets/%s/%s/lede-sdk-*.tar.xz" %(ts[0], ts[1]), "sdk.tar.xz"],
193 haltOnFailure = True))
195 factory.addStep(ShellCommand(
197 description = "Unpacking SDK archive",
198 command = ["tar", "--strip-components=1", "-C", "sdk/", "-vxJf", "sdk.tar.xz"],
199 haltOnFailure = True))
201 factory.addStep(FileDownload(mastersrc=home_dir+'/key-build', slavedest="sdk/key-build", mode=0600))
202 factory.addStep(FileDownload(mastersrc=home_dir+'/key-build.pub', slavedest="sdk/key-build.pub", mode=0600))
204 factory.addStep(ShellCommand(
206 description = "Preparing download directory",
207 command = ["sh", "-c", "mkdir -p $HOME/dl && rmdir ./sdk/dl && ln -sf $HOME/dl ./sdk/dl"]))
209 factory.addStep(ShellCommand(
211 description = "Preparing SDK configuration",
212 workdir = "build/sdk",
213 command = ["sh", "-c", "rm -f .config && make defconfig"]))
215 factory.addStep(ShellCommand(
216 name = "updatefeeds",
217 description = "Updating feeds",
218 workdir = "build/sdk",
219 command = ["./scripts/feeds", "update"]))
221 factory.addStep(ShellCommand(
222 name = "installfeeds",
223 description = "Installing feeds",
224 workdir = "build/sdk",
225 command = ["./scripts/feeds", "install", "-a"]))
227 factory.addStep(ShellCommand(
229 description = "Building packages",
230 workdir = "build/sdk",
231 command = ["make", WithProperties("-j%(nproc:~4)s"), "V=s", "IGNORE_ERRORS=n m y", "BUILD_LOG=1", "CONFIG_SIGNED_PACKAGES=y"]))
233 if gpg_keyid is not None:
234 factory.addStep(MasterShellCommand(
235 name = "signprepare",
236 description = "Preparing temporary signing directory",
237 command = ["mkdir", "-p", "%s/signing" %(home_dir)],
241 factory.addStep(ShellCommand(
243 description = "Packing files to sign",
244 workdir = "build/sdk",
245 command = "find bin/packages/%s/ -mindepth 2 -maxdepth 2 -type f -name Packages -print0 | xargs -0 tar -czf sign.tar.gz" %(arch[0]),
249 factory.addStep(FileUpload(
250 slavesrc = "sdk/sign.tar.gz",
251 masterdest = "%s/signing/%s.tar.gz" %(home_dir, arch[0]),
255 factory.addStep(MasterShellCommand(
257 description = "Signing files",
258 command = ["%s/signall.sh" %(home_dir), "%s/signing/%s.tar.gz" %(home_dir, arch[0]), gpg_keyid, gpg_passfile, gpg_comment],
262 factory.addStep(FileDownload(
263 mastersrc = "%s/signing/%s.tar.gz" %(home_dir, arch[0]),
264 slavedest = "sdk/sign.tar.gz",
268 factory.addStep(ShellCommand(
270 description = "Unpacking signed files",
271 workdir = "build/sdk",
272 command = ["tar", "-xzf", "sign.tar.gz"],
276 factory.addStep(ShellCommand(
277 name = "uploadprepare",
278 description = "Preparing package directory",
279 workdir = "build/sdk",
280 command = ["rsync", "-av", "--include", "/%s/" %(arch[0]), "--exclude", "/*", "--exclude", "/%s/*" %(arch[0]), "bin/packages/", "%s/packages/" %(rsync_bin_url)],
281 env={'RSYNC_PASSWORD': rsync_bin_key},
282 haltOnFailure = True,
286 factory.addStep(ShellCommand(
287 name = "packageupload",
288 description = "Uploading package files",
289 workdir = "build/sdk",
290 command = ["rsync", "--delete", "--checksum", "--delay-updates", "--partial-dir=.~tmp~%s" %(arch[0]), "-avz", "bin/packages/%s/" %(arch[0]), "%s/packages/%s/" %(rsync_bin_url, arch[0])],
291 env={'RSYNC_PASSWORD': rsync_bin_key},
292 haltOnFailure = True,
296 factory.addStep(ShellCommand(
298 description = "Preparing log directory",
299 workdir = "build/sdk",
300 command = ["rsync", "-av", "--include", "/%s/" %(arch[0]), "--exclude", "/*", "--exclude", "/%s/*" %(arch[0]), "bin/packages/", "%s/faillogs/" %(rsync_bin_url)],
301 env={'RSYNC_PASSWORD': rsync_bin_key},
302 haltOnFailure = True,
306 factory.addStep(ShellCommand(
308 description = "Finding failure logs",
309 workdir = "build/sdk/logs/package/feeds",
310 command = ["sh", "-c", "sed -ne 's!^ *ERROR: package/feeds/\\([^ ]*\\) .*$!\\1!p' ../error.txt | sort -u | xargs -r find > ../../../logs.txt"],
311 haltOnFailure = False
314 factory.addStep(ShellCommand(
316 description = "Collecting failure logs",
317 workdir = "build/sdk",
318 command = ["rsync", "-av", "--files-from=logs.txt", "logs/package/feeds/", "faillogs/"],
319 haltOnFailure = False
322 factory.addStep(ShellCommand(
324 description = "Uploading failure logs",
325 workdir = "build/sdk",
326 command = ["rsync", "--delete", "--delay-updates", "--partial-dir=.~tmp~%s" %(arch[0]), "-avz", "faillogs/", "%s/faillogs/%s/" %(rsync_bin_url, arch[0])],
327 env={'RSYNC_PASSWORD': rsync_bin_key},
328 haltOnFailure = False,
332 if rsync_src_url is not None:
333 factory.addStep(ShellCommand(
334 name = "sourceupload",
335 description = "Uploading source archives",
336 workdir = "build/sdk",
337 command = ["rsync", "--checksum", "--delay-updates", "--partial-dir=.~tmp~%s" %(arch[0]), "-avz", "dl/", "%s/" %(rsync_src_url)],
338 env={'RSYNC_PASSWORD': rsync_src_key},
339 haltOnFailure = False,
343 from buildbot.config import BuilderConfig
345 c['builders'].append(BuilderConfig(name=arch[0], slavenames=slaveNames, factory=factory))
348 ####### STATUS arches
350 # 'status' is a list of Status arches. The results of each build will be
351 # pushed to these arches. buildbot/status/*.py has a variety to choose from,
352 # including web pages, email senders, and IRC bots.
356 from buildbot.status import html
357 from buildbot.status.web import authz, auth
359 if ini.has_option("status", "bind"):
360 if ini.has_option("status", "user") and ini.has_option("status", "password"):
361 authz_cfg=authz.Authz(
362 # change any of these to True to enable; see the manual for more
364 auth=auth.BasicAuth([(ini.get("status", "user"), ini.get("status", "password"))]),
365 gracefulShutdown = 'auth',
366 forceBuild = 'auth', # use this to test your slave once it is set up
367 forceAllBuilds = 'auth',
370 stopAllBuilds = 'auth',
371 cancelPendingBuild = 'auth',
373 c['status'].append(html.WebStatus(http_port=ini.get("status", "bind"), authz=authz_cfg))
375 c['status'].append(html.WebStatus(http_port=ini.get("status", "bind")))
377 ####### PROJECT IDENTITY
379 # the 'title' string will appear at the top of this buildbot
380 # installation's html.WebStatus home page (linked to the
381 # 'titleURL') and is embedded in the title of the waterfall HTML page.
383 c['title'] = ini.get("general", "title")
384 c['titleURL'] = ini.get("general", "title_url")
386 # the 'buildbotURL' string should point to the location where the buildbot's
387 # internal web server (usually the html.WebStatus page) is visible. This
388 # typically uses the port number set in the Waterfall 'status' entry, but
389 # with an externally-visible host name which the buildbot cannot figure out
392 c['buildbotURL'] = ini.get("general", "buildbot_url")
397 # This specifies what database buildbot uses to store its state. You can leave
398 # this at its default for all but the largest installations.
399 'db_url' : "sqlite:///state.sqlite",