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__/rvm.cpython-310.pyc
o

�N�g9,�@sdZddlZddlZddlZddlZddlmZe�e	�Z
ddiZddiZd.dd�Z
d/d	d
�Zd/dd�Zd.d
d�Zd.dd�Zd/dd�Zd0dd�Zd.dd�Zd.dd�Zd1dd�Zd.dd�Zd.dd�Zd.dd �Zd2d"d#�Zd.d$d%�Zd.d&d'�Zd.d(d)�Zd.d*d+�Zd/d,d-�ZdS)3zK
Manage ruby installations and gemsets with RVM, the Ruby Version Manager.
�N)�CommandExecutionError�list_�list�	rvm.runascCs8|rtj�d|���}|�d�}tj�|�r|gSdgS)N�~z
/.rvm/bin/rvmz/usr/local/rvm/bin/rvm)�os�path�
expanduser�exists)�runasZ
runas_homeZrvmpath�r�D/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/rvm.py�_get_rvm_locations
rcCsZ|dur
tdd�}t|�sdSt|�|}td|||d|d�}|ddkr+|dSdS)	Nz
config.optionrF�cmd.run_all)r�cwd�python_shell�env�retcoder�stdout)�__salt__�is_installedr)�commandrrr�cmd�retrrr
�_rvms
�rcCst|pddg||||d�S)N�default�do�rrr�r��rubyrrrrrrr
�_rvm_do0sr!cCs,ztdt|�d�WStyYdSw)zs
    Check if RVM is installed.

    CLI Example:

    .. code-block:: bash

        salt '*' rvm.is_installed
    zcmd.has_execrF)rr�
IndexError�rrrr
r4s

�rcCsRd}tdd|�d�|dd�}|ddkr'd	}|d
r#|d|d
7}t|��dS)a
    Install RVM system-wide

    runas
        The user under which to run the rvm installer script. If not specified,
        then it be run as the user under which Salt is running.

    CLI Example:

    .. code-block:: bash

        salt '*' rvm.install
    zIhttps://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installerrz	curl -Ls z | bash -s stableT)rrrrz5Error encountered while downloading the RVM installer�stderrz. stderr follows:

)rr)rZ	installerr�msgrrr
�installDs�
�r&cCsN|durg}|r|dkrtdd|g||d�|�d�td|g|||d�S)	a
    Install a ruby implementation.

    ruby
        The version of ruby to install

    runas
        The user under which to run rvm. If not specified, then rvm will be run
        as the user under which Salt is running.

    env
        Environment to set for the install command. Useful for exporting compilation
        flags such as RUBY_CONFIGURE_OPTS

    opts
        List of options to pass to the RVM installer (ie -C, --patch, etc)

    CLI Example:

    .. code-block:: bash

        salt '*' rvm.install_ruby 1.9.3-p385
    N�rootZautolibs�disabler#z--disable-binaryr&�rr)r�append)r r�optsrrrr
�install_rubyfs
r,cCstd|g||d�S)aD
    Reinstall a ruby implementation

    ruby
        The version of ruby to reinstall

    runas
        The user under which to run rvm. If not specified, then rvm will be run
        as the user under which Salt is running.

    CLI Example:

    .. code-block:: bash

        salt '*' rvm.reinstall_ruby 1.9.3-p385
    Z	reinstallr)r)r rrrrr
�reinstall_ruby�sr-cCsfg}tdg|d�}|r1t�d�}|��D]}|�|�}|r0|�|�d�|�d�|�d�dkg�q|S)z�
    List all rvm-installed rubies

    runas
        The user under which to run rvm. If not specified, then rvm will be run
        as the user under which Salt is running.

    CLI Example:

    .. code-block:: bash

        salt '*' rvm.list
    rr#z(^[= ]([*> ]) ([^- ]+)-([^ ]+) \[ (.*) \]����*)r�re�compile�
splitlines�matchr*�group)rZrubies�output�regex�liner5rrr
r�s

&�cCstddd|g|d�S)a8
    Set the default ruby

    ruby
        The version of ruby to make the default

    runas
        The user under which to run rvm. If not specified, then rvm will be run
        as the user under which Salt is running.

    CLI Example:

    .. code-block:: bash

        salt '*' rvm.set_default 2.0.0
    �alias�createrr#r)r rrrr
�set_default�sr<�stablecCstd|g|d�S)z�
    Update RVM

    version : stable
        Which version of RVM to install, (e.g. stable or head)

    CLI Example:

    .. code-block:: bash

        salt '*' rvm.get
    �getr#r)�versionrrrr
r>�s
r>cGs d||g}|�|�t||d�S)am
    Install RVM wrapper scripts

    ruby_string
        Ruby/gemset to install wrappers for

    wrapper_prefix
        What to prepend to the name of the generated wrapper binaries

    runas
        The user under which to run rvm. If not specified, then rvm will be run
        as the user under which Salt is running.

    binaries : None
        The names of the binaries to create wrappers for. When nothing is
        given, wrappers for ruby, gem, rake, irb, rdoc, ri and testrb are
        generated.

    CLI Example:

    .. code-block:: bash

        salt '*' rvm.wrapper <ruby_string> <wrapper_prefix>
    �wrapperr#)�extendr)Zruby_stringZwrapper_prefixrZbinariesrrrr
