Feature: aur repo only option when upgrading whole system closes #2

pull/17/head
Jan Collijs 2018-07-25 12:45:02 +02:00
parent 9772b680dd
commit b8e4565eb3
No known key found for this signature in database
GPG Key ID: DFD84079F6AC6D5A
1 changed files with 20 additions and 4 deletions

24
aur.py
View File

@ -9,7 +9,7 @@ import tarfile
import os
import os.path
import tempfile
import re
DOCUMENTATION = '''
---
@ -30,6 +30,12 @@ options:
type: bool
default: no
aur_repo_only:
description:
- When upgrading using only the AUR repo
type: bool
default: no
use:
description:
- The helper to use, 'auto' uses the first known helper found and makepkg as a fallback.
@ -143,13 +149,18 @@ def install_with_makepkg(module, package):
return (rc, out, err)
def upgrade(module, use):
def upgrade(module, use, aur_repo_only):
"""
Upgrade the whole system
"""
assert use in use_cmd
rc, out, err = module.run_command(def_lang + use_cmd[use] + ['-u'], check_rc=True)
compatible_aur_use = re.match("(aurman|pacaur|trizen)" , use)
if compatible_aur_use and aur_repo_only:
rc, out, err = module.run_command(def_lang + use_cmd[use] + ['--aur'] + ['-u'], check_rc=True)
else:
message='all only'
rc, out, err = module.run_command(def_lang + use_cmd[use] + ['-u'], check_rc=True)
module.exit_json(
changed=not (out == '' or 'nothing to do' in out or 'No AUR updates found' in out),
@ -201,6 +212,10 @@ def main():
'default': False,
'type': 'bool',
},
'aur_repo_only': {
'default': False,
'type': 'bool',
},
'use': {
'default': 'auto',
'choices': ['auto', 'aurman', 'pacaur', 'trizen', 'pikaur', 'yaourt', 'yay', 'makepkg'],
@ -237,7 +252,8 @@ def main():
module.fail_json(msg="Upgrade cannot be used with this option.")
else:
if params['upgrade']:
upgrade(module, use)
aur_repo_only = params['aur_repo_only']
upgrade(module, use, aur_repo_only)
else:
install_packages(module, params['name'], use, params['skip_installed'])