403Webshell
Server IP : 3.96.16.70  /  Your IP : 216.73.216.15
Web Server : Apache
System : Linux ip-172-31-26-103.ca-central-1.compute.internal 6.1.163-186.299.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Feb 24 16:35:42 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3.9/site-packages/cfnbootstrap/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.9/site-packages/cfnbootstrap/__pycache__/rpm_tools.cpython-39.opt-1.pyc
a

��0iR3�@snddlmZddlmZddlmZmZddlZddlZddl	Z	e�
d�ZGdd�de�Z
Gdd	�d	e�ZdS)
�)�
cmp_to_key)�	ToolError)�
ProcessHelper�LoggingProcessHelperNzcfn.initc@s2eZdZdZddd�Zdd�Zdd�Zd	d
�ZdS)�YumToolz$
    Installs packages via Yum

    Nc
CsPg}|��st�d�|Stgd�dd���}|jrBt�d|j�tgd�dd���}|jrvt�d|j�t	d	|j��g}g}|D]�}||r�t
||t�r�||}	q�t�
||�}	nd
}	|	r�d||	fn|}
|�|
�r�t�d|
�q�|�|
��st�d
|
�t	d|
��q�|	�s(|�|
�|�|�q�t�|d�d}|�|	|��r\|�|
�|�|�q�t�d|
|�|�|
�|�|�q�|�s�t�d�gS|�r�t�d|�tgd�|dd�|�d���}|j�r�t�d|j�t	d|j��|�r@t�d|�tgd�|dd�|�d���}|j�r@t�d|j�t	d|j��t�d|�|S)aL
        Install a set of packages via yum, returning the packages actually installed or updated.

        Arguments:
        action -- a dict of package name to version; version can be empty, a single string or a list of strings

        Exceptions:
        ToolError -- on expected failures (such as a non-zero exit code)
        zNo packages specified for yum)�yum�-yZclean�metadatazyum clean metadata��namezSYum metadata clean failed. Will attempt to continue bootstapping anyway. Output: %s)rrZ	makecachez
yum makecachez Yum makecache failed. Output: %szCould not create yum cacheNz%s-%sz1%s will not be installed as it is already presentz#%s is not available to be installedz/Yum does not have %s available for installationF�z+Downgrading to %s from installed version %sz'All yum packages were already installedzInstalling/updating %s via yum)rrZinstallzyum install %s� zYum failed. Output: %sz2Could not successfully install/update yum packageszDowngrading %s via yum)rrZ	downgradezyum downgrade %sz-Could not successfully downgrade yum packageszYum installed %s)�keys�log�debugr�call�
returncode�warn�stdout�errorr�
isinstance�str�RpmTool�max_version�_pkg_installed�_pkg_available�append�get_package_version�_should_upgrade�join�info)
�self�action�auth_config�pkgs_changedZclean_resultZcache_resultZpkg_specs_to_upgradeZpkg_specs_to_downgrade�pkg_nameZpkg_ver�pkg_spec�installed_version�result�r)�:/usr/lib/python3.9/site-packages/cfnbootstrap/rpm_tools.py�apply sh






""z
YumTool.applycCsD|sdSt�||�}|dkr.t�d||�dSt�d||�dSdS)NTrzMRequested version %s is greater than installed version %s, so we will upgradezURequested version %s is NOT greater than installed version %s, so we will NOT upgradeF)r�compare_rpm_versionsrr)r!Z
requested_verr'Zver_cmpr)r)r*r}szYumTool._should_upgradecCs(tdddd|gd|d���}|jdkS)Nrr�listZ	installedzyum list installed %sr
r�rrr�r!�pkgr(r)r)r*r�szYumTool._pkg_installedcCs*tddddd|gd|d���}|jdkS)	Nrrz--showduplicatesr-Z	availablezyum list available %sr
rr.r/r)r)r*r�s zYumTool._pkg_available)N)�__name__�
__module__�__qualname__�__doc__r+rrrr)r)r)r*rs

]
rc@sXeZdZddd�Zdd�Zeddd	��Zed
d��Zedd
��Zedd��Z	dd�Z
dS)rNFcs�g}|��st�d�|Sg}|��D]H\}}t|t�r>|gn|}��fdd�|D�}	|	r&|�|	�|�|�q&|s�t�d�gSt�d|�t	gd�|��
�}
|
jr�t�d|
j
�td|
j��nt�d	|
j
�|S)
aL
        Install a set of packages via RPM, returning the packages actually installed or updated.

        Arguments:
        action -- a dict of package name to version; version can be empty, a single string or a list of strings

        Exceptions:
        ToolError -- on expected failures (such as a non-zero exit code)
        zNo packages installed for RPMcsg|]}��|��r|�qSr))�_package_filter)�.0Zpkg_key�r!�strict_moder)r*�
