]> git.decadent.org.uk Git - dak.git/commitdiff
Merge branch 'debug'
authorAnsgar Burchardt <ansgar@debian.org>
Sun, 16 Aug 2015 18:45:18 +0000 (20:45 +0200)
committerAnsgar Burchardt <ansgar@debian.org>
Sun, 16 Aug 2015 18:45:18 +0000 (20:45 +0200)
dak/dakdb/update110.py [new file with mode: 0644]
dak/process_policy.py
daklib/archive.py
daklib/checks.py
daklib/dbconn.py
daklib/utils.py

diff --git a/dak/dakdb/update110.py b/dak/dakdb/update110.py
new file mode 100644 (file)
index 0000000..a844f98
--- /dev/null
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+# coding=utf8
+
+"""
+Add a debug suite field to the suite table
+
+@contact: Debian FTP Master <ftpmaster@debian.org>
+@copyright: 2015, Paul Tagliamonte <paultag@debian.org>
+@license: GNU General Public License version 2 or later
+"""
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+################################################################################
+
+import psycopg2
+from daklib.dak_exceptions import DBUpdateError
+from daklib.config import Config
+
+statements = [
+"""
+ALTER TABLE suite ADD COLUMN debugsuite_id INTEGER REFERENCES suite(id)
+""",
+"""
+COMMENT ON COLUMN suite.debugsuite_id IS 'Suite to redirect debug packages (Section: debug) to'
+"""
+]
+
+################################################################################
+def do_update(self):
+    print __doc__
+    try:
+        cnf = Config()
+
+        c = self.db.cursor()
+
+        for stmt in statements:
+            c.execute(stmt)
+
+        c.execute("UPDATE config SET value = '110' WHERE name = 'db_revision'")
+        self.db.commit()
+
+    except psycopg2.ProgrammingError as msg:
+        self.db.rollback()
+        raise DBUpdateError('Unable to apply sick update 110, rollback issued. Error message: {0}'.format(msg))
index 0f2f22aab8a67d93e0d18b8610c1c5e1275f8648..7b6b9645ece4521cacd2373356ff750d81b271d0 100755 (executable)
@@ -49,6 +49,7 @@ from daklib.urgencylog import UrgencyLog
 from daklib.packagelist import PackageList
 
 import daklib.announce
+import daklib.utils
 
 # Globals
 Options = None
@@ -141,6 +142,12 @@ def comment_accept(upload, srcqueue, comments, transaction):
             component_name = section.split('/', 1)[0]
         return get_mapped_component(component_name, session=session)
 
+    def is_debug_binary(db_binary):
+        return daklib.utils.is_in_debug_section(db_binary.proxy)
+
+    def has_debug_binaries(upload):
+        return any((is_debug_binary(x) for x in upload.binaries))
+
     def source_component_func(db_source):
         package_list = PackageList(db_source.proxy)
         component = source_component_from_package_list(package_list, upload.target_suite)
@@ -157,13 +164,54 @@ def comment_accept(upload, srcqueue, comments, transaction):
     all_target_suites.extend([q.suite for q in upload.target_suite.copy_queues])
 
     for suite in all_target_suites:
+        debug_suite = suite.debug_suite
+
         if upload.source is not None:
-            transaction.copy_source(upload.source, suite, source_component_func(upload.source), allow_tainted=allow_tainted)
+            # If we have Source in this upload, let's include it into
+            # upload suite.
+            transaction.copy_source(
+                upload.source,
+                suite,
+                source_component_func(upload.source),
+                allow_tainted=allow_tainted,
+            )
+
+            if debug_suite is not None and has_debug_binaries(upload):
+                # If we're handing a debug package, we also need to include the
+                # source in the debug suite as well.
+                transaction.copy_source(
+                    upload.source,
+                    debug_suite,
+                    source_component_func(upload.source),
+                    allow_tainted=allow_tainted,
+                )
+
         for db_binary in upload.binaries:
-            # build queues may miss the source package if this is a binary-only upload
+            # Now, let's work out where to copy this guy to -- if it's
+            # a debug binary, and the suite has a debug suite, let's go
+            # ahead and target the debug suite rather then the stock
+            # suite.
+            copy_to_suite = suite
+            if debug_suite is not None and is_debug_binary(db_binary):
+                copy_to_suite = debug_suite
+
+            # build queues may miss the source package if this is a
+            # binary-only upload.
             if suite != upload.target_suite:
-                transaction.copy_source(db_binary.source, suite, source_component_func(db_binary.source), allow_tainted=allow_tainted)
-            transaction.copy_binary(db_binary, suite, binary_component_func(db_binary), allow_tainted=allow_tainted, extra_archives=[upload.target_suite.archive])
+                transaction.copy_source(
+                    db_binary.source,
+                    copy_to_suite,
+                    source_component_func(db_binary.source),
+                    allow_tainted=allow_tainted,
+                )
+
+            transaction.copy_binary(
+                db_binary,
+                copy_to_suite,
+                binary_component_func(db_binary),
+                allow_tainted=allow_tainted,
+                extra_archives=[upload.target_suite.archive],
+            )
 
     # Copy .changes if needed
     if upload.target_suite.copychanges:
