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 for section in ini.sections():
31 if section.startswith("slave "):
32 if ini.has_option(section, "name") and ini.has_option(section, "password"):
33 name = ini.get(section, "name")
34 password = ini.get(section, "password")
36 if ini.has_option(section, "builds"):
37 max_builds = ini.getint(section, "builds")
38 c['slaves'].append(BuildSlave(name, password, max_builds = max_builds))
40 # 'slavePortnum' defines the TCP port to listen on for connections from slaves.
41 # This must match the value configured into the buildslaves (with their
43 c['slavePortnum'] = 9990
46 c['mergeRequests'] = True
50 home_dir = os.path.abspath(ini.get("general", "homedir"))
52 repo_url = ini.get("repo", "url")
54 rsync_bin_url = ini.get("rsync", "binary_url")
55 rsync_bin_key = ini.get("rsync", "binary_password")
60 if ini.has_option("rsync", "source_url"):
61 rsync_src_url = ini.get("rsync", "source_url")
62 rsync_src_key = ini.get("rsync", "source_password")
68 findarches = subprocess.Popen([home_dir+'/dumpinfo.pl', 'architectures'],
69 stdout = subprocess.PIPE, cwd = home_dir+'/source.git')
72 line = findarches.stdout.readline()
75 at = line.strip().split()
77 archnames.append(at[0])
83 from buildbot.changes.gitpoller import GitPoller
84 c['change_source'] = []
86 with open(home_dir+'/source.git/feeds.conf.default', 'r') as f:
88 parts = line.strip().split()
89 if parts[0] == "src-git":
91 c['change_source'].append(GitPoller(parts[2], workdir='%s/%s.git' %(os.getcwd(), parts[1]), branch='master', pollinterval=300))
96 # Configure the Schedulers, which decide how to react to incoming changes. In this
97 # case, just kick off a 'basebuild' build
99 from buildbot.schedulers.basic import SingleBranchScheduler
100 from buildbot.schedulers.forcesched import ForceScheduler
101 from buildbot.changes import filter
103 c['schedulers'].append(SingleBranchScheduler(
105 change_filter=filter.ChangeFilter(branch='master'),
107 builderNames=archnames))
109 c['schedulers'].append(ForceScheduler(
111 builderNames=archnames))
115 # The 'builders' list defines the Builders, which tell Buildbot how to perform a build:
116 # what steps, and which slaves can execute them. Note that any particular build will
117 # only take place on one slave.
119 from buildbot.process.factory import BuildFactory
120 from buildbot.steps.source import Git
121 from buildbot.steps.shell import ShellCommand
122 from buildbot.steps.shell import SetProperty
123 from buildbot.steps.transfer import FileDownload
124 from buildbot.process.properties import WithProperties
128 dlLock = locks.SlaveLock("slave_dl")
132 for slave in c['slaves']:
133 slaveNames.append(slave.slavename)
136 ts = arch[1].split('/')
138 factory = BuildFactory()
140 # find number of cores
141 factory.addStep(SetProperty(
144 description = "Finding number of CPUs",
145 command = ["nproc"]))
148 factory.addStep(FileDownload(mastersrc="cleanup.sh", slavedest="cleanup.sh", mode=0755))
150 factory.addStep(ShellCommand(
152 description = "Cleaning previous builds",
153 command = ["./cleanup.sh", WithProperties("%(slavename)s"), WithProperties("%(buildername)s"), "full"],
154 haltOnFailure = True,
157 factory.addStep(ShellCommand(
159 description = "Cleaning work area",
160 command = ["./cleanup.sh", WithProperties("%(slavename)s"), WithProperties("%(buildername)s"), "single"],
161 haltOnFailure = True,
164 factory.addStep(ShellCommand(
166 description = "Preparing SDK directory",
167 command = ["mkdir", "sdk"],
168 haltOnFailure = True))
170 factory.addStep(ShellCommand(
171 name = "downloadsdk",
172 description = "Downloading SDK archive",
173 command = ["rsync", "-va", "downloads.lede-project.org::downloads/snapshots/targets/%s/%s/[Ll][Ee][Dd][Ee]-[Ss][Dd][Kk]-*.tar.bz2" %(ts[0], ts[1]), "sdk.tar.bz2"],
174 haltOnFailure = True))
176 factory.addStep(ShellCommand(
178 description = "Unpacking SDK archive",
179 command = ["tar", "--strip-components=1", "-C", "sdk/", "-vxjf", "sdk.tar.bz2"],
180 haltOnFailure = True))
182 factory.addStep(FileDownload(mastersrc=home_dir+'/key-build', slavedest="sdk/key-build", mode=0600))
183 factory.addStep(FileDownload(mastersrc=home_dir+'/key-build.pub', slavedest="sdk/key-build.pub", mode=0600))
185 factory.addStep(ShellCommand(
187 description = "Preparing download directory",
188 command = ["sh", "-c", "mkdir -p $HOME/dl && rmdir ./sdk/dl && ln -sf $HOME/dl ./sdk/dl"]))
190 factory.addStep(ShellCommand(
192 description = "Preparing SDK configuration",
193 workdir = "build/sdk",
194 command = ["sh", "-c", "rm -f .config && make defconfig"]))
196 factory.addStep(ShellCommand(
197 name = "updatefeeds",
198 description = "Updating feeds",
199 workdir = "build/sdk",
200 command = ["./scripts/feeds", "update"]))
202 factory.addStep(ShellCommand(
203 name = "installfeeds",
204 description = "Installing feeds",
205 workdir = "build/sdk",
206 command = ["./scripts/feeds", "install", "-a"]))
208 factory.addStep(ShellCommand(
210 description = "Building packages",
211 workdir = "build/sdk",
212 command = ["make", WithProperties("-j%(nproc:~4)s"), "V=s", "IGNORE_ERRORS=n m y", "BUILD_LOG=1", "CONFIG_SIGNED_PACKAGES=y"]))
214 factory.addStep(ShellCommand(
215 name = "uploadprepare",
216 description = "Preparing package directory",
217 workdir = "build/sdk",
218 command = ["rsync", "-av", "--include", "/%s/" %(arch[0]), "--exclude", "/*", "--exclude", "/%s/*" %(arch[0]), "bin/packages/", "%s/packages/" %(rsync_bin_url)],
219 env={'RSYNC_PASSWORD': rsync_bin_key},
220 haltOnFailure = True,
224 factory.addStep(ShellCommand(
225 name = "packageupload",
226 description = "Uploading package files",
227 workdir = "build/sdk",
228 command = ["rsync", "--delete", "--delay-updates", WithProperties("--partial-dir=.~tmp~%(buildername)s"), "-avz", "bin/packages/%s/" %(arch[0]), "%s/packages/%s/" %(rsync_bin_url, arch[0])],
229 env={'RSYNC_PASSWORD': rsync_bin_key},
230 haltOnFailure = True,
234 factory.addStep(ShellCommand(
236 description = "Preparing log directory",
237 workdir = "build/sdk",
238 command = ["rsync", "-av", "--include", "/%s/" %(arch[0]), "--exclude", "/*", "--exclude", "/%s/*" %(arch[0]), "bin/packages/", "%s/faillogs/" %(rsync_bin_url)],
239 env={'RSYNC_PASSWORD': rsync_bin_key},
240 haltOnFailure = True,
244 factory.addStep(ShellCommand(
246 description = "Finding failure logs",
247 workdir = "build/sdk/logs/package/feeds",
248 command = ["sh", "-c", "sed -ne 's!^ *ERROR: package/feeds/\\([^ ]*\\) .*$!\\1!p' ../error.txt | sort -u | xargs -r find > ../../../logs.txt"],
249 haltOnFailure = False
252 factory.addStep(ShellCommand(
254 description = "Collecting failure logs",
255 workdir = "build/sdk",
256 command = ["rsync", "-av", "--files-from=logs.txt", "logs/package/feeds/", "faillogs/"],
257 haltOnFailure = False
260 factory.addStep(ShellCommand(
262 description = "Uploading failure logs",
263 workdir = "build/sdk",
264 command = ["rsync", "--delete", "--delay-updates", WithProperties("--partial-dir=.~tmp~%(buildername)s"), "-avz", "faillogs/", "%s/faillogs/%s/" %(rsync_bin_url, arch[0])],
265 env={'RSYNC_PASSWORD': rsync_bin_key},
266 haltOnFailure = False,
270 if rsync_src_url is not None:
271 factory.addStep(ShellCommand(
272 name = "sourceupload",
273 description = "Uploading source archives",
274 workdir = "build/sdk",
275 command = ["rsync", "--delay-updates", WithProperties("--partial-dir=.~tmp~%(buildername)s"), "-avz", "dl/", "%s/" %(rsync_src_url)],
276 env={'RSYNC_PASSWORD': rsync_src_key},
277 haltOnFailure = False,
281 from buildbot.config import BuilderConfig
283 c['builders'].append(BuilderConfig(name=arch[0], slavenames=slaveNames, factory=factory))
286 ####### STATUS arches
288 # 'status' is a list of Status arches. The results of each build will be
289 # pushed to these arches. buildbot/status/*.py has a variety to choose from,
290 # including web pages, email senders, and IRC bots.
294 from buildbot.status import html
295 from buildbot.status.web import authz, auth
297 if ini.has_option("status", "bind"):
298 if ini.has_option("status", "user") and ini.has_option("status", "password"):
299 authz_cfg=authz.Authz(
300 # change any of these to True to enable; see the manual for more
302 auth=auth.BasicAuth([(ini.get("status", "user"), ini.get("status", "password"))]),
303 gracefulShutdown = False,
304 forceBuild = 'auth', # use this to test your slave once it is set up
305 forceAllBuilds = 'auth',
308 stopAllBuilds = 'auth',
309 cancelPendingBuild = 'auth',
311 c['status'].append(html.WebStatus(http_port=ini.get("status", "bind"), authz=authz_cfg))
313 c['status'].append(html.WebStatus(http_port=ini.get("status", "bind")))
315 ####### PROJECT IDENTITY
317 # the 'title' string will appear at the top of this buildbot
318 # installation's html.WebStatus home page (linked to the
319 # 'titleURL') and is embedded in the title of the waterfall HTML page.
321 c['title'] = ini.get("general", "title")
322 c['titleURL'] = ini.get("general", "title_url")
324 # the 'buildbotURL' string should point to the location where the buildbot's
325 # internal web server (usually the html.WebStatus page) is visible. This
326 # typically uses the port number set in the Waterfall 'status' entry, but
327 # with an externally-visible host name which the buildbot cannot figure out
330 c['buildbotURL'] = ini.get("general", "buildbot_url")
335 # This specifies what database buildbot uses to store its state. You can leave
336 # this at its default for all but the largest installations.
337 'db_url' : "sqlite:///state.sqlite",