%PDF- %PDF-
Mini Shell

Mini Shell

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

�

&��e�1���ddlmZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZddlmZddlmZddlmZmZmZdd	lmZGd
�de�Zedk(r%edd�Zed
ej=dd�z�yy)�)�TemplateN)�gettext)�SourcesList)�urlopen)�	HTTPError�)�get_dist�url_downloadable�country_mirror)�readlinec��eZdZdZdZdZdejvZd�Z	d�Z
d�Zd�Zd	�Z
	dd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zy
)�DistUpgradeFetcherCorez2 base class (without GUI) for the upgrade fetcher � http://archive.ubuntu.com/ubuntu�main�DEBUG_UPDATE_MANAGERc�L�||_t�|_||_g|_y�N)�new_distr	�current_dist_name�	_progress�run_options)�selfr�progresss   �D/usr/lib/python3/dist-packages/DistUpgrade/DistUpgradeFetcherCore.py�__init__zDistUpgradeFetcherCore.__init__1s"�� ��
�!)����!������c�b�|jr#tjj|dz�yy)z" helper to show debug information �
N)�DEBUG�sys�stderr�write)r�msgs  r�_debugzDistUpgradeFetcherCore._debug8s$���:�:��J�J���S�4�Z�(�rc��d|jvry|jj��|j|jj�}t	j
�}	t	jd�t|�}|j�jdd�}t	j|�t�t�ttd�d�
�t�}|j!�j#�j%td��ryy#t$r'|jtd�td��Yyt$r'|jtd	�td
��YywxYw)Nz(--frontend=DistUpgradeViewNonInteractiveT�zUTF-8�replacez'Could not find the release announcementzThe server may be overloaded.Fz+Could not download the release announcementz&Please check your internet connection.zContinue [yN] �)�end�y)rr�releaseNotesURI�
_expandUri�socket�getdefaulttimeout�setdefaulttimeoutr�read�decoder�error�_�IOError�printr�strip�lower�
startswith)r�uri�timeout�
release_notes�notes�ress      r�showReleaseNotesz'DistUpgradeFetcherCore.showReleaseNotes=s4��5��9I�9I�I���=�=�(�(�4��/�/�$�-�-�"?�"?�@�C��.�.�0�G�
��(�(��+� '���
�%�*�*�,�3�3�G�Y�G��
�$�$�W�-�
��
�e��
�a� �!�r�*��j���9�9�;����)�)�!�C�&�1�����
��
�
�1�F�G��<�=�?���
��
�
�1�J�K��E�F�H��
�s� AD"�"-F�,F�?Fc�0�t|�t|�y)z� minimal implementation for error display, should be overwriten
            by subclasses that want to more fancy method
        F)r5)r�summary�messages   rr2zDistUpgradeFetcherCore.errorXs��	�g��
�g��rc�
�|jjr�|jdztjj|jj�z}|jdztjj|jj�z}ttd�tjj|�tjj|�d�z�|j||�ryy)N�/z0authenticate '%(file)s' against '%(signature)s' )�file�	signatureTF)
r�upgradeToolSig�tmpdir�os�path�basename�upgradeToolr5r3�gpgauthenticate)r�f�sigs   r�authenticatez#DistUpgradeFetcherCore.authenticate`s����=�=�'�'����c�!�B�G�G�$4�$4�T�]�]�5N�5N�$O�O�A��+�+��#�b�g�g�&6�&6��
�
�,�,�'.�.�C��!�F�G����(�(��+��W�W�-�-�c�2�K4�4�
5��#�#�A�s�+��rNc��dg}|sd}|d|gz
}|d||gz
}tj|tj��}|dk(S)zx authenticated a file against a given signature, if no keyring
            is given use the apt default keyring
        zapt-keyz./usr/share/keyrings/ubuntu-archive-keyring.gpgz	--keyring�verify)r!r)�
