summaryrefslogtreecommitdiffstats
path: root/src/py-libs/util.py
diff options
context:
space:
mode:
authorMichael E Brown <mebrown@michaels-house.net>2007-10-22 13:34:14 -0500
committerMichael E Brown <mebrown@michaels-house.net>2007-10-22 13:34:14 -0500
commit9b3dc0ca978d566ea593ee2ae773bc6aed8530f2 (patch)
treefc12ed23210cadccfe6bd2d969a98a0a900cbc67 /src/py-libs/util.py
parent725e0550748ea414952e78145fa867678aabc44c (diff)
downloadmock-9b3dc0ca978d566ea593ee2ae773bc6aed8530f2.tar.gz
mock-9b3dc0ca978d566ea593ee2ae773bc6aed8530f2.tar.xz
mock-9b3dc0ca978d566ea593ee2ae773bc6aed8530f2.zip
more complete fix for immutable files in buildroot
Diffstat (limited to 'src/py-libs/util.py')
-rw-r--r--src/py-libs/util.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/py-libs/util.py b/src/py-libs/util.py
index 7f06e27..8cd8b3f 100644
--- a/src/py-libs/util.py
+++ b/src/py-libs/util.py
@@ -55,19 +55,20 @@ def rmtree(path, *args, **kargs):
"""version os shutil.rmtree that ignores no-such-file-or-directory errors,
and tries harder if it finds immutable files"""
tryAgain = 1
- triedTwice = 0
+ failedFilename = None
while tryAgain:
tryAgain = 0
try:
shutil.rmtree(path, *args, **kargs)
except OSError, e:
- if triedTwice: raise
if e.errno == 2: # no such file or directory
pass
- elif e.errno==1:
+ elif e.errno==1 or e.errno==13:
tryAgain = 1
- triedTwice = 1
- os.system("chattr -i -R %s" % path)
+ if failedFilename == e.filename:
+ raise
+ failedFilename = e.filename
+ os.system("chattr -R -i %s" % path)
else:
raise