<!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`S                 @   s   d dl mZ d dl mZ d dlZd dlm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)chain)commands)OptionParser)_dnfc               @   s   e Zd ZdZejejejdZdZ	de
ej  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d Zdd Zdd ZdS )InstallCommandzUA class containing methods needed by the cli to execute the
    install command.
    )z	install-nz
install-nazinstall-nevrazalternative-for({})installlocalinstallinz,install a package or packages on your systemc             C   s"   | j ddtdtjtdd d S )Npackage+ZPACKAGEzPackage to install)nargsmetavaractionhelp)add_argumentr   r   ZParseSpecGroupFileCallback)parser r   /usr/lib/python3.6/install.pyset_argparser1   s    zInstallCommand.set_argparserc             C   sH   | j j}d|_d|_d|_d|_tj| j| j  | j	j
sDtj| j dS )zVerify that conditions are met so that this command can run.
        That there are enabled repositories with gpg keys, and that
        this command is called with appropriate arguments.
        TN)clidemandsZsack_activationZavailable_reposZ	resolvingZ	root_userr   Z_checkGPGKeybaseopts	filenamesZ_checkEnabledRepo)selfr   r   r   r   	configure7   s    zInstallCommand.configurec       
      C   sP  g }g }g }| j  }| jj| j | jjdkrf| jjs>| jjrf| j| jj | jj	j
rftjjtdg }| jjo|| jjdkrTtjjrLy,tjjj| j}|j| jj| jj	j
d W n tjjk
rH } zp|jrx|jD ]}|j| qW |jrx|jD ]}|jd|  qW |j}	|	r8tjtjjj|	d  W Y d d }~X nX n| jj}| jjr|r| j| jj | jj	j
rtjjtdn| j }|r|r| j| | jj	j
rtjjtdn|r| jjdkr| j| | jjdkr| j |}t!|dks$t!|dks$|rL| jj	j
rLtjj"tddj#||dd S )	Nr   zNothing to do.)strict@r   zUnable to find a match )pkg_specZpackages)$_get_nevra_forms_from_commandr   Z _populate_update_security_filterr   command	grp_specs	pkg_specs_log_not_valid_rpm_file_pathsr   confr   r   
exceptionsErrorr   ZWITH_MODULESmodulemodule_baseZ
ModuleBaser
   ZMarkingErrorsZno_match_group_specsappendZerror_group_specsmodule_depsolv_errorsloggererrorZformat_modular_solver_errorsr   _inform_not_a_valid_combination_install_files_install_groups_install_packageslenZPackagesNotAvailableErrorjoin)
r   err_pkgserrsZerror_module_specsnevra_formsZskipped_grp_specsr,   eZe_specr.   r   r   r   runE   sX    

 


.zInstallCommand.runc             C   s&   | j j| jkr| j| j j gS g S d S )N)r   r$   r9   )r   r   r   r   r#   z   s    z,InstallCommand._get_nevra_forms_from_commandc             C   sJ   t dd |}x6t| jj|D ]$}td}tj|| jjj	j
| qW d S )Nc             S   s   d|  S )Nr    r   )gr   r   r   <lambda>   s    z>InstallCommand._log_not_valid_rpm_file_paths.<locals>.<lambda>zNot a valid rpm file path: %s)mapr   r   r&   r   r/   infor   outputtermbold)r   r%   Zgroup_namespkgmsgr   r   r   r'      s    z,InstallCommand._log_not_valid_rpm_file_pathsc             C   s2   x,|D ]$}t d}tj|| jjjj| qW d S )NzNot a valid form: %s)r   r/   Zwarningr   r@   rA   rB   )r   formsZformrD   r   r   r   r1      s    
z.InstallCommand._inform_not_a_valid_combinationc             C   s   g }| j jj}x~| j j| jj|| j jjdD ]^}y| j j||d W q, t	j
jk
r   td}tj|| j jjj|j |j| Y q,X q,W |S )N)r   progress)r   zNo match for argument: %s)r   r(   r   Zadd_remote_rpmsr   r   r@   rF   Zpackage_installr   r)   MarkingErrorr   r/   r?   rA   rB   locationr-   )r   r7   r   rC   rD   r   r   r   r2      s    
zInstallCommand._install_filesc             C   sP   y&| j j|t| j jj| j jjd W n$ tjjk
rJ   | j jjrF Y nX d S )N)r   )	r   Zenv_group_installtupler(   Zgroup_package_typesr   r   r)   r*   )r   r%   r   r   r   r3      s    
zInstallCommand._install_groupsc             C   sV   | j jj j| jj|d}|rRtd}tj|j|dj	t
tdd |D  d S )N)Zprovidesz/There are following alternatives for "{0}": {1}z, c             S   s   g | ]
}|j qS r   )name).0Zaltr   r   r   
<listcomp>   s    z7InstallCommand._report_alternatives.<locals>.<listcomp>)r   ZsackqueryZfiltermalternatives_provideformatr   r/   r?   r6   sortedset)r   r"   rM   rD   r   r   r   _report_alternatives   s    z#InstallCommand._report_alternativesc             C   s   g }| j jj}x| jjD ]}y| j j|||d W q tjjk
r } zJdj	|j
| j jjj|}tj| | j j| | j| |j| W Y d d }~X qX qW |S )N)r   rE   z{}: {})r   r(   r   r   r&   r
   r   r)   rG   rO   valuer@   rA   rB   r/   r?   Z_report_icase_hintrR   r-   )r   r9   r8   r   r"   r:   rD   r   r   r   r4      s    


 z InstallCommand._install_packagesN)r
   r   r   )__name__
__module____qualname____doc__hawkeyZ	FORM_NAMEZFORM_NAZ
FORM_NEVRAr9   rN   rI   keysaliasesr   Zsummarystaticmethodr   r   r;   r#   r'   r1   r2   r3   rR   r4   r   r   r   r   r	   %   s"   
5		r	   )Z
__future__r   r   Zlogging	itertoolsr   rX   Zdnf.exceptionsr   Zdnf.clir   Zdnf.cli.option_parserr   Zdnf.i18nr   Z	getLoggerr/   ZCommandr	   r   r   r   r   <module>   s   
