oe.patch: don't error when the symlink already exists and is correct
authorEvgeniy Dushistov <dushistov@mail.ru>
Mon, 26 Jul 2010 16:43:19 +0000 (09:43 -0700)
committerChris Larson <chris_larson@mentor.com>
Mon, 26 Jul 2010 17:59:36 +0000 (10:59 -0700)
Adds oe.path.symlink convenience function.

Signed-off-by: Evgeniy Dushistov <dushistov@mail.ru>
Signed-off-by: Chris Larson <chris_larson@mentor.com>
lib/oe/patch.py
lib/oe/path.py

index 607ad44..d7f4ccb 100644 (file)
@@ -1,3 +1,5 @@
+import oe.path
+
 class NotFoundError(Exception):
     def __init__(self, path):
         self.path = path
@@ -230,7 +232,7 @@ class QuiltTree(PatchSet):
         if not self.initialized:
             self.InitFromDir()
         PatchSet.Import(self, patch, force)
-        os.symlink(patch["file"], self._quiltpatchpath(patch["file"]))
+        oe.path.symlink(patch["file"], self._quiltpatchpath(patch["file"]))
         f = open(os.path.join(self.dir, "patches","series"), "a");
         f.write(os.path.basename(patch["file"]) + " -p" + patch["strippath"]+"\n")
         f.close()
index a145456..f58c013 100644 (file)
@@ -53,3 +53,14 @@ def remove(path):
             shutil.rmtree(path)
         elif exc.errno != errno.ENOENT:
             raise
+
+def symlink(source, destination, force=False):
+    """Create a symbolic link"""
+    import os, errno
+    try:
+        if force:
+            remove(destination)
+        os.symlink(source, destination)
+    except OSError, e:
+        if e.errno != errno.EEXIST or os.readlink(destination) != source:
+            raise