Commit dfc62f9d authored by Alain Takoudjou's avatar Alain Takoudjou

gitclone: allow to create symlink in repository after clone or pull

parent 5e95d882
......@@ -140,6 +140,10 @@ class Recipe(object):
setattr(self, option, None)
else:
setattr(self, option, value)
self.path_list = [self.location]
self.link_list = [link.strip()
for link in options.get('link-list', '').split('\n')
if link.strip()]
self.git_command = options.get('git-executable', '')
if self.git_command == '':
self.git_command = 'git'
......@@ -172,6 +176,16 @@ class Recipe(object):
command.append(revision)
check_call(command, cwd=self.location)
def configureSymlink(self):
for link in self.link_list:
source, dest = link.split(' ')
source_path = os.path.join(self.location, source.strip())
link_path = os.path.join(self.location, dest.strip())
if os.path.islink(link_path):
os.unlink(link_path)
os.symlink(source_path, link_path)
self.path_list.append(link_path)
def install(self):
"""
Do a git clone.
......@@ -188,7 +202,7 @@ class Recipe(object):
shutil.rmtree(self.location)
else:
# If develop is set, assume that this is a valid working copy
return [self.location]
return self.path_list
if getattr(self, 'branch_overrided', None):
print('Warning: "branch" parameter with value "%s" is ignored. '
......@@ -242,6 +256,7 @@ class Recipe(object):
# in main repo
check_call([self.git_command, 'submodule', 'update', '--init',
'--recursive'], cwd=self.location)
self.configureSymlink()
except CalledProcessError:
print("Unable to download from git repository."
" Trying from network cache...")
......@@ -255,7 +270,7 @@ class Recipe(object):
raise UserError(GIT_CLONE_CACHE_ERROR_MESSAGE)
self.gitReset()
return [self.location]
return self.path_list
def deletePycFiles(self, path):
"""Delete *.pyc files so that deleted/moved files can not be imported"""
......@@ -299,6 +314,7 @@ class Recipe(object):
# NOTE: This will put the submodule repo in a `Detached` state.
check_call([self.git_command, 'submodule', 'update', '--init', '-f',
'--recursive'], cwd=self.location)
self.configureSymlink()
except:
# Buildout will remove the installed location and mark the part as not
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment