]> git.decadent.org.uk Git - dak.git/blobdiff - dak/auto_decruft.py
auto-decruft: Fix wording of removal message
[dak.git] / dak / auto_decruft.py
index 159ca3599b99cb4b0b2a937c88d8e5e24de2cc87..5de8782167d4750d2403da68b61eab674be8d83b 100644 (file)
@@ -68,14 +68,13 @@ def remove_sourceless_cruft(suite_name, suite_id, session, dryrun):
     @param session: The database session in use
 
     @type dryrun: bool
-    @param dryrun: If True, just to print the actions rather than actually doing them
+    @param dryrun: If True, just print the actions rather than actually doing them
     """""
     global Options
     rows = query_without_source(suite_id, session)
     arch_all_id = get_architecture('all', session=session)
 
-
-    message = '[auto-cruft] no longer built from source and no reverse dependencies'
+    message = '[auto-cruft] no longer built from source, no reverse dependencies'
     for row in rows:
         package = row[0]
         if utils.check_reverse_depends([package], suite_name, [], session, cruft=True, quiet=True):
@@ -110,7 +109,7 @@ def removeNBS(suite_name, suite_id, session, dryrun):
     @param session: The database session in use
 
     @type dryrun: bool
-    @param dryrun: If True, just to print the actions rather than actually doing them
+    @param dryrun: If True, just print the actions rather than actually doing them
     """""
     global Options
     rows = queryNBS(suite_id, session)
@@ -120,7 +119,7 @@ def removeNBS(suite_name, suite_id, session, dryrun):
         if utils.check_reverse_depends(pkg_list, suite_name, arch_list, session, cruft=True, quiet=True):
             continue
         arch_string = ','.join(arch_list)
-        message = '[auto-cruft] NBS (no longer built by %s and had no reverse dependencies)' % source
+        message = '[auto-cruft] NBS (no longer built by %s, no reverse dependencies)' % source
 
         if dryrun:
             # Embed the -R just in case someone wants to run it manually later
@@ -131,17 +130,20 @@ def removeNBS(suite_name, suite_id, session, dryrun):
             for architecture in arch_list:
                 if architecture in arch2ids:
                     arch2ids[architecture] = utils.get_architecture(architecture, session=session)
-            arch_ids = ", ".join(arch2ids[architecture] for architecture in arch_list)
-            pkg_db_set = ", ".join('"%s"' % package for package in pkg_list)
-            # TODO: Fix this properly to remove the remaining non-bind arguments
+            arch_ids = tuple(arch2ids[architecture] for architecture in arch_list)
+            params = {
+                suite_id: suite_id,
+                arch_ids: arch2ids,
+                pkg_list: tuple(pkg_list),
+            }
             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
-            WHERE a.id IN (%s) AND b.package IN (%s) AND su.id = :suite_id
-            """ % (arch_ids, pkg_db_set), { suite_id: suite_id})
+            WHERE a.id IN :arch_ids AND b.package IN :pkg_db_set AND su.id = :suite_id
+            """, params)
             remove(session, message, [suite_name], list(q), partial=True, whoami="DAK's auto-decrufter")
 
 ################################################################################