<listcomp>�s�z!RpmTool.apply.<locals>.<listcomp>zAll RPMs were already installedzInstalling %s via RPM)�rpmz-U�--quiet�
--nosignaturez
--replacepkgszRPM failed. Output: %sz+Could not successfully install rpm packageszRPM output: %s)rrr�itemsrr�extendrr rrrrrr)r!r"r#r8r$Zpkgsr%ZlocZpkgs_to_processZ
pkgs_filteredr(r)r7r*r+�s.
�

z
RpmTool.applycCs2|st�d�dS|�||�r.t�d|�dSdS)NzRPM specified with no locationFz-Skipping RPM at %s as it is already installedT)rr�
_is_installedr)r!r0r8r)r)r*r5�s
zRpmTool._package_filterTcCs�|rdnd}t�d|�td|ddd|gtjd���}t�d	|j�t�d
|j�|jrht�	d|�dS|j�
��d
�\}}}||fS)aq
        Given the name of an installed package or package location, return a tuple of (name, version-release)
        of either the installed package or the specified package location

        Parameters:
            - pkg: the package name/location
            - is_file : if True, pkg refers to a package location; if False, the name of an installed package
        z-qpz-qaz"Querying for version of package %sr:z
--queryformatz%{NAME}|%{VERSION}-%{RELEASE}r<)�stderrzRPM stdout: %szRPM stderr: %sz2Could not determine package contained by rpm at %s)NN�|)rrr�
subprocess�PIPErrr@rr�strip�	partition)�clsr0�is_fileZ
query_modeZquery_resultr�sep�versionr)r)r*r�szRpmTool.get_package_versioncCst|t|j�d�S)N)�key)�sortedrr,)rFZpkg_versr)r)r*�order_versions�szRpmTool.order_versionscCs&d}|D]}|�||�dkr|}q|S)Nr)r,)rFZversionsZmax_verZverr)r)r*r�s
zRpmTool.max_versioncCsP|r|�dd�nd}|r$|�dd�nd}td�D�]}|t|�krRt�d||�ng}|t|�krrt�d||�ng}ttt|�t|���D]�}||}	||}
|	��r�|
��r�t|	�t|
�kt|	�t|
�k}|r�|SndSq�|
��r�dS|	|
k|	|
k}|r�|Sq�t|�}
t|�}|
|k|
|k}|r0|Sq0dS)z�
        Given two package versions in form VERSION-RELEASE, (-RELEASE optional), compare them
        based on "newness" (where "greater than" equals "newer")
        �-rr)�z[a-zA-Z]+|[0-9]+���r)�split�range�len�re�findall�min�isdigit�int)rFZ	first_pkgZ
second_pkgZfirst_fieldsZ
second_fields�iZfirst_charsZsecond_chars�jZc1Zc2Zint_cmpZstr_cmpZfirst_chars_lenZsecond_chars_lenZlen_cmpr)r)r*r,�s2   

zRpmTool.compare_rpm_versionscCsZt�|�}|r|ds"|rdSdS|dr4d�|�n|d}tddd|g���}|jdkS)	NrFTrrMr:z-qr;)rrrrrr)r!r0r8Zpkg_with_versionr&Ztest_resultr)r)r*r?-s
zRpmTool._is_installed)NF)T)r1r2r3r+r5�classmethodrrLrr,r?r)r)r)r*r�s
/


0r)�	functoolsrZ cfnbootstrap.construction_errorsrZcfnbootstrap.utilrrZloggingrSrBZ	getLoggerr�objectrrr)r)r)r*�<module>s
|

Youez - 2016 - github.com/yon3zu
LinuXploit