%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/uaclient/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/uaclient/__pycache__/apt.cpython-312.pyc

�

�Hcf����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/dZ0dZ1dZ2dZ3dZ4ejjjme d�ejjjme d�gejjjme d�ejjjme d�ejjjme d�ejjjme d�gd �Z7gd!�Z8ejr�Z:ejvejxe=��Z>ej~Gd"�d#ej���ZAed$d%eBfd&eBfd'eBfg�ZCd(�ZDeDd)eBd*eBfd+��ZEd,�ZFd-eBd.eeBfd/�ZG		dqd0eeBd1eeBd2ee
eBeBfd.eBfd3�ZHe
d�4�		dqd1eeBd2ee
eBeBfd.eBfd5��ZIGd6�d7�ZJd8�ZKd9�ZLd:eBd.eeBfd;�ZM	drd:eBd<eNd.eeBfd=�ZO	dsd2ee
eBeBfd.eBfd>�ZPej�ej�ej�fe8�d?eBfd@��ZT		dqdAeeBdBeeeBd2ee
eBeBfd.eBfdC�ZUdDeBd.eej�fdE�ZW	dsdFej�dGeeBd.eej�fdH�ZYdIeeBdJeBdKeNdLeBd.eBf
dM�ZZ	drdIeeBdJeBdKeNdLeBdNeBdOeNd.eBfdP�Z[dQeBdLeBdReBdIeeBdNeBd.dfdS�Z\dT�Z]dU�Z^	dsdQeBdLeBdNeeBd.dfdV�Z_dW�Z`dX�ZadY�ZbdZ�Zcd[eBd.eNfd\�Zdd.eeCfd]�Zed.eeBfd^�ZfddeAj�fd_eeBd`eeBdaeeAd.dfdb�Zhd.eeifdc�Zjd.eejfdd�Zkde�Zldtdf�ZmdgeeBdheBfdi�ZndgeeBdheBfdj�ZodgeeBfdk�Zpdl�Zqdm�ZrdneeBd.e
eBeeBeeBfffdo�Zsd.eBfdp�Zty)u�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-stamp)�xenial�bionic�focal�jammy�manticz�# 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�(�eZdZe�Ze�Zy)�
AptProxyScopeN)�__name__�
__module__�__qualname__�object�GLOBAL�UACLIENT���./usr/lib/python3/dist-packages/uaclient/apt.pyrrbs��
�X�F��x�Hr&r�InstalledAptPackage�name�version�archc�.��t���fd��}|S)z*Decorator ensuring apt_pkg is initialized.c���tjjd�dk(rtj��|i|��S)N�Dir�)�apt_pkg�config�get�init)�args�kwargs�fs  �r'�new_fz"ensure_apt_pkg_init.<locals>.new_fps5����>�>���e�$��*��L�L�N��$�!�&�!�!r&)r)r6r7s` r'�ensure_apt_pkg_initr8ms"����1�X�"��"��Lr&�a�bc�.�tj||�S�N)r0�version_compare)r9r:s  r'r=r={s���"�"�1�a�(�(r&c�J�|jd�\}}tjjd�sy	t	j
�5}t
jdddj||||�tjj|d�gtt��ddd�y#1swYyxYw#tj$r�}|jdk(r{t|j �j#�}t%j&d	|�rtj(|�
��t%j&d|�rtj*|�
��tj,t|����d}~wt.j0$rtj2t|�
��wxYw)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_sleeps�dz401\s+unauthorized|httperror401)�repozconnection timed out��detail)�secondsrC)�split�os�path�exists�tempfile�TemporaryDirectoryr�subp�format�join�APT_HELPER_TIMEOUT�APT_RETRIESr�ProcessExecutionError�	exit_code�str�stderr�lower�re�search�APTInvalidCredentials�
APTTimeout�APTUnexpectedError�
subprocess�TimeoutExpired�APTCommandTimeout)�repo_url�username�password�protocol�	repo_path�tmpd�erUs        r'�assert_valid_apt_credentialsrf�sR��#�.�.��/��H�i�
�7�7�>�>�3�4��
�
�
(�
(�
*�	�d��K�K�-�#�)�0�0� �(�H�i���G�G�L�L��':�;�
�+�(�
�	�	�	���+�+�;��;�;�#������]�(�(�*�F��y�y�;�V�D� �6�6�H�E�E����2�F�;� �+�+��:�:��+�+�3�q�6�:�:���$�$�
��*�*�&�Y�
�	
�
�s7�B4�
AB(�B4�(B1�-B4�1B4�4F"�B)E0�02F"�	apt_error�returnc��t�}|j�jd�D]W}|s�tjd|�}|s�d|j�djd�dz}|j
|��Y|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�striprGrWrX�	groupdict�add)rg�failed_repos�line�
pattern_match�repo_url_matchs     r'�(_parse_apt_update_for_invalid_apt_configrt�s���(�5�L����!�'�'��-�1����I�I�E�t��M���=�2�2�4�U�;�A�A�(�K�A�N�N��� � ��0�1��r&�cmd�	error_msg�override_env_varsc��	tj|dt|��\}}|S#tj$r�}dt|j�vrtj��	t|j�}|r.tjdjt|�����|r|n
t|�}tj|���d}~wwxYw)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)�capturerArwz%Could not get lock /var/lib/dpkg/lockrj)rprDN)
rrMrQrrRrTrU�APTProcessConflictErrorrt�APTInvalidRepoErrorrO�sortedr[)rurvrw�out�_errrerp�msgs        r'�run_apt_commandr��s���8��K�K���$�/�	
�	��T�.�J��#�+�+�8�2�c�!�(�(�m�C��4�4�6�6�
�
D�A�H�H�M�L�� �4�4�!%���6�,�+?�!@���%�i�#�a�&���+�+�3�7�7��!8�s� $�C�BC
�
C)�maxsizec�"�tddg||��S)N�	apt-cache�policy)rurvrw)r�)rvrws  r'�get_apt_cache_policyr��s��
�
�(�#��+��r&c��eZdZd�Zd�Zd�Zy)�PreserveAptCfgc� �||_i|_yr<)�apt_func�current_apt_cfg)�selfr�s  r'�__init__zPreserveAptCfg.__init__s�� ��
�!��r&c	���tj}|j�D�cic]'}|tj|j|����)c}|_|j�Scc}wr<)r0r1�keys�copy�deepcopyr2r�r�)r��cfg�keys   r'�	__enter__zPreserveAptCfg.__enter__
sR���n�n��8;���
� 
�14�C����s�w�w�s�|�,�,� 
����}�}����	 
s�,A'c���tj}|jj�D]!}|j	||j|��#tj
�yr<)r0r1r�r�rl�init_system)r��type�value�	tracebackr�r�s      r'�__exit__zPreserveAptCfg.__exit__sP���n�n���'�'�,�,�.�	4�C��G�G�C��-�-�c�2�3�	4����r&N)rr r!r�r�r�r%r&r'r�r�s��"��r&r�c���tjj�D]!}tjj|��#tj�tj
d�Sr<)r0r1r��clearr3�Cache�r�s r'�get_apt_pkg_cacher�sH���~�~�"�"�$�"�������S�!�"��L�L�N��=�=���r&c�r�	tjj�D]8}tjd|�r�tjj|��:tjj
dt�tj�tjd�S#t$ricYSwxYw)Nz^Acquirer.)r0r1r�rWrXr�rlrr3r��	Exceptionr�s r'�get_esm_apt_pkg_cacher�#s�����>�>�&�&�(�	*�C��9�9�Z��-����$�$�S�)�	*�	�����5�/�2�����
�}�}�T�"�"�����	��s�7B(�A-B(�(B6�5B6�pkg_namec���tt�5}	||}	ddd�jr|jjSy#t$rYddd�ywxYw#1swY�CxYwr<)r�r��KeyError�current_ver�ver_str)r��cache�packages   r'�get_pkg_versionr�6sn��	�)�	*��e�	��H�o�G������"�"�*�*�*���
�	��	��	����s(�A�A�	A�A�A�A�A#�check_esm_cachec�`�tt�5}	||}tj|�}|j|�}|s
	ddd�y|j}ddd�|sStt�5}|ri	||}tj|�}	|	j|�}
