Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Vincent Fazio <vfazio@gmail.com>
To: buildroot@buildroot.org
Cc: James Hilliard <james.hilliard1@gmail.com>,
	Vincent Fazio <vfazio@gmail.com>, Asaf Kahlon <asafka7@gmail.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: [Buildroot] [PATCH 1/1] package/python3: use depth first search for directory removal
Date: Tue, 16 Jul 2024 09:58:02 -0500	[thread overview]
Message-ID: <20240716145802.554307-1-vfazio@gmail.com> (raw)

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 <vfazio@gmail.com>
---
 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
 
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

             reply	other threads:[~2024-07-16 15:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-16 14:58 Vincent Fazio [this message]
2024-07-16 21:28 ` [Buildroot] [PATCH 1/1] package/python3: use depth first search for directory removal Thomas Petazzoni via buildroot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240716145802.554307-1-vfazio@gmail.com \
    --to=vfazio@gmail.com \
    --cc=asafka7@gmail.com \
    --cc=buildroot@buildroot.org \
    --cc=james.hilliard1@gmail.com \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox