]> git.pld-linux.org Git - projects/pld-builder.new.git/commitdiff
- buildlogs
authorMichal Moskal <michal@moskal.me>
Tue, 10 Jun 2003 19:54:56 +0000 (19:54 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
- wrapping main function to print trackback to log, not stderr
- lots of other changes :-)

Changed files:
    PLD_Builder/buildlogs.py -> 1.3
    PLD_Builder/config.py -> 1.3
    PLD_Builder/mailer.py -> 1.3
    PLD_Builder/path.py -> 1.5
    PLD_Builder/request_handler.py -> 1.7
    PLD_Builder/srpm_builder.py -> 1.5
    PLD_Builder/util.py -> 1.2
    admin/fresh-queue.sh -> 1.5
    bin/src-builder.sh -> 1.1
    config/builder.conf -> 1.2

PLD_Builder/buildlogs.py
PLD_Builder/config.py
PLD_Builder/mailer.py
PLD_Builder/path.py
PLD_Builder/request_handler.py
PLD_Builder/srpm_builder.py
PLD_Builder/util.py
admin/fresh-queue.sh
bin/src-builder.sh [new file with mode: 0644]
config/builder.conf

index eec456fa91478073afe93b7d024b46afd43f01b9..0940d0d1f7d49e1fb6ffd6634433aa8297a1a5ee 100644 (file)
@@ -1,10 +1,38 @@
+import path
+import os
+
+from config import config
+
+class Buildlogs_Queue:
+  def __init__(self):
+    self.queue = []
+    self.some_failed = 0
+
+  def add(self, logfile, failed):
+    name = os.path.basename(logfile) + ".bz2"
+    os.system("bzip2 --best --force < %s > %s" \
+                % (logfile, path.buildlogs_queue_dir + name))
+    self.queue.append({'name': name, 'failed': failed})
+
+  def flush(self):
+    def desc(l):
+      if l['failed']: s = "FAIL"
+      elif self.some_failed: s = "OKOF" # OK but Others Failed
+      else: s = "OK"
+      return "Target: %s/%s\nBuilder: %s\nStatus: %s\nEND\n" % \
+                (config.buildlogs_url, l['name'], config.builder, s)
+    
+    for l in self.queue:
+      f = open(path.buildlogs_queue_dir + l['name'] + ".desc", "w")
+      f.write(desc(l))
+      f.close()
+
+queue = Buildlogs_Queue()
 
 def add(logfile, failed):
   "Add new buildlog with specified status."
-  # FIXME
-  pass
+  queue.add(logfile, failed)
 
 def flush():
   "Send buildlogs to server."
-  # FIXME
-  pass
+  queue.flush()
index 5f86c8bc968cbbeff89ccad3f89f283a7cb1ae0f..46dbe0c80f42fd054053cec070ff7462c5e1859c 100644 (file)
@@ -19,7 +19,7 @@ class Builder_Conf:
       elif d != None:
         return d
       else:
-        log.panic("cannot find %s::%s" % (builder, d))
+        log.panic("cannot find %s::%s" % (builder, o))
         
     p.readfp(open(path.builder_conf))
     if builder not in p.sections():
@@ -28,6 +28,8 @@ class Builder_Conf:
     self.arch = get("arch")
     self.chroot = get("chroot")
     self.email = get("email")
+    self.buildlogs_url = get("buildlogs_url", "/dev/null")
+    self.ftp_url = get("ftp_url", "/dev/null")
 
 config = Builder_Conf()
 
index dee0049a1086c0f44a7b2a0df0797855eae7467e..80a8b09b9dced25ee1c102b547248a025779dfcd 100644 (file)
@@ -4,12 +4,7 @@ import sys
 import StringIO
 
 from config import config
-
-def sendfile(src, dst):
-  while 1:
-    s = src.read(10000)
-    if s == "": break
-    dst.write(s)
+import util
 
 class Message:
   def __init__(self):
@@ -51,7 +46,7 @@ class Message:
           self.body.write("\n\n[...]\n\n")
         line += 1
     else:
-      sendfile(open(log), self.body)
+      util.sendfile(open(log), self.body)
 
   def set_std_headers(self):
     self.headers["Date"] = time.asctime()
@@ -66,7 +61,7 @@ class Message:
       f.write("%s: %s\n" % (k, v))
     f.write("\n")
     self.body.seek(0)
-    sendfile(self.body, f)
+    util.sendfile(self.body, f)
 
   def send(self):
     # FIXME
index 3e12f3c6e40aa9a2d25e3e8d9eef532cdc54eb1b..4aec079ca666ef53d36c2e81cab65e23403eb67b 100644 (file)
@@ -13,6 +13,8 @@ builder_conf = conf_dir + "builder.conf"
 queue_file = spool_dir + "queue"
 req_queue_file = spool_dir + "req_queue"
 processed_ids_file = spool_dir + "processed_ids"
+buildlogs_queue_dir = spool_dir + "buildlogs/"
+ftp_queue_dir = spool_dir + "ftp/"
 
 # www/
 srpms_dir = www_dir + "srpms/"
