https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/uaclient/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/uaclient/__pycache__/apt.cpython-310.pyc
o

��Jh��@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZddlm
Z
mZmZmZmZmZmZddlZddlmZddlmZmZmZmZmZmZmZddlm Z ddl!m"Z"dZ#d	Z$d
Z%dZ&dZ'd
Z(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2dZ3dZ4dZ5ej6�7e d�ej6�7e d�gej6�7e d�ej6�7e d�ej6�7e d�ej6�7e d �gd!�Z8gd"�Z9e�:�Z;e�<e�=e>��Z?ej@Gd#d$�d$ejA��ZBed%d&eCfd'eCfd(eCfg�ZDd)d*�ZEeEd+eCd,eCfd-d.��ZFd/d0�ZGd1eCd2eeCfd3d4�ZH		d�d5eeCd6eeCd7ee
eCeCfd2eCfd8d9�ZIe
dd:�		d�d6eeCd7ee
eCeCfd2eCfd;d<��ZJGd=d>�d>�ZKd?d@�ZLdAdB�ZMdCeCd2eeCfdDdE�ZN	Fd�dCeCdGeOd2eeCfdHdI�ZP	d�d7ee
eCeCfd2eCfdJdK�ZQe�RejSejTfe9�dLeCfdMdN��ZU		d�dOeeCdPeeeCd7ee
eCeCfd2eCfdQdR�ZVdSeCd2eejWfdTdU�ZXdSeeCd2eejWfdVdW�ZY	d�dXejWdYeeCd2eejZfdZd[�Z[d\eeCd]eCd^eOd_eCd2eCf
d`da�Z\	Fd�d\eeCd]eCd^eOd_eCdbeCdceOd2eCfddde�Z]	Fd�dfeCd_eCdgeCd\eeCdbeCdheeCdieeOd2dfdjdk�Z^dldm�Z_dndo�Z`	d�dfeCd_eCdheeCdbeeCd2df
dpdq�Zadrds�Zbdtdu�Zcdvdw�Zddxdy�ZedzeCd2eOfd{d|�Zfd2eeDfd}d~�Zgd2eeCfdd��ZhddeBjifd�eeCd�eeCd�eeBd2dfd�d��Zjd2eekfd�d��Zld2eekfd�d��Zmd2eejfd�d��Znd�d��Zod�d�d��Zpd�eeCd�eCfd�d��Zqd�eeCd�eCfd�d��Zrd�eeCfd�d��Zsd�d��Ztd�d��Zud�eeCd2e
eCeeCeeCfffd�d��Zvd2eCfd�d��ZwdS)��N)�	lru_cache�wraps)�Dict�Iterable�List�
NamedTuple�Optional�Set�Union)�AcquireProgress)�event_logger�
exceptions�gpg�messages�secret_manager�system�util)�ESM_APT_ROOTDIR)�status_cache_filegN@z  # ubuntu-pro-clientzDir::Etc::netrc/zDir::Etc::netrcparts/zDir::State::lists/a�/*
 * Autogenerated by ubuntu-pro-client
 * Do not edit this file directly
 *
 * To change what ubuntu-pro-client sets, use the `pro config set`
 * or the `pro config unset` commands to set/unset either:
 *      global_apt_http_proxy and global_apt_https_proxy
 * for a global apt proxy
 * or
 *      ua_apt_http_proxy and ua_apt_https_proxy
 * for an apt proxy that only applies to Ubuntu Pro related repos.
 */
z$Acquire::http::Proxy "{proxy_url}";
z%Acquire::https::Proxy "{proxy_url}";
z4Acquire::http::Proxy::esm.ubuntu.com "{proxy_url}";
z5Acquire::https::Proxy::esm.ubuntu.com "{proxy_url}";
z/etc/apt/trusted.gpg.d/z/usr/share/keyringsz/usr/lib/apt/methods/httpsz /usr/sbin/update-ca-certificatesz//etc/apt/apt.conf.d/90ubuntu-advantage-aptproxyz*/var/lib/apt/periodic/update-success-stampz/var/lib/dpkg/status)�xenial�bionic�focal�jammyz�# Written by ubuntu-pro-client
Types: deb{deb_src}
URIs: {url}
Suites: {suites}
Components: main
Signed-By: {keyrings_dir}/{keyring_file}
zetc/apt/sources.listzvar/lib/dpkg/statuszetc/apt/apt.conf.dzetc/apt/preferences.dzvar/cache/apt/archives/partialzvar/lib/apt/lists/partial)�files�folders)g�?g@g$@c@seZdZe�Ze�ZdS)�
AptProxyScopeN)�__name__�
__module__�__qualname__�object�GLOBAL�UACLIENT�r"r"�./usr/lib/python3/dist-packages/uaclient/apt.pyrcs
r�InstalledAptPackage�name�version�archcst���fdd��}|S)z*Decorator ensuring apt_pkg is initialized.cs&tj�d�dkrt���|i|��S)N�Dir�)�apt_pkg�config�get�init)�args�kwargs��fr"r#�new_fqsz"ensure_apt_pkg_init.<locals>.new_f)r)r1r2r"r0r#�ensure_apt_pkg_initnsr3�a�bcCst�||�S�N)r*�version_compare)r4r5r"r"r#r7|sr7c
Cs|�d�\}}tj�d�sdSz0t���!}tjddd�||||�tj�	|d�gt
td�Wd�WdS1s8wYWdStj
y�}z4t�dt|��|jd	krtt|j���}t�d
|�rhtj|d��t�d|�rttj|d��tjt|�d
��d}~wtjy�tjt
|d��w)aValidate apt credentials for a PPA.

    @param repo_url: private-ppa url path
    @param username: PPA login username.
    @param password: PPA login password or resource token.

    @raises: UbuntuProError for invalid credentials, timeout or unexpected
        errors.
    �://z/usr/lib/apt/apt-helperNz
download-filez{}://{}:{}@{}/pool/zapt-helper-output)�timeout�retry_sleepszError running apt-helper: %s�dz401\s+unauthorized|httperror401)�repozconnection timed out��detail)�secondsr<)�split�os�path�exists�tempfile�TemporaryDirectoryr�subp�format�join�APT_HELPER_TIMEOUT�APT_RETRIESr
�ProcessExecutionError�LOG�error�str�	exit_code�stderr�lower�re�search�APTInvalidCredentials�
APTTimeout�APTUnexpectedError�
subprocess�TimeoutExpired�APTCommandTimeout)�repo_url�username�password�protocol�	repo_path�tmpd�erPr"r"r#�assert_valid_apt_credentials�s@

���&�

���ra�	apt_error�returncCsVt�}|���d�D]}|r(t�d|�}|r(d|��d�d�d}|�|�q
|S)aAParse apt update errors for invalid apt config in user machine.

    This functions parses apt update errors regarding the presence of
    invalid apt config in the system, for example, a ppa that cannot be
    reached, for example.

    In that scenario, apt will output a message in the following formats:

    The repository 'ppa 404 Release' ...
    Failed to fetch ppa 404 ...

    On some releases, both of these errors will be present in the apt error
    message.

    :param apt_error: The apt error string
    :return: a NamedMessage containing the error message
    �
z2(Failed to fetch |The repository .)(?P<url>[^\s]+)z- �urlz/distsr)�set�stripr@rRrS�	groupdict�add)rb�failed_repos�line�
pattern_match�repo_url_matchr"r"r#�(_parse_apt_update_for_invalid_apt_config�s��
�rn�cmd�	error_msg�override_env_varsc
Cs�ztj|dt|d�\}}W|StjyR}z7t�dt|�t|��dt|j�vr-t�	��	t
|j�}|r@tjd�t
|��d��|rD|nt|�}tj|d��d}~ww)	a�Run an apt command, retrying upon failure APT_RETRIES times.

    :param cmd: List containing the apt command to run, passed to subp.
    :param error_msg: The string to raise as UbuntuProError when all retries
       are exhausted in failure.
    :param override_env_vars: Passed directly as subp's override_env_vars arg

    :return: stdout from successful run of the apt command.
    :raise UbuntuProError: on issues running apt-cache policy.
    T)�capturer:rqz Error running apt command %s: %sz%Could not get lock /var/lib/dpkg/lockrd)rjr=N)rrFrJr
