'Install a Galaxy tool dependency package either via a url or a mercurial or git clone command.'

def install_and_build_package(self, install_environment, tool_dependency, actions_dict):

    install_dir = actions_dict['install_dir']
    package_name = actions_dict['package_name']
    actions = actions_dict.get('actions', None)
    filtered_actions = []
    env_file_builder = EnvFileBuilder(install_dir)
    step_manager = StepManager(self.app)
    if actions:
        with install_environment.use_tmp_dir() as work_dir:
            with lcd(work_dir):
                (action_type, action_dict) = actions[0]
                if (action_type in self.INSTALL_ACTIONS):
                    (tool_dependency, filtered_actions, dir) = step_manager.execute_step(tool_dependency=tool_dependency, package_name=package_name, actions=actions, action_type=action_type, action_dict=action_dict, filtered_actions=filtered_actions, env_file_builder=env_file_builder, install_environment=install_environment, work_dir=work_dir, current_dir=None, initial_download=True)
                else:
                    filtered_actions = [a for a in actions]
                    dir = install_dir
                for action_tup in filtered_actions:
                    if (dir is None):
                        dir = ''
                    current_dir = os.path.abspath(os.path.join(work_dir, dir))
                    with lcd(current_dir):
                        (action_type, action_dict) = action_tup
                        (tool_dependency, tmp_filtered_actions, tmp_dir) = step_manager.execute_step(tool_dependency=tool_dependency, package_name=package_name, actions=actions, action_type=action_type, action_dict=action_dict, filtered_actions=filtered_actions, env_file_builder=env_file_builder, install_environment=install_environment, work_dir=work_dir, current_dir=current_dir, initial_download=False)
                        if (tool_dependency.status in [self.install_model.ToolDependency.installation_status.ERROR]):
                            return tool_dependency
                        if (tmp_dir is not None):
                            dir = tmp_dir
    return tool_dependency
