]> git.decadent.org.uk Git - dak.git/commitdiff
Merge branch 'master' into pu/backports-merge
authorAnsgar Burchardt <ansgar@debian.org>
Mon, 17 Sep 2012 14:27:33 +0000 (16:27 +0200)
committerAnsgar Burchardt <ansgar@debian.org>
Mon, 17 Sep 2012 14:27:33 +0000 (16:27 +0200)
config/debian/dak.conf
config/debian/dak.conf-backports [new file with mode: 0644]
dak/admin.py
dak/rm.py
daklib/announce.py
daklib/config.py
daklib/queue.py
daklib/utils.py

index e326354ab6399a61a7c8a17425764f5892a7b7b9..82a76cb78aa52bf4ab2403c9a4f1a9a54dc4caae 100644 (file)
@@ -374,3 +374,8 @@ Generate-Releases
     experimental;
   };
 }
+
+ByGroup {
+  ftpteam "";
+  backports "/srv/ftp-master.debian.org/dak/config/debian/dak.conf-backports";
+};
diff --git a/config/debian/dak.conf-backports b/config/debian/dak.conf-backports
new file mode 100644 (file)
index 0000000..361909d
--- /dev/null
@@ -0,0 +1,15 @@
+Dir {
+  Log "/srv/ftp-master.debian.org/log/backports/";
+  Lock "/srv/ftp-master.debian.org/lock/backports/";
+};
+
+Rm {
+  LogFile "/srv/backports-web.debian.org/underlay/removals.txt";
+  LogFile822 "/srv/backports-web.debian.org/underlay/removals.822";
+};
+
+Process-New
+{
+  DinstallLockFile "/srv/ftp-master.debian.org/lock/backports/processnew.lock";
+  LockDir "/srv/ftp-master.debian.org/lock/backports/new/";
+};
index 798aa3b7b8948a8652760111d5e196e20b505de8..8ba79797bdaf6345e6d5b1c3bd0206c8c3313c08 100755 (executable)
@@ -556,6 +556,8 @@ def show_config(command):
             print "PGPORT=%s" % cnf["DB::Port"]
             e.append('PGPORT')
         print "export " + " ".join(e)
+    elif mode == 'get':
+        print cnf.get(args[2])
     else:
         session = DBConn().session()
         try:
index e4f4a6cb8e0d428042bb634847c86de91ac8cc13..ec36bf4e49f57687b94e2044812c7fc5629b0cab 100755 (executable)
--- a/dak/rm.py
+++ b/dak/rm.py
@@ -210,6 +210,7 @@ def main ():
 
     # Additional suite checks
     suite_ids_list = []
+    whitelists = []
     suites = utils.split_args(Options["Suite"])
     suites_list = utils.join_with_commas_and(suites)
     if not Options["No-Action"]:
@@ -217,6 +218,7 @@ def main ():
             s = get_suite(suite, session=session)
             if s is not None:
                 suite_ids_list.append(s.suite_id)
+                whitelists.append(s.mail_whitelist)
             if suite in ("oldstable", "stable"):
                 print "**WARNING** About to remove from the (old)stable suite!"
                 print "This should only be done just prior to a (point) release and not at"
@@ -498,7 +500,7 @@ def main ():
                 mail_message = utils.TemplateSubst(Subst_close_rm,cnf["Dir::Templates"]+"/rm.bug-close-with-related")
             else:
                 mail_message = utils.TemplateSubst(Subst_close_rm,cnf["Dir::Templates"]+"/rm.bug-close")
-            utils.send_mail(mail_message)
+            utils.send_mail(mail_message, whitelists=whitelists)
 
     # close associated bug reports
     if Options["Do-Close"]:
index 6c0fd374186aed603dfc74e7ebeab90a6e034acb..fdc3e468555a4782adc22c586dd75f0e1a3ebaf6 100644 (file)
@@ -87,9 +87,13 @@ def _subst_for_upload(upload):
 
     return subst
 
