File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/xbpspkg.cpython-310.pyc
o
�N�g*? � @ s. d Z ddlZddlZddlZddlZddlZddlm m Z ddl
ZddlZddlZddl
ZddlmZmZ e�e�ZdZdd� Ze jdd� �Ze jd d
� �Zdd� Zd,dd�Zd-dd�Zdd� ZeZdd� Zdd� Zdd� Z d-dd�Z!d.dd�Z"d/dd �Z#d!d"� Z$d#d$� Z%d,d%d&�Z&d0d(d)�Z'd*d+� Z(dS )1z[
Package support for XBPS package manager (used by VoidLinux)
.. versionadded:: 2016.11.0
� N)�CommandExecutionError�MinionError�pkgc C s t d dv rt� rtS dS )zM
Set the virtual pkg module if the os is Void and xbps-install found
�osZVoid)Fz Missing dependency: xbps-install)Z
__grains__�_check_xbps�__virtualname__� r r �H/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/xbpspkg.py�__virtual__ s r
c C s t jj�d�S )zQ
Looks to see if xbps-install is present on the system, return full path
�xbps-install)�salt�utils�path�whichr r r r r % s r c C sN t d t� dgdd�} | du rdS t�d�}|�| �}|sdS |�d��d �S )
z
Get the xbps version
�cmd.runz --version�trace��output_loglevelNFz!(?:XBPS:[\s]+)([\d.]+)(?:[\s]+.*)� �.)�__salt__r �re�compile�search�group�split)Zversion_stringZ
VERSION_MATCHZ
version_matchr r r �_get_version- s
�
r c C s6 t d d�} | �d�d dv rt d ddd � d
S d
S )z�
Recomputes internal hash table for the PATH variable.
Used whenever a new command is created during the current
session.
zenviron.getZSHELL�/���)ZcshZtcshr Zrehashr r N)r r )�shellr r r �_rehashA s �r Fc s� t jj�| �} t� fdd�dD ��ri S d}i }td |dd�}|�� D ],}|s)q$z|�d�d �d
d �\}}W n t yG t
�d|� Y nw td |||� q$td
|� | s_td |� |S )z�
List the packages currently installed as a dict::
{'<package_name>': '<version>'}
CLI Example:
.. code-block:: bash
salt '*' pkg.list_pkgs
c s g | ]}t jj�� �|���qS r )r r
�data�is_true�get��.0�x��kwargsr r �
<listcomp>[ s zlist_pkgs.<locals>.<listcomp>)ZremovedZ
purge_desiredz
xbps-query -lr r r Nr �-�/xbps-query: Unexpected formatting in line: "%s"zpkg_resource.add_pkgzpkg_resource.sort_pkglistzpkg_resource.stringify)r r
r! r"