tag 655919 + patch
quit

This is a working patch to implement a sourcesuite_id and use that to
lookup whether source exists in the corresponding suite when a package
is uploaded to a suite with a defined sourcesuite_id. i.e.
unstable-grip would have unstable defined as the source suite. If the
relevant source package does not exist in the source suite, the upload
is correctly rejected with this patch in place.

I hope this patch can be seen as a starting point, so that uploads can
start soon and the system improved later, to give the release team and
others a chance to work on any changes they may need before the freeze.

Note that the new unstable-grip suite should probably being given
the same overrides as unstable (for dsc and deb) so that there should
be no pushing of Emdebian Grip binary uploads through NEW. (Packages for
Emdebian must exist in unstable - and preferably testing - before being
processed.)

-- 


Neil Williams
=============
http://www.linux.codehelp.co.uk/

diff --git a/dak/dakdb/update72.py b/dak/dakdb/update72.py
index e69de29..4ffe379 100644
--- a/dak/dakdb/update72.py
+++ b/dak/dakdb/update72.py
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+# coding=utf8
+
+"""
+More suite config into the DB
+
+@contact: Debian FTP Master <ftpmas...@debian.org>
+@copyright: 2012  Neil Williams <codeh...@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
+import time
+from daklib.dak_exceptions import DBUpdateError
+
+################################################################################
+
+def do_update(self):
+    print "Adding the sourcesuite column to the suite config into the DB"
+
+    try:
+        c = self.db.cursor()
+
+        c.execute("ALTER TABLE suite ADD COLUMN sourcesuite_id INTEGER;")
+        # Add constraint
+        c.execute("ALTER TABLE suite ADD CONSTRAINT suite_sourcesuite FOREIGN KEY (sourcesuite_id) REFERENCES suite(id);")
+        c.execute("UPDATE config SET value = '72' WHERE name = 'db_revision'")
+        self.db.commit()
+
+    except psycopg2.ProgrammingError as msg:
+        self.db.rollback()
+        raise DBUpdateError("Unable to apply suite config updates, rollback issued. Error message : %s" % (str(msg)))
diff --git a/daklib/dbconn.py b/daklib/dbconn.py
index dac0675..d6fd02c 100755
--- a/daklib/dbconn.py
+++ b/daklib/dbconn.py
@@ -2924,7 +2924,7 @@ class Suite(ORMObject):
 
     def properties(self):
         return ['suite_name', 'version', 'sources_count', 'binaries_count', \
-            'overrides_count']
+            'overrides_count', 'sourcesuite_id']
 
     def not_null_constraints(self):
         return ['suite_name']
@@ -2997,6 +2997,12 @@ class Suite(ORMObject):
         else:
             return object_session(self).query(Suite).filter_by(suite_name=self.overridesuite).one()
 
+    def get_sourcesuite(self):
+        if self.sourcesuite_id is None:
+            return self
+        else:
+            return object_session(self).query(Suite).filter_by(suite_id=self.sourcesuite_id).one()
+
 __all__.append('Suite')
 
 @session_wrapper
@@ -3594,7 +3600,9 @@ class DBConn(object):
                                  copy_queues = relation(BuildQueue,
                                      secondary=self.tbl_suite_build_queue_copy),
                                  srcformats = relation(SrcFormat, secondary=self.tbl_suite_src_formats,
-                                     backref=backref('suites', lazy='dynamic'))),
+                                     backref=backref('suites', lazy='dynamic')),
+                                 sourcesuite = relation(Suite, secondary=self.tbl_src_associations,
+                                    primaryjoin=(self.tbl_suite.c.id==self.tbl_suite.c.sourcesuite_id))),
                 extension = validator)
 
         mapper(Uid, self.tbl_uid,
diff --git a/daklib/queue.py b/daklib/queue.py
index e2ab846..32d4f9e 100755
--- a/daklib/queue.py
+++ b/daklib/queue.py
@@ -877,6 +877,7 @@ class Upload(object):
             # Check in the SQL database
             if not source_exists(source_package, source_version, suites = \
                 self.pkg.changes["distribution"].keys(), session = session):
+                suite = get_suite(self.pkg.changes["distribution"].keys()[0], session = session)
                 # Check in one of the other directories
                 source_epochless_version = re_no_epoch.sub('', source_version)
                 dsc_filename = "%s_%s.dsc" % (source_package, source_epochless_version)
@@ -888,6 +889,14 @@ class Upload(object):
                     entry["byhand"] = 1
                 elif os.path.exists(os.path.join(new_dir, dsc_filename)):
                     entry["new"] = 1
+                # if no source in this suite, check for a sourcesuite
+                elif suite.sourcesuite_id:
+                    sourcesuite=suite.get_sourcesuite().suite_name
+                    if source_exists(source_package, source_version, sourcesuite, session = session):
+                        dsc_file_exists = True
+                    else:
+                        self.rejects.append("no source found for %s - %s (%s) in source suite: %s" % \
+                        (source_package, source_version, f, sourcesuite))
                 else:
                     dsc_file_exists = False
                     # TODO: Don't hardcode this list: use all relevant queues
@@ -900,7 +909,7 @@ class Upload(object):
                                 break
 
                     if not dsc_file_exists:
-                        self.rejects.append("no source found for %s %s (%s)." % (source_package, source_version, f))
+                        self.rejects.append("no source found for %s %s (%s) and no sourcesuite." % (source_package, source_version, f))
 
         # Check the version and for file overwrites
         self.check_binary_against_db(f, session)

Attachment: pgpTGDMnlaSS6.pgp
Description: PGP signature

Reply via email to