|
scddd�S|
j}tj|�dk\r|cddd�Sddd�S#t$rYddd�ywxYw#1swY��xYw#t$rcYcddd�SwxYw#1swYSxYw)Nr)	r�r�r�r0�DepCache�get_candidate_verr�r�r=)r�r�r�r��	dep_cache�	candidate�candidate_version�	esm_cache�esm_package�
esm_dep_cache�
esm_candidate�esm_candidate_versions            r'�get_pkg_candidate_versionr�Csh��
�)�	*�.�e�	��H�o�G��$�$�U�+�	��/�/��8�	���.�.�&�-�-��.�� � �	�-�	.�-�)��
)�'��1��$�,�,�Y�7�M�)�;�;�K�H�M� �(�-�-�%2�$9�$9�!��'�'�)�+<����
-�)-�-�-�,���G�	��	.�.�	��.�.��(�
)�(�(�-�-�
)��	-�,��si�C=�C&�)C=�	C=�0D#�4D	�9)D#�,&D#�&	C:�/C=�9C:�:C=�=D�	D �D#�D � D#�#D-c��	tddg|��}	tj�|S#tj$rtj��tj$r%}tj
|j���d}~wtj$r%}tj|j���d}~wwxYw#tj�wxYw)N�apt-get�update�rurw��repo_msgrD)r�rrz�APTUpdateProcessConflictErrorr{�APTUpdateInvalidRepoErrorr�UbuntuProError�APTUpdateFailedr��cache_clear)rwr}res   r'�run_apt_update_commandr�os���+���H�%�9J�
��	�(�(�*��J���-�-�9��6�6�8�8��)�)�C��2�2�A�E�E�B�B���$�$�7��(�(����6�6��7��	�(�(�*�s-�(�9B<�! B�B<� B7�7B<�<B?�?C�sources_list_pathc��tt�5}tjj	dt
jj|��tjj	dd�tjj	dd�tj�}|j�t�}t
jjtjjd�d�}tj|�}	|5|j||d�ddd�t*j-�	ddd�y#1swY�'xYw#ttd	d
�$rt!j"��t$$r$}t!j&t)|����d}~wwxYw#t*j-�wxYw#1swYyxYw)NzDir::Etc::sourcelistzDir::Etc::sourcepartszN.O.F.O.L.D.E.RzAPT::List-Cleanup�0zDir::State::Lists�lockr�Errorr%rD)r�r�r0r1rlrHrI�abspath�
SourceList�read_main_listrrO�find_dir�FileLockr��getattrrrz�SystemErrorr�rTr�r�)r�r��sources_list�fetch_progress�	lock_filer�res       r'�update_sources_listr��sl��

�)�	*�!/�e������"�B�G�G�O�O�4E�$F�	
�	�����2�4E�F������.��4��)�)�+���#�#�%�)�*���G�G�L�L��N�N�#�#�$7�8�&�
�	����	�*��		/��
>����^�\�1�=�
>�
!�,�,�.�C!/�!/�2
>�
>���w���,�	7��4�4�6�6��	<��,�,�C��F�;�;��	<��
!�,�,�.��C!/�!/�sT�C>G�E�E�%E�-G�E	�E�0F+�F&�&F+�+F.�.G�G�G�packages�apt_optionsc��|�g}	tgd�|z|z|��}|S#tj$rtj��tj$r%}tj
|j���d}~wwxYw)N)r��install�--assume-yesr�r�)r�rrz�APTInstallProcessConflictErrorr{�APTInstallInvalidRepoErrorr)r�r�rwr}res     r'�run_apt_install_commandr��s���
����
D��6�����0�	
���J���-�-�:��7�7�9�9��)�)�D��3�3�Q�U�U�C�C��D�s��9A;� A6�6A;�originc�4�t�}tt�5}|jD]F}|j}|s�|j
D]&\}}|j|k(s�|j|��(�H	ddd�t|�S#1swYt|�SxYwr<)	rlr�r�r�r��	file_listr�ro�list)r��resultr�r��installed_version�file�_s       r'� get_installed_packages_by_originr��s����U�F�	�)�	*�,�e��~�~�	,�G� '� 3� 3�� �0�:�:�,�G�D�!��{�{�f�,��
�
�7�+�,�	,�,���<��,���<��s�B�!B�B�Br��exclude_originc���g}|jD]R}|jD��cgc]%\}}|jdk7r|j|k7r|��'}}}|s�B|j	|��T|Scc}}w)N�now)�version_listr��	componentr��append)r�r��valid_versionsr*r�r��
valid_originss       r'�get_remote_versions_for_packager��s����N��'�'�
+��#�,�,�
���a��~�~��&�4�;�;�.�+H�
�
�
�
���!�!�'�*�
+����
s�*A&�suites�series�updates_enabledr_c��d}|D]?}||vr�d}d|vr|stjd||�d}|dj|||��z
}�A|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_commentrk�suite)�LOG�warningrN)r�r�r�r_�contentr�r�s       r'�_get_list_file_contentr��s|���G��
�������
������K�K����	
�!�M��
-�-3�V�+���.4�.�	
��
�&�Nr&�keyring_file�include_deb_srcc��|D�cgc]	}||vs�|��}}|s*tjd|�|D�cgc]	}d|vs�|��}}|rdnd}tj|dj	|�t
||��}	|	Scc}wcc}w)NzPNot enabling service-related -updates suites because "%s-updates" is not enabledr�z deb-srcr/� )rkr��keyrings_dirr��deb_src)r�r��DEB822_REPO_FILE_CONTENTrNrO�KEYRINGS_DIR)
r�r�r�r_r�r�r��appliable_suitesr�r�s
          r'�_get_sources_file_contentrs���,2�E�%�V�u�_��E��E�����
