diff options
author | Luis <luis.pinto.martins@gmail.com> | 2022-12-24 01:49:46 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-01-15 11:05:15 +0000 |
commit | f8187daf0ab7b7ece4750d9b49e9bdf8778dfb25 (patch) | |
tree | 7c39fef50d9a45cedd57a42149461cddfb5f95ef | |
parent | d369e47a825d7cbfb5f46a6bc137fc20231dcbf2 (diff) | |
download | poky-f8187daf0ab7b7ece4750d9b49e9bdf8778dfb25.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: 7ad7ba54916351f4fe2d0bd1542962539e5eb4bd)
Signed-off-by: Luis Martins <luis.pinto.martins@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit edcd9ad333bc4e504594e8af83e8cb7007d2e35c)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-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 8979714e62..f7ededff26 100644 --- a/meta/classes/rm_work.bbclass +++ b/meta/classes/rm_work.bbclass | |||
@@ -27,6 +27,13 @@ BB_SCHEDULER ?= "completion" | |||
27 | BB_TASK_IONICE_LEVEL:task-rm_work = "3.0" | 27 | BB_TASK_IONICE_LEVEL:task-rm_work = "3.0" |
28 | 28 | ||
29 | do_rm_work () { | 29 | do_rm_work () { |
30 | # Force using the HOSTTOOLS 'rm' - otherwise the SYSROOT_NATIVE 'rm' can be selected depending on PATH | ||
31 | # Avoids race-condition accessing 'rm' when deleting WORKDIR folders at the end of this function | ||
32 | RM_BIN="$(PATH=${HOSTTOOLS_DIR} command -v rm)" | ||
33 | if [ -z "${RM_BIN}" ]; then | ||
34 | bbfatal "Binary 'rm' not found in HOSTTOOLS_DIR, cannot remove WORKDIR data." | ||
35 | fi | ||
36 | |||
30 | # If the recipe name is in the RM_WORK_EXCLUDE, skip the recipe. | 37 | # If the recipe name is in the RM_WORK_EXCLUDE, skip the recipe. |
31 | for p in ${RM_WORK_EXCLUDE}; do | 38 | for p in ${RM_WORK_EXCLUDE}; do |
32 | if [ "$p" = "${PN}" ]; then | 39 | if [ "$p" = "${PN}" ]; then |
@@ -73,7 +80,7 @@ do_rm_work () { | |||
73 | # sstate version since otherwise we'd need to leave 'plaindirs' around | 80 | # sstate version since otherwise we'd need to leave 'plaindirs' around |
74 | # such as 'packages' and 'packages-split' and these can be large. No end | 81 | # such as 'packages' and 'packages-split' and these can be large. No end |
75 | # of chain tasks depend directly on do_package anymore. | 82 | # of chain tasks depend directly on do_package anymore. |
76 | rm -f -- $i; | 83 | "${RM_BIN}" -f -- $i; |
77 | ;; | 84 | ;; |
78 | *_setscene*) | 85 | *_setscene*) |
79 | # Skip stamps which are already setscene versions | 86 | # Skip stamps which are already setscene versions |
@@ -90,7 +97,7 @@ do_rm_work () { | |||
90 | ;; | 97 | ;; |
91 | esac | 98 | esac |
92 | done | 99 | done |
93 | rm -f -- $i | 100 | "${RM_BIN}" -f -- $i |
94 | esac | 101 | esac |
95 | done | 102 | done |
96 | 103 | ||
@@ -100,9 +107,9 @@ do_rm_work () { | |||
100 | # Retain only logs and other files in temp, safely ignore | 107 | # Retain only logs and other files in temp, safely ignore |
101 | # failures of removing pseudo folers on NFS2/3 server. | 108 | # failures of removing pseudo folers on NFS2/3 server. |
102 | if [ $dir = 'pseudo' ]; then | 109 | if [ $dir = 'pseudo' ]; then |
103 | rm -rf -- $dir 2> /dev/null || true | 110 | "${RM_BIN}" -rf -- $dir 2> /dev/null || true |
104 | elif ! echo "$excludes" | grep -q -w "$dir"; then | 111 | elif ! echo "$excludes" | grep -q -w "$dir"; then |
105 | rm -rf -- $dir | 112 | "${RM_BIN}" -rf -- $dir |
106 | fi | 113 | fi |
107 | done | 114 | done |
108 | } | 115 | } |