From 31540246dd1d05379ad03437656759479590c06d Mon Sep 17 00:00:00 2001 From: Will Thames Date: Tue, 19 Aug 2014 16:06:46 +1000 Subject: [PATCH] Handle older git archive commands Older git archive commands create tar archives even with a tar.gz extension. So change it to always create tar archives and have the install_role method cope. Removed ssh roles from the test case as they don't work unless you can connect to bitbucket via ssh and have your key there. Corrected a minor typo in error messages --- bin/ansible-galaxy | 9 ++++++--- test/integration/galaxy_roles.yml | 2 +- test/integration/galaxy_rolesfile | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bin/ansible-galaxy b/bin/ansible-galaxy index 3c624693b36..79594bad97d 100755 --- a/bin/ansible-galaxy +++ b/bin/ansible-galaxy @@ -343,10 +343,10 @@ def scm_archive_role(scm, role_url, role_version, role_name): rc = popen.wait() if rc != 0: print "Command %s failed" % ' '.join(clone_cmd) - print "in directory %s" % temp_dir + print "in directory %s" % tempdir return False - temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.tar.gz') + temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.tar') if scm == 'hg': archive_cmd = ['hg', 'archive', '--prefix', "%s/" % role_name] if role_version: @@ -491,7 +491,10 @@ def install_role(role_name, role_version, role_filename, options): print "Error: the file downloaded was not a tar.gz" return False else: - role_tar_file = tarfile.open(role_filename, "r:gz") + if role_filename.endswith('.gz'): + role_tar_file = tarfile.open(role_filename, "r:gz") + else: + role_tar_file = tarfile.open(role_filename, "r") # verify the role's meta file meta_file = None members = role_tar_file.getmembers() diff --git a/test/integration/galaxy_roles.yml b/test/integration/galaxy_roles.yml index f354f5985f4..cd610068401 100644 --- a/test/integration/galaxy_roles.yml +++ b/test/integration/galaxy_roles.yml @@ -1,7 +1,7 @@ - src: git+http://bitbucket.org/willthames/git-ansible-galaxy version: v1.4 -- src: ssh://hg@bitbucket.org/willthames/hg-ansible-galaxy +- src: http://bitbucket.org/willthames/hg-ansible-galaxy scm: hg - src: https://bitbucket.org/willthames/http-ansible-galaxy/get/master.tar.gz diff --git a/test/integration/galaxy_rolesfile b/test/integration/galaxy_rolesfile index 01aa27a52ac..a1374925ba7 100644 --- a/test/integration/galaxy_rolesfile +++ b/test/integration/galaxy_rolesfile @@ -1,3 +1,3 @@ git+http://bitbucket.org/willthames/git-ansible-galaxy,v1.4 -hg+ssh://hg@bitbucket.org/willthames/hg-ansible-galaxy +hg+http://bitbucket.org/willthames/hg-ansible-galaxy https://bitbucket.org/willthames/http-ansible-galaxy/get/master.tar.gz,,http-role