subprocess�call�PIPE)rrDrE�keyring�gpg�rets      rrLz&DistUpgradeFetcherCore.gpgauthenticatelsP��
�k���F�G���W�%�%����)�T�*�*���o�o�c�*�/�/�:���a�x�rc��tjj|jtjj	|j
��}t
td�tjj	|�z�tjj|�sy	tj|jdztjj	|j
�zd�}|D]}|j|��|j�y#tj$r"}tjd|z�Yd}~yd}~wwxYw)Nzextracting '%s'FrC�rzfailed to open tarfile (%s)T)rHrI�joinrGrJr9r5r3�exists�tarfile�open�extract�close�	ReadError�loggingr2)r�fname�tar�tarinfo�es     r�extractDistUpgraderz*DistUpgradeFetcherCore.extractDistUpgrader|s��������T�[�[�"�'�'�*:�*:�4�8�8�*D�E��
�a�!�"�R�W�W�%5�%5�e�%<�<�=��w�w�~�~�e�$��	��,�,�t�{�{�S�0�!�w�w�/�/����9� :�;>�@�C��
%�����G�$�
%��I�I�K���� � �	��M�M�7�!�;�<���	�s�'A5D�E�0E
�
Ec��|j�d|jj��x|_}tj
j
|�s3|jtd�td�dztd�z�Sy)NrCzCould not run the upgrade toolz.  z�This is most likely a bug in the upgrade tool. Please report it as a bug using the command 'ubuntu-bug ubuntu-release-upgrader-core'.T)	rGr�name�scriptrHrIr[r2r3)rris  r�verifyDistUpraderz(DistUpgradeFetcherCore.verifyDistUprader�sv��
+/�+�+�t�}�}�7I�7I�J�J���f��w�w�~�~�f�%��:�:�a� @�A�� @�A�E�I��!A�B�B�C�
C�rc��|jd|jz�td��}t�}|jD�]}|j
s|js|jdk(s�,|j|vr�;|jj|�r5|j|jk(r|j|jvr|cS|j|jk(s��d|jvs��|j|t|�dz}t||j�r|cS|j|j���|jd�y)	a
        try to figure what the mirror is from current sources.list

        do this by looing for matching DEFAULT_COMPONENT, current dist
        in sources.list and then doing a http HEAD/ftp size request
        to see if the uri is available on this server
        zmirror_from_sources_list: %sF)�withMatcher�debrNzno mirror foundr()r$rr�set�list�disabled�invalid�typer9r8�dist�DEFAULT_COMPONENT�comps�lenr
�add)rr9�default_uri�sources�seenre�
mirror_uris       r�mirror_from_sources_listz/DistUpgradeFetcherCore.mirror_from_sources_list�s��	
���2�T�5K�5K�K�L��%�0���u�����	 �A��z�z�Q�Y�Y�a�f�f��o���u�u��}����� � ��-��F�F�d�4�4�4��*�*�a�g�g�5��
��&�&�D�2�2�2�v����7H��U�U�S��[�)9�):�%;�;�
�#�J����<�%�%��������	 � 	
���%�&�rc��|j|j�r1|jd�|j||j�}|r|St	|�}t�}|j
|��}	t||j�std|z��	|S#t$r1}|jd|z�|j
d��}Yd}~|Sd}~wwxYw)z�
        expand the uri so that it uses a mirror if the url starts
        with a well known string (like archive.ubuntu.com)
        ztrying to find suitable mirror)�
