All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maxim Uvarov <maxim.uvarov@linaro.org>
To: openembedded-core@lists.openembedded.org
Subject: [PATCHv2] wic: fix images build in parallel
Date: Mon, 13 Jan 2020 16:08:27 +0300	[thread overview]
Message-ID: <20200113130827.7409-1-maxim.uvarov@linaro.org> (raw)

OE wic plugins create temporary file with the index of the line
tmp file name. This causes race in case several builds run in time.
Add more entropy as timestamp to remove this race.

Suggested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 v2: shortlog change to match template.

 scripts/lib/wic/plugins/source/bootimg-partition.py | 5 +++--
 scripts/lib/wic/plugins/source/bootimg-pcbios.py    | 3 ++-
 scripts/lib/wic/plugins/source/rawcopy.py           | 3 ++-
 scripts/lib/wic/plugins/source/rootfs.py            | 3 ++-
 4 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/scripts/lib/wic/plugins/source/bootimg-partition.py b/scripts/lib/wic/plugins/source/bootimg-partition.py
index 138986a71e..b6cea1096a 100644
--- a/scripts/lib/wic/plugins/source/bootimg-partition.py
+++ b/scripts/lib/wic/plugins/source/bootimg-partition.py
@@ -13,6 +13,7 @@
 import logging
 import os
 import re
+import time
 
 from glob import glob
 
@@ -38,7 +39,7 @@ class BootimgPartitionPlugin(SourcePlugin):
         """
         Called before do_prepare_partition(), create u-boot specific boot config
         """
-        hdddir = "%s/boot.%d" % (cr_workdir, part.lineno)
+        hdddir = "%s/boot.%d" % (cr_workdir, part.lineno, time.time())
         install_cmd = "install -d %s" % hdddir
         exec_cmd(install_cmd)
 
@@ -171,7 +172,7 @@ class BootimgPartitionPlugin(SourcePlugin):
         - sets up a vfat partition
         - copies all files listed in IMAGE_BOOT_FILES variable
         """
-        hdddir = "%s/boot.%d" % (cr_workdir, part.lineno)
+        hdddir = "%s/boot.%d_%s" % (cr_workdir, part.lineno, time.time())
 
         if not kernel_dir:
             kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
diff --git a/scripts/lib/wic/plugins/source/bootimg-pcbios.py b/scripts/lib/wic/plugins/source/bootimg-pcbios.py
index f2639e7004..8ac73c2067 100644
--- a/scripts/lib/wic/plugins/source/bootimg-pcbios.py
+++ b/scripts/lib/wic/plugins/source/bootimg-pcbios.py
@@ -13,6 +13,7 @@
 import logging
 import os
 import re
+import time
 
 from wic import WicError
 from wic.engine import get_custom_config
@@ -184,7 +185,7 @@ class BootimgPcbiosPlugin(SourcePlugin):
                      extra_blocks, part.mountpoint, blocks)
 
         # dosfs image, created by mkdosfs
-        bootimg = "%s/boot%s.img" % (cr_workdir, part.lineno)
+        bootimg = "%s/boot%s_%s.img" % (cr_workdir, part.lineno, time.time())
 
         dosfs_cmd = "mkdosfs -n boot -i %s -S 512 -C %s %d" % \
                     (part.fsuuid, bootimg, blocks)
diff --git a/scripts/lib/wic/plugins/source/rawcopy.py b/scripts/lib/wic/plugins/source/rawcopy.py
index 82970ce51b..9ada3d39c9 100644
--- a/scripts/lib/wic/plugins/source/rawcopy.py
+++ b/scripts/lib/wic/plugins/source/rawcopy.py
@@ -4,6 +4,7 @@
 
 import logging
 import os
+import time
 
 from wic import WicError
 from wic.pluginbase import SourcePlugin
@@ -57,7 +58,7 @@ class RawCopyPlugin(SourcePlugin):
             raise WicError("No file specified")
 
         src = os.path.join(kernel_dir, source_params['file'])
-        dst = os.path.join(cr_workdir, "%s.%s" % (source_params['file'], part.lineno))
+        dst = os.path.join(cr_workdir, "%s.%s_%s" % (source_params['file'], part.lineno, time.time()))
 
         if not os.path.exists(os.path.dirname(dst)):
             os.makedirs(os.path.dirname(dst))
diff --git a/scripts/lib/wic/plugins/source/rootfs.py b/scripts/lib/wic/plugins/source/rootfs.py
index 705aeb5563..37ebee89ea 100644
--- a/scripts/lib/wic/plugins/source/rootfs.py
+++ b/scripts/lib/wic/plugins/source/rootfs.py
@@ -15,6 +15,7 @@ import logging
 import os
 import shutil
 import sys
+import time
 
 from oe.path import copyhardlinktree
 
@@ -74,7 +75,7 @@ class RootfsPlugin(SourcePlugin):
         if part.exclude_path or part.include_path:
             # We need a new rootfs directory we can delete files from. Copy to
             # workdir.
-            new_rootfs = os.path.realpath(os.path.join(cr_workdir, "rootfs%d" % part.lineno))
+            new_rootfs = os.path.realpath(os.path.join(cr_workdir, "rootfs%d_%s" % (part.lineno, time.time())))
 
             if os.path.lexists(new_rootfs):
                 shutil.rmtree(os.path.join(new_rootfs))
-- 
2.17.1



             reply	other threads:[~2020-01-13 13:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-13 13:08 Maxim Uvarov [this message]
2020-01-13 13:31 ` [PATCHv2] wic: fix images build in parallel Paul Barker
2020-01-13 13:57   ` Maxim Uvarov
2020-01-13 14:00     ` Paul Barker
2020-01-13 14:11       ` Maxim Uvarov
2020-01-17 10:18         ` Paul Barker
2020-01-17 11:59           ` Maxim Uvarov
2020-01-17 12:17             ` Paul Barker
2020-01-17 12:27               ` Paul Barker
2020-01-17 12:39                 ` Maxim Uvarov
2020-01-17 21:26                   ` Maxim Uvarov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200113130827.7409-1-maxim.uvarov@linaro.org \
    --to=maxim.uvarov@linaro.org \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.