MOON
Server: Apache
System: Linux server2.shieldcogroup.com 3.10.0-1160.119.1.el7.tuxcare.els12.x86_64 #1 SMP Fri Nov 8 05:49:38 UTC 2024 x86_64
User: jacom (1029)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //etc/leapp/repos.d/system_upgrade/common/libraries/rpms.pyc
�
��ic@sddlmZddlmZddlmZdefd��YZiiiddgd6d	gd
6d6iddgd6d	gd
6d
6iddgd6d	gd
6d6ej6iidgd6dgd
6d6idgd6dgd
6d
6idgd6dgd
6d6ej	6iidgd6d6idgd6d
6idgd6d6ej
6iidgd6d6idgd6d
6idgd6d6ej6Ze
ejej	ejf�Zd�Zejd�Zd d d ejd�Zd�Zd�Zd�Zdd�Zd ed�Zd ed�Zd S(!i����(tstdlib(tget_source_major_version(tInstalledRPMtLeappComponentscBs&eZdZdZdZdZdZRS(sA
    Supported component values to be used with get_packages_function:
    * FRAMEWORK - the core of the leapp project: the leapp executable and
      associated leapp libraries
    * REPOSITORY - the leapp-repository project
    * COCKPIT - the cockpit-leapp project
    * TOOLS - miscellaneous tooling like snactor
    t	frameworkt
repositorytcockpitttools(t__name__t
__module__t__doc__t	FRAMEWORKt
REPOSITORYtCOCKPITtTOOLS(((sP/usr/share/leapp-repository/repositories/system_upgrade/common/libraries/rpms.pyRs
tleapps
python2-leapptpkgss
leapp-depstdepst7s
python3-leappt8t9sleapp-upgrade-el7toel8sleapp-upgrade-el7toel8-depssleapp-upgrade-el8toel9sleapp-upgrade-el8toel9-depssleapp-upgrade-el9toel10sleapp-upgrade-el9toel10-depss
cockpit-leapptsnactorcCsddddg}ytj|dt�dSWnKtjk
rz}djd|jd	|j�}tjj�j	|�gSXdS(
Ns/bin/rpms-qas
--queryformats�%{NAME}|%{VERSION}|%{RELEASE}|%|EPOCH?{%{EPOCH}}:{0}||%|PACKAGER?{%{PACKAGER}}:{(none)}||%|ARCH?{%{ARCH}}:{}||%|DSAHEADER?{%{DSAHEADER:pgpsig}}:{%|RSAHEADER?{%{RSAHEADER:pgpsig}}:{(none)}|}|\ntsplittstdoutsDExecution of {CMD} returned {RC}. Unable to find installed packages.tCMDtRC(
RtruntTruetCalledProcessErrortformattcommandt	exit_codetapitcurrent_loggerterror(trpm_cmdterrR"((sP/usr/share/leapp-repository/repositories/system_upgrade/common/libraries/rpms.pytget_installed_rpms3s	cs�ttd�|j|�D�|��|�}y%|rK�fd�|D�St�SWnCtk
r�tjj�jdj	d|d|d���t�SXdS(s&
    Create a lookup set from one of the model fields.

    :param model: model class
    :param field: model field, its value will be taken for lookup data
    :param key: property of the field's data that will be used to build a resulting set
    :param context: context of the execution
    css|]}|VqdS(N((t.0tm((sP/usr/share/leapp-repository/repositories/system_upgrade/common/libraries/rpms.pys	<genexpr>Mscs,h|]"�t�fd��D���qS(c3s|]}t�|�VqdS(N(tgetattr(R&tkey(tobj(sP/usr/share/leapp-repository/repositories/system_upgrade/common/libraries/rpms.pys	<genexpr>Os(ttuple(R&(tkeys(R*sP/usr/share/leapp-repository/repositories/system_upgrade/common/libraries/rpms.pys	<setcomp>Os	s:{model}.{field}.{keys} is not iterable, can't build lookuptmodeltfieldR,N(
R(tnexttconsumetsett	TypeErrorRR R!R"R(R-R.R,tcontexttdata((R,sP/usr/share/leapp-repository/repositories/system_upgrade/common/libraries/rpms.pyt
create_lookupDs	.%
	c
	Cs�t|t�ot|t�s"tSdg}|rA|jd�n|rW|jd�n|rm|jd�n|g}|g|||fD]}|d	k	r�|^q�7}t|ddd|d|�}	t|�|	kS(
s�
    Expects a model DistributionSignedRPM or InstalledUnsignedRPM.
    Can be useful in cases like a quick item presence check, ex. check in actor that
    a certain package is installed.

    :param model: model class
    :param package_name: package to be checked
    :param arch: filter by architecture. None means all arches.
    :param version: filter by version. None means all versions.
    :param release: filter by release. None means all releases.
    tnametarchtversiontreleaseR.titemsR,R3N(	t
isinstancettypet
issubclassRtFalsetappendtNoneR5R+(
R-tpackage_nameR7R8R9R3R,t
attributestattrt
rpm_lookup((sP/usr/share/leapp-repository/repositories/system_upgrade/common/libraries/rpms.pythas_packageXs		2cCssy*tjdd|gdtdt�dSWnBtk
rn}dj|t|��}tjj�j	|�gSXdS(sr
    Ask RPM database whether the configuration file was modified.

    :param config: a config file to check
    trpms-VfRtcheckedRs:Failed to check the modification status of the file {}: {}N(
RRRR>tOSErrorRtstrR R!R"(tconfigR$R"((sP/usr/share/leapp-repository/repositories/system_upgrade/common/libraries/rpms.pyt_read_rpm_modificationsts*cCsft}xY|D]Q}|jd�}|d|kr
d|dksRd|dkr^t}q^q
q
W|S(s�
    Handle the output of rpm verify command to figure out if configuration file was modified.

    :param data: output of the rpm verify
    :param config: a config file to check
    t i����t5itS(R>RR(R4RJtmodifiedtlinetparts((sP/usr/share/leapp-repository/repositories/system_upgrade/common/libraries/rpms.pyt_parse_config_modification�s	
 cCst|�}t||�S(s
    Check if the given configuration file tracked by RPM was modified

    This is useful when figuring out if the file will be replaced by the rpm on the upgrade
    or we need to take care of the upgrade manually.

    :param config: The configuration file to check
    (RKRR(RJtoutput((sP/usr/share/leapp-repository/repositories/system_upgrade/common/libraries/rpms.pytcheck_file_modification�s	c		Cs`t�}t|t�r!|gn|}|s<t�g}nt|t�rT|gn|}|s�djdttj���}t|��nx�|D]�}x�|D]�}|tkr�djd|dttj���}t|��n|t|kr-djd|dtt|j���}t|��n|j	t||j
|g��q�Wq�Wt|�S(s�
    Private implementation of get_leapp_packages() and get_leapp_deps_packages().

    :param major_version: Same as for :func:`get_leapp_packages` and
        :func:`get_leapp_deps_packages`
    :param component: Same as for :func:`get_leapp_packages` and :func:`get_leapp_deps_packages`
    :param type_: Either "pkgs" or "deps".  Determines which set of packages we're looking for.
        Corresponds to the keys in the `_LEAPP_PACKAGES_MAP`.

    Retrieving the set of leapp and leapp-deps packages only differs in which key is used to
    retrieve the packages from _LEAPP_PACKAGES_MAP.  This function abstracts that difference.
    sdAt least one component must be specified when calling this function, available choices are {choices}tchoicessJThe requested component {comp} is unknown, available choices are {choices}tcompsMThe requested major_version {ver} is unknown, available choices are {choices}tver(R1R;RIRRtsortedt_LEAPP_PACKAGES_MAPR,t
ValueErrortupdatetget(	t
major_versiont	componentttype_trestmajor_versionst
componentst	error_msgRVta_major_version((sP/usr/share/leapp-repository/repositories/system_upgrade/common/libraries/rpms.pyt_get_leapp_packages_of_type�s*
		

		)cCst||dd�S(s�
    Get list of leapp packages.

    :param major_version: a list or string specifying major_versions. If not defined then current
        system_version will be used.
    :param component: a list or a single enum value specifying leapp components
        (use enum :class: LeappComponents) If defined then only packages related to the specific
        component(s) will be returned.
        The default set of components is in `GET_LEAPP_PACKAGES_DEFAULT_COMPONENTS` and
        simple modifications of the default can be achieved with code like:

        .. code-block:: python
            get_leapp_packages(
                component=GET_LEAPP_PACKAGES_DEFAULT_COMPONENTS.difference(
                    [LeappComponents.TOOLS]
            ))

    :raises ValueError: if a requested component or major_version doesn't exist.

    .. note::
        Call :func:`get_leapp_dep_packages` as well if you also need the deps metapackages.
        Those packages determine which RPMs need to be installed for leapp to function.
        They aren't just Requires on the base leapp and leapp-repository RPMs because they
        need to be switched from the old system_version's to the new ones at a different
        point in the upgrade than the base RPMs.
    R_R(Re(R]R^((sP/usr/share/leapp-repository/repositories/system_upgrade/common/libraries/rpms.pytget_leapp_packages�scCst||dd�S(sI
    Get list of leapp dep metapackages.

    :param major_version: a list or string specifying major_versions. If not defined then current
        system_version will be used.
    :param component: a list or a single enum value specifying leapp components
        (use enum :class: LeappComponents) If defined then only packages related to the specific
        component(s) will be returned.
        The default set of components is in `GET_LEAPP_PACKAGES_DEFAULT_COMPONENTS` and
        simple modifications of the default can be achieved with code like:

        .. code-block:: python
            get_leapp_packages(
                component=GET_LEAPP_PACKAGES_DEFAULT_COMPONENTS.difference(
                    [LeappComponents.TOOLS]
            ))
    :raises ValueError: if a requested component or major_version doesn't exist.
    R_R(Re(R]R^((sP/usr/share/leapp-repository/repositories/system_upgrade/common/libraries/rpms.pytget_leapp_dep_packages�sN(tleapp.librariesRt%leapp.libraries.common.config.versionRtleapp.modelsRtobjectRRRR
RRYt	frozensett%GET_LEAPP_PACKAGES_DEFAULT_COMPONENTSR%R R5R@RERKRRRTReRfRg(((sP/usr/share/leapp-repository/repositories/system_upgrade/common/libraries/rpms.pyt<module>sD

					
/