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/utils/pkg/__pycache__/rpm.cpython-310.pyc
o

�N�g��@s�dZddlZddlZddlZddlZddlZddlZddlZe�	e
�ZdZdZ
dZdZdZdZd	Zd
ZdZee
eeeeeeZdZd
d�Zddd�Zddd�Zddd�Zddd�Zdd�Zdd�ZdS)z0
Common functions for working with RPM packages
�N)�x86_64Zathlon�amd64Zia32eZia64Zgeode)Zi386Zi486Zi586Zi686)�ppcZppc64Zppc64leZppc64iseriesZppc64pseries)Zs390Zs390x)ZsparcZsparcv8Zsparcv9Zsparcv9vZsparc64Zsparc64v)
�alphaZalphaev4Z	alphaev45Zalphaev5Z	alphaev56Z
alphapca56Zalphaev6Z	alphaev67Z	alphaev68Zalphaev7)Zarmv5telZ	armv5tejlZarmv6lZarmv6hlZarmv7lZarmv7hlZarmv7hnl)�aarch64)Zsh3Zsh4Zsh4azS%{NAME}_|-%{EPOCH}_|-%{VERSION}_|-%{RELEASE}_|-%{ARCH}_|-%{REPOID}_|-%{INSTALLTIME}cCsptjj�d�rtjgd�dtjtjd���d}nd�dd�t	�
�d	d
�D�dd
��}tjj�|��
�p7dS)
z2
    Get the os architecture using rpm --eval
    �rpm)rz--evalz%{_host_cpu}T)�	close_fds�stdout�stderrr�cSsg|]}|r|�qS�r��.0�xrr�F/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/pkg/rpm.py�
<listcomp>Iszget_osarch.<locals>.<listcomp>���N����unknown)�salt�utils�path�which�
subprocess�Popen�PIPE�communicate�join�platform�unameZstringutilsZto_str�strip)�retrrr�
get_osarch=s��(r"cCs:|durt�}tdd�||fD��ptdd�||fD��S)zT
    Returns True if both the OS arch and the passed arch are x86 or ARM 32-bit
    Ncs��|]}|tvVqdS�N)�	ARCHES_32r
rrr�	<genexpr>Ts�zcheck_32.<locals>.<genexpr>csr#r$)�
ARCHES_ARM_32r
rrrr&Ts�
�)r"�all)�arch�osarchrrr�check_32Ns
�r+cCst�dd�}|||||||�S)z/
    Build and return a pkginfo namedtuple
    ZPkgInfo)�name�versionr)�repoid�install_date�install_date_time_t)�collections�
namedtuple)r,r-r)r.r/r0Z
pkginfo_tuplerrr�pkginfoYs
�r3cCs6|durt�}t||�s||dfvr|d|��7}|S)z�
    Resolve the package name and arch into a unique name referred to by salt.
    For example, on a 64-bit OS, a 32-bit package will be pkgname.i386.
    NZnoarch�.)r"r+)r,r)r*rrr�resolve_nameds
r5cCs�z|�d�\}}}}}}}Wn
tyYdSwt|||�}|r(|d|��7}|dvr3d�||f�}|dvrHtj�t|����d}	t|�}
nd}	d}
t|||||	|
�S)zf
    A small helper to parse an rpm/repoquery command's output. Returns a
    pkginfo namedtuple.
    z_|-N�-)z(none)�0�:�Z)	�split�
ValueErrorr5r�datetime�utcfromtimestamp�int�	isoformatr3)�liner*r,�epochr-�releaser)r.Zinstall_timer/r0rrr�
parse_pkginfoqs"��
rCcCsTt|t�s|g}g}|D]}t|t�st|�}|�d�|�d�����qd�|�S)z�
    Given a list of comments, strings, a single comment or a single string,
    return a single string of text containing all of the comments, prepending
    the '#' and joining with newlines as necessary.
    z# {}
�#r)�
isinstance�list�str�append�format�lstripr)Zcommentsr!Zcommentrrr�combine_comments�s


rKcCs�|dvrdS|�d�}|dkr'ztt|d|���}Wn
ty&d}Ynwd}|�d�}|dkrC||d|�}||dd�}n
||dd�}d	}|||fS)
a[
    Split the package version string into epoch, version and release.
    Return this as tuple.

    The epoch is always not empty. The version and the release can be an empty
    string if such a component could not be found in the version string.

    "2:1.0-1.2" => ('2', '1.0', '1.2)
    "1.0" => ('0', '1.0', '')
    "" => ('0', '', '')
    )Nr)r7rrr8rNr7r6�r)�findrGr>r;)Z	verstringZidx_erAZidx_rr-rBrrr�version_to_evr�s"
�

rNr$)NN)�__doc__r1r<�loggingrrZsalt.utils.pathrZsalt.utils.stringutils�	getLogger�__name__�logZ	ARCHES_64r%Z
ARCHES_PPCZARCHES_S390ZARCHES_SPARCZARCHES_ALPHAr'Z
ARCHES_ARM_64Z	ARCHES_SHZARCHESZQUERYFORMATr"r+r3r5rCrKrNrrrr�<module>sT
	��������