+def _whitelists(upload):
+    return [ s.mail_whitelist for s in upload.suites ]
+
 def announce_reject(upload, reason, rejected_by=None):
     cnf = Config()
     subst = _subst_for_upload(upload)
+    whitelists = _whitelists(upload)
 
     automatic = rejected_by is None
 
@@ -103,11 +107,12 @@ def announce_reject(upload, reason, rejected_by=None):
         subst['__BCC__'] = '{0}\nBcc: {1}'.format(subst['__BCC__'], cnf['Dinstall::MyEmailAddress'])
 
     message = TemplateSubst(subst, os.path.join(cnf['Dir::Templates'], 'queue.rejected'))
-    send_mail(message)
+    send_mail(message, whitelists=whitelists)
 
 def announce_accept(upload):
     cnf = Config()
     subst = _subst_for_upload(upload)
+    whitelists = _whitelists(upload)
 
     accepted_to_real_suite = any(suite.policy_queue is None or suite in upload.from_policy_suites for suite in upload.suites)
 
@@ -121,7 +126,7 @@ def announce_accept(upload):
     subst['__SUITE__'] = ', '.join(suite_names) or '(none)'
 
     message = TemplateSubst(subst, os.path.join(cnf['Dir::Templates'], 'process-unchecked.accepted'))
-    send_mail(message)
+    send_mail(message, whitelists=whitelists)
 
     if accepted_to_real_suite and upload.sourceful:
         # senf mail to announce lists and tracking server
@@ -141,7 +146,7 @@ def announce_accept(upload):
             my_subst['__ANNOUNCE_LIST_ADDRESS__'] = announce_list_address
 
             message = TemplateSubst(my_subst, os.path.join(cnf['Dir::Templates'], 'process-unchecked.announce'))
-            send_mail(message)
+            send_mail(message, whitelists=whitelists)
 
     close_bugs_default = cnf.find_b('Dinstall::CloseBugs')
     close_bugs = any(s.close_bugs if s.close_bugs is not None else close_bugs_default for s in upload.suites)
@@ -151,11 +156,12 @@ def announce_accept(upload):
             my_subst['__BUG_NUMBER__'] = str(bug)
 
             message = TemplateSubst(my_subst, os.path.join(cnf['Dir::Templates'], 'process-unchecked.bug-close'))
-            send_mail(message)
+            send_mail(message, whitelists=whitelists)
 
 def announce_new(upload):
     cnf = Config()
     subst = _subst_for_upload(upload)
+    whitelists = _whitelists(upload)
 
     message = TemplateSubst(subst, os.path.join(cnf['Dir::Templates'], 'process-unchecked.new'))
-    send_mail(message)
+    send_mail(message, whitelists=whitelists)
index 65874250906bc74a3f485a348faaeec1648af4bc..339604a1a60f275fda8c10954ecb3f1dde33792d 100755 (executable)
@@ -28,6 +28,7 @@ Config access class
 
 ################################################################################
 
+import grp
 import os
 import apt_pkg
 import socket
@@ -76,6 +77,19 @@ class Config(object):
         if conffile:
             apt_pkg.read_config_file_isc(self.Cnf, conffile)
 
+        # Read group-specific options
+        if 'ByGroup' in self.Cnf:
+            bygroup = self.Cnf.subtree('ByGroup')
+            groups = set([os.getgid()])
+            groups.update(os.getgroups())
+
+            for group in bygroup.list():
+                gid = grp.getgrnam(group).gr_gid
+                if gid in groups:
+                    if bygroup.get(group):
+                        apt_pkg.read_config_file_isc(self.Cnf, bygroup[group])
+                    break
+
         # Rebind some functions
         # TODO: Clean this up
         self.get = self.Cnf.get
index 547972ed0932b6af669e836e96a61dbfcbdf100d..9dd2702ca02aa296071f768cd7764c7c4e9f37cf 100644 (file)
@@ -104,6 +104,7 @@ def check_valid(overrides, session):
 def prod_maintainer(notes, upload):
     cnf = Config()
     changes = upload.changes
