[oe-commits] Evgeniy Dushistov : oe.patch: don' t error when the symlink already exists and is correct

git version control git at git.openembedded.org
Mon Jul 26 17:59:52 UTC 2010


Module: openembedded.git
Branch: org.openembedded.dev
Commit: c47c6611be11d3b80f61a75f80187e9398eccbd4
URL:    http://gitweb.openembedded.net/?p=openembedded.git&a=commit;h=c47c6611be11d3b80f61a75f80187e9398eccbd4

Author: Evgeniy Dushistov <dushistov at mail.ru>
Date:   Mon Jul 26 09:43:19 2010 -0700

oe.patch: don't error when the symlink already exists and is correct

Adds oe.path.symlink convenience function.

Signed-off-by: Evgeniy Dushistov <dushistov at mail.ru>
Signed-off-by: Chris Larson <chris_larson at mentor.com>

---

 lib/oe/patch.py |    4 +++-
 lib/oe/path.py  |   11 +++++++++++
 2 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/lib/oe/patch.py b/lib/oe/patch.py
index 607ad44..d7f4ccb 100644
--- a/lib/oe/patch.py
+++ b/lib/oe/patch.py
@@ -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()
diff --git a/lib/oe/path.py b/lib/oe/path.py
index a145456..f58c013 100644
--- a/lib/oe/path.py
+++ b/lib/oe/path.py
@@ -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





More information about the Openembedded-commits mailing list