index b77bfa0bc076c1a2bfe80f566763736040783217..e3bf91267e14f0d9ff64b2067abf9d41ae4c2a4f 100644 (file)
@@ -1025,14 +1025,33 @@ class ArchiveUpload(object):
         source = self.changes.source
         if source is not None:
             component = source_component_func(source)
-            db_source = self.transaction.install_source(self.directory, source, suite, component, changed_by, fingerprint=self.fingerprint)
+            db_source = self.transaction.install_source(
+                self.directory,
+                source,
+                suite,
+                component,
+                changed_by,
+                fingerprint=self.fingerprint
+            )
         else:
             db_source = None
 
         db_binaries = []
         for binary in self.changes.binaries:
+            copy_to_suite = suite
+            if utils.is_in_debug_section(binary.control) and suite.debug_suite is not None:
+                copy_to_suite = suite.debug_suite
+
             component = binary_component_func(binary)
-            db_binary = self.transaction.install_binary(self.directory, binary, suite, component, fingerprint=self.fingerprint, source_suites=source_suites, extra_source_archives=extra_source_archives)
+            db_binary = self.transaction.install_binary(
+                self.directory,
+                binary,
+                copy_to_suite,
+                component,
+                fingerprint=self.fingerprint,
+                source_suites=source_suites,
+                extra_source_archives=extra_source_archives
+            )
             db_binaries.append(db_binary)
 
         if suite.copychanges:
index 60149b5c94c5d9f049ee45520d83cd5c9588552e..2eec769def845f125f40882163541d918efbb318 100644 (file)
@@ -286,13 +286,41 @@ class ExternalHashesCheck(Check):
 class BinaryCheck(Check):
     """Check binary packages for syntax errors."""
     def check(self, upload):
+        debug_deb_name_postfix = "-dbgsym"
+        # XXX: Handle dynamic debug section name here
+
         for binary in upload.changes.binaries:
             self.check_binary(upload, binary)
 
-        binary_names = set([ binary.control['Package'] for binary in upload.changes.binaries ])
-        for bn in binary_names:
-            if bn not in upload.changes.binary_names:
-                raise Reject('Package {0} is not mentioned in Binary field in changes'.format(bn))
+        binaries = {binary.control['Package']: binary
+                        for binary in upload.changes.binaries}
+
+        for name, binary in binaries.items():
+            if name in upload.changes.binary_names:
+                # Package is listed in Binary field. Everything is good.
+                pass
+            elif daklib.utils.is_in_debug_section(binary.control):
+                # If we have a binary package in the debug section, we
+                # can allow it to not be present in the Binary field
+                # in the .changes file, so long as its name (without
+                # -dbgsym) is present in the Binary list.
+                if not name.endswith(debug_deb_name_postfix):
+                    raise Reject('Package {0} is in the debug section, but '
+                                 'does not end in {1}.'.format(name, debug_deb_name_postfix))
+
+                # Right, so, it's named properly, let's check that
+                # the corresponding package is in the Binary list
+                origin_package_name = name[:-len(debug_deb_name_postfix)]
+                if origin_package_name not in upload.changes.binary_names:
+                    raise Reject(
+                        "Debug package {debug}'s corresponding binary package "
+                        "{origin} is not present in the Binary field.".format(
+                            debug=name, origin=origin_package_name))
+            else:
+                # Someone was a nasty little hacker and put a package
+                # into the .changes that isn't in debian/control. Bad,
+                # bad person.
+                raise Reject('Package {0} is not mentioned in Binary field in changes'.format(name))
 
         return True
 
index 973fa797552fe3ae86025e4ccff7d9e31248743a..985caf1d2e2b1a7f0bac65fac318d14c454f312c 100644 (file)
@@ -2548,6 +2548,7 @@ class DBConn(object):
                properties = dict(suite_id = self.tbl_suite.c.id,
                                  policy_queue = relation(PolicyQueue, primaryjoin=(self.tbl_suite.c.policy_queue_id == self.tbl_policy_queue.c.id)),
                                  new_queue = relation(PolicyQueue, primaryjoin=(self.tbl_suite.c.new_queue_id == self.tbl_policy_queue.c.id)),
+                                 debug_suite = relation(Suite, remote_side=[self.tbl_suite.c.id]),
                                  copy_queues = relation(BuildQueue,
                                      secondary=self.tbl_suite_build_queue_copy),
                                  srcformats = relation(SrcFormat, secondary=self.tbl_suite_src_formats,
index 401712381674a2fb83c9ec71e6b3a7e3336972fe..d33ec308366415e874cf2dc1383a63666f5cfeb2 100644 (file)
@@ -1325,3 +1325,17 @@ def parse_built_using(control):
         bu.append((source_name, source_version))
 
     return bu
+
+################################################################################
+
+def is_in_debug_section(control):
+    """binary package is a debug package
+
+    @type  control: dict-like
+    @param control: control file of binary package
+
+    @rtype Boolean
+    @return: True if the binary package is a debug package
+    """
+    section = control['Section'].split('/', 1)[-1]
+    return section == "debug"