X-Git-Url: https://git.tld-linux.org/?a=blobdiff_plain;f=TLD_Builder%2Fsrpm_builder.py;h=9e45e55e30614d8a35d190a87c3a3dfda27cc875;hb=98531ab4a0e4e065d3b11b051b3e4bd7653c6ac0;hp=c4c48afa9edccb900e129f0fae30a106f1eda4ae;hpb=d669326f72cf23beb12b0ef087bd002442708236;p=tld-builder.git diff --git a/TLD_Builder/srpm_builder.py b/TLD_Builder/srpm_builder.py index c4c48af..9e45e55 100644 --- a/TLD_Builder/srpm_builder.py +++ b/TLD_Builder/srpm_builder.py @@ -4,8 +4,11 @@ import email import string import time import os -import StringIO import sys +if sys.version_info[0] == 2: + import StringIO +else: + from io import StringIO import re import shutil import atexit @@ -24,6 +27,7 @@ import notify import status import build import report +#import messagebus from lock import lock from bqueue import B_Queue @@ -32,7 +36,7 @@ from config import config, init_conf def pick_request(q): def mycmp(r1, r2): if r1.kind != 'group' or r2.kind != 'group': - raise Exception, "non-group requests" + raise Exception("non-group requests") pri_diff = cmp(r1.priority, r2.priority) if pri_diff == 0: return cmp(r1.time, r2.time) @@ -51,7 +55,7 @@ def store_binary_request(r): return r.batches = new_b # store new queue and max_req_no for binary builders - num = int(string.strip(open(path.max_req_no_file, "r").read())) + 1 + num = int(open(path.max_req_no_file, "r").read().strip()) + 1 r.no = num q = B_Queue(path.req_queue_file) @@ -71,7 +75,7 @@ def store_binary_request(r): cnt_f.flush() os.fsync(cnt_f.fileno()) cnt_f.close() - os.chmod(tmpfname, 0644) + os.chmod(tmpfname, 0o0644) os.rename(tmpfname, path.max_req_no_file) def transfer_file(r, b): @@ -79,7 +83,7 @@ def transfer_file(r, b): f = b.src_rpm_file # export files from chroot chroot.cp(f, outfile = local, rm = True) - os.chmod(local, 0644) + os.chmod(local, 0o0644) ftp.add(local) if config.gen_upinfo and 'test-build' not in r.flags: @@ -96,6 +100,7 @@ def build_srpm(r, b): return "FAIL" status.push("building %s" % b.spec) +# messagebus.notify(topic="build_srpm.start", spec=b.spec, flags=r.flags, batch=b, request=r) b.src_rpm = "" builder_opts = "-nu -nm --nodeps --http --define \'_tld_builder 1\'" @@ -120,9 +125,9 @@ def build_srpm(r, b): util.append_to(b.logfile, "error: No files produced.") res = "FAIL" if res == 0 and not "test-build" in r.flags: - util.append_to(b.logfile, "Writing pkgrev") - res = chroot.run("cd rpm/packages; ./builder -bs %s -r %s --pkgrev %s %s" % \ - (b.bconds_string(), b.branch, b.defines_string(), b.spec), logfile = b.logfile) + util.append_to(b.logfile, "Writing package revision") + res = chroot.run("cd rpm/packages; ./builder -bs %s -r %s --pkgrev %s %s" % \ + (b.bconds_string(), b.branch, b.defines_string(), b.spec), logfile = b.logfile) if res == 0: transfer_file(r, b) @@ -135,11 +140,13 @@ def build_srpm(r, b): if res: res = "FAIL" + +# messagebus.notify(topic="build_srpm.finish", spec=b.spec) return res def handle_request(r): os.mkdir(path.srpms_dir + '/' + r.id) - os.chmod(path.srpms_dir + '/' + r.id, 0755) + os.chmod(path.srpms_dir + '/' + r.id, 0o0755) ftp.init(r) buildlogs.init(r) build.build_all(r, build_srpm)