1 # vi: encoding=utf-8 ts=8 sts=4 sw=4 et
16 from config import config, init_conf
19 def run_command(batch):
20 if "no-chroot" in batch.command_flags:
21 c = "%s >> %s 2>&1" % (batch.command, batch.logfile)
23 for l in f.xreadlines():
32 if "as-builder" in batch.command_flags:
34 return chroot.run(batch.command, logfile = batch.logfile, user = user)
36 def build_all(r, build_fnc):
37 status.email = r.requester_email
39 tmp = path.build_dir + util.uuid() + "/"
42 atexit.register(util.clean_tmp, tmp)
44 log.notice("started processing %s" % r.id)
47 for batch in r.batches:
50 for dep in batch.depends_on:
55 if batch.is_command() and can_build:
56 batch.logfile = tmp + "command"
57 if config.builder in batch.builders:
58 log.notice("running %s" % batch.command)
60 batch.build_failed = run_command(batch)
61 if batch.build_failed:
62 log.notice("running %s FAILED" % batch.command)
63 notify.add_batch(batch, "FAIL")
66 log.notice("running %s OK" % batch.command)
67 notify.add_batch(batch, "OK")
68 batch.build_time = stopwatch.stop()
69 report.add_pld_builder_info(batch)
70 buildlogs.add(batch.logfile, failed = batch.build_failed, id=r.id)
72 log.notice("not running command, not for me.")
73 batch.build_failed = 0
74 batch.log_line("queued command %s for other builders" % batch.command)
76 buildlogs.add(batch.logfile, failed = batch.build_failed, id=r.id)
78 log.notice("building %s" % batch.spec)
80 batch.logfile = tmp + batch.spec + ".log"
82 batch.requester=r.requester
83 batch.requester_email=r.requester_email
84 batch.build_failed = build_fnc(r, batch)
85 if batch.build_failed:
86 log.notice("building %s FAILED (%s)" % (batch.spec, batch.build_failed))
87 notify.add_batch(batch, batch.build_failed)
90 log.notice("building %s OK" % (batch.spec))
91 notify.add_batch(batch, "OK")
92 batch.build_time = stopwatch.stop()
93 report.add_pld_builder_info(batch)
94 buildlogs.add(batch.logfile, failed = batch.build_failed, id=r.id)
96 batch.build_failed = 1
97 batch.skip_reason = "SKIPED [%s failed]" % failed_dep
100 log.notice("building %s %s" % (batch.spec, batch.skip_reason))
101 notify.add_batch(batch, "SKIP")
104 chroot.run("rm -f %s" % string.join(r.chroot_files))