Change to how SCM is determined

Change SCM determination from executing git/hg commands to explicit
in URL.

Fix check for already installed dependencies
pull/6637/merge
Will Thames 10 years ago committed by Michael DeHaan
parent 36177396c4
commit bf3066e650

@ -331,21 +331,10 @@ def api_get_list(api_server, what):
# scm repo utility functions # scm repo utility functions
#------------------------------------------------------------------------------------- #-------------------------------------------------------------------------------------
def repo_fetch_role(role_name, role_version):
check_repo_cmd = { 'git': ['git', 'ls-remote', role_name],
'hg': ['hg', 'identify', role_name]}
with open('/dev/null', 'w') as devnull:
for (scm, cmd) in check_repo_cmd.items():
popen = subprocess.Popen(cmd, stdout=devnull, stderr=devnull)
rc = popen.wait()
if rc == 0:
return scm_archive_role(scm, role_name, role_version)
print "Repo doesn't seem to be hg or git"
sys.exit(2)
def scm_archive_role(scm, role_url, role_version): def scm_archive_role(scm, role_url, role_version):
if scm not in ['hg', 'git']:
print "SCM %s is not currently supported" % scm
return False
tempdir = tempfile.mkdtemp() tempdir = tempfile.mkdtemp()
role_name = role_url.split('/')[-1] role_name = role_url.split('/')[-1]
clone_cmd = [scm, 'clone', role_url] clone_cmd = [scm, 'clone', role_url]
@ -355,7 +344,7 @@ def scm_archive_role(scm, role_url, role_version):
if rc != 0: if rc != 0:
print "Command %s failed" % ' '.join(clone_cmd) print "Command %s failed" % ' '.join(clone_cmd)
print "in directory %s" % temp_dir print "in directory %s" % temp_dir
sys.exit(1) return False
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.tar.gz') temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.tar.gz')
if scm == 'hg': if scm == 'hg':
@ -377,7 +366,7 @@ def scm_archive_role(scm, role_url, role_version):
if rc != 0: if rc != 0:
print "Command %s failed" % ' '.join(archive_cmd) print "Command %s failed" % ' '.join(archive_cmd)
print "in directory %s" % tempdir print "in directory %s" % tempdir
sys.exit(1) return False
shutil.rmtree(tempdir) shutil.rmtree(tempdir)
@ -738,10 +727,11 @@ def execute_install(args, options, parser):
print "%s (%s) was NOT installed successfully." % (role_name,tar_file) print "%s (%s) was NOT installed successfully." % (role_name,tar_file)
exit_without_ignore(options) exit_without_ignore(options)
else: else:
if '://' in role_name: if '+' in role_name:
# installing from scm url (scm, role_url) = role_name.split('+')
tmp_file = repo_fetch_role(role_name, role_version)
role_name = role_name.split('/')[-1] role_name = role_name.split('/')[-1]
# create tar file from scm url
tmp_file = scm_archive_role(scm, role_url, role_version)
role_data = None role_data = None
else: else:
# installing remotely # installing remotely
@ -784,7 +774,7 @@ def execute_install(args, options, parser):
role_dependencies = role_data['summary_fields']['dependencies'] # api_fetch_role_related(api_server, 'dependencies', role_data['id']) role_dependencies = role_data['summary_fields']['dependencies'] # api_fetch_role_related(api_server, 'dependencies', role_data['id'])
for dep_name in role_dependencies: for dep_name in role_dependencies:
#dep_name = "%s.%s" % (dep['owner'], dep['name']) #dep_name = "%s.%s" % (dep['owner'], dep['name'])
if not get_role_metadata(dep_name, options): if not get_role_metadata(dep_name.split('/')[-1], options):
print ' adding dependency: %s' % dep_name print ' adding dependency: %s' % dep_name
roles_left.append(dep_name) roles_left.append(dep_name)
else: else:

Loading…
Cancel
Save