rKrLrMrNrP�APTProcessConflictErrorrn�APTInvalidRepoErrorrH�sortedrV)rorprq�out�_errr`rj�msgr"r"r#�run_apt_command�s,��
���ry)�maxsizecCstddg||d�S)N�	apt-cache�policy)rorprq)ry)rprqr"r"r#�get_apt_cache_policy�s
�r}c@s$eZdZdd�Zdd�Zdd�ZdS)�PreserveAptCfgcCs||_i|_dSr6)�apt_func�current_apt_cfg)�selfrr"r"r#�__init__	s
zPreserveAptCfg.__init__cs&tj��fdd����D�|_|��S)Ncsi|]}|t���|���qSr")�copy�deepcopyr,)�.0�key��cfgr"r#�
<dictcomp>s�z,PreserveAptCfg.__enter__.<locals>.<dictcomp>)r*r+�keysr�r)r�r"r�r#�	__enter__
s

�zPreserveAptCfg.__enter__cCs4tj}|j��D]}|�||j|�qt��dSr6)r*r+r�r�rf�init_system)r��type�value�	tracebackr�r�r"r"r#�__exit__szPreserveAptCfg.__exit__N)rrrr�r�r�r"r"r"r#r~sr~cCs.tj��D]}tj�|�qt��t�d�Sr6)r*r+r��clearr-�Cache�r�r"r"r#�get_apt_pkg_caches
r�cCshz(t�tj��D]}t�d|�stj�|�q	tj�dt�t�	�t�
d�WSty3iYSw)Nz^Acquirer()�_ensure_esm_cache_structurer*r+r�rRrSr�rfrr-r��	Exceptionr�r"r"r#�get_esm_apt_pkg_cache&s��r��pkg_namec	Cshtt��}z||}WntyYWd�dSwWd�n1s&wY|jr2|jjSdSr6)r~r��KeyError�current_ver�ver_str)r��cache�packager"r"r#�get_pkg_version>s
���r�F�check_esm_cachec	CsTtt��7}z||}WntyYWd�dSwt�|�}|�|�}|s1	Wd�dS|j}Wd�n1s>wY|sG|Stt��U}|r�z||}Wntyf|YWd�Swt�|�}	|	�|�}
|
s||Wd�S|
j}t�||�dkr�|Wd�SWd�|SWd�|S1s�wY|S)Nr)	r~r�r�r*�DepCache�get_candidate_verr�r�r7)r�r�r�r��	dep_cache�	candidate�candidate_version�	esm_cache�esm_package�
esm_dep_cache�
esm_candidate�esm_candidate_versionr"r"r#�get_pkg_candidate_versionKsZ
�

��

�

����
��
��r�c
Cs�zQz
tddg|d�}Wn?tjy$}zt�dt|��t���d}~wtjy7}ztj|j	d��d}~wtj
yJ}ztj|j	d��d}~wwWt�
�|St�
�w)N�apt-get�update�rorqz Error running apt-get update: %s��repo_msgr=)ryr
rsrLrMrN�APTUpdateProcessConflictErrorrt�APTUpdateInvalidRepoErrorrx�UbuntuProError�APTUpdateFailedr}�cache_clear)rqrvr`r"r"r#�run_apt_update_commandws&
������
�r��sources_list_pathcCsDtt���}tj�dtj�|��tj�dd�tj�dd�t��}|�	�t
�}tj�tj�d�d�}t�
|�}zQz|�|�||d�Wd�n1sOwYWn/ttd	d
�yq}zt�dt|��t���d}~wty�}ztjt|�d��d}~wwWt��nt��wWd�dS1s�wYdS)
NzDir::Etc::sourcelistzDir::Etc::sourcepartszN.O.F.O.L.D.E.RzAPT::List-Cleanup�0zDir::State::Lists�lockr�Errorr"zError updating apt cache: %sr=)r~r�r*r+rfrArB�abspath�
SourceList�read_main_listrrH�find_dir�FileLockr��getattrrLrMrNr
rs�SystemErrorr�r}r�)r�r��sources_list�fetch_progress�	lock_filer�r`r"r"r#�update_sources_list�s:
��
������"�r��packages�apt_optionsc
Csv|durg}ztgd�|||d�}W|Stjy't�d|�t���tjy:}ztj|jd��d}~ww)N)r��install�--assume-yesr�z)Error running apt install for packages %sr�)	ryr
rsrLrM�APTInstallProcessConflictErrorrt�APTInstallInvalidRepoErrorrx)r�r�rqrvr`r"r"r#�run_apt_install_command�s&������r��origincCsvt�}tt��(}|jD]}|j}|r$|jD]\}}|j|kr#|�|�qqWd�t|�S1s2wYt|�Sr6)	rfr~r�r�r��	file_listr�ri�list)r��resultr�r��installed_version�file�_r"r"r#� get_installed_packages_by_origin�s



