]> git.decadent.org.uk Git - dak.git/blobdiff - dak/auto_decruft.py
Merge remote-tracking branch 'jcristau/cs-set-log-suite'
[dak.git] / dak / auto_decruft.py
index 6157a4f3c9a7f9f74de35849627ff592013977ab..66479a47fd863f155257a37c9d3bfdf61c9d7bdd 100644 (file)
@@ -76,7 +76,8 @@ def compute_sourceless_groups(suite_id, session):
     """""
     rows = query_without_source(suite_id, session)
     message = '[auto-cruft] no longer built from source, no reverse dependencies'
-    arch_all_id_tuple = tuple([get_architecture('all', session=session)])
+    arch = get_architecture('all', session=session)
+    arch_all_id_tuple = tuple([arch.arch_id])
     arch_all_list = ["all"]
     for row in rows:
         package = row[0]
@@ -218,15 +219,15 @@ def auto_decruft_suite(suite_name, suite_id, session, dryrun, debug):
     )
     for group in group_generator:
         group_name = group["name"]
+        pkgs = group["packages"]
+        affected_archs = group["architectures"]
+        # If we remove an arch:all package, then the breakage can occur on any
+        # of the architectures.
+        if "all" in affected_archs:
+            affected_archs = all_architectures
+        for pkg_arch in product(pkgs, affected_archs):
+            pkg_arch2groups[pkg_arch].add(group_name)
         if group_name not in groups:
-            pkgs = group["packages"]
-            affected_archs = group["architectures"]
-            # If we remove an arch:all package, then the breakage can occur on any
-            # of the architectures.
-            if "all" in affected_archs:
-                affected_archs = all_architectures
-            for pkg_arch in product(pkgs, affected_archs):
-                pkg_arch2groups[pkg_arch].add(group_name)
             groups[group_name] = group
             group_order.append(group_name)
         else:
@@ -358,20 +359,17 @@ def sources2removals(source_list, suite_id, session):
     params = {"suite_id": suite_id, "sources": tuple(source_list)}
     q = session.execute("""
                     SELECT s.source, s.version, 'source', s.id
-                    FROM source s,
+                    FROM source s
                          JOIN src_associations sa ON sa.source = s.id
-                         JOIN suite su ON sa.suite = su.id
-                    WHERE su.id = :suite_id AND s.source IN :sources""", params)
+                    WHERE sa.suite = :suite_id AND s.source IN :sources""", params)
     to_remove.extend(q)
     q = session.execute("""
                     SELECT b.package, b.version, a.arch_string, b.id
                     FROM binaries b
                          JOIN bin_associations ba ON b.id = ba.bin
                          JOIN architecture a ON b.architecture = a.id
-                         JOIN suite su ON ba.suite = su.id
                          JOIN source s ON b.source = s.id
-                         JOIN src_associations sa ON s.id = sa.source AND sa.suite = su.id
-                    WHERE su.id = :suite_id AND s.source IN :sources""", params)
+                    WHERE ba.suite = :suite_id AND s.source IN :sources""", params)
     to_remove.extend(q)
     return to_remove
 
@@ -416,8 +414,9 @@ def main ():
                  ('n',"dry-run","Auto-Decruft::Options::Dry-Run"),
                  ('d',"debug","Auto-Decruft::Options::Debug"),
                  ('s',"suite","Auto-Decruft::Options::Suite","HasArg"),
-                 ('z','if-newer-version-in',"Auto-Decruft::Options::OtherSuite", "HasArg"),
-                 ('Z','if-newer-version-in-rm-msg',"Auto-Decruft::Options::OtherSuiteRMMsg", "HasArg")]
+                 # The "\0" seems to be the only way to disable short options.
+                 ("\0",'if-newer-version-in',"Auto-Decruft::Options::OtherSuite", "HasArg"),
+                 ("\0",'if-newer-version-in-rm-msg',"Auto-Decruft::Options::OtherSuiteRMMsg", "HasArg")]
     for i in ["help", "Dry-Run", "Debug", "OtherSuite", "OtherSuiteRMMsg"]:
         if not cnf.has_key("Auto-Decruft::Options::%s" % (i)):
             cnf["Auto-Decruft::Options::%s" % (i)] = ""
@@ -455,6 +454,9 @@ def main ():
         osuite = get_suite(Options["OtherSuite"].lower(), session).suite_name
         decruft_newer_version_in(osuite, suite_name, suite_id, Options["OtherSuiteRMMsg"], session, dryrun)
 
+    if not dryrun:
+        session.commit()
+
 ################################################################################
 
 if __name__ == '__main__':