mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Updated layman.add and layman.delete to adjust make.conf
When the first overlay is added, the make.conf needs to source layman's make.conf so that emerge sees the packages in the overlay. Likewise, when the last overlay is deleted, the make.conf needs to no longer source layman's make.conf as it will cause emerge to break.
This commit is contained in:
parent
ffd6a38408
commit
583fa7c9a9
@ -13,6 +13,18 @@ def __virtual__():
|
||||
return 'layman'
|
||||
return False
|
||||
|
||||
def _get_makeconf():
|
||||
'''
|
||||
Find the correct make.conf. Gentoo recently moved the make.conf
|
||||
but still supports the old location, using the old location first
|
||||
'''
|
||||
old_conf = '/etc/make.conf'
|
||||
new_conf = '/etc/portage/make.conf'
|
||||
if __salt__['file.file_exists'](old_conf):
|
||||
return old_conf
|
||||
elif __salt__['file.file_exists'](new_conf):
|
||||
return new_conf
|
||||
|
||||
def add(overlay):
|
||||
'''
|
||||
Add the given overlay from the caced remote list to your locally
|
||||
@ -31,6 +43,15 @@ def add(overlay):
|
||||
__salt__['cmd.retcode'](cmd)
|
||||
new_overlays = list_local()
|
||||
|
||||
# If we did not have any overlays before and we sucessfully added
|
||||
# a new one. We need to ensure the make.conf is sourcing layman's
|
||||
# make.conf so emerge can see the overlays
|
||||
if len(old_overlays == 0) and len(new_overlays > 0):
|
||||
srcline = 'source /var/lib/layman/make.conf'
|
||||
makeconf = _get_makeconf()
|
||||
if not __salt__['file.contains'](makeconf, layman):
|
||||
__salt__['file.append'](makeconf, srcline)
|
||||
|
||||
ret = [overlay for overlay in new_overlays if overlay not in old_overlays]
|
||||
return ret
|
||||
|
||||
@ -52,6 +73,14 @@ def delete(overlay):
|
||||
__salt__['cmd.retcode'](cmd)
|
||||
new_overlays = list_local()
|
||||
|
||||
# If we now have no overlays added, We need to ensure that the make.conf
|
||||
# does not source layman's make.conf, as it will break emerge
|
||||
if len(new_overlays == 0):
|
||||
srcline = 'source /var/lib/layman/make.conf'
|
||||
makeconf = _get_makeconf()
|
||||
if __salt__['file.contains'](makeconf, layman):
|
||||
__salt__['file.sed'](makeconf, srcline, '')
|
||||
|
||||
ret = [overlay for overlay in old_overlays if overlay not in new_overlays]
|
||||
return ret
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user