��
��r�c	Cs�|durgSt�}tt��8}t�|�}|jD]$}|j}|r:|�|�}|r:||kr:|jD]\}}|j	|kr9|�
|�q+qWd�t|�S1sHwYt|�Sr6)rfr~r�r*r�r�r�r�r�r�rir�)	r�r�r�r�r�r�r�r�r�r"r"r#�;get_installed_packages_with_uninstalled_candidate_in_origin�s&





��
��r�r��exclude_origincs6g}|jD]}�fdd�|jD�}|r|�|�q|S)Ncs(g|]\}}|jdkr|j�kr|�qS)�now)�	componentr�)r�r�r��r�r"r#�
<listcomp>�s
�z3get_remote_versions_for_package.<locals>.<listcomp>)�version_listr��append)r�r��valid_versionsr&�
valid_originsr"r�r#�get_remote_versions_for_package�s

�
�r��suites�series�updates_enabledrZcCsRd}|D]"}||vrqd}d|vr|st�d||�d}|dj|||d�7}q|S)Nr)�-updatesz?Not enabling apt suite "%s" because "%s-updates" is not enabledz# zC{maybe_comment}deb {url} {suite} main
# deb-src {url} {suite} main
)�
maybe_commentre�suite)rL�warningrG)r�r�r�rZ�contentr�r�r"r"r#�_get_list_file_content	s&���r��keyring_file�include_deb_srcc	sZ�fdd�|D�}|st�d��dd�|D�}|rdnd}tj|d�|�t||d�}|S)	Ncsg|]}�|vr|�qSr"r"�r�r��r�r"r#r�+�z-_get_sources_file_content.<locals>.<listcomp>zPNot enabling service-related -updates suites because "%s-updates" is not enabledcSsg|]}d|vr|�qS)r�r"r�r"r"r#r�2sz deb-srcr)� )rer��keyrings_dirr��deb_src)rLr��DEB822_REPO_FILE_CONTENTrGrH�KEYRINGS_DIR)	r�r�r�rZr�r��appliable_suitesr�r�r"r�r#�_get_sources_file_content#s$���r��
repo_filename�credentials�
snapshot_urls�check_updates_pocketcCs*z	|�d�\}}Wn
tyd}|}Ynwtj�|�t��j}	|�d�r-|dd�}t	|||�d}
|rWd}
t
dd	gtj�}|�
�D]}d
�|	�|vrOqEd|vrTqEd}
|g|D]}
t|
||�q\|	tvr�tj�t|�}tj�t|�}t�||�t||	|
|�}nt||	|
||�}t�||�dS)z�Add an authenticated apt repo and credentials to the system.

    @raises: InvalidAPTCredentialsError when the token provided can't access
        the repo PPA.
    �:�bearer�/N���TFr{r|za={}-updatesz	o=Ubuntu,)r@�
ValueErrorr�secrets�
add_secretr�get_release_infor��endswithraryr�APT_POLICY_FAILED�
splitlinesrG�add_apt_auth_conf_entry�SERIES_NOT_USING_DEB822rArBrHr��APT_KEYS_DIRr�export_gpg_keyr�r��
write_file)r�rZr�r�r�r�r�r[r\r�r�r|rkre�source_keyring_file�destination_keyring_filer�r"r"r#�add_auth_apt_repoCsJ�


��
�r
c
Cst�}d|vr|�d�\}}n|}|�d�s|d7}tj�|�r&t�|�}nd}dj|||t	d�}d}g}	|�
�D].}
|sb|
��}t|�dkrb|d}||krW|	�|�d	}q9||vrb|	�|�d	}|	�|
�q9|so|	�|�|	�d�tj
|d
�|	�dd�d
S)zBAdd or replace an apt auth line in apt's auth.conf file or conf.d.r8r�r)z:machine {repo_path} login {login} password {password}{cmt})r^�loginr\�cmtF��Trd���modeN)�!get_apt_auth_file_from_apt_configr@rrArBrCr�	load_filerG�APT_AUTH_COMMENTr�lenr�rrH)
rZrr\�
apt_auth_file�	_protocolr^�orig_content�repo_auth_line�added_new_auth�	new_linesrk�
split_line�curr_line_repor"r"r#r�sH
��	



rcs�d|vr|�d�\}}n|}|�d�r|dd�}t�}tj�|�rNt�|�}dj|d��d�	�fdd	�|�
�D��}|sDt�|�dStj||d
d�dSdS)z+Remove a repo from the shared apt auth filer8r�Nr�zmachine {repo_path}/ login)r^rdcsg|]}�|vr|�qSr"r")r�rk��auth_prefixr"r#r��r�z2remove_repo_from_apt_auth_file.<locals>.<listcomp>rr)
r@rrrArBrCrrrGrHr�ensure_file_absentr)rZrr^r�apt_authr�r"rr#�remove_repo_from_apt_auth_file�s 

��r"cCs^t�|�|�d�rt�t�|d��|r!tj�t|�}t�|�|g|D]}t	|�q&dS)z>Remove an authenticated apt repo and credentials to the systemz.sourcesr�N)
rr rr�set_filename_extensionrArBrHrr")r�rZr�r�rer"r"r#�remove_auth_apt_repo�s


�

�r$cCsB|�d�\}}|�d�r|dd�}dj||d�}t�||�dS)z.Add an apt preferences file and pin for a PPA.r8r�Nr�z<Package: *
Pin: release o={origin}
Pin-Priority: {priority}
)r��priority)r@rrGrr)�apt_preference_filerZr�r%rr^r�r"r"r#�add_ppa_pinning�s
��r'cCsVt�dddtg�\}}|r|�d�ddSt�dddtg�\}}|�d�d�d�S)z7Return to patch to the system configured APT auth file.�
apt-config�shellr��'rz90ubuntu-advantager�)rrF�APT_CONFIG_AUTH_PARTS_DIRr@�APT_CONFIG_AUTH_FILE�rstrip)rvrwr"r"r#r�s
�
�rc
Cs~|�d�\}}|�d�r|dd�}d}t�dddtg�\}}|r(|�d	�d
}|�dd�}tt�tj	�
||d�|����S)
zEList any apt files in APT_CONFIG_LISTS_DIR given repo_url and series.r8r�Nr�z/var/lib/apt/listsr(r)r�r*rr�z
_dists_{}*)r@rrrF�APT_CONFIG_LISTS_DIR�replaceru�globrArBrHrG)rZr�rr^�	lists_dirrvrw�aptlist_filenamer"r"r#�find_apt_list_files�s"

����r3cCst||�D]}t�|�qdS)z?Remove any apt list files present for this repo_url and series.N)r3rr )rZr�rBr"r"r#�remove_apt_list_filess�r4�pkgcCs
|t�vSr6)�get_installed_packages_names)r5r"r"r#�is_installeds
r7c	Csbg}tt��!}|jD]}|j}|r|�t|j|j|jd��q
Wd�|S1s*wY|S)N)r%r&r')	r~r�r�r�r�r$r%r�r')�	installedr�r�r�r"r"r#�get_installed_packagess$

����
��r9cCst�}dd�|D�}|S)NcSsg|]}|j�qSr")r%)r�r5r"r"r#r�*sz0get_installed_packages_names.<locals>.<listcomp>)r9)�package_list�	pkg_namesr"r"r#r6(sr6�
http_proxy�https_proxy�proxy_scopecCs�|s|r!|r!d}|tjkrd}n|tjkrd}t�tjj|d��d}|r@|tjkr3|tj|d�7}n
|tjkr@|t	j|d�7}|r]|tjkrP|t
j|d�7}n
|tjkr]|tj|d�7}|dkret|}|dkrpt
�t�dSt
�t|�dS)a�
    Writes an apt conf file that configures apt to use the proxies provided as
    args.
    If both args are None, then no apt conf file is written. If this function
    previously wrote a conf file, and was run again with both args as None,
    the existing file is removed.

    :param http_proxy: the url of the http proxy apt should use, or None
    :param https_proxy: the url of the https proxy apt should use, or None
    :return: None
    r)z	UA-scoped�global)�scope)�	proxy_urlN)rr!r �event�infor�SETTING_SERVICE_PROXY_SCOPErG�APT_CONFIG_UA_PROXY_HTTP�APT_CONFIG_GLOBAL_PROXY_HTTP�APT_CONFIG_UA_PROXY_HTTPS�APT_CONFIG_GLOBAL_PROXY_HTTPS�APT_PROXY_CONFIG_HEADERrr �APT_PROXY_CONF_FILEr)r<r=r>�message�apt_proxy_configr"r"r#�setup_apt_proxy.sD

�

�
�

