[Git][haskell-team/tools][master] 2 commits: transition: Retry bts commands

Ilias Tsitsimpis (@iliastsi) gitlab at salsa.debian.org
Sat Feb 14 20:42:09 GMT 2026



Ilias Tsitsimpis pushed to branch master at Debian Haskell Group / tools


Commits:
afc047af by Ilias Tsitsimpis at 2026-01-25T20:39:00+02:00
transition: Retry bts commands

- - - - -
0a5980ce by Ilias Tsitsimpis at 2026-01-25T20:51:52+02:00
transition: Support multiple version of the same binary package

- - - - -


1 changed file:

- transition.py


Changes:

=====================================
transition.py
=====================================
@@ -19,7 +19,9 @@ import apt_pkg
 import logging
 import argparse
 import requests
-from subprocess import check_output
+import subprocess
+import tenacity
+
 try:
     from functools import cached_property
 except Exception:
@@ -46,22 +48,20 @@ DHG_SOURCES_IGNORE = ["diffoscope",
                       "nginx-confgen",
                       "dh-runit",
                       "pkg-haskell-tools",
-                      "pandoc"
+                      "pandoc",
+                      "ganeti",
                       ]
 # Ignore these binary packages. This may be because:
 # - They provide modules that are now available in GHC.
 # - They are causing other problems, and not managed by us.
-DHG_BINARIES_IGNORE = ["ganeti-htools",
-                       "libghc-exceptions-dev",
-                       "libghc-exceptions-doc",
-                       "libghc-exceptions-prof",
+DHG_BINARIES_IGNORE = ["libghc-os-string-dev",
+                       "libghc-os-string-doc",
+                       "libghc-os-string-prof",
                        ]
 
 # Parse these packages (e.g., retrieve their dependencies etc)
 # but don't perform any actions on them.
-DHG_SOURCES_NO_ACTION = ["ghc",
-                         "ganeti",
-                         ]
+DHG_SOURCES_NO_ACTION = ["ghc"]
 
 # These binary packages don't have a proper Provides/Ghc-Package field
 DHG_BINARIES_PROVIDES_IGNORE = [
@@ -70,6 +70,17 @@ DHG_BINARIES_PROVIDES_IGNORE = [
     "haskell-platform-prof"
 ]
 
+# This configures the retry logic:
+# 1. Stop after 3 attemps
+# 2. Wait 1 second between attemps
+# 3. Only retry if the error is a CalledProcessError
+ at tenacity.retry(
+    stop=tenacity.stop_after_attempt(3),
+    wait=tenacity.wait_fixed(1),
+    retry=tenacity.retry_if_exception_type(subprocess.CalledProcessError))
+def run_command(cmd):
+    return subprocess.check_output(cmd, text=True)
+
 
 class DHGPackages(object):
     def __init__(self, srcf, pkgf, excf, repos):
@@ -199,11 +210,30 @@ class DHGPackages(object):
 
         binary = DHGBinary(self, bindict)
 
-        assert binary.name not in self.binaries, binary.name
-        self.binaries[binary.name] = binary
-        for p in binary.provides:
-            assert p not in self.binaries, p
-            self.binaries[p] = binary
+        add_binary_to_cache = True
+
+        if binary.name in self.binaries:
+            log.debug("Double entry for '%s' binary package", binary.name)
+            old_binary = self.binaries[binary.name]
+            if apt_pkg.version_compare(binary.version, old_binary.version) < 0:
+                add_binary_to_cache = False
+
+        if add_binary_to_cache:
+            self.binaries[binary.name] = binary
+            # Populate package-plan properties
+            if "Ghc-Package" in bindict:
+                pname, pver, _ = bindict["Ghc-Package"].rsplit("-", 2)
+                self.pplan[pname] = {"debian_version": pver}
+                binary.source.pplan = self.pplan[pname]
+            elif binary.name in DHG_BINARIES_PROVIDES_IGNORE:
+                pass
+            elif binary.name.endswith("-dev"):
+                log.warning("Binary package '%s' doesn't have a Ghc-Package field",
+                            binary.name)
+
+            # Add virtual packages
+            for p in binary.provides:
+                self.binaries[p] = binary
 
     def actions(self, args):
         log.info("Evaluating available actions...")
@@ -219,11 +249,11 @@ class DHGPackages(object):
         cmd = ["bts", "select",
                "maintainer:pkg-haskell-maintainers at lists.alioth.debian.org",
                "user:lucas at debian.org", "tag:ftbfs-source-after-build"]
-        bugs = set(check_output(cmd, text=True).split())
+        bugs = set(run_command(cmd).split())
         cmd = ["bts", "select",
                "maintainer:pkg-haskell-maintainers at lists.alioth.debian.org",
                "user:lucas at debian.org", "tag:ftbfs-binary-after-build"]
-        bugs.update(set(check_output(cmd, text=True).split()))
+        bugs.update(set(run_command(cmd).split()))
         return bugs
 
 
@@ -352,7 +382,7 @@ class DHGSource(object):
 
     def get_bugs(self):
         cmd = ["bts", "select", "source:%s" % self.name]
-        bugs = check_output(cmd, text=True)
+        bugs = run_command(cmd)
         bugs = set(bugs.split())
         return bugs - self.packages.ignored_bugs
 
@@ -503,18 +533,6 @@ class DHGBinary(object):
                           if "ghc" in d or "haddock" in d]
         self._missing_deps = []
 
-        # Populate package-plan properties
-        if "Ghc-Package" in bindict:
-            pname, pver, _ = bindict["Ghc-Package"].rsplit("-", 2)
-            assert pname not in self.packages.pplan, pname
-            self.packages.pplan[pname] = {"debian_version": pver}
-            self.source.pplan = self.packages.pplan[pname]
-        elif self.name in DHG_BINARIES_PROVIDES_IGNORE:
-            pass
-        elif self.name.endswith("-dev"):
-            log.warning("Binary package '%s' doesn't have a Ghc-Package field",
-                        self.name)
-
     def __eq__(self, other):
         return (self.name == other.name and self.version == other.version)
 



View it on GitLab: https://salsa.debian.org/haskell-team/tools/-/compare/457f634ca479785648019c0ed74899cdca14955e...0a5980ceb0fe383e2a6aa1f63bc72be5f1e26ddd

-- 
View it on GitLab: https://salsa.debian.org/haskell-team/tools/-/compare/457f634ca479785648019c0ed74899cdca14955e...0a5980ceb0fe383e2a6aa1f63bc72be5f1e26ddd
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-haskell-commits/attachments/20260214/fa84eaa6/attachment-0001.htm>


More information about the Pkg-haskell-commits mailing list