]> TLD Linux GIT Repositories - tld-builder.git/blobdiff - TLD_Builder/srpm_builder.py
- more python3 fixes, dropped python2 support
[tld-builder.git] / TLD_Builder / srpm_builder.py
index 6476b043990b7bf3eeb96efd782b32fea3cb73ef..510b1f7e58bf2702afc98d3e3d91255f6e918a01 100644 (file)
@@ -4,7 +4,6 @@ import email
 import string
 import time
 import os
-import StringIO
 import sys
 import re
 import shutil
@@ -24,6 +23,7 @@ import notify
 import status
 import build
 import report
+#import messagebus
 
 from lock import lock
 from bqueue import B_Queue
@@ -32,13 +32,13 @@ 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)
         else:
             return pri_diff
-    q.requests.sort(mycmp)
+    q.requests.sort(key=util.cmp_to_key(mycmp))
     ret = q.requests[0]
     q.requests = q.requests[1:]
     return ret
@@ -51,7 +51,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 +71,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 +79,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,16 +96,13 @@ 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\'"
-    if ("test-build" in r.flags):
-        tag_test=""
-    else:
-        tag_test=" -Tp %s -tt" % (config.tag_prefixes[0],)
-    cmd = ("cd rpm/packages; nice -n %s ./builder %s -bs %s -r %s %s %s %s %s 2>&1" %
+    cmd = ("cd rpm/packages; nice -n %s ./builder %s -bs %s -r %s %s %s %s 2>&1" %
              (config.nice, builder_opts, b.bconds_string(), b.branch,
-              tag_test, b.kernel_string(), b.defines_string(), b.spec))
+              b.kernel_string(), b.defines_string(), b.spec))
     util.append_to(b.logfile, "request from: %s" % r.requester)
     util.append_to(b.logfile, "started at: %s" % time.asctime())
     util.append_to(b.logfile, "building SRPM using: %s\n" % cmd)
@@ -124,10 +121,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:
-        for pref in config.tag_prefixes:
-            util.append_to(b.logfile, "Tagging with prefix: %s" % pref)
-           res = chroot.run("cd rpm/packages; ./builder -bs %s -r %s -Tp %s -Tv --pkgrev %s %s" % \
-                        (b.bconds_string(), b.branch, pref, 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)
 
@@ -140,11 +136,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)