countrymirrorzfailed to download %sz url '%s' could not be downloadedr(N)	r8�DEFAULT_MIRRORr$r|rr�safe_substituter
�	Exception)rr9�new_uri�uri_template�mres      rr,z!DistUpgradeFetcherCore._expandUri�s����>�>�$�-�-�.��K�K�8�9��3�3�C��9L�9L�M�G������}������.�.�Q�.�?��	E�#�G�T�[�[�9�� 7�'� A�B�B�:����	�	E��K�K�:�Q�>�?�"�2�2��2�D�G����		E�s�5$B�	C�%&C�Cc�
�tjd��}||_tj|�tjd|z�|jdkDr@tjjdd�tjjdd�tj|j�}|jj�H|j|jj�}tj ||t#d��	�}||jj$��V|j|jj$�|_tj ||j&t#d
��	�}||j)�}||j*k7rtj,d|z�ytj.j1|jj�tj.j1|jj$�fD]]}tj.j3|�r#tj.j5|�dkDr�Etj,d
|z�yyy)z. download the tarball with the upgrade script zubuntu-release-upgrader-)�prefixzusing tmpdir: '%s'rzDebug::Acquire::http�1zDebug::Acquire::ftpzUpgrade tool signature)�descrzUpgrade toolzfetch result != continue (%s)Fzfile '%s' missingT)�tempfile�mkdtemprGrH�chdirra�debugr�apt_pkg�configrn�AcquirerrrFr,�AcquireFiler3rKr9�run�RESULT_CONTINUE�warningrIrJr[�getsize)rrG�fetcherr9�af1�af2�resultrMs        r�fetchDistUpgraderz(DistUpgradeFetcherCore.fetchDistUpgrader�s����!�!�)C�D�����
������
�
�*�V�3�4��:�:��>��N�N���5�s�;��N�N���4�c�:��/�/�$�.�.�1���=�=�'�'�3��/�/�$�-�-�">�">�?�C��%�%�g�&)�,-�.F�,G�I�C�
��=�=�$�$�0����t�}�}�'@�'@�A�D�H��%�%�g�&*�h�h�,-�n�,=�?�C�
��[�[�]�F���0�0�0���� ?�&� H�I���g�g�&�&�t�}�}�'C�'C�D��g�g�&�&�t�}�}�'@�'@�A�C�
!�������q�)�b�g�g�o�o�a�.@�1�.D��O�O�$7�!�$;�<� �	
!�
�rc���|jg|jz}tj�dk7rtjdddg|z�ytj|j|�y)Nrz
/usr/bin/sudo�sudoz-E)rirrH�getuid�execv)r�argss  r�runDistUpgraderz&DistUpgradeFetcherCore.runDistUpgrader�sO�����}�t�/�/�/��
�9�9�;�!���H�H�_�v�t�n�t�&;�<��H�H�T�[�[�$�'rc�l�tjd�tj|j�y)Nz..)rHr��shutil�rmtreerG)rs r�cleanupzDistUpgradeFetcherCore.cleanups��
������
�
�d�k�k�"rc���|j�sy|j�s%|jtd�td��y|j	�s5|jtd�td��|j�y|j
�s%|jtd�td��y|j�s5|jtd�td��|j�y	tj|jtj�s!td	|jz�}d
|_
|�|j�y#t$rs}|jd
k(r)|jtd�td��Yd}~y
|jtd�td�|jz�Yd}~yd}~wwxYw)NzFailed to fetchz=Fetching the upgrade failed. There may be a network problem. zAuthentication failedz_Authenticating the upgrade failed. There may be a problem with the network or with the server. zFailed to extractz[Extracting the upgrade failed. There may be a problem with the network or with the server. zVerification failedz[Verifying the upgrade failed.  There may be a problem with the network or with the server. zCan not execute '%s'�
zCan not run the upgradezyThis usually is caused by a system where /tmp is mounted noexec. Please remount without noexec and run the upgrade again.FzThe error message is '%s'.T)r>r�r2r3rOr�rfrjrH�accessri�X_OK�OSError�errnor��strerror)r�exres   rr�zDistUpgradeFetcherCore.runs����$�$�&���%�%�'��J�J�q�*�+��%�&�
'�
�� � �"��J�J�q�0�1��I�J�
K�
�L�L�N���'�'�)��J�J�q�,�-��I�J�
K�
��%�%�'��J�J�q�.�/��I�J�
K�
�L�L�N��	I��9�9�T�[�[�"�'�'�2��3�d�k�k�A�B�������� � �"����		I��w�w�"�}��
�
�1�6�7��A�B�C���
�
�1�6�7��9�:�Q�Z�Z�G�I�I���		I�s�AE'�'	G#�03G�(1G�G#r)�__name__�
__module__�__qualname__�__doc__rrtrH�environrrr$r>r2rOrLrfrjr|r,r�r�r�r��rrrr*sj��8�7�N���"�b�j�j�0�E��)�
�6�
�!%�� �"
��<�2%�N(�#�-rr�__main__zgot mirror: '%s'zghttp://archive.ubuntu.com/ubuntu/dists/intrepid-proposed/main/dist-upgrader-all/0.93.34/intrepid.tar.gzr)�stringrrHr�rar\r�r�r-r rRrr3�aptsources.sourceslistr�urllib.requestr�urllib.errorr�utilsr	r
r�DistUpgradeViewTextr�objectrr��dr5r|r�rr�<module>r�s���.�	�����
�
�
�� �.�"�"�=�=�)�J�V�J�Z�z���t�T�*�A�	�
�
�
$�
$�:�0�2�2�3�r

Zerion Mini Shell 1.0