mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge pull request #8309 from shadowfax-chc/emerge-errors
More error reporting in ebuild module
This commit is contained in:
commit
6738451c9e
@ -84,13 +84,28 @@ def _cpv_to_version(cpv):
|
||||
return portage.versions.cpv_getversion(cpv)
|
||||
|
||||
|
||||
def _process_emerge_err(stderr):
|
||||
def _process_emerge_err(stdout, stderr):
|
||||
'''
|
||||
Used to parse emerge output to provide meaningful output when emerge fails
|
||||
'''
|
||||
ret = {}
|
||||
changes = {}
|
||||
rexp = re.compile(r'([<>=][^ ]+/[^ ]+ [^\n]+)')
|
||||
rexp = re.compile(r'^[<>=][^ ]+/[^ ]+ [^\n]+', re.M)
|
||||
|
||||
slot_conflicts = re.compile(r'^[^ \n]+/[^ ]+:[^ ]', re.M).findall(stderr)
|
||||
if slot_conflicts:
|
||||
changes['slot conflicts'] = slot_conflicts
|
||||
|
||||
blocked = re.compile(r'(?m)^\[blocks .+\] '
|
||||
r'([^ ]+/[^ ]+-[0-9]+[^ ]+)'
|
||||
r'.*$').findall(stdout)
|
||||
|
||||
unsatisfied = re.compile(
|
||||
r'Error: The above package list contains').findall(stderr)
|
||||
|
||||
# If there were blocks and emerge could not resolve it.
|
||||
if blocked and unsatisfied:
|
||||
changes['blocked'] = blocked
|
||||
|
||||
sections = re.split('\n\n', stderr)
|
||||
for section in sections:
|
||||
@ -102,7 +117,7 @@ def _process_emerge_err(stderr):
|
||||
changes['use'] = rexp.findall(section)
|
||||
elif 'The following mask changes' in section:
|
||||
changes['mask'] = rexp.findall(section)
|
||||
ret['changes'] = changes
|
||||
ret['changes'] = {'Needed changes': changes}
|
||||
return ret
|
||||
|
||||
|
||||
@ -551,7 +566,7 @@ def install(name=None,
|
||||
call = __salt__['cmd.run_all'](cmd)
|
||||
__context__.pop('pkg.list_pkgs', None)
|
||||
if call['retcode'] != 0:
|
||||
return _process_emerge_err(call['stderr'])
|
||||
return _process_emerge_err(call['stdout'], call['stderr'])
|
||||
new = list_pkgs()
|
||||
changes.update(salt.utils.compare_dicts(old, new))
|
||||
return changes
|
||||
@ -596,7 +611,7 @@ def update(pkg, slot=None, fromrepo=None, refresh=False):
|
||||
call = __salt__['cmd.run_all'](cmd)
|
||||
__context__.pop('pkg.list_pkgs', None)
|
||||
if call['retcode'] != 0:
|
||||
return _process_emerge_err(call['stderr'])
|
||||
return _process_emerge_err(call['stdout'], call['stderr'])
|
||||
new = list_pkgs()
|
||||
return salt.utils.compare_dicts(old, new)
|
||||
|
||||
@ -624,7 +639,7 @@ def upgrade(refresh=True):
|
||||
call = __salt__['cmd.run_all'](cmd)
|
||||
__context__.pop('pkg.list_pkgs', None)
|
||||
if call['retcode'] != 0:
|
||||
return _process_emerge_err(call['stderr'])
|
||||
return _process_emerge_err(call['stdout'], call['stderr'])
|
||||
new = list_pkgs()
|
||||
return salt.utils.compare_dicts(old, new)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user