summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Client
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2013-06-07 13:43:09 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2013-06-18 19:15:10 +0200
commit72e7bff7123e3639bf7da0866c633bdc123d1af4 (patch)
tree859c1cba3f4500e78601f44edf87c36789b14573 /src/lib/Bcfg2/Client
parenta0612263ec30e7cb81dfd4bbd9bc73798630474d (diff)
downloadbcfg2-72e7bff7123e3639bf7da0866c633bdc123d1af4.tar.gz
bcfg2-72e7bff7123e3639bf7da0866c633bdc123d1af4.tar.bz2
bcfg2-72e7bff7123e3639bf7da0866c633bdc123d1af4.zip
Client/Tools/VCS: add support for symlinks
Diffstat (limited to 'src/lib/Bcfg2/Client')
-rw-r--r--src/lib/Bcfg2/Client/Tools/VCS.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/lib/Bcfg2/Client/Tools/VCS.py b/src/lib/Bcfg2/Client/Tools/VCS.py
index 4a30d9d90..947cff11f 100644
--- a/src/lib/Bcfg2/Client/Tools/VCS.py
+++ b/src/lib/Bcfg2/Client/Tools/VCS.py
@@ -6,6 +6,7 @@
# * integrate properly with reports
missing = []
+import errno
import os
import shutil
import sys
@@ -102,10 +103,22 @@ class VCS(Bcfg2.Client.Tools.Tool):
full_path = os.path.join(destname, fname)
dulwich.file.ensure_dir_exists(os.path.dirname(full_path))
- file = open(full_path, 'wb')
- file.write(destr[sha].as_raw_string())
- file.close()
- os.chmod(full_path, mode)
+ if dulwich.objects.S_ISGITLINK(mode):
+ src_path = destr[sha].as_raw_string()
+ try:
+ os.symlink(src_path, full_path)
+ except OSError:
+ e = sys.exc_info()[1]
+ if e.errno == errno.EEXIST:
+ os.unlink(full_path)
+ os.symlink(src_path, full_path)
+ else:
+ raise
+ else:
+ file = open(full_path, 'wb')
+ file.write(destr[sha].as_raw_string())
+ file.close()
+ os.chmod(full_path, mode)
return True
# FIXME: figure out how to write the git index properly