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:":
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/skipme;\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 # TODO: the append here by shell hack should be solved in python
37 c = "(%s) >> %s 2>&1" % (command, batch.logfile)
48 if "as-builder" in batch.command_flags:
50 return chroot.run(command, logfile = batch.logfile, user = user)
52 def build_all(r, build_fnc):
53 status.email = r.requester_email
55 tmp = path.build_dir + '/' + util.uuid() + "/"
58 atexit.register(util.clean_tmp, tmp)
60 log.notice("started processing %s" % r.id)
63 for batch in r.batches:
66 for dep in batch.depends_on:
71 if batch.is_command() and can_build:
72 batch.logfile = tmp + "command"
73 if config.builder in batch.builders:
74 log.notice("running %s" % batch.command)
76 batch.build_failed = run_command(batch)
77 if batch.build_failed:
78 log.notice("running %s FAILED" % batch.command)
79 notify.add_batch(batch, "FAIL")
82 log.notice("running %s OK" % batch.command)
83 notify.add_batch(batch, "OK")
84 batch.build_time = stopwatch.stop()
85 report.add_tld_builder_info(batch)
86 buildlogs.add(batch.logfile, failed = batch.build_failed, id=r.id)
88 log.notice("not running command, not for me.")
89 batch.build_failed = 0
90 batch.log_line("queued command %s for other builders" % batch.command)
92 buildlogs.add(batch.logfile, failed = batch.build_failed, id=r.id)
94 log.notice("building %s" % batch.spec)
96 batch.logfile = tmp + batch.spec + ".log"
98 batch.requester=r.requester
99 batch.requester_email=r.requester_email
100 batch.build_failed = build_fnc(r, batch)
101 if batch.build_failed:
102 log.notice("building %s FAILED (%s)" % (batch.spec, batch.build_failed))
103 notify.add_batch(batch, batch.build_failed)
106 log.notice("building %s OK" % (batch.spec))
107 notify.add_batch(batch, "OK")
108 batch.build_time = stopwatch.stop()
109 report.add_tld_builder_info(batch)
110 buildlogs.add(batch.logfile, failed = batch.build_failed, id=r.id)
112 batch.build_failed = 1
113 batch.skip_reason = "SKIPED [%s failed]" % failed_dep
115 batch.build_time = ""
116 log.notice("building %s %s" % (batch.spec, batch.skip_reason))
117 notify.add_batch(batch, "SKIP")
120 chroot.run("rm -f %s" % string.join(r.chroot_files))