18 Commits
v0.22 ... v0.24

Author SHA1 Message Date
kewl
9f52f507c6 Merge pull request #25 from hvariant/fix-package-name-quote
fix quoting of package name
2019-08-31 09:02:49 +01:00
Zhansong Li
e1443632a3 use the correct module and function name 2019-08-31 17:41:39 +10:00
Zhansong Li
f4868a5bac fix quoting of package name 2019-08-31 11:17:57 +10:00
kewl fft
9a2500338c improved readme 2019-07-28 09:30:00 +02:00
kewl fft
5acabdc819 optional argument default for get bin path removed 2019-04-11 20:09:27 +01:00
kewl fft
2766c2661c if in one line 2019-04-11 20:03:55 +01:00
kewl fft
473d06fe54 revert grammatical correction 2019-04-11 19:59:22 +01:00
kewl fft
59d69056a2 grammatical correction always many packages at this point 2019-04-11 19:45:03 +01:00
kewl fft
8b1ba99cdc choices list is now dynamic 2019-04-11 19:39:01 +01:00
kewl fft
72d432ac7a yaourt remove from choices 2019-04-11 19:17:36 +01:00
kewl fft
b462d9893f improved error message when pkg not found thanks @juergenhoetzel 2019-04-11 19:05:57 +01:00
kewl fft
8f8af5fa5f correct package name in readme 2018-12-21 08:33:16 +00:00
kewl fft
6ee60c77bb yay afterclean added 2018-11-15 20:08:23 +00:00
kewl
eeca05b629 Merge pull request #21 from juergenhoetzel/check-for-fakeroot
makepkg: Check for "fakeroot" binary
2018-10-30 19:18:28 +00:00
Juergen Hoetzel
f92a1522a3 makepkg: Check for "fakeroot" binary 2018-10-30 16:50:07 +01:00
kewl fft
6f5a4f9b6d yay positionned #1 and comments refreshed 2018-10-13 12:01:48 +01:00
kewl
85f6d7c93f Merge pull request #19 from visibilityspots/master
Feature: use the skip_new_locations option for aurman wrapper
2018-08-21 21:18:42 +01:00
Jan Collijs
80279644a8 Feature: use the skip_new_locations option for aurman wrapper 2018-08-21 11:42:38 +02:00
2 changed files with 22 additions and 23 deletions

View File

