summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2013-06-07 04:48:18 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2013-06-07 13:14:09 +0200
commita197ad87598b0a816e7187f6e107c593b4498560 (patch)
treed156d166ecd55db435bdfbfa221338a165200bcc
parentc30e56a92ab4d9e1e2dccf5fea2535951cebb633 (diff)
downloadbcfg2-a197ad87598b0a816e7187f6e107c593b4498560.tar.gz
bcfg2-a197ad87598b0a816e7187f6e107c593b4498560.tar.bz2
bcfg2-a197ad87598b0a816e7187f6e107c593b4498560.zip
Client/Tools/VCS: add support for symlinks
-rw-r--r--debian/changelog3
-rw-r--r--src/lib/Client/Tools/VCS.py20
2 files changed, 18 insertions, 5 deletions
diff --git a/debian/changelog b/debian/changelog
index 05381d869..b26280577 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,8 +3,9 @@ bcfg2 (1.2.3-17) unstable; urgency=low
* Client/Tools/VCS: create directory for repository
* Client/Tools/VCS: add always on top feature
* Client/Tools/VCS: some simplyfications using dulwich api
+ * Client/Tools/VCS: add support for symlinks
- -- Alexander Sulfrian <alex@spline.inf.fu-berlin.de> Fri, 07 Jun 2013 04:47:39 +0200
+ -- Alexander Sulfrian <alex@spline.inf.fu-berlin.de> Fri, 07 Jun 2013 04:48:51 +0200
bcfg2 (1.2.3-16) unstable; urgency=low
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