HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/rbenv.cpython-310.pyc
o

�N�g=�@shdZddlZddlZddd�Zddd�Zddd	�Zdd
d�Zddd
�Zddd�Zddd�Z	ddd�Z
dS)a�
Managing Ruby installations with rbenv
======================================

This module is used to install and manage ruby installations with rbenv and the
ruby-build plugin. Different versions of ruby can be installed, and uninstalled.
Rbenv will be installed automatically the first time it is needed and can be
updated later. This module will *not* automatically install packages which rbenv
will need to compile the versions of ruby. If your version of ruby fails to
install, refer to the ruby-build documentation to verify you are not missing any
dependencies: https://github.com/rbenv/ruby-build/wiki

If rbenv is run as the root user then it will be installed to /usr/local/rbenv,
otherwise it will be installed to the users ~/.rbenv directory. To make
rbenv available in the shell you may need to add the rbenv/shims and rbenv/bin
directories to the users PATH. If you are installing as root and want other
users to be able to access rbenv then you will need to add RBENV_ROOT to
their environment.

The following state configuration demonstrates how to install Ruby 1.9.x
and 2.x using rbenv on Ubuntu/Debian:

.. code-block:: yaml

    rbenv-deps:
      pkg.installed:
        - names:
          - bash
          - git
          - openssl
          - libssl-dev
          - make
          - curl
          - autoconf
          - bison
          - build-essential
          - libffi-dev
          - libyaml-dev
          - libreadline6-dev
          - zlib1g-dev
          - libncurses5-dev

    ruby-1.9.3-p429:
      rbenv.absent:
        - require:
          - pkg: rbenv-deps

    ruby-2.0.0-p598:
      rbenv.installed:
        - default: True
        - require:
          - pkg: rbenv-deps
�NcCs td|�sd|d<d|d<|S)z-
    Check to see if rbenv is installed.
    zrbenv.is_installedF�resultzRbenv is not installed.�comment��__salt__��ret�user�r	�E/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/rbenv.py�_check_rbenv;srcCsNtd|d�}td|�D]}||kr$d|d<d|d<||k|d<|Sq
|S)	z2
    Check to see if given ruby is installed.
    �
rbenv.default�Zrunaszrbenv.versionsTrzRequested ruby existsr�defaultr)r�rubyrr�versionr	r	r
�_ruby_installedEs�rFcCsxt|||d�}|ds0td||d�r&d|d<d|d|<d|d	<||d
<n
d|d<d|d	<|S|r:td
||d�|S)z?
    Verify that ruby is installed, install if unavailable
    �rrzrbenv.install_rubyr
TZ	Installed�changeszSuccessfully installed rubyrrFzFailed to install rubyr�rr)rrrrr	r	r
�_check_and_install_rubyTs
rcCs�|ddid�}t�|�}|�d�rt�dd|�}tdr;t|||d�}|ds1d	|�d
�|d<|Sd	|�d�|d<|St||�}|dd
urPd
|d<d|d<|St||||d�S)aM
    Verify that the specified ruby is installed with rbenv. Rbenv is
    installed if necessary.

    name
        The version of ruby to install

    default : False
        Whether to make this ruby the default.

    user: None
        The user to run rbenv as.

        .. versionadded:: 0.17.0

    .. versionadded:: 0.16.0
    N���namerrr�ruby-�^ruby-�testrr�Ruby z is set to be installedrz is already installedF�Rbenv failed to install)	�copy�deepcopy�
startswith�re�sub�__opts__r�_check_and_install_rbenvr)rrrrZrbenv_installed_retr	r	r
�	installedjs"

�
r%cCs�t|||d�}|dr9|drtdd|d�td||d�r/d|d<d	|d
|<d|d<|Sd
|d<d|d<|Sd|d<d|�d�|d<|S)z)
    Verify that ruby is uninstalled
    rrrr�systemr
zrbenv.uninstall_rubyTZUninstalledrzSuccessfully removed rubyrFzFailed to uninstall rubyrz is already absentr)rrrr	r	r
�_check_and_uninstall_ruby�sr'cCs�|ddid�}|�d�rt�dd|�}t||�}|ddur,d|d<d	|�d
�|d<|StdrWt|||d
�}|drId|d<d|�d�|d<|Sd|d<d|�d�|d<|St|||d
�S)a
    Verify that the specified ruby is not installed with rbenv. Rbenv
    is installed if necessary.

    name
        The version of ruby to uninstall

    user: None
        The user to run rbenv as.

        .. versionadded:: 0.17.0

    .. versionadded:: 0.16.0
    NrrrrrFTzRbenv not installed, z not eitherrrrrz is set to be uninstalledz is already uninstalled)r r!r"rr#rr'�rrrr	r	r
�absent�s$

�r)cCs^t||�}|ddur%td|�rd|d<d|d<|Sd|d<d|d<|Sd|d<d|d<|S)	z@
    Verify that rbenv is installed, install if unavailable
    rFz
rbenv.installTzRbenv installedrr�Rbenv is already installed)rrrr	r	r
r$�s
��r$cCs`|ddid�}tdr+t||d�}|ddur!d|d<d|d	<|Sd
|d<d|d	<|St||�S)a�
    Install rbenv if not installed. Allows you to require rbenv be installed
    prior to installing the plugins. Useful if you want to install rbenv
    plugins via the git or file modules and need them installed before
    installing any rubies.

    Use the rbenv.root configuration option to set the path for rbenv if you
    want a system wide install that is not in a user home dir.

    user: None
        The user to run rbenv as.
    NrrrrrFzRbenv is set to be installedrTr*)r#rr$r(r	r	r
�
install_rbenv�s
�
r+)N)FN)�__doc__rr!rrrr%r'r)r$r+r	r	r	r
�<module>s6





)

'