aboutsummaryrefslogtreecommitdiffstats
path: root/lib/oe/path.py
diff options
context:
space:
mode:
authorEvgeniy Dushistov <dushistov@mail.ru>2010-07-26 09:43:19 -0700
committerChris Larson <chris_larson@mentor.com>2010-07-26 10:59:36 -0700
commitc47c6611be11d3b80f61a75f80187e9398eccbd4 (patch)
treea744f0ea729e14f2bf86438779b3a20c908e6539 /lib/oe/path.py
parent8d209c6d13f52d872031b5ac41f2fb4ec2cd4170 (diff)
downloadopenembedded-c47c6611be11d3b80f61a75f80187e9398eccbd4.tar.gz
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@mail.ru> Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'lib/oe/path.py')
-rw-r--r--lib/oe/path.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/oe/path.py b/lib/oe/path.py
index a145456659..f58c0138bb 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