diff mbox series

[meta-java] java-library.bbclass: resolve do_deletebinaries race condition

Message ID 20260305035459.3561243-1-douglas.royds@taitcommunications.com
State New
Headers show
Series [meta-java] java-library.bbclass: resolve do_deletebinaries race condition | expand

Commit Message

Douglas Royds March 5, 2026, 3:54 a.m. UTC
From: Stanley Stanton <stanley.stanton@taitcommunications.com>

The do_deletebinaries task is attempting to delete directories created
and destroyed by other bitbake classes such as sstate.bbclass and
create-spdx-2.2.bbclass. If these classes remove their directories
before do_deletebinaries has a chance to delete them, but after they are
found, the following types of errors occur:

Log data follows:
| DEBUG: Executing shell function do_deletebinaries
| find: ‘/build/tmp/work/x86_64-linux/junit-native/3.8.2/sstate-build-create_spdx’: No such file or directory
| WARNING: exit code 1 from a shell command.

Rewrite do_deletebinaries such that it is explicitly not looking through
directories that are managed by other bitbake classes, to avoid this
race condition.

Suggested-by:  Douglas Royds <douglas.royds@taitcommunications.com>
Signed-off-by: Stanley Stanton <stanley.stanton@taitcommunications.com>
---
 classes/java-library.bbclass | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Gyorgy Sarvari March 5, 2026, 11:15 a.m. UTC | #1
- patches for meta-java should go to yocto-patches ML
(yocto-patches@lists.yoctoproject.org), though now I see that this info
isn't updated in all places
- AFAIK meta-java is still in deep sleep due to bitrot, and accepts no
patches due to this, until someone makes the layer build at least

in any case, cc'd Tim, the last maintainer that I know of.

On 3/5/26 04:54, Douglas Royds via lists.openembedded.org wrote:
> From: Stanley Stanton <stanley.stanton@taitcommunications.com>
>
> The do_deletebinaries task is attempting to delete directories created
> and destroyed by other bitbake classes such as sstate.bbclass and
> create-spdx-2.2.bbclass. If these classes remove their directories
> before do_deletebinaries has a chance to delete them, but after they are
> found, the following types of errors occur:
>
> Log data follows:
> | DEBUG: Executing shell function do_deletebinaries
> | find: ‘/build/tmp/work/x86_64-linux/junit-native/3.8.2/sstate-build-create_spdx’: No such file or directory
> | WARNING: exit code 1 from a shell command.
>
> Rewrite do_deletebinaries such that it is explicitly not looking through
> directories that are managed by other bitbake classes, to avoid this
> race condition.
>
> Suggested-by:  Douglas Royds <douglas.royds@taitcommunications.com>
> Signed-off-by: Stanley Stanton <stanley.stanton@taitcommunications.com>
> ---
>  classes/java-library.bbclass | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/classes/java-library.bbclass b/classes/java-library.bbclass
> index 67541d2..033d6d4 100644
> --- a/classes/java-library.bbclass
> +++ b/classes/java-library.bbclass
> @@ -55,10 +55,9 @@ ALTJARFILENAMES = "${BPN}.jar"
>  # Java "source" distributions often contain precompiled things
>  # we want to delete first.
>  do_deletebinaries() {
> -  find ${WORKDIR} ! -path "${RECIPE_SYSROOT}/*" ! -path "${RECIPE_SYSROOT_NATIVE}/*" \
> -                  -name "*.jar" -exec rm {} \;
> -  find ${WORKDIR} ! -path "${RECIPE_SYSROOT}/*" ! -path "${RECIPE_SYSROOT_NATIVE}/*" \
> -                  -name "*.class" -exec rm {} \;
> +  dirs_to_search="$(find ${WORKDIR}/* -maxdepth 0 -type d | grep -Ev "recipe-sysroot|sstate|spdx")"
> +  find $dirs_to_search -name "*.jar" -exec rm {} \;
> +  find $dirs_to_search -name "*.class" -exec rm {} \;
>  }
>  
>  addtask deletebinaries after do_unpack before do_patch
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#124864): https://lists.openembedded.org/g/openembedded-devel/message/124864
> Mute This Topic: https://lists.openembedded.org/mt/118149274/6084445
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [skandigraun@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/classes/java-library.bbclass b/classes/java-library.bbclass
index 67541d2..033d6d4 100644
--- a/classes/java-library.bbclass
+++ b/classes/java-library.bbclass
@@ -55,10 +55,9 @@  ALTJARFILENAMES = "${BPN}.jar"
 # Java "source" distributions often contain precompiled things
 # we want to delete first.
 do_deletebinaries() {
-  find ${WORKDIR} ! -path "${RECIPE_SYSROOT}/*" ! -path "${RECIPE_SYSROOT_NATIVE}/*" \
-                  -name "*.jar" -exec rm {} \;
-  find ${WORKDIR} ! -path "${RECIPE_SYSROOT}/*" ! -path "${RECIPE_SYSROOT_NATIVE}/*" \
-                  -name "*.class" -exec rm {} \;
+  dirs_to_search="$(find ${WORKDIR}/* -maxdepth 0 -type d | grep -Ev "recipe-sysroot|sstate|spdx")"
+  find $dirs_to_search -name "*.jar" -exec rm {} \;
+  find $dirs_to_search -name "*.class" -exec rm {} \;
 }
 
 addtask deletebinaries after do_unpack before do_patch