14 from config import config, init_conf
17 def run_command(batch):
18 if "no-chroot" in batch.command_flags:
19 c = "%s >> %s 2>&1" % (batch.command, batch.logfile)
21 for l in f.xreadlines():
30 if "as-builder" in batch.command_flags:
32 return chroot.run(batch.command, logfile = batch.logfile, user = user)
34 def build_all(r, build_fnc):
35 status.email = r.requester_email
37 tmp = path.spool_dir + util.uuid() + "/"
40 atexit.register(util.clean_tmp, tmp)
42 log.notice("started processing %s" % r.id)
45 for batch in r.batches:
48 for dep in batch.depends_on:
53 if batch.is_command() and can_build:
54 batch.logfile = tmp + "command"
55 if config.builder in batch.builders:
56 log.notice("running %s" % batch.command)
58 batch.build_failed = run_command(batch)
59 if batch.build_failed:
60 log.notice("running %s FAILED" % batch.command)
61 notify.add_batch(batch, "FAIL")
64 log.notice("running %s OK" % batch.command)
65 notify.add_batch(batch, "OK")
66 batch.build_time = stopwatch.stop()
67 report.add_pld_builder_info(batch)
68 buildlogs.add(batch.logfile, failed = batch.build_failed)
70 log.notice("not running command, not for me.")
71 batch.build_failed = 0
72 batch.log_line("queued command %s for other builders" % batch.command)
74 buildlogs.add(batch.logfile, failed = batch.build_failed)
76 log.notice("building %s" % batch.spec)
78 batch.logfile = tmp + batch.spec + ".log"
80 batch.build_failed = build_fnc(r, batch)
81 if batch.build_failed:
82 log.notice("building %s FAILED" % batch.spec)
83 notify.add_batch(batch, "FAIL")
86 log.notice("building %s OK" % batch.spec)
87 notify.add_batch(batch, "OK")
88 batch.build_time = stopwatch.stop()
89 report.add_pld_builder_info(batch)
90 buildlogs.add(batch.logfile, failed = batch.build_failed)
92 batch.build_failed = 1
93 batch.skip_reason = "SKIPED [%s failed]" % failed_dep
96 log.notice("building %s %s" % (batch.spec, batch.skip_reason))
97 notify.add_batch(batch, "SKIP")
100 chroot.run("rm -f %s" % string.join(r.chroot_files))