File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/makeconf.cpython-310.pyc
o
�N�g�D � @ sx d Z ddlZddlZdd� Zdd� Zdd� Zd d
� Zdd� Zd
d� Z dd� Z
dd� Zdd� Zdd� Z
dd� Zdd� Zdd� Zdd� Zdd � Zd!d"� Zd#d$� Zd%d&� Zd'd(� Zd)d*� Zd+d,� Zd-d.� Zd/d0� Zd1d2� Zd3d4� Zd5d6� Zd7d8� Zd9d:� Zd;d<� Z d=d>� Z!d?d@� Z"dAdB� Z#dCdD� Z$dEdF� Z%dGdH� Z&dIdJ� Z'dKdL� Z(dMdN� Z)dOdP� Z*dQdR� Z+dSdT� Z,dUdV� Z-dWdX� Z.dYdZ� Z/dS )[z/
Support for modifying make.conf under Gentoo
� Nc C s t d dkrdS dS )z
Only work on Gentoo
�osZGentoo�makeconf)FzQThe makeconf execution module cannot be loaded: only available on Gentoo systems.)Z
__grains__� r r �I/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/makeconf.py�__virtual__
s r c C s, d} d}t d | �r| S t d |�r|S dS )z�
Find the correct make.conf. Gentoo recently moved the make.conf
but still supports the old location, using the old location first
z/etc/make.confz/etc/portage/make.confzfile.file_existsN)�__salt__)Zold_confZnew_confr r r �
_get_makeconf s �r c C sf t � }d}| � d|� d�}td ||�r*ddd�|�dd �|�|g}td
|� dS td ||� dS )
z�
Add a new var to the make.conf. If using layman, the source line
for the layman make.conf needs to be at the very end of the
config. This ensures that the new var will be above the source
line.
z source /var/lib/layman/make.conf�="�"z
file.containsZsedz-iz /{}/ i\{}�/z\/zcmd.runzfile.appendN)r r �format�replace)�var�valuer ZlaymanZfullvar�cmdr r r �_add_var$ s �r c C s\ t � }t| �}|durtd |d| � d�| � d|� d�� nt| |� t| �}| ||d�iS )a
Set a variable in the make.conf
Return a dict containing the new value for variable::
{'<variable>': {'old': '<old-value>',
'new': '<new-value>'}}
CLI Example:
.. code-block:: bash
salt '*' makeconf.set_var 'LINGUAS' 'en'
N�file.sed�^�=.*r r
��old�new�r �get_varr r �r r r � old_value� new_valuer r r �set_var; s &
r c C sD t � }t| �}|durtd |d| � d�d� t| �}| ||d�iS )a'
Remove a variable from the make.conf
Return a dict containing the new value for the variable::
{'<variable>': {'old': '<old-value>',
'new': '<new-value>'}}
CLI Example:
.. code-block:: bash
salt '*' makeconf.remove_var 'LINGUAS'
Nr r r � r �r r r )r r r r r r r �
remove_varX s r c C sj t � }t| �}|dur%|� d|� �}td |d| � d�| � d|� d�� nt| |� t| �}| ||d�iS ) a4
Add to or create a new variable in the make.conf
Return a dict containing the new value for variable::
{'<variable>': {'old': '<old-value>',
'new': '<new-value>'}}
CLI Example:
.. code-block:: bash
salt '*' makeconf.append_var 'LINGUAS' 'en'
N� r r r r r
r r )r r r r Zappended_valuer r r r �
append_vars s &
r"