diff --git a/README.md b/README.md index daaf51b..771a025 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,13 @@ makepkg will be used if no helper was found or if it's specified explicitly. - [makepkg](https://wiki.archlinux.org/index.php/makepkg) ## Options -|parameter |required |default |choices |comments| -|--- |--- |--- |--- |---| -|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_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.| +|parameter |required |default |choices |comments| +|--- |--- |--- |--- |---| +|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 |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 * Either *name* or *upgrade* is required, both cannot be used together. @@ -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 diff --git a/aur.py b/aur.py index 85aaa3c..8223547 100644 --- a/aur.py +++ b/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,10 +170,12 @@ 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): - rc = 0 - continue + vcs = package.endswith(vcs_suffixes) + if skip_installed == 'all' or (skip_installed == 'versioned' and not vcs): + rc = 0 + continue if use == 'makepkg': rc, out, err = install_with_makepkg(module, package) else: @@ -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,