]> git.decadent.org.uk Git - dak.git/blobdiff - dak/generate_packages_sources2.py
Replace os.popen with the subprocess.Popen in a few places.
[dak.git] / dak / generate_packages_sources2.py
index f709e806f3492f0b8caae6d9352c02d6bb066db5..3b58217a271df20671af2d9cf949cacbb097e64b 100755 (executable)
@@ -34,6 +34,7 @@ def usage():
     print """Usage: dak generate-packages-sources2 [OPTIONS]
 Generate the Packages/Sources files
 
+  -a, --archive=ARCHIVE        process suites in ARCHIVE
   -s, --suite=SUITE            process this suite
                                Default: All suites not marked 'untouchable'
   -f, --force                  Allow processing of untouchable suites
@@ -66,24 +67,35 @@ SELECT
    WHERE s.id=sm.src_id
   )
   ||
+  CASE
+    WHEN src_associations_full.extra_source THEN E'\nExtra-Source-Only\: yes'
+    ELSE ''
+  END
+  ||
   E'\nDirectory\: pool/' || :component_name || '/' || SUBSTRING(f.filename FROM E'\\A(.*)/[^/]*\\Z')
   ||
-  E'\nPriority\: ' || pri.priority
+  E'\nPriority\: ' || COALESCE(pri.priority, 'extra')
   ||
-  E'\nSection\: ' || sec.section
+  E'\nSection\: ' || COALESCE(sec.section, 'misc')
 
 FROM
 
 source s
-JOIN src_associations sa ON s.id = sa.source
+JOIN src_associations_full ON src_associations_full.suite = :suite AND s.id = src_associations_full.source
 JOIN files f ON s.file=f.id
-JOIN override o ON o.package = s.source
-JOIN section sec ON o.section = sec.id
-JOIN priority pri ON o.priority = pri.id
+JOIN files_archive_map fam
+  ON fam.file_id = f.id
+     AND fam.archive_id = (SELECT archive_id FROM suite WHERE id = :suite)
+     AND fam.component_id = :component
+LEFT JOIN override o ON o.package = s.source
+                     AND o.suite = :overridesuite
+                     AND o.component = :component
+                     AND o.type = :dsc_type
+LEFT JOIN section sec ON o.section = sec.id
+LEFT JOIN priority pri ON o.priority = pri.id
 
 WHERE
-  sa.suite = :suite
-  AND o.suite = :overridesuite AND o.component = :component AND o.type = :dsc_type
+  (src_associations_full.extra_source OR o.suite IS NOT NULL)
 
 ORDER BY
 s.source, s.version
@@ -311,6 +323,7 @@ def main():
     cnf = Config()
 
     Arguments = [('h',"help","Generate-Packages-Sources::Options::Help"),
+                 ('a','archive','Generate-Packages-Sources::Options::Archive','HasArg'),
                  ('s',"suite","Generate-Packages-Sources::Options::Suite"),
                  ('f',"force","Generate-Packages-Sources::Options::Force"),
                  ('o','option','','ArbItem')]
@@ -329,7 +342,7 @@ def main():
 
     logger = daklog.Logger('generate-packages-sources2')
 
-    from daklib.dbconn import Component, DBConn, get_suite, Suite
+    from daklib.dbconn import Component, DBConn, get_suite, Suite, Archive
     session = DBConn().session()
     session.execute("SELECT add_missing_description_md5()")
     session.commit()
@@ -344,11 +357,13 @@ def main():
                 print "I: Cannot find suite %s" % s
                 logger.log(['Cannot find suite %s' % s])
     else:
-        suites = session.query(Suite).filter(Suite.untouchable == False).all()
+        query = session.query(Suite).filter(Suite.untouchable == False)
+        if 'Archive' in Options:
+            query = query.join(Suite.archive).filter(Archive.archive_name==Options['Archive'])
+        suites = query.all()
 
     force = Options.has_key("Force") and Options["Force"]
 
-    component_ids = [ c.component_id for c in session.query(Component).all() ]
 
     def parse_results(message):
         # Split out into (code, msg)
@@ -361,9 +376,10 @@ def main():
             logger.log(['E: ', msg])
 
     for s in suites:
+        component_ids = [ c.component_id for c in s.components ]
         if s.untouchable and not force:
-            import utils
-            utils.fubar("Refusing to touch %s (untouchable and not forced)" % s.suite_name)
+            import daklib.utils
+            daklib.utils.fubar("Refusing to touch %s (untouchable and not forced)" % s.suite_name)
         for c in component_ids:
             pool.apply_async(generate_sources, [s.suite_id, c], callback=parse_results)
             if not s.include_long_description: