diff options
Diffstat (limited to 'src/lib/Client/Tools/VCS.py')
-rw-r--r-- | src/lib/Client/Tools/VCS.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/lib/Client/Tools/VCS.py b/src/lib/Client/Tools/VCS.py index c9fa90a5d..4c1090bfd 100644 --- a/src/lib/Client/Tools/VCS.py +++ b/src/lib/Client/Tools/VCS.py @@ -9,6 +9,7 @@ missing = [] import os import shutil import sys +import errno # python-dulwich git imports try: import dulwich @@ -106,10 +107,21 @@ class VCS(Bcfg2.Client.Tools.Tool): full_path = os.path.join(destname, fname) dulwich.file.ensure_dir_exists(os.path.dirname(full_path)) - with open(full_path, 'wb') as file: - #write blob's content to file - file.write(destr[sha].as_raw_string()) - 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: + if e.errno == errno.EEXIST: + os.unlink(full_path) + os.symlink(src_path, full_path) + else: + raise + else: + with open(full_path, 'wb') as file: + #write blob's content to file + file.write(destr[sha].as_raw_string()) + os.chmod(full_path, mode) return True # FIXME: figure out how to write the git index properly |