[PATCH] D45345: [annotated_builder] try harder to clean build directories
Bob Haarman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 5 18:32:14 PDT 2018
inglorion created this revision.
inglorion added reviewers: gkistanova, rnk, zturner.
Herald added a subscriber: mehdi_amini.
llvm-objcopy has a test that creates a non-writable file. This file
is causing the clang-with-thin-lto-windows bot to fail because it
cannot clean its build directory. This change makes util.clean_dir()
try harder to remove directory trees, which should allow the bot
to succeed.
https://reviews.llvm.org/D45345
Files:
zorg/buildbot/builders/annotated/util.py
Index: zorg/buildbot/builders/annotated/util.py
===================================================================
--- zorg/buildbot/builders/annotated/util.py
+++ zorg/buildbot/builders/annotated/util.py
@@ -10,11 +10,11 @@
def clean_dir(path):
"""
- Remove directory path if it exists and create a new, empty directory
- in its place.
+ Removes directory at path (and all its subdirectories) if it exists,
+ and creates an empty directory in its place.
"""
try:
- shutil.rmtree(path)
+ rmtree(path)
except OSError as e:
if e.errno != errno.ENOENT:
raise
@@ -58,6 +58,24 @@
raise
+def rmtree(path):
+ """
+ Remove directory path and all its subdirectories. This differs from
+ shutil.rmtree() in that it tries to adjust permissions so that deletion
+ will succeed.
+ """
+ # Some files will not be deletable, so we set permissions that allow
+ # deletion before we try deleting files.
+ for root, dirs, files in os.walk(path):
+ os.chmod(root, 0o755)
+ for f in files:
+ p = os.path.join(root, f)
+ os.chmod(p, 0o644)
+ os.unlink(p)
+ # At this point, we should have a tree of deletable directories.
+ shutil.rmtree(path)
+
+
def safe_pjoin(dirname, *args):
"""
Join path components with os.path.join, skipping the first component
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45345.141252.patch
Type: text/x-patch
Size: 1409 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180406/99963e04/attachment.bin>
More information about the llvm-commits
mailing list