]> git.decadent.org.uk Git - dak.git/commitdiff
Merge remote-tracking branch 'ansgar/pu/multiarchive-2'
authorJoerg Jaspert <joerg@debian.org>
Sun, 12 Aug 2012 16:28:58 +0000 (18:28 +0200)
committerJoerg Jaspert <joerg@debian.org>
Sun, 12 Aug 2012 16:28:58 +0000 (18:28 +0200)
* ansgar/pu/multiarchive-2:
  dak/make_pkg_file_mapping.py: update for multi-archive changes

Signed-off-by: Joerg Jaspert <joerg@debian.org>
dak/make_pkg_file_mapping.py

index c457820fc0faf53d1e0e53dcbb3bc80e80832313..175376709a14405dcafb737eb8f375fd389141ed 100755 (executable)
@@ -31,11 +31,13 @@ and binary package version it has in a standard rfc2822-like format.
 
 ################################################################################
 
+import sys
+
 from daklib.dbconn import *
 
 ################################################################################
 
-def build_mapping():
+def build_mapping(archive, session):
     # The ORDER BY is in the queries so that compression of the output works
     # better.  It's the difference between a 9 megabyte bzip2 and a 2.5 mb
     # bzip2 file.
@@ -44,10 +46,13 @@ def build_mapping():
     SELECT
         source.source,
         source.version,
-        './pool/' || files.filename AS path
+        './pool/' || component.name || '/' || files.filename AS path
     FROM source
       JOIN dsc_files ON source.id=dsc_files.source
       JOIN files ON files.id=dsc_files.file
+      JOIN files_archive_map ON files.id = files_archive_map.file_id
+      JOIN component ON files_archive_map.component_id = component.id
+    WHERE files_archive_map.archive_id = :archive_id
     ORDER BY source, version
     """
 
@@ -56,26 +61,27 @@ def build_mapping():
         source.source,
         source.version,
         architecture.arch_string AS arch,
-        './pool/' || files.filename AS path,
+        './pool/' || component.name || '/' || files.filename AS path,
         binaries.package,
         binaries.version AS bin_version
     FROM source
       JOIN binaries ON source.id=binaries.source
       JOIN files ON binaries.file=files.id
+      JOIN files_archive_map ON files.id = files_archive_map.file_id
+      JOIN component ON files_archive_map.component_id = component.id
       JOIN architecture ON architecture.id=binaries.architecture
+    WHERE files_archive_map.archive_id = :archive_id
     ORDER BY source, version, package, bin_version
     """
 
-    session = DBConn().session()
-
-    for row in session.execute(query_sources).fetchall():
+    for row in session.execute(query_sources, {'archive_id': archive.archive_id}).fetchall():
         (source, version, path) = row
         print "Path: %s"%path
         print "Source: %s"%source
         print "Source-Version: %s"%version
         print
 
-    for row in session.execute(query_binaries).fetchall():
+    for row in session.execute(query_binaries, {'archive_id': archive.archive_id}).fetchall():
         (source, version, arch, path, bin, binv) = row
         print "Path: %s"%path
         print "Source: %s"%source
@@ -87,9 +93,21 @@ def build_mapping():
 
 ################################################################################
 
+def usage():
+    print "usage: dak make-pkg-file-mapping <archive>"
+    sys.exit(0)
+
+################################################################################
+
 def main():
-    DBConn()
-    build_mapping()
+    if len(sys.argv) != 2:
+        usage()
+
+    archive_name = sys.argv[1]
+
+    session = DBConn().session()
+    archive = session.query(Archive).filter_by(archive_name=archive_name).one()
+    build_mapping(archive, session)
 
 #########################################################################################