Skip to contentSkip to conversation

add_tasks: use sets to dedup from debug output

PATCH New Yann Dirson 1 participant 3 messages Apr 13

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 add_tasks: use sets to dedup from debug output

When packages appear multiple times it gets hard to make any sense of the list display. Using sets does the job for us.

---
 lib/bb/taskdata.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/bb/taskdata.py +4 -4
index 66545a65a..b40afc02b 100644
@@ -138,15 +138,15 @@ class TaskData:
             rdependids = set()
             rdepends = dataCache.rundeps[fn]
             rrecs = dataCache.runrecs[fn]
-            rdependlist = []
-            rreclist = []
+            rdependlist = set()
+            rreclist = set()
             for package in rdepends:
                 for rdepend in rdepends[package]:
-                    rdependlist.append(rdepend)
+                    rdependlist.add(rdepend)
                     rdependids.add(rdepend)
             for package in rrecs:
                 for rdepend in rrecs[package]:
-                    rreclist.append(rdepend)
+                    rreclist.add(rdepend)
                     rdependids.add(rdepend)
             if rdependlist:
                 logger.debug2("Added runtime dependencies %s for %s", str(rdependlist), fn)
Signature · 10 lines
2.47.3



--
 | Vates

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech
#1 lore raw

PATCH 2/3 RunQueueData.prepare: fix comment typos

---
 lib/bb/runqueue.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/bb/runqueue.py +2 -2
index a880a0d54..8aae4e290 100644
@@ -693,7 +693,7 @@ class RunQueueData:
         # To create the actual list of tasks to execute we fix the list of
         # providers and then resolve the dependencies into task IDs. This
         # process is repeated for each type of dependency (tdepends, deptask,
-        # rdeptast, recrdeptask, idepends).
+        # rdeptask, recrdeptask, idepends).
 
         def add_build_dependencies(depids, tasknames, depends, mc):
             for depname in depids:
@@ -841,7 +841,7 @@ class RunQueueData:
         # (makes sure sometask runs after someothertask of all DEPENDS, RDEPENDS and intertask dependencies, recursively)
         # We need to do this separately since we need all of runtaskentries[*].depends to be complete before this is processed
 
-        # Generating/interating recursive lists of dependencies is painful and potentially slow
+        # Generating/iterating recursive lists of dependencies is painful and potentially slow
         # Precompute recursive task dependencies here by:
         #     a) create a temp list of reverse dependencies (revdeps)
         #     b) walk up the ends of the chains (when a given task no longer has dependencies i.e. len(deps) == 0)
Signature · 10 lines
2.47.3



--
Yann Dirson | Vates Platform Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech
#2 lore raw

PATCH 3/3 goh1_file: deal with false positives from is_zipfile

In reply to Yann Dirson

This function is known https://github.com/python/cpython/issues/72680 for false-positives. With python 3.13.5 there is one with
https://vault.almalinux.org/10.0/CRB/x86_64_v2/os/Packages/jdom2-2.0.6.1-8.el10.noarch.rpm

The double "is_zipfile = False" is redundant but likely more clear.

---
 lib/bb/utils.py | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
lib/bb/utils.py +12 -7
index 366836bfc..aeeb3f2ee 100644
@@ -694,14 +694,19 @@ def goh1_file(filename):
     import zipfile
 
     lines = []
+    is_zipfile = False
     if zipfile.is_zipfile(filename):
-        with zipfile.ZipFile(filename) as archive:
-            for fn in sorted(archive.namelist()):
-                method = hashlib.sha256()
-                method.update(archive.read(fn))
-                hash = method.hexdigest()
-                lines.append("%s  %s\n" % (hash, fn))
-    else:
+        try:
+            with zipfile.ZipFile(filename) as archive:
+                for fn in sorted(archive.namelist()):
+                    method = hashlib.sha256()
+                    method.update(archive.read(fn))
+                    hash = method.hexdigest()
+                    lines.append("%s  %s\n" % (hash, fn))
+            is_zipfile = True
+        except zipfile.BadZipFile:
+            is_zipfile = False
+    if not is_zipfile:
         hash = _hasher(hashlib.sha256(), filename)
         lines.append("%s  go.mod\n" % hash)
     method = hashlib.sha256()
Signature · 10 lines
2.47.3



--
Yann Dirson | Vates Platform Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech