From ec531a271b4973a5b622525f10b7451c5fbacea1 Mon Sep 17 00:00:00 2001 From: Vincent Fazio Date: Tue, 16 Jul 2024 09:58:02 -0500 Subject: [PATCH] package/python3: use depth first search for directory removal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, Python builds could intermittently fail when removing files if `find` removed a directory before searching within it [0]. An arbitrary example: /tmp/tmp.h9KMUse5zO $ find . -type d -name __pycache__ -exec rm -rvf {} \; ; echo -e "RETURN CODE: $?" removed directory './a/b/c/d/e/__pycache__' find: ‘./a/b/c/d/e/__pycache__’: No such file or directory removed directory './a/b/c/d/e/f/__pycache__' find: ‘./a/b/c/d/e/f/__pycache__’: No such file or directory removed directory './a/b/c/d/e/f/g/__pycache__' RETURN CODE: 1 Now, pass the `-depth` argument to `find` so a depth-first search is performed to avoid trying to search within an already deleted folder. Fixes: 54d48c8cad4e ("package/python3: miscellaneous fixups") Fixes: http://autobuild.buildroot.net/results/ba1d4213ae9912d53412ded6d8e257b67a4f7c0e/ Signed-off-by: Vincent Fazio Signed-off-by: Thomas Petazzoni --- package/python3/python3.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/python3/python3.mk b/package/python3/python3.mk index a82bc47a57..f85dcfad30 100644 --- a/package/python3/python3.mk +++ b/package/python3/python3.mk @@ -205,8 +205,8 @@ define PYTHON3_REMOVE_USELESS_FILES rm -f $(TARGET_DIR)/usr/bin/python$(PYTHON3_VERSION_MAJOR)-config rm -f $(TARGET_DIR)/usr/bin/python3-config find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/config-$(PYTHON3_VERSION_MAJOR)*/ \ - -type f -not -name Makefile -exec rm -rf {} \; - find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/ -type d \ + -depth -type f -not -name Makefile -exec rm -rf {} \; + find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/ -depth -type d \ -name __pycache__ -exec rm -rf {} \; endef