def bundle_cloudman(vm_launcher, options):
    cloudman_options = options.get('cloudman')
    cloudman_repository_path = cloudman_options['cloudman_repository']
    delete_repository = False
    bucket_source = cloudman_options.get("bucket_source")
    if cloudman_repository_path.startswith("http"):
        # Not a local path, lets clone it out of a remote repostiroy,
        temp_directory = mkdtemp()
        if cloudman_repository_path.endswith(".git"):
            branch_opts = ""
            repository_branch = cloudman_options.get('repository_branch', None)
            if repository_branch:
                branch_opts = "-b '%s'" % repository_branch
            clone_command = "git clone " + branch_opts + " '%s' '%s'"
        else:
            clone_command = "hg clone '%s' '%s'"
        local(clone_command % (cloudman_repository_path, temp_directory))
        cloudman_repository_path = temp_directory
        delete_repository = True
    try:
        with lcd(cloudman_repository_path):
            try:
                local("tar czvf cm.tar.gz *")
                local("mv cm.tar.gz '%s'" % bucket_source)
            finally:
                local("rm -f cm.tar.gz")
    finally:
        if delete_repository:
            local("rm -rf '%s'" % cloudman_repository_path)
dataset/ETHPy150Open chapmanb/cloudbiolinux/cloudbio/deploy/plugins/cloudman.py/bundle_cloudman/original