r@�s

r@cCst|d|g|d�S)a�
    Installs a specific rubygems version in the given ruby

    ruby
        The ruby for which to install rubygems

    version
        The version of rubygems to install, or 'remove' to use the version that
        ships with 1.9

    runas
        The user under which to run rvm. If not specified, then rvm will be run
        as the user under which Salt is running.

    CLI Example:

    .. code-block:: bash

        salt '*' rvm.rubygems 2.0.0 1.8.24
    �rubygemsr#�r!)r r?rrrr
rB�srBcCst|ddd|g|d�S)a{
    Creates a gemset.

    ruby
        The ruby version for which to create the gemset

    gemset
        The name of the gemset to create

    runas
        The user under which to run rvm. If not specified, then rvm will be run
        as the user under which Salt is running.

    CLI Example:

    .. code-block:: bash

        salt '*' rvm.gemset_create 2.0.0 foobar
    �rvm�gemsetr;r#rC�r rErrrr
�
gemset_createsrGrcCsTg}t|gd�|d�}|r(t�d�}|��D]}|�|�}|r'|�|�d��q|S)aS
    List all gemsets for the given ruby.

    ruby : default
        The ruby version for which to list the gemsets

    runas
        The user under which to run rvm. If not specified, then rvm will be run
        as the user under which Salt is running.

    CLI Example:

    .. code-block:: bash

        salt '*' rvm.gemset_list
    )rDrErr#�^   ([^ ]+)r0)r!r2r3r4r5r*r6)r r�gemsetsr7r8r9r5rrr
�gemset_list*s

�rJcC�t|dddd|g|d�S)aj
    Delete a gemset

    ruby
        The ruby version to which the gemset belongs

    gemset
        The gemset to delete

    runas
        The user under which to run rvm. If not specified, then rvm will be run
        as the user under which Salt is running.

    CLI Example:

    .. code-block:: bash

        salt '*' rvm.gemset_delete 2.0.0 foobar
    rD�--forcerE�deleter#rCrFrrr
�
gemset_deleteF�rNcCrK)aw
    Remove all gems from a gemset.

    ruby
        The ruby version to which the gemset belongs

    gemset
        The gemset to empty

    runas
        The user under which to run rvm. If not specified, then rvm will be run
        as the user under which Salt is running.

    CLI Example:

    .. code-block:: bash

        salt '*' rvm.gemset_empty 2.0.0 foobar
    rDrLrE�emptyr#rCrFrrr
�gemset_empty]rOrQcCstdd||g|d�S)a�
    Copy all gems from one gemset to another.

    source
        The name of the gemset to copy, complete with ruby version

    destination
        The destination gemset

    runas
        The user under which to run rvm. If not specified, then rvm will be run
        as the user under which Salt is running.

    CLI Example:

    .. code-block:: bash

        salt '*' rvm.gemset_copy foobar bazquo
    rE�copyr#r)�sourceZdestinationrrrr
�gemset_copytsrTcCs�i}d}tdgd�|d�}|rAt�d�}t�d�}|��D]#}|�|�}|r/|�d�}g||<|�|�}|r@||�|�d��q|S)aX
    List all gemsets for all installed rubies.

    Note that you must have set a default ruby before this can work.

    runas
        The user under which to run rvm. If not specified, then rvm will be run
        as the user under which Salt is running.

    CLI Example:

    .. code-block:: bash

        salt '*' rvm.gemset_list_all
    Nr)rDrEZlist_allr#rHz^gemsets for ([^ ]+)r0)r!r2r3r4r5r6r*)rrIZcurrent_rubyr7Z
gems_regexZgemset_regexr9r5rrr
�gemset_list_all�s 




�rUcCsJz	tjj�|�}Wntytjj�t|��}Ynwt|||||d�S)a�
    Execute a command in an RVM controlled environment.

    ruby
        Which ruby to use

    command
        The rvm command to execute

    runas
        The user under which to run rvm. If not specified, then rvm will be run
        as the user under which Salt is running.

    cwd
        The directory from which to run the rvm command. Defaults to the user's
        home directory.

    CLI Example:

    .. code-block:: bash

        salt '*' rvm.do 2.0.0 <command>
    r)�salt�utils�argsZshlex_split�AttributeError�strr!rrrr
r�s�r)N)NNN)NN)r=N)rN) �__doc__�loggingrr2Zsalt.utils.argsrVZsalt.exceptionsr�	getLogger�__name__�logZ__func_alias__Z__opts__rrr!rr&r,r-rr<r>r@rBrGrJrNrQrTrUrrrrr
�<module>s:
�

	



"
&










!