aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido G√ľnther <agx@sigxcpu.org>2008-11-13 15:52:11 +0100
committerGuido Guenther <agx@sigxcpu.org>2008-11-13 15:52:11 +0100
commita6f5472e6fc3318173f3fbf02b2520ef37c20b3d (patch)
tree254e5169ace4ea9127b8083f8bd3d5e62f3b0cd3
parent7f24b98cb2b2e9588176bd1bc99dc077ae6d816d (diff)
Don't fail on symlink creation
iff the symlink already points to the correct target. This way it doesn't make a difference if one points git-import-orig to the file downloaded via uscan or to the symlink created by uscan. Closes: #502565
-rwxr-xr-xgit-import-orig19
1 files changed, 14 insertions, 5 deletions
diff --git a/git-import-orig b/git-import-orig
index 95ea1b5..fac26b3 100755
--- a/git-import-orig
+++ b/git-import-orig
@@ -39,6 +39,14 @@ def cleanup_tmp_tree(tree):
print >>sys.stderr, "Removal of tmptree %s failed." % tree
+def is_link_target(target, link):
+ """does symlink link already point to target?"""
+ if os.path.exists(link):
+ if os.path.samefile(target, link):
+ return True
+ return False
+
+
def symlink_orig(archive, pkg, version):
"""
create a symlink <pkg>_<version>.orig.tar.gz so pristine-tar will see the
@@ -48,13 +56,14 @@ def symlink_orig(archive, pkg, version):
if os.path.isdir(archive):
return None
ext = os.path.splitext(archive)[1]
- dst = "../%s_%s.orig.tar%s" % (pkg, version, ext)
- if os.path.basename(archive) != os.path.basename(dst):
+ link = "../%s_%s.orig.tar%s" % (pkg, version, ext)
+ if os.path.basename(archive) != os.path.basename(link):
try:
- os.symlink(os.path.abspath(archive), dst)
+ if not is_link_target(archive, link):
+ os.symlink(os.path.abspath(archive), link)
except OSError, err:
- raise GbpError, "Cannot symlink '%s' to '%s': %s" % (archive, dst, err[1])
- return dst
+ raise GbpError, "Cannot symlink '%s' to '%s': %s" % (archive, link, err[1])
+ return link
else:
return archive