index 1bb76a14f6ba333ad67a87e504f825fb6f76a251..2a19462c99031c026c10128b6db4b3ca5748213d 100644 (file)
@@ -9,6 +9,7 @@ import gpg
 import request
 import log
 import path
+import util
 from acl import acl
 from lock import lock
 from bqueue import B_Queue
@@ -96,4 +97,4 @@ def main():
   handle_request(sys.stdin)
   sys.exit(0)
 
-main()
+util.wrap(main)
index afab1f877fa06e4b741fed044a06fc27f95941d4..308b8eda23451ccaf8c28a786820d4a44dcdc338 100644 (file)
@@ -6,17 +6,20 @@ import os.path
 import StringIO
 import sys
 import re
+import atexit
 
 import gpg
 import request
 import log
 import path
+import util
+import chroot
+import buildlogs
+
 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):
@@ -42,15 +45,6 @@ def collect_files(log):
       files.append(m.group(1))
   return files
 
-def append_to(log, msg):
-  f = open(log, "a")
-  f.write("%s\n" % msg)
-  f.close()
-
-def clean_tmp(dir):
-  # FIXME: use python
-  os.system("rm -f %s/*; rmdir %s" % (dir, dir))
-
 def handle_request(r):
   def build_srpm(b):
     b.src_rpm = ""
@@ -58,25 +52,26 @@ def handle_request(r):
     cmd = "cd rpm/SPECS; ./builder %s -bs %s -r %s %s 2>&1" % \
                  (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)
+    util.append_to(spec_log, "Building SRPM using: %s\n" % cmd)
     res = chroot.run(cmd, logfile = spec_log)
     files = collect_files(spec_log)
     if len(files) > 0:
       if len(files) > 1:
-        append_to(spec_log, "error: More then one file produced: %s" % files)
+        util.append_to(spec_log, "error: More then one file produced: %s" % files)
         res = 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.")
+      util.append_to(spec_log, "error: No files produced.")
       res = 1
     buildlogs.add(logfile = spec_log, failed = res)
     return res
 
   tmp = path.spool_dir + r.id + "/"
   os.mkdir(tmp)
+  atexit.register(util.clean_tmp, tmp)
   user = acl.user(r.requester)
   log.notice("started processing %s" % r.id)
   all_files = []
@@ -93,7 +88,6 @@ def handle_request(r):
       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)
@@ -120,6 +114,7 @@ def handle_request(r):
   cnt_f.write("%d\n" % num)
   cnt_f.close()
   # FIXME: send notification?
+  buildlogs.flush()
 
 def main():
   init_conf("src")
@@ -133,4 +128,4 @@ def main():
   q.unlock()
   handle_request(r)
 
-main()
+util.wrap(main)
index 5c48a9513a0dfe25644387677ec949436db7a66f..7ef653251e6ec7669128eb96caba53c04e452778 100644 (file)
@@ -1,8 +1,42 @@
 import re
 import sys
+import os
+import log
+import traceback
+import StringIO
 
 def pkg_name(nvr):
   return re.match(r"(.+)-[^-]+-[^-]+", nvr).group(1)
   
 def msg(m):
   sys.stderr.write(m)
+
+def sendfile(src, dst):
+  while 1:
+    s = src.read(10000)
+    if s == "": break
+    dst.write(s)
+
+def append_to(log, msg):
+  f = open(log, "a")
+  f.write("%s\n" % msg)
+  f.close()
+
+def clean_tmp(dir):
+  # FIXME: use python
+  os.system("rm -f %s/* 2>/dev/null; rmdir %s 2>/dev/null" % (dir, dir))
+
+status = "unknown"
+
+def wrap(main):
+  try:
+    main()
+  except:
+    exctype, value = sys.exc_info()[:2]
+    if exctype == SystemExit:
+      sys.exit(value)
+    s = StringIO.StringIO()
+    traceback.print_exc(file = s, limit = 20)
+    log.alert("fatal python exception during: %s" % status)
+    log.alert(s.getvalue())
+    sys.exit(1)
index 7ed0af42373d9cf04e4eb854ed4d91f44273ea50..83a552d9f1065f89d99351e218d4e4b4c1adef54 100755 (executable)
@@ -6,7 +6,7 @@ if [ "$1" != "y" ] ; then
   exit 1
 fi
 
-mkdir -p spool www/srpms log lock
+mkdir -p spool/{buildlogs,ftp} www/srpms log lock
 echo 1 > www/counter
 echo -n > spool/processed_ids
 echo '<queue/>' > spool/queue
diff --git a/bin/src-builder.sh b/bin/src-builder.sh
new file mode 100644 (file)
index 0000000..bfe0066
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+cd ~/pld-builder.new
+python PLD_Builder/srpm_builder.py
index 2870a510927531079aa6d23fad55d90e20fcb7d0..1539a238e532d714899a6cb656723a934ea6d9b1 100644 (file)
@@ -4,3 +4,5 @@ email = malekith@roke.freak
 [src]
 arch = athlon
 chroot = /adm/chroot-src
+buildlogs_url = scp://malekith@roke.freak/home/services/ftpd/buildlogs/
+ftp_url = scp://malekith@roke.freak/home/services/ftpd/dists/nest/NEW/ready/SRPMS
This page took 1.25786 seconds and 4 git commands to generate.