diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2013-06-07 04:48:18 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2013-06-07 13:14:09 +0200 |
commit | a197ad87598b0a816e7187f6e107c593b4498560 (patch) | |
tree | d156d166ecd55db435bdfbfa221338a165200bcc /src/lib/Client | |
parent | c30e56a92ab4d9e1e2dccf5fea2535951cebb633 (diff) | |
download | bcfg2-a197ad87598b0a816e7187f6e107c593b4498560.tar.gz bcfg2-a197ad87598b0a816e7187f6e107c593b4498560.tar.bz2 bcfg2-a197ad87598b0a816e7187f6e107c593b4498560.zip |
Client/Tools/VCS: add support for symlinks
Diffstat (limited to 'src/lib/Client')
-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 |