1 # vi: encoding=utf-8 ts=8 sts=4 sw=4 et
16 from config import config, init_conf
20 def run_command(batch):
21 # we want to keep "skip" in queue.html
22 command = batch.command
24 # rewrite special "skip:BUILD_ID into touch
25 if command[:5] == "skip:":
26 c = "set -x; echo SKIPME; echo SKIPME >&2;"
27 for id in command[5:].split(','):
28 if os.path.isdir(path.srpms_dir + '/' + id):
29 c = c + "echo skip:%s;\n" % (id)
30 c = c + "touch %s/%s;\n" % (path.srpms_dir, id)
32 c = c + "echo %s is not valid build-id;\n" % (id)
35 if "no-chroot" in batch.command_flags:
36 c = "%s >> %s 2>&1" % (command, batch.logfile)
38 for l in f.xreadlines():
47 if "as-builder" in batch.command_flags:
49 return chroot.run(command, logfile = batch.logfile, user = user)
51 def build_all(r, build_fnc):
52 status.email = r.requester_email
54 tmp = path.build_dir + '/' + util.uuid() + "/"
57 atexit.register(util.clean_tmp, tmp)
59 log.notice("started processing %s" % r.id)
62 for batch in r.batches:
65 for dep in batch.depends_on:
70 if batch.is_command() and can_build:
71 batch.logfile = tmp + "command"
72 if config.builder in batch.builders:
73 log.notice("running %s" % batch.command)
75 batch.build_failed = run_command(batch)
76 if batch.build_failed:
77 log.notice("running %s FAILED" % batch.command)
78 notify.add_batch(batch, "FAIL")
81 log.notice("running %s OK" % batch.command)
82 notify.add_batch(batch, "OK")
83 batch.build_time = stopwatch.stop()
84 report.add_pld_builder_info(batch)
85 buildlogs.add(batch.logfile, failed = batch.build_failed, id=r.id)
87 log.notice("not running command, not for me.")
88 batch.build_failed = 0
89 batch.log_line("queued command %s for other builders" % batch.command)
91 buildlogs.add(batch.logfile, failed = batch.build_failed, id=r.id)
93 log.notice("building %s" % batch.spec)
95 batch.logfile = tmp + batch.spec + ".log"
97 batch.requester=r.requester
98 batch.requester_email=r.requester_email
99 batch.build_failed = build_fnc(r, batch)
100 if batch.build_failed:
101 log.notice("building %s FAILED (%s)" % (batch.spec, batch.build_failed))
102 notify.add_batch(batch, batch.build_failed)
105 log.notice("building %s OK" % (batch.spec))
106 notify.add_batch(batch, "OK")
107 batch.build_time = stopwatch.stop()
108 report.add_pld_builder_info(batch)
109 buildlogs.add(batch.logfile, failed = batch.build_failed, id=r.id)
111 batch.build_failed = 1
112 batch.skip_reason = "SKIPED [%s failed]" % failed_dep
114 batch.build_time = ""
115 log.notice("building %s %s" % (batch.spec, batch.skip_reason))
116 notify.add_batch(batch, "SKIP")
119 chroot.run("rm -f %s" % string.join(r.chroot_files))