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")
69 rsync_sdk_pat = "lede-sdk-*.tar.xz"
71 if ini.has_option("rsync", "sdk_url"):
72 rsync_sdk_url = ini.get("rsync", "sdk_url")
73 rsync_sdk_key = ini.get("rsync", "sdk_password")
75 if ini.has_option("rsync", "sdk_pattern"):
76 rsync_sdk_pat = ini.get("rsync", "sdk_pattern")
79 gpg_comment = "Unattended build signature"
80 gpg_passfile = "/dev/null"
82 if ini.has_option("gpg", "keyid"):
83 gpg_keyid = ini.get("gpg", "keyid")
85 if ini.has_option("gpg", "comment"):
86 gpg_comment = ini.get("gpg", "comment")
88 if ini.has_option("gpg", "passfile"):
89 gpg_passfile = ini.get("gpg", "passfile")
96 findarches = subprocess.Popen([home_dir+'/dumpinfo.pl', 'architectures'],
97 stdout = subprocess.PIPE, cwd = home_dir+'/source.git')
100 line = findarches.stdout.readline()
103 at = line.strip().split()
105 archnames.append(at[0])
111 from buildbot.changes.gitpoller import GitPoller
112 c['change_source'] = []
114 with open(home_dir+'/source.git/feeds.conf.default', 'r') as f:
116 parts = line.strip().split()
117 if parts[0] == "src-git":
119 c['change_source'].append(GitPoller(parts[2], workdir='%s/%s.git' %(os.getcwd(), parts[1]), branch='master', pollinterval=300))
124 # Configure the Schedulers, which decide how to react to incoming changes. In this
125 # case, just kick off a 'basebuild' build
127 from buildbot.schedulers.basic import SingleBranchScheduler
128 from buildbot.schedulers.forcesched import ForceScheduler
129 from buildbot.changes import filter
131 c['schedulers'].append(SingleBranchScheduler(
133 change_filter=filter.ChangeFilter(branch='master'),
135 builderNames=archnames))
137 c['schedulers'].append(ForceScheduler(
139 builderNames=archnames))
143 # The 'builders' list defines the Builders, which tell Buildbot how to perform a build:
144 # what steps, and which slaves can execute them. Note that any particular build will
145 # only take place on one slave.
147 from buildbot.process.factory import BuildFactory
148 from buildbot.steps.source import Git
149 from buildbot.steps.shell import ShellCommand
150 from buildbot.steps.shell import SetProperty
151 from buildbot.steps.transfer import FileUpload
152 from buildbot.steps.transfer import FileDownload
153 from buildbot.steps.master import MasterShellCommand
154 from buildbot.process.properties import WithProperties
158 dlLock = locks.SlaveLock("slave_dl")
162 for slave in c['slaves']:
163 slaveNames.append(slave.slavename)
166 ts = arch[1].split('/')
168 factory = BuildFactory()
170 # find number of cores
171 factory.addStep(SetProperty(
174 description = "Finding number of CPUs",
175 command = ["nproc"]))
178 factory.addStep(FileDownload(mastersrc="cleanup.sh", slavedest="cleanup.sh", mode=0755))
180 factory.addStep(ShellCommand(
182 description = "Cleaning previous builds",
183 command = ["./cleanup.sh", WithProperties("%(slavename)s"), WithProperties("%(buildername)s"), "full"],
184 haltOnFailure = True,
187 factory.addStep(ShellCommand(
189 description = "Cleaning work area",
190 command = ["./cleanup.sh", WithProperties("%(slavename)s"), WithProperties("%(buildername)s"), "single"],
191 haltOnFailure = True,
194 factory.addStep(ShellCommand(
196 description = "Preparing SDK directory",
197 command = ["mkdir", "sdk"],
198 haltOnFailure = True))
200 factory.addStep(ShellCommand(
201 name = "downloadsdk",
202 description = "Downloading SDK archive",
203 command = ["rsync", "-va", "%s/%s/%s/%s" %(rsync_sdk_url, ts[0], ts[1], rsync_sdk_pat), "sdk.archive"],
204 env={'RSYNC_PASSWORD': rsync_sdk_key},
205 haltOnFailure = True,
208 factory.addStep(ShellCommand(
210 description = "Unpacking SDK archive",
211 command = ["tar", "--strip-components=1", "-C", "sdk/", "-vxf", "sdk.archive"],
212 haltOnFailure = True))
214 factory.addStep(FileDownload(mastersrc=home_dir+'/key-build', slavedest="sdk/key-build", mode=0600))
215 factory.addStep(FileDownload(mastersrc=home_dir+'/key-build.pub', slavedest="sdk/key-build.pub", mode=0600))
217 factory.addStep(ShellCommand(
219 description = "Preparing download directory",
220 command = ["sh", "-c", "mkdir -p $HOME/dl && rmdir ./sdk/dl && ln -sf $HOME/dl ./sdk/dl"]))
222 factory.addStep(ShellCommand(
224 description = "Preparing SDK configuration",
225 workdir = "build/sdk",
226 command = ["sh", "-c", "rm -f .config && make defconfig"]))
228 factory.addStep(ShellCommand(
229 name = "updatefeeds",
230 description = "Updating feeds",
231 workdir = "build/sdk",
232 command = ["./scripts/feeds", "update"]))
234 factory.addStep(ShellCommand(
235 name = "installfeeds",
236 description = "Installing feeds",
237 workdir = "build/sdk",
238 command = ["./scripts/feeds", "install", "-a"]))
240 factory.addStep(ShellCommand(
242 description = "Building packages",
243 workdir = "build/sdk",
244 command = ["make", WithProperties("-j%(nproc:~4)s"), "V=s", "IGNORE_ERRORS=n m y", "BUILD_LOG=1", "CONFIG_SIGNED_PACKAGES=y"]))
246 if gpg_keyid is not None:
247 factory.addStep(MasterShellCommand(
248 name = "signprepare",
249 description = "Preparing temporary signing directory",
250 command = ["mkdir", "-p", "%s/signing" %(home_dir)],
254 factory.addStep(ShellCommand(
256 description = "Packing files to sign",
257 workdir = "build/sdk",
258 command = "find bin/packages/%s/ -mindepth 2 -maxdepth 2 -type f -name Packages -print0 | xargs -0 tar -czf sign.tar.gz" %(arch[0]),
262 factory.addStep(FileUpload(
263 slavesrc = "sdk/sign.tar.gz",
264 masterdest = "%s/signing/%s.tar.gz" %(home_dir, arch[0]),
268 factory.addStep(MasterShellCommand(
270 description = "Signing files",
271 command = ["%s/signall.sh" %(home_dir), "%s/signing/%s.tar.gz" %(home_dir, arch[0]), gpg_keyid, gpg_passfile, gpg_comment],
275 factory.addStep(FileDownload(
276 mastersrc = "%s/signing/%s.tar.gz" %(home_dir, arch[0]),
277 slavedest = "sdk/sign.tar.gz",
281 factory.addStep(ShellCommand(
283 description = "Unpacking signed files",
284 workdir = "build/sdk",
285 command = ["tar", "-xzf", "sign.tar.gz"],
289 factory.addStep(ShellCommand(
290 name = "uploadprepare",
291 description = "Preparing package directory",
292 workdir = "build/sdk",
293 command = ["rsync", "-av", "--include", "/%s/" %(arch[0]), "--exclude", "/*", "--exclude", "/%s/*" %(arch[0]), "bin/packages/", "%s/packages/" %(rsync_bin_url)],
294 env={'RSYNC_PASSWORD': rsync_bin_key},
295 haltOnFailure = True,
299 factory.addStep(ShellCommand(
300 name = "packageupload",
301 description = "Uploading package files",
302 workdir = "build/sdk",
303 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])],
304 env={'RSYNC_PASSWORD': rsync_bin_key},
305 haltOnFailure = True,
309 factory.addStep(ShellCommand(
311 description = "Preparing log directory",
312 workdir = "build/sdk",
313 command = ["rsync", "-av", "--include", "/%s/" %(arch[0]), "--exclude", "/*", "--exclude", "/%s/*" %(arch[0]), "bin/packages/", "%s/faillogs/" %(rsync_bin_url)],
314 env={'RSYNC_PASSWORD': rsync_bin_key},
315 haltOnFailure = True,
319 factory.addStep(ShellCommand(
321 description = "Finding failure logs",
322 workdir = "build/sdk/logs/package/feeds",
323 command = ["sh", "-c", "sed -ne 's!^ *ERROR: package/feeds/\\([^ ]*\\) .*$!\\1!p' ../error.txt | sort -u | xargs -r find > ../../../logs.txt"],
324 haltOnFailure = False
327 factory.addStep(ShellCommand(
329 description = "Collecting failure logs",
330 workdir = "build/sdk",
331 command = ["rsync", "-av", "--files-from=logs.txt", "logs/package/feeds/", "faillogs/"],
332 haltOnFailure = False
335 factory.addStep(ShellCommand(
337 description = "Uploading failure logs",
338 workdir = "build/sdk",
339 command = ["rsync", "--delete", "--delay-updates", "--partial-dir=.~tmp~%s" %(arch[0]), "-avz", "faillogs/", "%s/faillogs/%s/" %(rsync_bin_url, arch[0])],
340 env={'RSYNC_PASSWORD': rsync_bin_key},
341 haltOnFailure = False,
345 if rsync_src_url is not None:
346 factory.addStep(ShellCommand(
347 name = "sourceupload",
348 description = "Uploading source archives",
349 workdir = "build/sdk",
350 command = ["rsync", "--checksum", "--delay-updates", "--partial-dir=.~tmp~%s" %(arch[0]), "-avz", "dl/", "%s/" %(rsync_src_url)],
351 env={'RSYNC_PASSWORD': rsync_src_key},
352 haltOnFailure = False,
356 from buildbot.config import BuilderConfig
358 c['builders'].append(BuilderConfig(name=arch[0], slavenames=slaveNames, factory=factory))
361 ####### STATUS arches
363 # 'status' is a list of Status arches. The results of each build will be
364 # pushed to these arches. buildbot/status/*.py has a variety to choose from,
365 # including web pages, email senders, and IRC bots.
369 from buildbot.status import html
370 from buildbot.status.web import authz, auth
372 if ini.has_option("status", "bind"):
373 if ini.has_option("status", "user") and ini.has_option("status", "password"):
374 authz_cfg=authz.Authz(
375 # change any of these to True to enable; see the manual for more
377 auth=auth.BasicAuth([(ini.get("status", "user"), ini.get("status", "password"))]),
378 gracefulShutdown = 'auth',
379 forceBuild = 'auth', # use this to test your slave once it is set up
380 forceAllBuilds = 'auth',
383 stopAllBuilds = 'auth',
384 cancelPendingBuild = 'auth',
386 c['status'].append(html.WebStatus(http_port=ini.get("status", "bind"), authz=authz_cfg))
388 c['status'].append(html.WebStatus(http_port=ini.get("status", "bind")))
390 ####### PROJECT IDENTITY
392 # the 'title' string will appear at the top of this buildbot
393 # installation's html.WebStatus home page (linked to the
394 # 'titleURL') and is embedded in the title of the waterfall HTML page.
396 c['title'] = ini.get("general", "title")
397 c['titleURL'] = ini.get("general", "title_url")
399 # the 'buildbotURL' string should point to the location where the buildbot's
400 # internal web server (usually the html.WebStatus page) is visible. This
401 # typically uses the port number set in the Waterfall 'status' entry, but
402 # with an externally-visible host name which the buildbot cannot figure out
405 c['buildbotURL'] = ini.get("general", "buildbot_url")
410 # This specifies what database buildbot uses to store its state. You can leave
411 # this at its default for all but the largest installations.
412 'db_url' : "sqlite:///state.sqlite",