]> git.decadent.org.uk Git - dak.git/blobdiff - daklib/rm.py
Add by-hash support
[dak.git] / daklib / rm.py
index 00643b1e5f1b09a850ba53f76c761718810e11e6..1e523d2e0a0dc4662bc90452fe24232c0b47f421 100644 (file)
@@ -350,6 +350,7 @@ def remove(session, reason, suites, removals,
     binaries = []
     whitelists = []
     versions = []
+    newest_source = ''
     suite_ids_list = []
     suites_list = utils.join_with_commas_and(suites)
     cnf = utils.get_conf()
@@ -372,7 +373,7 @@ def remove(session, reason, suites, removals,
     if date is None:
         date = commands.getoutput("date -R")
 
-    if partial:
+    if partial and components:
 
         component_ids_list = []
         for componentname in components:
@@ -400,6 +401,8 @@ def remove(session, reason, suites, removals,
         for version in versions:
             d[package][version].sort(utils.arch_compare_sw)
             summary += "%10s | %10s | %s\n" % (package, version, ", ".join(d[package][version]))
+            if apt_pkg.version_compare(version, newest_source) > 0:
+                newest_source = version
 
     for package in summary.split("\n"):
         for row in package.split("\n"):
@@ -465,7 +468,7 @@ def remove(session, reason, suites, removals,
                     session.execute("DELETE FROM bin_associations WHERE bin = :packageid AND suite = :suiteid",
                                     {'packageid': package_id, 'suiteid': suite_id})
                 # Delete from the override file
-                if partial:
+                if not partial:
                     if architecture == "source":
                         type_id = dsc_type_id
                     else:
@@ -527,13 +530,19 @@ def remove(session, reason, suites, removals,
             Subst_close_other = Subst_common
             bcc = []
             wnpp = utils.parse_wnpp_bug_file()
-            versions = list(set([re_bin_only_nmu.sub('', v) for v in versions]))
-            if len(versions) == 1:
-                Subst_close_other["__VERSION__"] = versions[0]
+            newest_source = re_bin_only_nmu.sub('', newest_source)
+            if len(set(s.split("_", 1)[0] for s in sources)) == 1:
+                source_pkg = source.split("_", 1)[0]
+            else:
+                logfile.write("=========================================================================\n")
+                logfile822.write("\n")
+                raise ValueError("Closing bugs for multiple source packages is not supported.  Please do it yourself.")
+            if newest_source != '':
+                Subst_close_other["__VERSION__"] = newest_source
             else:
                 logfile.write("=========================================================================\n")
                 logfile822.write("\n")
-                raise ValueError("Closing bugs with multiple package versions is not supported.  Do it yourself.")
+                raise ValueError("No versions can be found. Close bugs yourself.")
             if bcc:
                 Subst_close_other["__BCC__"] = "Bcc: " + ", ".join(bcc)
             else:
@@ -541,12 +550,6 @@ def remove(session, reason, suites, removals,
             # at this point, I just assume, that the first closed bug gives
             # some useful information on why the package got removed
             Subst_close_other["__BUG_NUMBER__"] = done_bugs[0]
-            if len(sources) == 1:
-                source_pkg = source.split("_", 1)[0]
-            else:
-                logfile.write("=========================================================================\n")
-                logfile822.write("\n")
-                raise ValueError("Closing bugs for multiple source packages is not supported.  Please do it yourself.")
             Subst_close_other["__BUG_NUMBER_ALSO__"] = ""
             Subst_close_other["__SOURCE__"] = source_pkg
             merged_bugs = set()
@@ -585,6 +588,3 @@ def remove(session, reason, suites, removals,
 
         logfile.write("=========================================================================\n")
         logfile822.write("\n")
-
-        fcntl.lockf(logfile822, fcntl.LOCK_UN)
-        fcntl.lockf(logfile, fcntl.LOCK_UN)