]> git.decadent.org.uk Git - dak.git/blobdiff - daklib/dbconn.py
add get_binary_components (from p-u)
[dak.git] / daklib / dbconn.py
index 42ef7e9f78eb5da11fd116ed88231fba25791fd5..cf9ca9a54c7df7d12a007c36161ff86dbfefdaa6 100755 (executable)
@@ -210,6 +210,23 @@ def get_binaries_from_name(package, session=None):
 
 __all__.append('get_binaries_from_name')
 
+def get_binary_components(package, suitename, arch, session=None):
+# Check for packages that have moved from one component to another
+    query = """SELECT c.name FROM binaries b, bin_associations ba, suite s, location l, component c, architecture a, files f
+    WHERE b.package=:package AND s.suite_name=:suitename
+      AND (a.arch_string = :arch OR a.arch_string = 'all')
+      AND ba.bin = b.id AND ba.suite = s.id AND b.architecture = a.id
+      AND f.location = l.id
+      AND l.component = c.id
+      AND b.file = f.id"""
+
+    vals = {'package': package, 'suitename': suitename, 'arch': arch}
+
+    if session is None:
+        session = DBConn().session()
+    return session.execute(query, vals)
+
+__all__.append('get_binary_components')
 ################################################################################
 
 class Component(object):
@@ -908,13 +925,21 @@ class SuiteArchitecture(object):
 
 __all__.append('SuiteArchitecture')
 
-def get_suite_architectures(suite, session=None):
+def get_suite_architectures(suite, skipsrc=False, skipall=False, session=None):
     """
     Returns list of Architecture objects for given C{suite} name
 
     @type source: str
     @param source: Suite name to search for
 
+    @type skipsrc: boolean
+    @param skipsrc: Whether to skip returning the 'source' architecture entry
+    (Default False)
+
+    @type skipall: boolean
+    @param skipall: Whether to skip returning the 'all' architecture entry
+    (Default False)
+
     @type session: Session
     @param session: Optional SQL session object (a temporary one will be
     generated if not supplied)
@@ -928,7 +953,12 @@ def get_suite_architectures(suite, session=None):
 
     q = session.query(Architecture)
     q = q.join(SuiteArchitecture)
-    q = q.join(Suite).filter_by(suite_name=suite).order_by('arch_string')
+    q = q.join(Suite).filter_by(suite_name=suite)
+    if skipsrc:
+        q = q.filter(Architecture.arch_string != 'source')
+    if skipall:
+        q = q.filter(Architecture.arch_string != 'all')
+    q = q.order_by('arch_string')
     return q.all()
 
 __all__.append('get_suite_architectures')