[projects/pld-builder.new] - rudimentary blacklist support to prevent listed packages from being built

baggins baggins at pld-linux.org
Sat Jun 22 23:35:15 CEST 2013


commit d8d56d0f562c7ec4635d3de126cc7f77d881e3b0
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Sat Jun 22 23:34:46 2013 +0200

    - rudimentary blacklist support to prevent listed packages from being built

 PLD_Builder/blacklist.py       | 49 ++++++++++++++++++++++++++++++++++++++++++
 PLD_Builder/path.py            |  1 +
 PLD_Builder/request_handler.py |  9 ++++++++
 3 files changed, 59 insertions(+)
---
diff --git a/PLD_Builder/blacklist.py b/PLD_Builder/blacklist.py
new file mode 100644
index 0000000..54cc66b
--- /dev/null
+++ b/PLD_Builder/blacklist.py
@@ -0,0 +1,49 @@
+# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
+
+import string
+import fnmatch
+import os
+import stat
+import re
+
+import path
+import log
+import status
+from mailer import Message
+from config import config
+
+class Blacklist_File:
+    def __init__(self):
+        self.reload()
+
+    def try_reload(self):
+        mtime = os.stat(path.blacklist_file)[stat.ST_MTIME]
+        if mtime != self.blacklist_file_mtime:
+            log.notice("blacklist file has changed, reloading...")
+            self.reload()
+            return True
+        return False
+
+    def reload(self):
+        self.blacklist_file_mtime = os.stat(path.blacklist_file)[stat.ST_MTIME]
+        self.blacklist = {}
+        status.push("reading package-blacklist")
+        with open(path.blacklist_file) as f:
+            for l in f:
+                p = l.rstrip()
+                if re.match(r"^#.*", p):
+                    continue
+                self.blacklist[p] = 1
+                log.notice("blacklist added: %s (%d)" % (l, self.blacklist.has_key(p)))
+        status.pop()
+
+    def package(self, p):
+#       log.notice("blacklist check: %s (%d)" % (p, self.blacklist.has_key(p)))
+        if self.blacklist.has_key(p):
+            return True
+        return False
+
+    def packages(self):
+        return self.blacklist
+
+blacklist = Blacklist_File()
diff --git a/PLD_Builder/path.py b/PLD_Builder/path.py
index 1558ab9..cc7872d 100644
--- a/PLD_Builder/path.py
+++ b/PLD_Builder/path.py
@@ -13,6 +13,7 @@ www_dir = root_dir + "/www"
 acl_conf = conf_dir + "/acl.conf"
 builder_conf = conf_dir + "/builder.conf"
 rsync_password_file = conf_dir + "/rsync-passwords"
+blacklist_file = conf_dir + "/package-blacklist"
 
 # spool/
 queue_file = spool_dir + "/queue"
diff --git a/PLD_Builder/request_handler.py b/PLD_Builder/request_handler.py
index 44c3964..a026865 100644
--- a/PLD_Builder/request_handler.py
+++ b/PLD_Builder/request_handler.py
@@ -16,6 +16,7 @@ import util
 import wrap
 import status
 from acl import acl
+from blacklist import blacklist
 from lock import lock
 from bqueue import B_Queue
 from config import config, init_conf
@@ -129,6 +130,14 @@ def handle_group(r, user):
                    lockf.close()
                    return
 
+            pkg = batch.spec
+            if pkg.endswith(".spec"):
+                pkg = pkg[:-5]
+            if not "test-build" in r.flags and blacklist.package(pkg):
+                   fail_mail("package '%s' is blacklisted, only test-builds allowed" % pkg)
+                   lockf.close()
+                   return
+
     r.priority = user.check_priority(r.priority,config.builder)
     r.time = time.time()
     log.notice("queued %s from %s" % (r.id, user.get_login()))
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/pld-builder.new.git/commitdiff/d8d56d0f562c7ec4635d3de126cc7f77d881e3b0



More information about the pld-cvs-commit mailing list