mirror of https://github.com/kewlfft/ansible-aur
Explicitly pass makepkg-specific params through install functions
parent
6615fd76e9
commit
59d3e012ea
|
@ -146,7 +146,7 @@ def check_packages(module, packages):
|
||||||
module.exit_json(changed=status, msg=message, diff=diff)
|
module.exit_json(changed=status, msg=message, diff=diff)
|
||||||
|
|
||||||
|
|
||||||
def install_with_makepkg(module, package):
|
def install_with_makepkg(module, package, skip_pgp_check, ignore_arch):
|
||||||
"""
|
"""
|
||||||
Install the specified package with makepkg
|
Install the specified package with makepkg
|
||||||
"""
|
"""
|
||||||
|
@ -161,19 +161,20 @@ def install_with_makepkg(module, package):
|
||||||
tar = tarfile.open(mode='r|*', fileobj=f)
|
tar = tarfile.open(mode='r|*', fileobj=f)
|
||||||
tar.extractall(tmpdir)
|
tar.extractall(tmpdir)
|
||||||
tar.close()
|
tar.close()
|
||||||
if module.params['skip_pgp_check']:
|
command = build_command_prefix('makepkg', [], skip_pgp_check=skip_pgp_check, ignore_arch=ignore_arch)
|
||||||
use_cmd['makepkg'].append('--skippgpcheck')
|
rc, out, err = module.run_command(command, cwd=os.path.join(tmpdir, result['Name']), check_rc=True)
|
||||||
if module.params['ignore_arch']:
|
|
||||||
use_cmd['makepkg'].append('--ignorearch')
|
|
||||||
rc, out, err = module.run_command(use_cmd['makepkg'], cwd=os.path.join(tmpdir, result['Name']), check_rc=True)
|
|
||||||
return (rc, out, err)
|
return (rc, out, err)
|
||||||
|
|
||||||
|
|
||||||
def build_command_prefix(use, use_args, aur_only):
|
def build_command_prefix(use, use_args, skip_pgp_check=False, ignore_arch=False, aur_only=False):
|
||||||
"""
|
"""
|
||||||
Create the prefix of a command that can be used by the install and upgrade functions.
|
Create the prefix of a command that can be used by the install and upgrade functions.
|
||||||
"""
|
"""
|
||||||
command = def_lang + use_cmd[use]
|
command = def_lang + use_cmd[use]
|
||||||
|
if skip_pgp_check:
|
||||||
|
command.append('--skippgpcheck')
|
||||||
|
if ignore_arch:
|
||||||
|
command.append('--ignorearch')
|
||||||
if (aur_only and use in has_aur_option):
|
if (aur_only and use in has_aur_option):
|
||||||
command.append('--aur')
|
command.append('--aur')
|
||||||
command += use_args
|
command += use_args
|
||||||
|
@ -186,7 +187,7 @@ def upgrade(module, use, use_args, aur_only):
|
||||||
"""
|
"""
|
||||||
assert use in use_cmd
|
assert use in use_cmd
|
||||||
|
|
||||||
command = build_command_prefix(use, use_args, aur_only)
|
command = build_command_prefix(use, use_args, aur_only=aur_only)
|
||||||
command.append('-u')
|
command.append('-u')
|
||||||
|
|
||||||
rc, out, err = module.run_command(command, check_rc=True)
|
rc, out, err = module.run_command(command, check_rc=True)
|
||||||
|
@ -198,7 +199,7 @@ def upgrade(module, use, use_args, aur_only):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def install_packages(module, packages, use, use_args, state, aur_only):
|
def install_packages(module, packages, use, use_args, state, skip_pgp_check, ignore_arch, aur_only):
|
||||||
"""
|
"""
|
||||||
Install the specified packages
|
Install the specified packages
|
||||||
"""
|
"""
|
||||||
|
@ -212,9 +213,9 @@ def install_packages(module, packages, use, use_args, state, aur_only):
|
||||||
rc = 0
|
rc = 0
|
||||||
continue
|
continue
|
||||||
if use == 'makepkg':
|
if use == 'makepkg':
|
||||||
rc, out, err = install_with_makepkg(module, package)
|
rc, out, err = install_with_makepkg(module, package, skip_pgp_check, ignore_arch)
|
||||||
else:
|
else:
|
||||||
command = build_command_prefix(use, use_args, aur_only)
|
command = build_command_prefix(use, use_args, aur_only=aur_only)
|
||||||
command.append(package)
|
command.append(package)
|
||||||
rc, out, err = module.run_command(command, check_rc=True)
|
rc, out, err = module.run_command(command, check_rc=True)
|
||||||
|
|
||||||
|
@ -305,7 +306,7 @@ def apply_module(module, use):
|
||||||
elif params.get('upgrade', False):
|
elif params.get('upgrade', False):
|
||||||
upgrade(module, use, params['use_args'], params['aur_only'])
|
upgrade(module, use, params['use_args'], params['aur_only'])
|
||||||
else:
|
else:
|
||||||
install_packages(module, params['name'], use, params['use_args'], params['state'], params['aur_only'])
|
install_packages(module, params['name'], use, params['use_args'], params['state'], params['skip_pgp_check'], params['ignore_arch'], params['aur_only'])
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
Loading…
Reference in New Issue