From 08dac879d70bdf8ad87652f85da303459a29c581 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sun, 5 Jun 2016 12:07:04 +0000 Subject: [PATCH] Try to work around shutil.rmtree permission denied problem. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3238 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- tools/update-deps | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/update-deps b/tools/update-deps index f315098b..145f46c9 100755 --- a/tools/update-deps +++ b/tools/update-deps @@ -2,6 +2,7 @@ import os import shutil +import stat import subprocess import sys @@ -29,6 +30,13 @@ def run(*args, **kw): print 'Running:', args, kw subprocess.check_call(*args, **kw) +def makeWritableAndRetry(function, path, exc_info): + if not os.access(path, os.W_OK): + os.chmod(path, stat.S_IWUSR) + function(path) + else: + raise + def updateUv(): print 'libuv' print @@ -45,7 +53,7 @@ def updateUv(): if clean: if os.path.isdir(os.path.join(kUvWork)): print 'Cleaning', kUvWork - shutil.rmtree(os.path.join(kUvWork)) + shutil.rmtree(os.path.join(kUvWork), onerror=makeWritableAndRetry) if not os.path.isdir(kUvWork): run(['git', 'clone', '--branch', kUvBranch, kUvRepository, kUvWork]) open(os.path.join(kUvWork, '.update-deps-branch'), 'w').write(kUvBranch) @@ -81,7 +89,7 @@ def updateV8(): if clean: if os.path.isdir(kV8Work): - shutil.rmtree(kV8Work) + shutil.rmtree(kV8Work, onerror=makeWritableAndRetry) if True or sys.platform == 'linux2': # XXX Modify this one .py file which assumes things that conflict with my debian environment.