mirror of
https://github.com/kewlfft/ansible-aur.git
synced 2025-09-17 08:30:39 +03:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
dff3cfb450 | ||
![]() |
89e26748da | ||
![]() |
de92aa87cb | ||
![]() |
5d952d26fd |
@@ -108,11 +108,17 @@ def check_packages(module, packages):
|
|||||||
Inform the user what would change if the module were run
|
Inform the user what would change if the module were run
|
||||||
"""
|
"""
|
||||||
would_be_changed = []
|
would_be_changed = []
|
||||||
|
diff = {
|
||||||
|
'before': '',
|
||||||
|
'after': '',
|
||||||
|
}
|
||||||
|
|
||||||
for package in packages:
|
for package in packages:
|
||||||
installed = package_installed(module, package)
|
installed = package_installed(module, package)
|
||||||
if not installed:
|
if not installed:
|
||||||
would_be_changed.append(package)
|
would_be_changed.append(package)
|
||||||
|
if module._diff:
|
||||||
|
diff['after'] += package + "\n"
|
||||||
|
|
||||||
if would_be_changed:
|
if would_be_changed:
|
||||||
status = True
|
status = True
|
||||||
@@ -126,7 +132,7 @@ def check_packages(module, packages):
|
|||||||
message = 'all packages are already installed'
|
message = 'all packages are already installed'
|
||||||
else:
|
else:
|
||||||
message = 'package is already installed'
|
message = 'package is already installed'
|
||||||
module.exit_json(changed=status, msg=message)
|
module.exit_json(changed=status, msg=message, diff=diff)
|
||||||
|
|
||||||
|
|
||||||
def install_with_makepkg(module, package):
|
def install_with_makepkg(module, package):
|
||||||
@@ -140,22 +146,15 @@ def install_with_makepkg(module, package):
|
|||||||
return (1, '', 'package {} not found'.format(package))
|
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()
|
|
||||||
with tempfile.TemporaryDirectory() as tmpdir:
|
with tempfile.TemporaryDirectory() as tmpdir:
|
||||||
os.chdir(tmpdir)
|
tar = tarfile.open(mode='r|*', fileobj=f)
|
||||||
tar_file = '{}.tar.gz'.format(result['Name'])
|
tar.extractall(tmpdir)
|
||||||
with open(tar_file, 'wb') as out:
|
|
||||||
out.write(f.read())
|
|
||||||
tar = tarfile.open(tar_file)
|
|
||||||
tar.extractall()
|
|
||||||
tar.close()
|
tar.close()
|
||||||
os.chdir(format(result['Name']))
|
|
||||||
if module.params['skip_pgp_check']:
|
if module.params['skip_pgp_check']:
|
||||||
use_cmd['makepkg'].append('--skippgpcheck')
|
use_cmd['makepkg'].append('--skippgpcheck')
|
||||||
if module.params['ignore_arch']:
|
if module.params['ignore_arch']:
|
||||||
use_cmd['makepkg'].append('--ignorearch')
|
use_cmd['makepkg'].append('--ignorearch')
|
||||||
rc, out, err = module.run_command(use_cmd['makepkg'], check_rc=True)
|
rc, out, err = module.run_command(use_cmd['makepkg'], cwd=os.path.join(tmpdir, result['Name']), check_rc=True)
|
||||||
os.chdir(current_path)
|
|
||||||
return (rc, out, err)
|
return (rc, out, err)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user