]> git.pld-linux.org Git - projects/pld-builder.new.git/commitdiff
- src builder is starting to work
authorMichal Moskal <michal@moskal.me>
Tue, 10 Jun 2003 17:32:51 +0000 (17:32 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    PLD_Builder/acl.py -> 1.5
    PLD_Builder/bqueue.py -> 1.2
    PLD_Builder/buildlogs.py -> 1.2
    PLD_Builder/chroot.py -> 1.4
    PLD_Builder/mailer.py -> 1.2
    PLD_Builder/request_handler.py -> 1.6
    PLD_Builder/srpm_builder.py -> 1.4
    admin/install-chroot.sh -> 1.2

PLD_Builder/acl.py
PLD_Builder/bqueue.py
PLD_Builder/buildlogs.py
PLD_Builder/chroot.py
PLD_Builder/mailer.py
PLD_Builder/request_handler.py
PLD_Builder/srpm_builder.py
admin/install-chroot.sh

index 9913e5c2d667f4c2e68456521250bc30dc732a30..52235668aa0683ce7e7858122df96947590ccf78 100644 (file)
@@ -63,10 +63,13 @@ class ACL_Conf:
         self.users[e] = user
       self.users[login] = user
   
-  def user(self, ems):
+  def user_by_email(self, ems):
     for e in ems:
       if self.users.has_key(e):
         return self.users[e]
     return None
 
+  def user(self, l):
+    return self.users[l]
+
 acl = ACL_Conf()
index 740f2bbe602e1ed3b4375bbbf1641418bd9065a0..f9d1b17dd3a6512d7003fe815774f04a53cb4a66 100644 (file)
@@ -71,9 +71,9 @@ class B_Queue:
     sio = gpg.sign(sio)
     if os.access(name, os.F_OK): os.unlink(name)
     if re.search(r"\.gz$", name):
-      f = gzip.open(self.name, "w", 6)
+      f = gzip.open(name, "w", 6)
     else:
-      f = open(self.name, "w")
+      f = open(name, "w")
     f.write(sio.read())
     f.close()
 
index 35b6c2642eb8ab81bfa055c7a393e5347fd4d936..eec456fa91478073afe93b7d024b46afd43f01b9 100644 (file)
@@ -1,10 +1,10 @@
 
-def add(logfile, failed)
+def add(logfile, failed):
   "Add new buildlog with specified status."
   # FIXME
   pass
 
-def flush()
+def flush():
   "Send buildlogs to server."
   # FIXME
   pass
index c8e13c6458a4aa0302f6730e1c698cbf48b3db99..0be6188c04441f4cc452df78dea2ac8d8547c43f 100644 (file)
@@ -11,11 +11,11 @@ def command(cmd, user = "builder"):
 def command_sh(cmd):
   return "sudo chroot %s /bin/sh -c \"export LC_ALL=C; %s\"" % (config.chroot, quote(cmd))
 
-def popen(cmd, user = None):
+def popen(cmd, user = "builder"):
   f = os.popen(command(cmd, user))
   return f
   
-def run(cmd, user = None, logfile = None)
+def run(cmd, user = "builder", logfile = None):
   c = command(cmd, user)
   if logfile != None:
     c = "%s >> %s 2>&1" % (c, logfile)
@@ -25,5 +25,5 @@ def run(cmd, user = None, logfile = None)
   r = f.close()
   if r == None:
     return 0
-  else
+  else:
     return r
index a348fe6a980e471dfdb6ca09116f227b4d66213a..dee0049a1086c0f44a7b2a0df0797855eae7467e 100644 (file)
@@ -41,7 +41,7 @@ class Message:
       f = open(log)
       line_cnt = 0
       for l in f.xreadlines():
-        line_cnt++
+        line_cnt += 1
       f.seek(0)
       line = 0
       for l in f.xreadlines():
@@ -49,7 +49,7 @@ class Message:
           self.body.write(l)
         if line == line_cnt - 100:
           self.body.write("\n\n[...]\n\n")
-        line++
+        line += 1
     else:
       sendfile(open(log), self.body)
 
index e549a4f6d6e98a6ecb54a6c612ceef17ac08c917..1bb76a14f6ba333ad67a87e504f825fb6f76a251 100644 (file)
@@ -74,7 +74,7 @@ def handle_request(f):
   sio.write(f.read())
   sio.seek(0)
   (em, body) = gpg.verify_sig(sio)
-  user = acl.user(em)
+  user = acl.user_by_email(em)
   if user == None:
     # FIXME: security email here
     log.alert("invalid signature, or not in acl %s" % em)
index 3d686c2a9c0a6a6b03bc00b6912f66fb48a90ce6..afab1f877fa06e4b741fed044a06fc27f95941d4 100644 (file)
@@ -2,8 +2,10 @@ import email
 import string
 import time
 import os
+import os.path
 import StringIO
 import sys
+import re
 
 import gpg
 import request
@@ -13,8 +15,8 @@ from acl import acl
 from lock import lock
 from bqueue import B_Queue
 from config import config, init_conf
-
 import chroot
+import buildlogs
 
 def pick_request(q):
   def mycmp(r1, r2):
@@ -25,9 +27,9 @@ def pick_request(q):
       return cmp(r1.time, r2.time)
     else:
       return pri_diff
-  q.batches.sort(mycmp)
-  ret = q.batches[0]
-  q.batches = q.batches[1:]
+  q.requests.sort(mycmp)
+  ret = q.requests[0]
+  q.requests = q.requests[1:]
   return ret
 
 def collect_files(log):
@@ -40,7 +42,7 @@ def collect_files(log):
       files.append(m.group(1))
   return files
 
-def append_to(log, msg)
+def append_to(log, msg):
   f = open(log, "a")
   f.write("%s\n" % msg)
   f.close()
@@ -54,7 +56,7 @@ def handle_request(r):
     b.src_rpm = ""
     builder_opts = "-nu --clean --nodeps"
     cmd = "cd rpm/SPECS; ./builder %s -bs %s -r %s %s 2>&1" % \
-                 (build_opts, b.bconds_string(), b.branch, b.spec)
+                 (builder_opts, b.bconds_string(), b.branch, b.spec)
     spec_log = tmp + b.spec + ".log"
     append_to(spec_log, "Building SRPM using: %s\n" % cmd)
     res = chroot.run(cmd, logfile = spec_log)
@@ -63,7 +65,9 @@ def handle_request(r):
       if len(files) > 1:
         append_to(spec_log, "error: More then one file produced: %s" % files)
         res = 1
-      b.src_rpm = files[len(files) - 1]
+      last = files[len(files) - 1]
+      b.src_rpm_file = last
+      b.src_rpm = os.path.basename(last)
       all_files.extend(files)
     else:
       append_to(spec_log, "error: No files produced.")
@@ -71,8 +75,8 @@ def handle_request(r):
     buildlogs.add(logfile = spec_log, failed = res)
     return res
 
-  tmp = spool_dir + r.id + "/"
-  mkdir(tmp)
+  tmp = path.spool_dir + r.id + "/"
+  os.mkdir(tmp)
   user = acl.user(r.requester)
   log.notice("started processing %s" % r.id)
   all_files = []
@@ -83,22 +87,25 @@ def handle_request(r):
       log.notice("building %s failed" % batch.spec)
       chroot.run("rm -f %s" % string.join(all_files))
       m = user.message_to()
-      m.set_headers(subject = "SRPMS: %s failed" % r.spec)
-      m.write("Building SRPM failed for %s.\nAttached log:\n" % r.spec)
-      m.append_log(tmp + b.spec + ".log")
+      m.set_headers(subject = "SRPMS: %s failed" % batch.spec)
+      # FIXME: write about other specs from group
+      m.write("Building SRPM failed for %s.\nAttached log:\n" % batch.spec)
+      m.append_log(tmp + batch.spec + ".log")
       m.send()
       buildlogs.flush()
       clean_tmp(tmp)
       return
+    log.notice("building %s finished" % batch.spec)
   os.mkdir(path.srpms_dir + r.id)
   for batch in r.batches:
     # export files from chroot
     local = path.srpms_dir + r.id + "/" + batch.src_rpm
+    f = batch.src_rpm_file
     chroot.run("cat %s; rm -f %s" % (f, f), logfile = local)
     # FIXME: copy files to ftp
 
   # store new queue and counter for binary builders
-  cnt_f = open(counter_file, "r+")
+  cnt_f = open(path.counter_file, "r+")
   num = int(string.strip(cnt_f.read()))
   r.no = num
   q = B_Queue(path.req_queue_file)
@@ -108,10 +115,11 @@ def handle_request(r):
   q.write()
   q.unlock()
   q.write_signed(path.req_queue_signed_file)
-  num++
+  num += 1
   cnt_f.seek(0)
   cnt_f.write("%d\n" % num)
   cnt_f.close()
+  # FIXME: send notification?
 
 def main():
   init_conf("src")
@@ -119,7 +127,7 @@ def main():
   q = B_Queue(path.queue_file)
   if not q.lock(1): return
   q.read()
-  if q.batches == []: return
+  if q.requests == []: return
   r = pick_request(q)
   q.write()
   q.unlock()
index 9fd12f8a2d337c558a2f676130aae2f0f4c85cb9..ab273cb68e934bf1e1cc0146750c5e999a76cc6a 100755 (executable)
@@ -15,7 +15,7 @@ default_config () {
 
   case "$1" in
   src* )
-    builder_arch_pkgs="cvs wget"
+    builder_arch_pkgs="cvs wget rpm-perlprov rpm-php-pearprov rpm-pythonprov"
     ;;
   esac
 }
This page took 0.175925 seconds and 4 git commands to generate.