Skip to content

Commit

Permalink
allow use of makepkg options with auto as long as the only tool avail…
Browse files Browse the repository at this point in the history
…able
  • Loading branch information
kewlfft committed May 31, 2020
1 parent c148105 commit 559f25f
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions library/aur.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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'
Expand All @@ -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

Expand Down

0 comments on commit 559f25f

Please sign in to comment.