Skip to contentSkip to conversation

package_manager.py: Fix race condition in OpkgIndexer.write_index()

PATCH New [email protected] 1 participant 1 message Mar 11, 2016 1 message not in the archive

lore
Share & tools
lore
#1 lore raw

PATCH 1/1 package_manager.py: Fix race condition in OpkgIndexer.write_index()

In reply to a message not in the archive

From: Mariano Lopez <[email protected]>

When writing the index using ipk packages there could be a race condition when populate the index. This happens because the architectures are repeated (specially all) and the commands generated to write the index run in parallel.

This change avoid the duplication of commands using a set instead of a list.

[YOCTO #8924]

---
 meta/lib/oe/package_manager.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/lib/oe/package_manager.py +2 -2
index b701b8c..fe3f8c5 100644
@@ -157,7 +157,7 @@ class OpkgIndexer(Indexer):
         if not os.path.exists(os.path.join(self.deploy_dir, "Packages")):
             open(os.path.join(self.deploy_dir, "Packages"), "w").close()
 
-        index_cmds = []
+        index_cmds = set()
         for arch_var in arch_vars:
             archs = self.d.getVar(arch_var, True)
             if archs is None:
@@ -173,7 +173,7 @@ class OpkgIndexer(Indexer):
                 if not os.path.exists(pkgs_file):
                     open(pkgs_file, "w").close()
 
-                index_cmds.append('%s -r %s -p %s -m %s' %
+                index_cmds.add('%s -r %s -p %s -m %s' %
                                   (opkg_index_cmd, pkgs_file, pkgs_file, pkgs_dir))
 
         if len(index_cmds) == 0:
Signature · 1 line
2.6.2