@@ -1,14 +1,14 @@
# Ansible AUR helper # Ansible AUR helper
Ansible module to use some Arch User Repository (AUR) helpers as well as makepkg. Ansible module to use some Arch User Repository (AUR) helpers as well as makepkg.
The following helpers are supported and automatically selected in the order they are listed: The following helpers are supported and automatically selected, if present, in the order listed below:
- [aurman](https://github.com/polygamma/aurman)
- [yay](https://github.com/Jguer/yay) - [yay](https://github.com/Jguer/yay)
- [aurman](https://github.com/polygamma/aurman)
- [pacaur](https://github.com/rmarquis/pacaur) - [pacaur](https://github.com/rmarquis/pacaur)
- [trizen](https://github.com/trizen/trizen) - [trizen](https://github.com/trizen/trizen)
- [pikaur](https://github.com/actionless/pikaur) - [pikaur](https://github.com/actionless/pikaur)
makepkg will be used if no helper was found or if it's specified explicitly. *makepkg* will be used if no helper was found or if it is explicitly specified:
- [makepkg](https://wiki.archlinux.org/index.php/makepkg) - [makepkg](https://wiki.archlinux.org/index.php/makepkg)
## Options ## Options
@@ -16,7 +16,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.| |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.| |upgrade |no |no |yes, no |Whether or not to upgrade whole system.|
|use |no |auto |auto, aurman, yay, pacaur, trizen, pikaur, makepkg |The helper to use, 'auto' uses the first known helper found and makepkg as a fallback.| |use |no |auto |auto, yay, aurman, pacaur, trizen, pikaur, 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 |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.| |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.|
|aur_only |no |no |yes, no |Limit operation to the AUR. Compatible with yay, aurman, pacaur and trizen.| |aur_only |no |no |yes, no |Limit operation to the AUR. Compatible with yay, aurman, pacaur and trizen.|
@@ -28,7 +28,7 @@ makepkg will be used if no helper was found or if it's specified explicitly.
## Installing ## Installing
### AUR package ### AUR package
The [aur-ansible-git](https://aur.archlinux.org/packages/ansible-aur-git) package is available in the AUR. The [ansible-aur-git](https://aur.archlinux.org/packages/ansible-aur-git) package is available in the AUR.
Note the module is installed in `/usr/share/ansible/plugins/modules` which is one of the default module library paths. Note the module is installed in `/usr/share/ansible/plugins/modules` which is one of the default module library paths.
### Manual installation ### Manual installation
@@ -38,9 +38,9 @@ git clone https://github.com/kewlfft/ansible-aur.git ~/.ansible/plugins/modules/
``` ```
## Usage ## Usage
### Note ### Notes
* This module aims to cover the AUR, for package removal or system upgrade with the repositories, it is recommended to use the official *pacman* module, * This module aims to cover the AUR; for package removal or system upgrade with the repositories, it is recommended to use the official *pacman* module.
* A package is reinstalled only if an update is available, using the *--needed* parameter, except for *yay* which does not support it and systematically reinstalls. * The *--needed* parameter of the helper is systematically used, it means if a package is up to date, it is not built and reinstalled.
### Examples ### Examples
Use it in a task, as in the following examples: Use it in a task, as in the following examples:
@@ -68,7 +68,7 @@ Use it in a task, as in the following examples:
``` ```
### Create the "aur_builder" user ### Create the "aur_builder" user
While Ansible expects to SSH as root, AUR helpers do not allow executing operations as root, they all fail with "you cannot perform this operation as root". It is therefore recommended to create a user, that we will call for example *aur_builder*, that has no need for password with pacman in sudoers. While Ansible expects to SSH as root, AUR helpers do not allow executing operations as root, they all fail with "you cannot perform this operation as root". It is therefore recommended to create a user, let's call it *aur_builder*, that has no need for password with pacman in sudoers.
This can be done in Ansible with the following actions: This can be done in Ansible with the following actions:
``` ```
- user: - user:

27
aur.py
View File

@@ -9,6 +9,7 @@ import tarfile
import os import os
import os.path import os.path
import tempfile import tempfile
import urllib.parse
DOCUMENTATION = ''' DOCUMENTATION = '''
@@ -34,7 +35,7 @@ options:
description: description:
- The helper to use, 'auto' uses the first known helper found and makepkg as a fallback. - The helper to use, 'auto' uses the first known helper found and makepkg as a fallback.
default: auto default: auto
choices: [ auto, aurman, pacaur, trizen, pikaur, yay, makepkg ] choices: [ auto, yay, aurman, pacaur, trizen, pikaur, makepkg ]
skip_installed: skip_installed:
description: description:
@@ -76,8 +77,8 @@ EXAMPLES = '''
def_lang = ['env', 'LC_ALL=C'] def_lang = ['env', 'LC_ALL=C']
use_cmd = { use_cmd = {
'aurman': ['aurman', '-S', '--noconfirm', '--noedit', '--needed', '--skip_news', '--pgp_fetch'], 'yay': ['yay', '-S', '--noconfirm', '--needed', '--cleanafter'],
'yay': ['yay', '-S', '--noconfirm', '--needed'], 'aurman': ['aurman', '-S', '--noconfirm', '--noedit', '--needed', '--skip_news', '--pgp_fetch', '--skip_new_locations'],
'pacaur': ['pacaur', '-S', '--noconfirm', '--noedit', '--needed'], 'pacaur': ['pacaur', '-S', '--noconfirm', '--noedit', '--needed'],
'trizen': ['trizen', '-S', '--noconfirm', '--noedit', '--needed'], 'trizen': ['trizen', '-S', '--noconfirm', '--noedit', '--needed'],
'pikaur': ['pikaur', '-S', '--noconfirm', '--noedit', '--needed'], 'pikaur': ['pikaur', '-S', '--noconfirm', '--noedit', '--needed'],
@@ -108,13 +109,13 @@ def check_packages(module, packages):
if would_be_changed: if would_be_changed:
status = True status = True
if (len(packages) > 1): if len(packages) > 1:
message = '%s package(s) would be installed' % str(len(would_be_changed)) message = '{} package(s) would be installed'.format(len(would_be_changed))
else: else:
message = 'package would be installed' message = 'package would be installed'
else: else:
status = False status = False
if (len(packages) > 1): if len(packages) > 1:
message = 'all packages are already installed' message = 'all packages are already installed'
else: else:
message = 'package is already installed' message = 'package is already installed'
@@ -125,10 +126,11 @@ def install_with_makepkg(module, package):
""" """
Install the specified package with makepkg Install the specified package with makepkg
""" """
f = open_url('https://aur.archlinux.org/rpc/?v=5&type=info&arg={}'.format(package)) module.get_bin_path('fakeroot', required=True)
f = open_url('https://aur.archlinux.org/rpc/?v=5&type=info&arg={}'.format(urllib.parse.quote(package)))
result = json.loads(f.read().decode('utf8')) result = json.loads(f.read().decode('utf8'))
if result['resultcount'] != 1: if result['resultcount'] != 1:
return (1, '', 'package not found') return (1, '', 'package {} not found'.format(package))
result = result['results'][0] result = result['results'][0]
f = open_url('https://aur.archlinux.org/{}'.format(result['URLPath'])) f = open_url('https://aur.archlinux.org/{}'.format(result['URLPath']))
current_path = os.getcwd() current_path = os.getcwd()
@@ -183,10 +185,7 @@ def install_packages(module, packages, use, skip_installed, aur_only):
changed_iter = changed_iter or not (out == '' or '-- skipping' in out or 'nothing to do' in out) changed_iter = changed_iter or not (out == '' or '-- skipping' in out or 'nothing to do' in out)
if changed_iter: message = 'installed package(s)' if changed_iter else 'package(s) already installed'
message = 'installed package(s)'
else:
message = 'package(s) already installed'
module.exit_json( module.exit_json(
changed=changed_iter, changed=changed_iter,
@@ -208,7 +207,7 @@ def main():
}, },
'use': { 'use': {
'default': 'auto', 'default': 'auto',
'choices': ['auto', 'aurman', 'pacaur', 'trizen', 'pikaur', 'yaourt', 'yay', 'makepkg'], 'choices': ['auto'] + list(use_cmd.keys()),
}, },
'skip_installed': { 'skip_installed': {
'default': False, 'default': False,
@@ -236,7 +235,7 @@ def main():
use = 'makepkg' use = 'makepkg'
# auto: select the first helper for which the bin is found # auto: select the first helper for which the bin is found
for k in use_cmd: for k in use_cmd:
if module.get_bin_path(k, False): if module.get_bin_path(k):
use = k use = k
break break
else: else: