<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
3
ft`~                 @   st   d dl mZ d dl mZ d dlZd dlZd dlZd dlmZ d dl	m
Z
 d dlmZ ejdZG dd	 d	ejZdS )
    )absolute_import)unicode_literalsN)commands)OptionParser)_dnfc               @   sX   e Zd ZdZdZedZed	d
 Zdd Z	dd Z
dd Zdd Zdd Zdd ZdS )UpgradeCommandzTA class containing methods needed by the cli to execute the
    update command.
    upgradeupdate
upgrade-to	update-tolocalupdateupz,upgrade a package or packages on your systemc             C   s"   | j ddtdtjtdd d S )NZpackages*zPackage to upgradeZPACKAGE)nargshelpactionmetavar)add_argumentr   r   ZParseSpecGroupFileCallback)parser r   /usr/lib/python3.6/upgrade.pyset_argparser*   s    zUpgradeCommand.set_argparserc             C   sZ   | j j}d|_d|_d|_d|_tj| j| j  | j	j
sDtj| j d| _d| _d| _dS )zVerify that conditions are met so that this command can run.

        These include that there are enabled repositories with gpg
        keys, and that this command is being run by the root user.
        TN)clidemandsZsack_activationZavailable_reposZ	resolvingZ	root_userr   Z_checkGPGKeybaseopts	filenamesZ_checkEnabledRepoupgrade_minimalall_securityskipped_grp_specs)selfr   r   r   r   	configure0   s    zUpgradeCommand.configurec             C   s   | j r
dnd}| jj| j|| jd | jjs<| jjs<| jjrzd}|| j O }|| j	 O }|| j
 O }|| j O }|rd S n| jj  d S tjjtdd S )NeqZgte)cmp_typeallFzNo packages marked for upgrade.)r   r   Z _populate_update_security_filterr   r   r   	pkg_specs	grp_specs_update_modules_update_files_update_packages_update_groupsr   Zupgrade_allr   
exceptionsErrorr   )r!   r$   resultr   r   r   runB   s    

zUpgradeCommand.runc             C   sN   t | jj}tjjr6tjjj| j}|j	| jj| _
n
| jj| _
t | j
|kS )N)lenr   r'   r   r   ZWITH_MODULESmodulemodule_baseZ
ModuleBaser	   r    )r!   Zgroup_specs_numr2   r   r   r   r(   V   s    
zUpgradeCommand._update_modulesc             C   s   d}| j jrx~| jj| j jd| jjjdD ]^}y| jj| d}W q* tjj	k
r } z$t
jtd| jjjj|j W Y d d }~X q*X q*W |S )NF)strictprogressTzNo match for argument: %s)r   r   r   Zadd_remote_rpmsoutputr4   Zpackage_upgrader   r,   MarkingErrorloggerinfor   termboldlocation)r!   successZpkger   r   r   r)   `   s    
*zUpgradeCommand._update_filesc             C   sr   d}xh| j jD ]\}y| jj| d}W q tjjk
rh } z"tjt	d| jj
jj| W Y d d }~X qX qW |S )NFTzNo match for argument: %s)r   r&   r   r	   r   r,   r6   r7   r8   r   r5   r9   r:   )r!   r<   Zpkg_specr=   r   r   r   r*   m   s    
(zUpgradeCommand._update_packagesc             C   s   | j r| jj| j  dS dS )NTF)r    r   Zenv_group_upgrade)r!   r   r   r   r+   x   s    zUpgradeCommand._update_groupsN)r	   r
   r   r   r   r   )__name__
__module____qualname____doc__aliasesr   Zsummarystaticmethodr   r"   r/   r(   r)   r*   r+   r   r   r   r   r   #   s   
r   )Z
__future__r   r   ZloggingZdnf.exceptionsr   Zdnf.baseZdnf.clir   Zdnf.cli.option_parserr   Zdnf.i18nr   Z	getLoggerr7   ZCommandr   r   r   r   r   <module>   s   