+��	
� 0�
��:�U�3J�E�
��
�,�j��G�&�-�-���x�x�(�)�!�!��.��G��N��+F��
s�	A6�A6�	A;�A;�
repo_filename�credentialsc��	|jd�\}}tjj	|�tj�j}|jd�r|dd}t|||�d}tddgtj�}	|	j�D]}
d	j|�|
vr�d
|
vr�d}nt|||�|t vrmt"j$j't(|�}t"j$j't*|�}t-j.||�t1||||�}
nt3|||||�}
tj4||
�y#t$rd}|}Y��gwxYw)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���Fr�r�za={}-updatesz	o=Ubuntu,T)rG�
ValueErrorr�secrets�
add_secretr�get_release_infor��endswithrfr�r�APT_POLICY_FAILED�
splitlinesrN�add_apt_auth_conf_entry�SERIES_NOT_USING_DEB822rHrIrOr��APT_KEYS_DIRr�export_gpg_keyr�r�
write_file)rr_rr�r�r`rar�r�r�rq�source_keyring_file�destination_keyring_filer�s              r'�add_auth_apt_repor!sz���(�.�.�s�3���(����%�%�h�/�
�
$�
$�
&�
-�
-�F�������C�R�=�� ��8�X�>��O�
�	�h���!;�!;��F��!�!�#���� � ��(��4���d�"����
���H�h��9�
�(�(� �g�g�l�l�<��F��#%�7�7�<�<��l�#K� ����.�0H�I�(��F�O�X�
��,��F�O�X�|�
�����m�W�-��O�������s�E-�-
E>�=E>c��t�}|jd�\}}|jd�s|dz
}tjj|�rt
j|�}nd}dj|||t��}d}g}	|j�D]h}
|sS|
j�}t|�dk\r5|d}||k(r|	j|�d	}�A||vr|	j|�d	}|	j|
��j|s|	j|�|	jd�t
j|d
j|	�d��y
)zBAdd or replace an apt auth line in apt's auth.conf file or conf.d.r?rr/z:machine {repo_path} login {login} password {password}{cmt})rc�loginra�cmtF��Trj���modeN)�!get_apt_auth_file_from_apt_configrGr
rHrIrJr�	load_filerN�APT_AUTH_COMMENTr�lenr�rrO)
r_rra�
apt_auth_file�	_protocolrc�orig_content�repo_auth_line�added_new_auth�	new_linesrq�
split_line�curr_line_repos
             r'rrYsK��5�7�M�#�>�>�%�0��I�y����c�"��S��	�	�w�w�~�~�m�$��'�'�
�6����	������ �	�
���N��I��'�'�)��������J��:��!�#�!+�A���!�Y�.��$�$�^�4�%)�N��!�Y�.��$�$�^�4�%)�N������� �����(�
���R��
���m�T�Y�Y�y�%9��Fr&c���|jd�\}}|jd�r|dd}t�}tjj|�r�t
j|�}dj|��}dj|j�D�cgc]	}||vs�|��c}�}|st
j|�yt
j||d�	�yycc}w)
z+Remove a repo from the shared apt auth filer?rNrzmachine {repo_path}/ login)rcrjrr)
rGr
r rHrIrJrr!rNrOr�ensure_file_absentr)r_r%rcr$�apt_auth�auth_prefixrqr�s        r'�remove_repo_from_apt_auth_filer0�s���#�>�>�%�0��I�y����#���c�r�N�	�5�7�M�	�w�w�~�~�m�$��#�#�M�2��2�9�9�I�9�N���)�)�&�1�1�3�O�d�{�$�7N�T�O�
����%�%�m�4����m�W�5�A�%��
Ps�	C�"Cc�.�tj|�|jd�r)tjtj|d��|r9t
jjt|�}tj|�t|�y)z>Remove an authenticated apt repo and credentials to the systemz.sourcesr�N)
rr-r
r�set_filename_extensionrHrIrOrr0)rr_r�s   r'�remove_auth_apt_repor3�sm�����m�,����j�)��!�!��'�'�
�v�>�	
���w�w�|�|�L�,�?���!�!�,�/�"�8�,r&c��|jd�\}}|jd�r|dd}dj||��}tj||�y)z.Add an apt preferences file and pin for a PPA.r?rNrz<Package: *
Pin: release o={origin}
Pin-Priority: {priority}
)r��priority)rGr
rNrr)�apt_preference_filer_r�r5r%rcr�s       r'�add_ppa_pinningr7�sY��#�>�>�%�0��I�y����#���c�r�N�	�	%�%+�V�6�H�V�%M��
���)�7�3r&c��tjdddtg�\}}|r|jd�ddzStjdddtg�\}}|jd�djd�S)z7Return to patch to the system configured APT auth file.�
apt-config�shellr��'rz90ubuntu-advantager)rrM�APT_CONFIG_AUTH_PARTS_DIRrG�APT_CONFIG_AUTH_FILE�rstrip)r}r~s  r'r r �s~�����	�w��'@�A��I�C����y�y��~�a� �#7�7�7��K�K�
�7�E�+?�@�
�	��T��y�y��~�a� �'�'��,�,r&c��|jd�\}}|jd�r|dd}d}tjdddtg�\}}|r|jd	�d
}|jdd�}t
tjtjj||dj|�z���S)
zEList any apt files in APT_CONFIG_LISTS_DIR given repo_url and series.r?rNrz/var/lib/apt/listsr9r:r�r;rr�z
_dists_{}*)rGr
rrM�APT_CONFIG_LISTS_DIR�replacer|�globrHrIrOrN)r_r�r%rc�	lists_dirr}r~�aptlist_filenames        r'�find_apt_list_filesrE�s���#�>�>�%�0��I�y����#���c�r�N�	�$�I����	�w��';�<��I�C����I�I�c�N�1�%�	� �(�(��c�2����	�	��G�G�L�L��+�l�.A�.A�&�.I�I�
�	
��r&c�P�t||�D]}tj|��y)z?Remove any apt list files present for this repo_url and series.N)rErr-)r_r�rIs   r'�remove_apt_list_filesrG�s&��#�H�f�5�(���!�!�$�'�(r&�pkgc��|t�vSr<)�get_installed_packages_names)rHs r'�is_installedrK�s���.�0�0�0r&c
�
�tjgd��\}}|j�dd}|D�cgc]F}t|j	d�d|j	d�d|j	d�d����Hc}Scc}w)N)�aptr�z--installedrrrr�r)r)r*r+)rrMrr(rG)r}r��package_list�entrys    r'�get_installed_packagesrP�s���
�[�[�7�
8�F�C���>�>�#�A�B�'�L�"�
�
�	����S�!�!�$��K�K��$�Q�'����S�!�!�$�	
����s�ABc�V�t�}|D�cgc]}|j��}}|Scc}wr<)rPr))rNrH�	pkg_namess   r'rJrJ�s,��)�+�L�%1�2�c����2�I�2����3s�&�
http_proxy�https_proxy�proxy_scopec���|s|rb|r`d}|tjk(rd}n|tjk(rd}tj	t
jj|���d}|rY|tjk(r|tj|��z
}n,|tjk(r|tj|��z
}|rY|tjk(r|tj|��z
}n,|tjk(r|tj|��z
}|dk7r	t|z}|dk(rtjt�ytj t|�y)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_SCOPErN�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)rSrTrU�message�apt_proxy_configs     r'�setup_apt_proxyre�sm�� �[���G��m�4�4�4�%���
� 4� 4�4�"���J�J��4�4�;�;�'�;�J�
�����-�0�0�0�� 8� ?� ?�$�!@�!�
���M�0�0�
0�� <� C� C�$�!D�!�
����-�0�0�0�� 9� @� @�%�!A�!�
���M�0�0�
0�� =� D� D�%�!E�!�
���2��2�5E�E���2���!�!�"5�6����-�/?�@r&c��d}tjjt�r#tjt�j
}|Sr<)rHrIrJ�APT_UPDATE_SUCCESS_STAMP_PATH�stat�st_mtime��
cache_times r'�get_apt_cache_timerl.s3���J�	�w�w�~�~�3�4��W�W�:�;�D�D�
��r&c��t�}|�ytjj|tjj�Sr<)rl�datetime�
fromtimestamp�timezone�utcrjs r'�get_apt_cache_datetimerr5s8��#�%�J�������*�*�:�x�7H�7H�7L�7L�M�Mr&c���tjtjjtd�d���t
dt
dz}t
�fd�|D��rytjt�t
dD]}tj|��t
dD]}tj|dd���y)	Nz**/*T)�	recursiverrc3�&�K�|]}|�v���
y�wr<r%)�.0r��existing_filess  �r'�	<genexpr>z._ensure_esm_cache_structure.<locals>.<genexpr>Ds�����=�t�D�N�"�=�s�i�)�exist_okr)rBrHrIrOr�ESM_BASIC_FILE_STRUCTURE�allr�ensure_folder_absent�create_file�makedirs)�
desired_filesr��folderrws   @r'�_ensure_esm_cache_structurer�<s�����Y�Y�
�����_�f�-���N�	!��)�,D�Y�,O�O���=�}�=�>������0�)��1�!�����4� �!�*�9�5�7��
���F�T��6�7r&c	�J�tj�syt�ddlm}ddlm}ddlm}m	}d}d}tj�}|�||�d}|jdg�D]W}|jdd�d	k(r|jd
d�dk(}|jdd�d
k(s�C|jd
d�dk(}�Y||�}	|r1|	j�d|jk(r|	j�n|	j!�tj"�rK||�}
|r1|
j�d|jk(r|
j�n|
j!�t%t&�5}t)j*�}|j-�Gd�dt.�}
|
�}	|j1||d�ddd�y#t2$r7}t4j7dj9t;|���Yd}~�Dd}~wwxYw#1swYyxYw)Nr)�status)�ApplicationStatus)�ESMAppsEntitlement�ESMInfraEntitlementF�servicesr)r/zesm-apps�	available�no�yesz	esm-infrac�L�eZdZdejfd�Zdejfd�Zy)�-update_esm_caches.<locals>.EsmAcquireProgress�itemc�`�tjdj|j��y)NzFetched ESM Apt Cache item: {})r��debugrN�uri�r�r�s  r'�donez2update_esm_caches.<locals>.EsmAcquireProgress.done�s���	�	�:�A�A�$�(�(�K�Lr&c�`�tjdj|j��y)Nz&Failed to fetch ESM Apt Cache item: {})r�r�rNr�r�s  r'�failz2update_esm_caches.<locals>.EsmAcquireProgress.fail�s �����<�C�C�D�H�H�M�r&N)rr r!r0�AcquireItemDescr�r�r%r&r'�EsmAcquireProgressr��s(��
M��!8�!8�
M�
��!8�!8�
r&r�z%Failed to fetch the ESM Apt Cache: {})r�is_current_series_ltsr��uaclient.actionsr��(uaclient.entitlements.entitlement_statusr��uaclient.entitlements.esmr�r�r�readr2�application_status�DISABLED�setup_local_esm_repo�disable_local_esm_repo�is_current_series_active_esmr�r�r0r�r�rr�r�r�r�rNrT)r�r�r�r�r��apps_available�infra_available�current_status�service�apps�infrar�r�r�r�res                r'�update_esm_cachesr�Qs����'�'�)���!�'�J��
�N��O�&�+�+�-�N������Q���!�%�%�j�"�5�F���;�;�v�r�"�j�0�$�[�[��d�;�u�D�N��;�;�v�r�"�k�1�%�k�k�+�t�<��E�O�	F��c�"�D�	��#�#�%�a�(�,=�,F�,F�F��!�!�#��#�#�%��*�*�,�#�C�(����(�(�*�1�-�1B�1K�1K�K��&�&�(��(�(�*�
�-�	.�P�%��)�)�+���#�#�%�	��	�,�-��	P��L�L���q�9�P�P�� �	P��K�K�?�F�F�s�1�v�N�O�O��	P��!P�P�s0�>;H�:G�	H�-H�H�H�H�H"�
package_names�
error_messagec�@�tgd�t|�z|ddi��y)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�rwN�r�r��r�r�s  r'�remove_packagesr���.���	
��}�
�	�	�,�.>�?�r&c�@�tgd�t|�z|ddi��y)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�s  r'�purge_packagesr��r�r&c�(�t|gd�ddi��y)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�rwN)r�)r�s r'�reinstall_packagesr��s����
�
-�.>�?�r&c���tjj�D]!}tjj|��#tj�tjSr<)r0r1r�r��init_configr�s r'�_get_apt_configr��sJ���~�~�"�"�$�"�������S�!�"������>�>�r&c�r�tt�5}|j|�}ddd�|S#1swYSxYwr<)r�r�r�)�base_key�apt_cfg�apt_cfg_keyss   r'�get_apt_config_keysr��s:��	��	(�.�G��|�|�H�-��.���.���s�,�6�	cfg_namesc���i}tt�5}|D]8}|j|�}t|�s|j	|�xsd}|||<�:	ddd�|S#1swY|SxYw)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�r2rT�
value_list)r��apt_cfg_dictr��cfg_name�	cfg_values     r'�get_apt_config_valuesr��sv���L�	��	(�/�G�!�	/�H����H�-�I��y�>�#�.�.�x�8�@�D�	�%.�L��"�
	/�/���/���s�>A�A%c�P�d}d}tjj|�r|S|S)Nz/etc/apt/sources.listz&/etc/apt/sources.list.d/ubuntu.sources)rHrIrJ)�old_sources_path�new_sources_paths  r'�get_system_sources_filer�s5��.��?���7�7�>�>�*�+�	���r&)NN)Fr<)rhN)ur�rn�enumrB�loggingrHrWr\rK�	functoolsrr�typingrrrrr	r
rr0�apt.progress.baser�uaclientr
rrrrrr�uaclient.defaultsr�uaclient.files.state_filesrrPr"r=r<r@rar^r`r]r_rr��APT_METHOD_HTTPS_FILE�CA_CERTIFICATES_FILErbrgrr�rIrOrzrQ�get_event_loggerrZ�	getLogger�replace_top_level_logger_namerr��unique�EnumrrTr(r8r=rfrtr�r�r�r�r�r��boolr�r��retryrzr�r�r��Packager��Versionr�r�rrrr0r3r7r rErGrKrPrJr#re�floatrlrrr�r�r�r�r�r�r�r�r�r%r&r'�<module>r�sG�������	�	���&�I�I�I��-����.�8���*��)��3��+��
�� K�� L��?��A��)��$��4��9��G�� L��J����	�����_�&<�=�
�����_�&;�<��
	�����_�&:�;�
�����_�&=�>�
�����_�&F�G�
�����_�&A�B�	���"��%��%�%�'���g���:��:�:�8�D�E������D�I�I��
��
!��V�S�M�I�s�+;�f�c�]�K���
��)�s�)�s�)��)�&
�R#��#���X�#�P $�26�'�	
�c��'���}�'� ��S�#�X��/�'�	�	'�T�4��#�26����}����S�#�X��/��	������.��&
�c�
�h�s�m�
�,1�)��)�$(�)�
�c�]�)�Z37����S�#�X��/����,�����'�'��)C�)C�D���"/�3�"/�	�"/�N(,�26���3�i���$�s�)�$�� ��S�#�X��/��	�	�.�S��T�'�/�/�5J�� ?C��
�_�_��.6�s�m��	�'�/�/���&���I��"��59��EH����@"�
���I�������	�
���
�	��@5.��5.��5.��5.�
��I�	5.�
�5.�
�
5.�p)G�XB�&FJ�-��-�"%�-�5=�c�]�-�	�-�"
4�-��,(�1�c�1�d�1�
��%8� 9�
��d�3�i��!%�!%�+8�+?�+?�5A���
�5A��#��5A��-�(�5A�
�	5A�p�H�U�O��N���):�):� ;�N�7�*BP�J�4��9��S��0�$�s�)��C��0�d�3�i��2�����}��	�#�u�S�$�s�)�^�$�
$�%��,��r&

Zerion Mini Shell 1.0