mirror of https://github.com/kewlfft/ansible-aur
Make skip_installed an enum instead of boolean
With these changes skip_installed allows you to skip 'all', 'versioned' (non-vcs) or 'none' Fixes #9pull/10/head
parent
2df576955a
commit
7be9a67264
|
@ -17,7 +17,7 @@ makepkg will be used if no helper was found or if it's specified explicitly.
|
|||
|name |no | | |Name or list of names of the package(s) to install or upgrade.|
|
||||
|upgrade |no |no |yes, no |Whether or not to upgrade whole system.|
|
||||
|use |no |auto |auto, aurman, pacaur, trizen, pikaur, yay, makepkg |The helper to use, 'auto' uses the first known helper found and makepkg as a fallback.|
|
||||
|skip_installed |no |no |yes, no |Skip operations if the package is present.|
|
||||
|skip_installed |no |versioned|all, versioned, none |Skip operations if the package is present. Choosing versioned will all you to skip non-VCS (-git, -hg, etc.) packages.|
|
||||
|skip_pgp_check |no |no |yes, no |Skip verification of PGP signatures. This is useful when installing packages on a host without GnuPG (properly) configured. Only valid with makepkg.|
|
||||
|
||||
### Note
|
||||
|
@ -45,7 +45,7 @@ git clone https://github.com/kewlfft/ansible-aur.git ~/.ansible/plugins/modules/
|
|||
Use it in a task, as in the following examples:
|
||||
```
|
||||
# Install trizen using makepkg, skip if trizen is already installed
|
||||
- aur: name=trizen use=makepkg skip_installed=true
|
||||
- aur: name=trizen use=makepkg skip_installed=all
|
||||
become: yes
|
||||
become_user: aur_builder
|
||||
|
||||
|
|
13
aur.py
13
aur.py
|
@ -39,8 +39,9 @@ options:
|
|||
skip_installed:
|
||||
description:
|
||||
- Skip operations if the package is present.
|
||||
type: bool
|
||||
Choosing versioned will all you to skip non-VCS (-git, -hg, etc.) packages.
|
||||
default: no
|
||||
choices: [ all, versioned, none]
|
||||
|
||||
skip_pgp_check:
|
||||
description:
|
||||
|
@ -81,6 +82,8 @@ use_cmd = {
|
|||
}
|
||||
# optional: aurman, pacaur, trizen have a --aur option, do things only for aur
|
||||
|
||||
# From https://wiki.archlinux.org/index.php/VCS_package_guidelines
|
||||
vcs_suffixes = ('-git', '-bzr', '-darcs', '-hg', '-svn', '-cvs')
|
||||
|
||||
def package_installed(module, package):
|
||||
"""
|
||||
|
@ -167,8 +170,10 @@ def install_packages(module, packages, use, skip_installed):
|
|||
changed_iter = False
|
||||
|
||||
for package in packages:
|
||||
if skip_installed:
|
||||
if skip_installed in ('all', 'versioned'):
|
||||
if package_installed(module, package):
|
||||
vcs = package.endswith(vcs_suffixes)
|
||||
if skip_installed == 'all' or (skip_installed == 'versioned' and not vcs):
|
||||
rc = 0
|
||||
continue
|
||||
if use == 'makepkg':
|
||||
|
@ -206,8 +211,8 @@ def main():
|
|||
'choices': ['auto', 'aurman', 'pacaur', 'trizen', 'pikaur', 'yaourt', 'yay', 'makepkg'],
|
||||
},
|
||||
'skip_installed': {
|
||||
'default': False,
|
||||
'type': 'bool',
|
||||
'default': 'versioned',
|
||||
'choices': ['all', 'versioned', 'none'],
|
||||
},
|
||||
'skip_pgp_check': {
|
||||
'default': False,
|
||||
|
|
Loading…
Reference in New Issue