HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/makeconf.cpython-310.pyc
o

�N�g�D�@sxdZddlZddlZdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�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

�NcCstddkrdSdS)z
    Only work on Gentoo
    �osZGentoo�makeconf)FzQThe makeconf execution module cannot be loaded: only available on Gentoo systems.)Z
__grains__�rr�I/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/makeconf.py�__virtual__
srcCs,d}d}td|�r|Std|�r|SdS)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_confrrr�
_get_makeconfs�rcCsft�}d}|�d|�d�}td||�r*ddd�|�dd	�|�|g}td
|�dStd||�dS)
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)rr�format�replace)�var�valuerZlaymanZfullvar�cmdrrr�_add_var$s�rcCs\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_varrr�rrr�	old_value�	new_valuerrr�set_var;s&
rcCsDt�}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'
    Nrrr�r�rrr)rrrrrrr�
remove_varXsr cCsjt�}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� rrrr	r
rr)rrrrZappended_valuerrrr�
append_varss&
r"cCs@t�}t|�}|durtd||d|d�t|�}|||d�iS)a1
    Remove a value from 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.trim_var 'LINGUAS' 'en'
    Nrr)�limitrrrrrr�trim_var�sr$cCs�t�}tjj�|��}tjj�|���}Wd�n1swY|D].}|�|�rS|�	dd�d}d|vr@|�	d�d}nd|vrK|�	d�d}|�
�}|Sq%dS)z�
    Get the value of a variable in make.conf

    Return the value of the variable or None if the variable is not in
    make.conf

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.get_var 'LINGUAS'
    N�=�r
�#r)r�salt�utils�filesZfopen�data�decode�	readlines�
startswith�split�strip)rrZfn_Z	conf_file�line�retrrrr�s
�
�rcCs,t|�}|�dd�}|durdS||��vS)z�
    Verify if variable contains a value in make.conf

    Return True if value is set for var

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.var_contains 'LINGUAS' 'en'
    �\rNF)rr
r/)rrZsetvalrrr�var_contains�s
r4cC�
td|�S)a&
    Set the CFLAGS variable

    Return a dict containing the new value for variable::

        {'<variable>': {'old': '<old-value>',
                        'new': '<new-value>'}}

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.set_cflags '-march=native -O2 -pipe'
    �CFLAGS�r�rrrr�
set_cflags��
r9cC�td�S)z�
    Get the value of CFLAGS variable in the make.conf

    Return the value of the variable or None if the variable is
    not in the make.conf

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.get_cflags
    r6�rrrrr�
get_cflags��
r=cCr5)a.
    Add to or create a new CFLAGS 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_cflags '-pipe'
    r6�r"r8rrr�
append_cflags�r:r@cCr5)a2
    Remove a value from CFLAGS 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.trim_cflags '-pipe'
    r6�r$r8rrr�trim_cflagsr:rBcCr5)z�
    Verify if CFLAGS variable contains a value in make.conf

    Return True if value is set for var

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.cflags_contains '-pipe'
    r6�r4r8rrr�cflags_contains#�
rDcCr5)a*
    Set the CXXFLAGS variable

    Return a dict containing the new value for variable::

        {'<variable>': {'old': '<old-value>',
                        'new': '<new-value>'}}

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.set_cxxflags '-march=native -O2 -pipe'
    �CXXFLAGSr7r8rrr�set_cxxflags2r:rGcCr;)z�
    Get the value of CXXFLAGS variable in the make.conf

    Return the value of the variable or None if the variable is
    not in the make.conf

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.get_cxxflags
    rFr<rrrr�get_cxxflagsDr>rHcCr5)a2
    Add to or create a new CXXFLAGS 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_cxxflags '-pipe'
    rFr?r8rrr�append_cxxflagsTr:rIcCr5)a6
    Remove a value from CXXFLAGS 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.trim_cxxflags '-pipe'
    rFrAr8rrr�
trim_cxxflagsfr:rJcCr5)z�
    Verify if CXXFLAGS variable contains a value in make.conf

    Return True if value is set for var

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.cxxflags_contains '-pipe'
    rFrCr8rrr�cxxflags_containsxrErKcCr5)a 
    Set the CHOST variable

    Return a dict containing the new value for variable::

        {'<variable>': {'old': '<old-value>',
                        'new': '<new-value>'}}

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.set_chost 'x86_64-pc-linux-gnu'
    �CHOSTr7r8rrr�	set_chost�r:rMcCr;)z�
    Get the value of CHOST variable in the make.conf

    Return the value of the variable or None if the variable is
    not in the make.conf

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.get_chost
    rLr<rrrr�	get_chost�r>rNcCr5)z�
    Verify if CHOST variable contains a value in make.conf

    Return True if value is set for var

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.chost_contains 'x86_64-pc-linux-gnu'
    rLrCr8rrr�chost_contains�rErOcCr5)a
    Set the MAKEOPTS variable

    Return a dict containing the new value for variable::

        {'<variable>': {'old': '<old-value>',
                        'new': '<new-value>'}}

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.set_makeopts '-j3'
    �MAKEOPTSr7r8rrr�set_makeopts�r:rQcCr;)z�
    Get the value of MAKEOPTS variable in the make.conf

    Return the value of the variable or None if the variable is
    not in the make.conf

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.get_makeopts
    rPr<rrrr�get_makeopts�r>rRcCr5)a0
    Add to or create a new MAKEOPTS 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_makeopts '-j3'
    rPr?r8rrr�append_makeopts�r:rScCr5)a4
    Remove a value from MAKEOPTS 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.trim_makeopts '-j3'
    rPrAr8rrr�
trim_makeopts�r:rTcCr5)z�
    Verify if MAKEOPTS variable contains a value in make.conf

    Return True if value is set for var

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.makeopts_contains '-j3'
    rPrCr8rrr�makeopts_contains�rErUcCr5)a/
    Set the EMERGE_DEFAULT_OPTS variable

    Return a dict containing the new value for variable::

        {'<variable>': {'old': '<old-value>',
                        'new': '<new-value>'}}

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.set_emerge_default_opts '--jobs'
    �EMERGE_DEFAULT_OPTSr7r8rrr�set_emerge_default_opts
r:rWcCr;)a
    Get the value of EMERGE_DEFAULT_OPTS variable in the make.conf

    Return the value of the variable or None if the variable is
    not in the make.conf

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.get_emerge_default_opts
    rVr<rrrr�get_emerge_default_optsr>rXcCr5)aI
    Add to or create a new EMERGE_DEFAULT_OPTS 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_emerge_default_opts '--jobs'
    rVr?r8rrr�append_emerge_default_opts/r:rYcCr5)aM
    Remove a value from EMERGE_DEFAULT_OPTS 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.trim_emerge_default_opts '--jobs'
    rVrAr8rrr�trim_emerge_default_optsAr:rZcCr5)z�
    Verify if EMERGE_DEFAULT_OPTS variable contains a value in make.conf

    Return True if value is set for var

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.emerge_default_opts_contains '--jobs'
    rVrCr8rrr�emerge_default_opts_containsSrEr[cCr5)a:
    Set the GENTOO_MIRRORS variable

    Return a dict containing the new value for variable::

        {'<variable>': {'old': '<old-value>',
                        'new': '<new-value>'}}

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.set_gentoo_mirrors 'http://distfiles.gentoo.org'
    �GENTOO_MIRRORSr7r8rrr�set_gentoo_mirrorsbr:r]cCr;)z�
    Get the value of GENTOO_MIRRORS variable in the make.conf

    Return the value of the variable or None if the variable is
    not in the make.conf

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.get_gentoo_mirrors
    r\r<rrrr�get_gentoo_mirrorstr>r^cCr5)aT
    Add to or create a new GENTOO_MIRRORS 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_gentoo_mirrors 'http://distfiles.gentoo.org'
    r\r?r8rrr�append_gentoo_mirrors�r:r_cCr5)aX
    Remove a value from GENTOO_MIRRORS 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.trim_gentoo_mirrors 'http://distfiles.gentoo.org'
    r\rAr8rrr�trim_gentoo_mirrors�r:r`cCr5)z�
    Verify if GENTOO_MIRRORS variable contains a value in make.conf

    Return True if value is set for var

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.gentoo_mirrors_contains 'http://distfiles.gentoo.org'
    r\rCr8rrr�gentoo_mirrors_contains�rEracCr5)a;
    Set the SYNC variable

    Return a dict containing the new value for variable::

        {'<variable>': {'old': '<old-value>',
                        'new': '<new-value>'}}

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.set_sync 'rsync://rsync.namerica.gentoo.org/gentoo-portage'
    �SYNCr7r8rrr�set_sync�r:rccCr;)z�
    Get the value of SYNC variable in the make.conf

    Return the value of the variable or None if the variable is
    not in the make.conf

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.get_sync
    rbr<rrrr�get_sync�r>rdcCr5)z�
    Verify if SYNC variable contains a value in make.conf

    Return True if value is set for var

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.sync_contains 'rsync://rsync.namerica.gentoo.org/gentoo-portage'
    rbrCr8rrr�
sync_contains�rErecCr;)z�
    Get the value of FEATURES variable in the make.conf

    Return the value of the variable or None if the variable is
    not in the make.conf

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.get_features
    �FEATURESr<rrrr�get_features�r>rgcCr5)a9
    Add to or create a new FEATURES 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_features 'webrsync-gpg'
    rfr?r8rrr�append_features�r:rhcCr5)a=
    Remove a value from FEATURES 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.trim_features 'webrsync-gpg'
    rfrAr8rrr�
trim_features
r:ricCr5)z�
    Verify if FEATURES variable contains a value in make.conf

    Return True if value is set for var

    CLI Example:

    .. code-block:: bash

        salt '*' makeconf.features_contains 'webrsync-gpg'
    rfrCr8rrr�features_containsrErj)0�__doc__Zsalt.utils.datar(Zsalt.utils.filesrrrrr r"r$rr4r9r=r@rBrDrGrHrIrJrKrMrNrOrQrRrSrTrUrWrXrYrZr[r]r^r_r`rarcrdrergrhrirjrrrr�<module>s^