diff options
author | Luis <luis.pinto.martins@gmail.com> | 2022-12-24 01:49:46 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-12-26 18:49:07 +0000 |
commit | 4e75ed32a0e01ef3245ee900e3b66ed1cdc7eaf9 (patch) | |
tree | 0437792dacef7fa36ab7ae16059d88d0cd5d7e5b /meta/classes/rm_work.bbclass | |
parent | f27e91305b2c47c371151812343cb0a960ec7a49 (diff) | |
download | poky-4e75ed32a0e01ef3245ee900e3b66ed1cdc7eaf9.tar.gz |
rm_work.bbclass: use HOSTTOOLS 'rm' binary exclusively
The do_rm_work() task is using the first available 'rm' binary
available in PATH to remove files and folders.
However, depending on the PATH setup and RECIPE_SYSROOT_NATIVE
contents, the function can be using the 'rm' binary available
in RECIPE_SYSROOT_NATIVE, a folder that will get removed.
This causes a sporadic race-condition when trying to access the
'rm' binary of a folder already deleted.
Solve this by exclusively using the HOSTTOOLS 'rm' binary, as
this folder will not get removed.
(From OE-Core rev: edcd9ad333bc4e504594e8af83e8cb7007d2e35c)
Signed-off-by: Luis Martins <luis.pinto.martins@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/rm_work.bbclass')
-rw-r--r-- | meta/classes/rm_work.bbclass | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/meta/classes/rm_work.bbclass b/meta/classes/rm_work.bbclass index 1f28bc7187..8b5fe1b808 100644 --- a/meta/classes/rm_work.bbclass +++ b/meta/classes/rm_work.bbclass | |||
@@ -33,6 +33,13 @@ BB_SCHEDULER ?= "completion" | |||
33 | BB_TASK_IONICE_LEVEL:task-rm_work = "3.0" | 33 | BB_TASK_IONICE_LEVEL:task-rm_work = "3.0" |
34 | 34 | ||
35 | do_rm_work () { | 35 | do_rm_work () { |
36 | # Force using the HOSTTOOLS 'rm' - otherwise the SYSROOT_NATIVE 'rm' can be selected depending on PATH | ||
37 | # Avoids race-condition accessing 'rm' when deleting WORKDIR folders at the end of this function | ||
38 | RM_BIN="$(PATH=${HOSTTOOLS_DIR} command -v rm)" | ||
39 | if [ -z "${RM_BIN}" ]; then | ||
40 | bbfatal "Binary 'rm' not found in HOSTTOOLS_DIR, cannot remove WORKDIR data." | ||
41 | fi | ||
42 | |||
36 | # If the recipe name is in the RM_WORK_EXCLUDE, skip the recipe. | 43 | # If the recipe name is in the RM_WORK_EXCLUDE, skip the recipe. |
37 | for p in ${RM_WORK_EXCLUDE}; do | 44 | for p in ${RM_WORK_EXCLUDE}; do |
38 | if [ "$p" = "${PN}" ]; then | 45 | if [ "$p" = "${PN}" ]; then |
@@ -79,7 +86,7 @@ do_rm_work () { | |||
79 | # sstate version since otherwise we'd need to leave 'plaindirs' around | 86 | # sstate version since otherwise we'd need to leave 'plaindirs' around |
80 | # such as 'packages' and 'packages-split' and these can be large. No end | 87 | # such as 'packages' and 'packages-split' and these can be large. No end |
81 | # of chain tasks depend directly on do_package anymore. | 88 | # of chain tasks depend directly on do_package anymore. |
82 | rm -f -- $i; | 89 | "${RM_BIN}" -f -- $i; |
83 | ;; | 90 | ;; |
84 | *_setscene*) | 91 | *_setscene*) |
85 | # Skip stamps which are already setscene versions | 92 | # Skip stamps which are already setscene versions |
@@ -96,7 +103,7 @@ do_rm_work () { | |||
96 | ;; | 103 | ;; |
97 | esac | 104 | esac |
98 | done | 105 | done |
99 | rm -f -- $i | 106 | "${RM_BIN}" -f -- $i |
100 | esac | 107 | esac |
101 | done | 108 | done |
102 | 109 | ||
@@ -106,9 +113,9 @@ do_rm_work () { | |||
106 | # Retain only logs and other files in temp, safely ignore | 113 | # Retain only logs and other files in temp, safely ignore |
107 | # failures of removing pseudo folers on NFS2/3 server. | 114 | # failures of removing pseudo folers on NFS2/3 server. |
108 | if [ $dir = 'pseudo' ]; then | 115 | if [ $dir = 'pseudo' ]; then |
109 | rm -rf -- $dir 2> /dev/null || true | 116 | "${RM_BIN}" -rf -- $dir 2> /dev/null || true |
110 | elif ! echo "$excludes" | grep -q -w "$dir"; then | 117 | elif ! echo "$excludes" | grep -q -w "$dir"; then |
111 | rm -rf -- $dir | 118 | "${RM_BIN}" -rf -- $dir |
112 | fi | 119 | fi |
113 | done | 120 | done |
114 | } | 121 | } |