use update_cache

pull/63/head
Assaf Sapir 2021-10-22 12:23:07 +03:00
parent f12cb1b36b
commit 2319468c2e
2 changed files with 12 additions and 12 deletions

View File

@ -69,7 +69,7 @@ The following helpers are supported and automatically selected, if present, in t
| name | | Name or list of names of the package(s) to install or upgrade. | | name | | Name or list of names of the package(s) to install or upgrade. |
| state | **present**, latest | Desired state of the package, 'present' skips operations if the package is already installed. | | state | **present**, latest | Desired state of the package, 'present' skips operations if the package is already installed. |
| upgrade | yes, **no** | Whether or not to upgrade whole system. | | upgrade | yes, **no** | Whether or not to upgrade whole system. |
| refresh | yes, **no** | Whether or not to refresh the packages cache | | update_cache | yes, **no** | Whether or not to refresh the packages cache |
| use | **auto**, yay, paru, pacaur, trizen, pikaur, aurman, makepkg | The tool to use, 'auto' uses the first known helper found and makepkg as a fallback. | | use | **auto**, yay, paru, pacaur, trizen, pikaur, aurman, makepkg | The tool to use, 'auto' uses the first known helper found and makepkg as a fallback. |
| extra_args | **null** | A list of additional arguments to pass directly to the tool. Cannot be used in 'auto' mode. | | extra_args | **null** | A list of additional arguments to pass directly to the tool. Cannot be used in 'auto' mode. |
| aur_only | yes, **no** | Limit helper operation to the AUR. | | aur_only | yes, **no** | Limit helper operation to the AUR. |

View File

@ -39,9 +39,9 @@ options:
default: no default: no
type: bool type: bool
refresh: update_cache:
description: description:
- Whether or not to refresh the package cache. - Whether or not to update_cache the package cache.
default: no default: no
type: bool type: bool
@ -166,7 +166,7 @@ def check_packages(module, packages):
module.exit_json(changed=status, msg=message, diff=diff) 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, local_pkgbuild=None, refresh=False): def build_command_prefix(use, extra_args, skip_pgp_check=False, ignore_arch=False, aur_only=False, local_pkgbuild=None, update_cache=False):
""" """
Create the prefix of a command that can be used by the install and upgrade functions. Create the prefix of a command that can be used by the install and upgrade functions.
""" """
@ -182,7 +182,7 @@ def build_command_prefix(use, extra_args, skip_pgp_check=False, ignore_arch=Fals
command.append('--aur') command.append('--aur')
if local_pkgbuild and use != 'makepkg': if local_pkgbuild and use != 'makepkg':
command.append(local_pkgbuild) command.append(local_pkgbuild)
if refresh: if update_cache:
command.append('-y') command.append('-y')
if extra_args: if extra_args:
command += shlex.split(extra_args) command += shlex.split(extra_args)
@ -240,13 +240,13 @@ def check_upgrade(module, use):
) )
def upgrade(module, use, extra_args, aur_only, refresh): def upgrade(module, use, extra_args, aur_only, update_cache):
""" """
Upgrade the whole system Upgrade the whole system
""" """
assert use in use_cmd assert use in use_cmd
command = build_command_prefix(use, extra_args, aur_only=aur_only, refresh=refresh) command = build_command_prefix(use, extra_args, aur_only=aur_only, update_cache=update_cache)
command.append('-u') command.append('-u')
rc, out, err = module.run_command(command, check_rc=True) rc, out, err = module.run_command(command, check_rc=True)
@ -258,7 +258,7 @@ def upgrade(module, use, extra_args, aur_only, refresh):
) )
def install_packages(module, packages, use, extra_args, state, skip_pgp_check, ignore_arch, aur_only, local_pkgbuild, refresh): def install_packages(module, packages, use, extra_args, state, skip_pgp_check, ignore_arch, aur_only, local_pkgbuild, update_cache):
""" """
Install the specified packages Install the specified packages
""" """
@ -279,7 +279,7 @@ def install_packages(module, packages, use, extra_args, state, skip_pgp_check, i
elif local_pkgbuild: elif local_pkgbuild:
rc, out, err = install_local_package(module, package, use, extra_args, local_pkgbuild) rc, out, err = install_local_package(module, package, use, extra_args, local_pkgbuild)
else: else:
command = build_command_prefix(use, extra_args, aur_only=aur_only, refresh=refresh) command = build_command_prefix(use, extra_args, aur_only=aur_only, update_cache=update_cache)
command.append(package) command.append(package)
rc, out, err = module.run_command(command, check_rc=True) rc, out, err = module.run_command(command, check_rc=True)
@ -308,7 +308,7 @@ def make_module():
'upgrade': { 'upgrade': {
'type': 'bool', 'type': 'bool',
}, },
'refresh': { 'update_cache': {
'default': False, 'default': False,
'type': 'bool', 'type': 'bool',
}, },
@ -384,7 +384,7 @@ def apply_module(module, use):
if module.check_mode: if module.check_mode:
check_upgrade(module, use) check_upgrade(module, use)
else: else:
upgrade(module, use, params['extra_args'], params['aur_only'], params['refresh']) upgrade(module, use, params['extra_args'], params['aur_only'], params['update_cache'])
else: else:
if module.check_mode: if module.check_mode:
check_packages(module, params['name']) check_packages(module, params['name'])
@ -398,7 +398,7 @@ def apply_module(module, use):
params['ignore_arch'], params['ignore_arch'],
params['aur_only'], params['aur_only'],
params['local_pkgbuild'], params['local_pkgbuild'],
params['refresh']) params['update_cache'])
def main(): def main():