+    whitelists = [ upload.target_suite.mail_whitelist ]
 
     # Here we prepare an editor and get them ready to prod...
     (fd, temp_filename) = utils.temp_filename()
@@ -154,7 +155,7 @@ def prod_maintainer(notes, upload):
         Subst,cnf["Dir::Templates"]+"/process-new.prod")
 
     # Send the prod mail
-    utils.send_mail(prod_mail_message)
+    utils.send_mail(prod_mail_message, whitelists=whitelists)
 
     print "Sent prodding message"
 
index 63d8f471e6a773f9d4fe0ba70a6fe218707ad058..1034628ea217ce39b383d0feed9ddce67ad4c90a 100755 (executable)
@@ -43,6 +43,7 @@ import email as modemail
 import subprocess
 import ldap
 
+import daklib.config as config
 from dbconn import DBConn, get_architecture, get_component, get_suite, \
                    get_override_type, Keyring, session_wrapper, \
                    get_active_keyring_paths, get_primary_keyring_path, \
@@ -603,8 +604,16 @@ def build_package_list(dsc, session = None):
 
 ################################################################################
 
-def send_mail (message, filename=""):
-    """sendmail wrapper, takes _either_ a message string or a file as arguments"""
+def send_mail (message, filename="", whitelists=None):
+    """sendmail wrapper, takes _either_ a message string or a file as arguments
+
+    @type  whitelists: list of (str or None)
+    @param whitelists: path to whitelists. C{None} or an empty list whitelists
+                       everything, otherwise an address is whitelisted if it is
+                       included in any of the lists.
+                       In addition a global whitelist can be specified in
+                       Dinstall::MailWhiteList.
+    """
 
     maildir = Cnf.get('Dir::Mail')
     if maildir:
@@ -624,23 +633,24 @@ def send_mail (message, filename=""):
         os.write (fd, message)
         os.close (fd)
 
-    if Cnf.has_key("Dinstall::MailWhiteList") and \
-           Cnf["Dinstall::MailWhiteList"] != "":
+    if whitelists is None or None in whitelists:
+        whitelists = []
+    if Cnf.get('Dinstall::MailWhiteList', ''):
+        whitelists.append(Cnf['Dinstall::MailWhiteList'])
+    if len(whitelists) != 0:
         message_in = open_file(filename)
         message_raw = modemail.message_from_file(message_in)
         message_in.close();
 
         whitelist = [];
-        whitelist_in = open_file(Cnf["Dinstall::MailWhiteList"])
-        try:
+        for path in whitelists:
+          with open_file(path, 'r') as whitelist_in:
             for line in whitelist_in:
                 if not re_whitespace_comment.match(line):
                     if re_re_mark.match(line):
                         whitelist.append(re.compile(re_re_mark.sub("", line.strip(), 1)))
                     else:
                         whitelist.append(re.compile(re.escape(line.strip())))
-        finally:
-            whitelist_in.close()
 
         # Fields to check.
         fields = ["To", "Bcc", "Cc"]
@@ -657,7 +667,7 @@ def send_mail (message, filename=""):
                             mail_whitelisted = 1
                             break
                     if not mail_whitelisted:
-                        print "Skipping %s since it's not in %s" % (item, Cnf["Dinstall::MailWhiteList"])
+                        print "Skipping {0} since it's not whitelisted".format(item)
                         continue
                     match.append(item)
 
@@ -1542,14 +1552,7 @@ def get_changes_files(from_dir):
 
 ################################################################################
 
-apt_pkg.init()
-
-Cnf = apt_pkg.Configuration()
-if not os.getenv("DAK_TEST"):
-    apt_pkg.read_config_file_isc(Cnf,default_config)
-
-if which_conf_file() != default_config:
-    apt_pkg.read_config_file_isc(Cnf,which_conf_file())
+Cnf = config.Config().Cnf
 
 ################################################################################