[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [emerge] bin: fixed permission denied problems installing or merging of readonly files
From:       Ralf Habacker <ralf.habacker () freenet ! de>
Date:       2012-01-11 12:09:22
Message-ID: 20120111120922.790E5A60A6 () git ! kde ! org
[Download RAW message or body]

Git commit 4b70d1f688988a74e0a08e6112c42eb5aa10e252 by Ralf Habacker.
Committed on 11/01/2012 at 13:03.
Pushed by habacker into branch 'master'.

fixed permission denied problems installing or merging of readonly files

In case a copy or remove fails, remove the readonly file attribute and try again.

M  +26   -5    bin/utils.py

http://commits.kde.org/emerge/4b70d1f688988a74e0a08e6112c42eb5aa10e252

diff --git a/bin/utils.py b/bin/utils.py
index fc7faf5..e77c8e9 100644
--- a/bin/utils.py
+++ b/bin/utils.py
@@ -749,12 +749,20 @@ def unmergeFileList(rootdir, fileList, forced=False):
             currentHash = digestFile(fullPath)
             if currentHash == filehash or filehash == "":
                 debug( "deleting file %s" % fullPath)
-                os.remove(fullPath)
+                try:
+                    os.remove(fullPath)
+                except OSError:
+                    system( "cmd /C \"attrib -R %s\"" % fullPath )
+                    os.remove(fullPath)
             else:
                 if forced:
                     warning( "file %s has different hash: %s %s, deleting anyway" % \
\  (fullPath, currentHash, filehash ) )
-                    os.remove(fullPath)
+                    try:
+                        os.remove(fullPath)
+                    except OSError:
+                        system( "cmd /C \"attrib -R %s\"" % fullPath )
+                        os.remove(fullPath)
                 else:
                     warning( "file %s has different hash: %s %s, run with option \
--force to delete it anyway" % \  (fullPath, currentHash, filehash ) )
@@ -927,12 +935,21 @@ def cleanDirectory( directory ):
                 try:
                     os.remove( os.path.join(root, name) )
                 except OSError:
-                    die( "couldn't delete file %s\n ( %s )" % ( name, os.path.join( \
root, name ) ) ) +                    system( "cmd /C \"attrib -R %s\"" % \
os.path.join(root, name) ) +                    try:
+                        os.remove( os.path.join(root, name) )
+                    except OSError:
+                        die( "couldn't delete file %s\n ( %s )" % ( name, \
os.path.join(root, name) ) ) +
             for name in dirs:
                 try:
                     os.rmdir( os.path.join(root, name) )
                 except OSError:
-                    die( "couldn't delete directory %s\n( %s )" % ( name, \
os.path.join( root, name ) ) ) +                    system( "cmd /C \"attrib -R %s\"" \
% os.path.join(root, name) ) +                    try:
+                        os.rmdir( os.path.join(root, name) )
+                    except OSError:
+                        die( "couldn't delete directory %s\n( %s )" % ( name, \
os.path.join(root, name) ) )  else:
         os.makedirs( directory )
 
@@ -1138,7 +1155,11 @@ def copyDir( srcdir, destdir ):
             if ( not os.path.exists( tmpdir ) ):
                 os.makedirs( tmpdir )
             for fileName in files:
-                shutil.copy( os.path.join( root, fileName ), tmpdir )
+                try:
+                    shutil.copy( os.path.join( root, fileName ), tmpdir )
+                except OSError:
+                    system("cmd /C \"attrib -R %s\"" % os.path.join(tmpdir, \
fileName) ) +                    shutil.copy( os.path.join( root, fileName ), tmpdir \
                )
                 debug( "copy %s to %s" % ( os.path.join( root, fileName ), \
os.path.join( tmpdir, fileName ) ), 2)  
 def moveDir( srcdir, destdir ):


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic