depcheck.py: reduce use of BUILD_ARCH
authorHelmut Grohne <helmut@subdivi.de>
Mon, 5 Oct 2020 21:36:02 +0000 (23:36 +0200)
committerHelmut Grohne <helmut@subdivi.de>
Mon, 5 Oct 2020 21:39:16 +0000 (23:39 +0200)
depcheck.py

index 1069414..ad0a18d 100755 (executable)
@@ -330,17 +330,18 @@ def latest_versions(pkgs):
     return (p for p in packages.values()
             if "Package" in p and not "Negative-Entry" in p)
 
-def make_binary_list_build(mirror, arch):
-    for p in parse_deb822(mirror.fetch_binaries(BUILD_ARCH)):
+def make_binary_list_build(mirror, buildarch, hostarch):
+    for p in parse_deb822(mirror.fetch_binaries(buildarch)):
         if p["Package"].startswith("crossbuild-essential-"):
-            if p["Package"] != "crossbuild-essential-" + arch:
+            if p["Package"] != "crossbuild-essential-" + hostarch:
                 continue
-            p["Depends"] += ", libc-dev:%s, libstdc++-dev:%s" % (arch, arch)
+            p["Depends"] += ", libc-dev:%s, libstdc++-dev:%s" % \
+                    (hostarch, hostarch)
         strip_dict(p, binfields)
         yield p
 
-def make_binary_list_host(mirror, arch):
-    for p in parse_deb822(mirror.fetch_binaries(arch)):
+def make_binary_list_host(mirror, hostarch):
+    for p in parse_deb822(mirror.fetch_binaries(hostarch)):
         if p["Architecture"] == "all":
             continue
         if p.get("Multi-Arch") == "foreign":
@@ -352,15 +353,15 @@ def make_binary_list_host(mirror, arch):
         strip_dict(p, binfields)
         yield p
 
-def make_binary_list(mirror, arch):
-    return itertools.chain(make_binary_list_build(mirror, arch),
-                           make_binary_list_host(mirror, arch))
+def make_binary_list(mirror, buildarch, hostarch):
+    return itertools.chain(make_binary_list_build(mirror, buildarch, hostarch),
+                           make_binary_list_host(mirror, hostarch))
 
-def make_source_list(mirror, arch):
+def make_source_list(mirror, hostarch):
     for p in parse_deb822(mirror.fetch_sources()):
         if p.get("Extra-Source-Only") == "yes":
             continue
-        if any(arch_match(arch, pattern)
+        if any(arch_match(hostarch, pattern)
                for pattern in p["Architecture"].split()):
             strip_dict(p, srcfields)
             strip_alternatvies(p, srcdepfields)
@@ -370,10 +371,10 @@ def make_source_list(mirror, arch):
             yield {"Package": p["Package"], "Version": p["Version"],
                    "Negative-Entry": "yes"}
 
-def check_bdsat(mirror, arch):
+def check_bdsat(mirror, buildarch, hostarch):
     cmd = [
-        "--deb-native-arch=" + BUILD_ARCH,
-        "--deb-host-arch=" + arch,
+        "--deb-native-arch=" + buildarch,
+        "--deb-host-arch=" + hostarch,
         "--deb-drop-b-d-indep",
         "--deb-profiles=" + ",".join(PROFILES),
         "--successes",
@@ -386,12 +387,12 @@ def check_bdsat(mirror, arch):
     result = {}
     with tempfile.NamedTemporaryFile("w", encoding="utf8") as bintmp, \
             tempfile.NamedTemporaryFile("w", encoding="utf8") as srctmp:
-        for p in make_binary_list(mirror, arch):
+        for p in make_binary_list(mirror, buildarch, hostarch):
             bintmp.write(serialize_deb822(p))
         bintmp.flush()
         cmd.append(bintmp.name)
 
-        for p in latest_versions(make_source_list(mirror, arch)):
+        for p in latest_versions(make_source_list(mirror, hostarch)):
             srctmp.write(serialize_deb822(p))
         srctmp.flush()
         cmd.append(srctmp.name)
@@ -436,7 +437,7 @@ def update_depcheck(mirror, db, updatetime, architecture, state):
 
 
 def main_docheck(mirror, architecture):
-    return (architecture, check_bdsat(mirror, architecture))
+    return (architecture, check_bdsat(mirror, BUILD_ARCH, architecture))
 
 
 class SequentialPool: