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

22
aur.py
View File

@ -9,7 +9,7 @@ import tarfile
import os import os
import os.path import os.path
import tempfile import tempfile
import re
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
@ -30,6 +30,12 @@ options:
type: bool type: bool
default: no default: no
aur_repo_only:
description:
- When upgrading using only the AUR repo
type: bool
default: no
use: use:
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.
@ -143,12 +149,17 @@ def install_with_makepkg(module, package):
return (rc, out, err) return (rc, out, err)
def upgrade(module, use): def upgrade(module, use, aur_repo_only):
""" """
Upgrade the whole system Upgrade the whole system
""" """
assert use in use_cmd assert use in use_cmd
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) rc, out, err = module.run_command(def_lang + use_cmd[use] + ['-u'], check_rc=True)
module.exit_json( module.exit_json(
@ -201,6 +212,10 @@ def main():
'default': False, 'default': False,
'type': 'bool', 'type': 'bool',
}, },
'aur_repo_only': {
'default': False,
'type': 'bool',
},
'use': { 'use': {
'default': 'auto', 'default': 'auto',
'choices': ['auto', 'aurman', 'pacaur', 'trizen', 'pikaur', 'yaourt', 'yay', 'makepkg'], '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.") module.fail_json(msg="Upgrade cannot be used with this option.")
else: else:
if params['upgrade']: if params['upgrade']:
upgrade(module, use) aur_repo_only = params['aur_repo_only']
upgrade(module, use, aur_repo_only)
else: else:
install_packages(module, params['name'], use, params['skip_installed']) install_packages(module, params['name'], use, params['skip_installed'])