�
�rMcC� d}tj�t�rt�t�j}|Sr6)rArBrC�APT_UPDATE_SUCCESS_STAMP_PATH�stat�st_mtime��
cache_timer"r"r#�get_apt_cache_timef�rTcCrNr6)rArBrC�DPKG_STATUS_PATHrPrQ)�status_timer"r"r#�get_dpkg_status_timemrUrXcCs$t�}|dur	dStj�|tjj�Sr6)rT�datetime�
fromtimestamp�timezone�utcrRr"r"r#�get_apt_cache_datetimetsr]cs�tjtj�td�dd��tdtd}t�fdd�|D��r!dSt�t�tdD]}t�	|�q*tdD]
}tj
|ddd	�q6dS)
Nz**/*T)�	recursiverrc3s�|]}|�vVqdSr6r")r�r���existing_filesr"r#�	<genexpr>�s�z._ensure_esm_cache_structure.<locals>.<genexpr>i�)�exist_okr)r0rArBrHr�ESM_BASIC_FILE_STRUCTURE�allr�ensure_folder_absent�create_file�makedirs)�
desired_filesr��folderr"r_r#r�{s��
�r�cCs�t��sdSt�ddlm}ddlm}ddlm}m	}d}d}t
��}|dur/||�d}|�dg�D]"}|�dd�d	krG|�d
d�dk}|�dd�d
krW|�d
d�dk}q5||�}	|rl|	�
�d|jkrl|	��n|	��t��r�||�}
|r�|
�
�d|jkr�|
��n|
��tt��J}t��}|��Gdd�dt�}
|
�}z	|�||d�Wnty�}zt�d�t|���WYd}~n
d}~wwWd�dSWd�dS1s�wYdS)Nr)�status)�ApplicationStatus)�ESMAppsEntitlement�ESMInfraEntitlementF�servicesr%r)zesm-apps�	available�no�yesz	esm-infrac@s,eZdZdejfdd�Zdejfdd�ZdS)z-update_esm_caches.<locals>.EsmAcquireProgress�itemcS�t�d�|j��dS)NzFetched ESM Apt Cache item: {})rL�debugrG�uri�r�rrr"r"r#�done�sz2update_esm_caches.<locals>.EsmAcquireProgress.donecSrs)Nz&Failed to fetch ESM Apt Cache item: {})rLr�rGrurvr"r"r#�fail�s
�z2update_esm_caches.<locals>.EsmAcquireProgress.failN)rrrr*�AcquireItemDescrwrxr"r"r"r#�EsmAcquireProgress�srzz%Failed to fetch the ESM Apt Cache: {})r�is_current_series_ltsr��uaclient.actionsrj�(uaclient.entitlements.entitlement_statusrk�uaclient.entitlements.esmrlrmr�readr,�application_status�DISABLED�setup_local_esm_repo�disable_local_esm_repo�is_current_series_active_esmr~r�r*r�r�rr�r�rLr�rGrN)r�rjrkrlrm�apps_available�infra_available�current_status�service�apps�infrar�r�rzr�r`r"r"r#�update_esm_caches�sZ��
�

	 ����"�r��
package_names�
error_messagecC�"tgd�t|�|ddid�dS)a�
    Remove APT packages from the system.

    Setting DEBIAN_FRONTEND to noninteractive makes sure no prompts will
    appear during the operation. In this case, --force-confdef will
    automatically pick the default option when some debconf should appear.
    In the absence of a default option, --force-confold will automatically
    choose to keep the old configuration file.
    )r��remover��$-o Dpkg::Options::="--force-confdef"�$-o Dpkg::Options::="--force-confold"�DEBIAN_FRONTEND�noninteractive�rqN�ryr��r�r�r"r"r#�remove_packages��
�
�r�cCr�)a�
    Purge APT packages from the system - remove everything.

    Setting DEBIAN_FRONTEND to noninteractive makes sure no prompts will
    appear during the operation. In this case, --force-confdef will
    automatically pick the default option when some debconf should appear.
    In the absence of a default option, --force-confold will automatically
    choose to keep the old configuration file.
    )r��purger�r�r�r�r�r�Nr�r�r"r"r#�purge_packages�r�r�cCst|gd�ddid�dS)a6
    Install packages, allowing downgrades.

    The --allow downgrades flag is needed because sometimes we need to
    reinstall the packages to a lower version (passed in the package_name
    string, as package=version).

    Setting DEBIAN_FRONTEND to noninteractive makes sure no prompts will
    appear during the operation. In this case, --force-confdef will
    automatically pick the default option when some debconf should appear.
    In the absence of a default option, --force-confold will automatically
    choose to keep the old configuration file.
    )z--allow-downgradesr�r�r�r�)r�rqN)r�)r�r"r"r#�reinstall_packagess

�r�cCs*tj��D]}tj�|�qt��tjSr6)r*r+r�r��init_configr�r"r"r#�_get_apt_configsr�cCs8tt��}|�|�}Wd�|S1swY|Sr6)r~r�r�)�base_key�apt_cfg�apt_cfg_keysr"r"r#�get_apt_config_keys(s

��r��	cfg_namescCsdi}tt��"}|D]}|�|�}t|�s|�|�pd}|||<q	Wd�|S1s+wY|S)z�
    Get all APT configuration values for the given config names. If
    one of the config names is not present on the APT config, that
    config name will have a value of None
    N)r~r�r,rN�
value_list)r��apt_cfg_dictr��cfg_name�	cfg_valuer"r"r#�get_apt_config_values/s


�
�	�	r�cCsd}d}tj�|�r|S|S)Nz/etc/apt/sources.listz&/etc/apt/sources.list.d/ubuntu.sources)rArBrC)�old_sources_path�new_sources_pathr"r"r#�get_system_sources_fileEs
���r�)NN)Fr6)rcN)xr�rY�enumr0�loggingrArRrWrD�	functoolsrr�typingrrrrrr	r
r*�apt.progress.baser�uaclientrr
rrrrr�uaclient.defaultsr�uaclient.files.state_filesrrIrr,r+r.rIrFrHrErGrr��APT_METHOD_HTTPS_FILE�CA_CERTIFICATES_FILErJrOrVrr�rBrHrcrJ�get_event_loggerrB�	getLogger�replace_top_level_logger_namerrL�unique�EnumrrNr$r3r7rarnryr}r~r�r�r��boolr�r��retryrsr�r�r��Packager�r��Versionr�r�r�r
rr"r$r'rr3r4r7r9r6r rM�floatrTrXr]r�r�r�r�r�r�r�r�r�r"r"r"r#�<module>s�$$	������*�
�(����
�+�������
�-��
�
�(��
��
��
����
�����
� �������
�'��������
�A/�����
�
����
�8
E
�
�

https://t.me/RX1948 - 2025