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

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]

(From OE-Core rev: 74adb14b0002e20099cc2c34e01862e8ddb8e013)

Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Mariano Lopez 2016-03-11 07:29:17 +00:00 committed by Richard Purdie
parent 35be679513
commit 36bf66654a
1 changed files with 4 additions and 4 deletions

View File

@ -164,8 +164,8 @@ 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_sign_files = []
index_cmds = set()
index_sign_files = set()
for arch_var in arch_vars:
archs = self.d.getVar(arch_var, True)
if archs is None:
@ -181,10 +181,10 @@ 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))
index_sign_files.append(pkgs_file)
index_sign_files.add(pkgs_file)
if len(index_cmds) == 0:
bb.note("There are no packages in %s!" % self.deploy_dir)