From 559f25fc41850e8b5e70ea0071e64739e91e43a4 Mon Sep 17 00:00:00 2001 From: kewl fft Date: Sun, 31 May 2020 19:40:17 -0400 Subject: [PATCH] allow use of makepkg options with auto as long as the only tool available --- library/aur.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/library/aur.py b/library/aur.py index 94072a4..577b7c3 100644 --- a/library/aur.py +++ b/library/aur.py @@ -145,6 +145,22 @@ def check_packages(module, packages): module.exit_json(changed=status, msg=message, diff=diff) +def build_command_prefix(use, extra_args, skip_pgp_check=False, ignore_arch=False, aur_only=False): + """ + Create the prefix of a command that can be used by the install and upgrade functions. + """ + command = def_lang + use_cmd[use] + if skip_pgp_check: + command.append('--skippgpcheck') + if ignore_arch: + command.append('--ignorearch') + if aur_only and use in has_aur_option: + command.append('--aur') + if extra_args: + command += shlex.split(extra_args) + return command + + def install_with_makepkg(module, package, extra_args, skip_pgp_check, ignore_arch): """ Install the specified package with makepkg @@ -165,22 +181,6 @@ def install_with_makepkg(module, package, extra_args, skip_pgp_check, ignore_arc return (rc, out, err) -def build_command_prefix(use, extra_args, skip_pgp_check=False, ignore_arch=False, aur_only=False): - """ - Create the prefix of a command that can be used by the install and upgrade functions. - """ - command = def_lang + use_cmd[use] - if skip_pgp_check: - command.append('--skippgpcheck') - if ignore_arch: - command.append('--ignorearch') - if aur_only and use in has_aur_option: - command.append('--aur') - if extra_args: - command += shlex.split(extra_args) - return command - - def upgrade(module, use, extra_args, aur_only): """ Upgrade the whole system @@ -273,10 +273,7 @@ def make_module(): params = module.params if params['use'] == 'auto' and params['extra_args'] is not None: - module.fail_json(msg="You must specify a tool other than 'auto' to use the 'extra_args' option.") - - if params['use'] != 'makepkg' and (params['skip_pgp_check'] or params['ignore_arch']): - module.fail_json(msg="You must use 'makepkg' to use this option.") + module.fail_json(msg="'extra_args' option cannot be used with 'auto', a tool must be specified.") if params['use'] == 'auto': use = 'makepkg' @@ -288,8 +285,11 @@ def make_module(): else: use = params['use'] + if use != 'makepkg' and (params['skip_pgp_check'] or params['ignore_arch']): + module.fail_json(msg="This option is only available with 'makepkg'.") + if params.get('upgrade', False) and use == 'makepkg': - module.fail_json(msg="Upgrade cannot be used with the tool 'makepkg'.") + module.fail_json(msg="The 'upgrade' action cannot be used with 'makepkg'.") return module, use