package/python3: use depth first search for directory removal
PATCH 1/1 package/python3: use depth first search for directory removal
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.
--- package/python3/python3.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
package/python3/python3.mk +2 -2
@@ -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
Signature · 6 lines
2.34.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Thomas Petazzoni via buildroot
AppliedQuoted 16 lines · On Tue, 16 Jul 2024 09:58:02 -0500 Vincent Fazio <[email protected]> wrote:
Previously, Python builds could intermittently fail when removing files if
findremoved 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: 1Now, pass the
-depthargument tofindso a depth-first search is performed to avoid trying to search within an already deleted folder.
Quoted 6 lines
Fixes 54d48c8cad4e ("package/python3: miscellaneous fixups")Signed-off-by Vincent Fazio <[email protected]>--- package/python3/python3.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Applied to master, thanks.
Thomas
Signature · 7 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot