diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2015-02-28 09:25:27 +0100 |
---|---|---|
committer | Michael Olbrich <m.olbrich@pengutronix.de> | 2015-02-28 09:50:51 +0100 |
commit | 4069b7ff2b042f3a01d2bb2534c7944379547c5e (patch) | |
tree | a3e09b0462ebf4882eac85225015f011179350b3 /scripts/lib/ptxd_make_world_install.sh | |
parent | c0eeac2770f0ea52ab2c5a45dde8034dd2352a8f (diff) | |
download | ptxdist-4069b7ff2b042f3a01d2bb2534c7944379547c5e.tar.gz ptxdist-4069b7ff2b042f3a01d2bb2534c7944379547c5e.tar.xz |
ptxd_make_world_install_post: fix race condition
Just copying ${pkg_pkg_dir} recursively can fail. This can happen with -jeX
when 'cp' is executed for two packages the same time: 'cp' first checks if a
directory exists, and creates it if not. If two instances of 'cp' try this with
the same directory at the same time, there is a race condition and the second
'cp' may fail to create the directory because it already exists.
Avoid this by creating the directories first. 'mkdir -p' will just try to
create the directories and ignores any EEXIST.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'scripts/lib/ptxd_make_world_install.sh')
-rw-r--r-- | scripts/lib/ptxd_make_world_install.sh | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/scripts/lib/ptxd_make_world_install.sh b/scripts/lib/ptxd_make_world_install.sh index 59711c206..13e73dfd1 100644 --- a/scripts/lib/ptxd_make_world_install.sh +++ b/scripts/lib/ptxd_make_world_install.sh @@ -180,7 +180,10 @@ ptxd_make_world_install_post() { fi done && - cp -dprf -- "${pkg_pkg_dir}"/* "${pkg_sysroot_dir}" + # create directories first to avoid race contitions with -jeX + find "${pkg_pkg_dir}" -type d -printf "%P\0" | \ + xargs -0 -I{} mkdir -p "${pkg_sysroot_dir}/{}" && + cp -dprf -- "${pkg_pkg_dir}"/* "${pkg_sysroot_dir}" && # host and cross packages if [ "${pkg_type}" != "target" ]; then |