summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLee Chee Yang <chee.yang.lee@intel.com>2020-07-23 09:16:13 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-07-31 22:02:52 +0100
commitbb048311202b2de473ded6ac48b2264fec45c8f1 (patch)
treeee57f6a58d8fd23c236c31ab2d31477c46eb3097
parent37657703e1ade4088c7c731eec2861f3388cb641 (diff)
downloadpoky-bb048311202b2de473ded6ac48b2264fec45c8f1.tar.gz
buildhistory: use pid for temporary txt file name
buildhistory create .txt file bh_installed_pkgs.txt and bh_installed_pkgs_deps.txt while listing down installed package. These file is later removed in buildhistory_get_installed(). when multiple process runs in parellal there are chances to race for the file where one process created the file while another task remove the file right after it. using different file name for each process should avoid the race. So add PID to the file name to make it unique. [yocto #13709] (From OE-Core rev: af8f5fe82f27702ad727b27daefd5e97d9e64efa) Signed-off-by: Lee Chee Yang <chee.yang.lee@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 214d236d93700abffa2d586cc744a00455818fa4) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/buildhistory.bbclass11
1 files changed, 6 insertions, 5 deletions
diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass
index eb7295570d..156324d339 100644
--- a/meta/classes/buildhistory.bbclass
+++ b/meta/classes/buildhistory.bbclass
@@ -426,8 +426,8 @@ def buildhistory_list_installed(d, rootfs_type="image"):
426 from oe.sdk import sdk_list_installed_packages 426 from oe.sdk import sdk_list_installed_packages
427 from oe.utils import format_pkg_list 427 from oe.utils import format_pkg_list
428 428
429 process_list = [('file', 'bh_installed_pkgs.txt'),\ 429 process_list = [('file', 'bh_installed_pkgs_%s.txt' % os.getpid()),\
430 ('deps', 'bh_installed_pkgs_deps.txt')] 430 ('deps', 'bh_installed_pkgs_deps_%s.txt' % os.getpid())]
431 431
432 if rootfs_type == "image": 432 if rootfs_type == "image":
433 pkgs = image_list_installed_packages(d) 433 pkgs = image_list_installed_packages(d)
@@ -457,9 +457,10 @@ buildhistory_get_installed() {
457 457
458 # Get list of installed packages 458 # Get list of installed packages
459 pkgcache="$1/installed-packages.tmp" 459 pkgcache="$1/installed-packages.tmp"
460 cat ${WORKDIR}/bh_installed_pkgs.txt | sort > $pkgcache && rm ${WORKDIR}/bh_installed_pkgs.txt 460 cat ${WORKDIR}/bh_installed_pkgs_${PID}.txt | sort > $pkgcache && rm ${WORKDIR}/bh_installed_pkgs_${PID}.txt
461 461
462 cat $pkgcache | awk '{ print $1 }' > $1/installed-package-names.txt 462 cat $pkgcache | awk '{ print $1 }' > $1/installed-package-names.txt
463
463 if [ -s $pkgcache ] ; then 464 if [ -s $pkgcache ] ; then
464 cat $pkgcache | awk '{ print $2 }' | xargs -n1 basename > $1/installed-packages.txt 465 cat $pkgcache | awk '{ print $2 }' | xargs -n1 basename > $1/installed-packages.txt
465 else 466 else
@@ -468,8 +469,8 @@ buildhistory_get_installed() {
468 469
469 # Produce dependency graph 470 # Produce dependency graph
470 # First, quote each name to handle characters that cause issues for dot 471 # First, quote each name to handle characters that cause issues for dot
471 sed 's:\([^| ]*\):"\1":g' ${WORKDIR}/bh_installed_pkgs_deps.txt > $1/depends.tmp && 472 sed 's:\([^| ]*\):"\1":g' ${WORKDIR}/bh_installed_pkgs_deps_${PID}.txt > $1/depends.tmp &&
472 rm ${WORKDIR}/bh_installed_pkgs_deps.txt 473 rm ${WORKDIR}/bh_installed_pkgs_deps_${PID}.txt
473 # Remove lines with rpmlib(...) and config(...) dependencies, change the 474 # Remove lines with rpmlib(...) and config(...) dependencies, change the
474 # delimiter from pipe to "->", set the style for recommend lines and 475 # delimiter from pipe to "->", set the style for recommend lines and
475 # turn versioned dependencies into edge labels. 476 # turn versioned dependencies into edge labels.