HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/DistUpgrade/__pycache__/DistUpgradeFetcherCore.cpython-38.pyc
U

٪zc-�@s�ddlmZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
m
Zddlm
Z
ddlmZmZmZGdd�de�Zed	kr�edd�Zed
e�dd��dS)
�)�TemplateN)�gettext)�SourcesList�)�get_dist�url_downloadable�country_mirrorc@s�eZdZdZdZdZdejkZdd�Z	dd�Z
d	d
�Zdd�Zd
d�Z
d"dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�ZdS)#�DistUpgradeFetcherCorez2 base class (without GUI) for the upgrade fetcher � http://archive.ubuntu.com/ubuntu�mainZDEBUG_UPDATE_MANAGERcCs||_t�|_||_g|_dS)N)�new_distr�current_dist_name�	_progress�run_options)�selfrZprogress�r�D/usr/lib/python3/dist-packages/DistUpgrade/DistUpgradeFetcherCore.py�__init__-szDistUpgradeFetcherCore.__init__cCs|jrtj�|d�dS)z" helper to show debug information �
N)�DEBUG�sys�stderr�write)r�msgrrr�_debug4szDistUpgradeFetcherCore._debugcCsdS)NTr�rrrr�showReleaseNotes9sz'DistUpgradeFetcherCore.showReleaseNotescCst|�t|�dS)z dummy implementation for error display, should be overwriten
            by subclasses that want to more fancy method
        F)�print)rZsummary�messagerrr�error<szDistUpgradeFetcherCore.errorcCsv|jjrr|jdtj�|jj�}|jdtj�|jj�}ttd�tj�|�tj�|�d��|�	||�rrdSdS)N�/z0authenticate '%(file)s' against '%(signature)s' )�file�	signatureTF)
r�upgradeToolSig�tmpdir�os�path�basename�upgradeToolr�_�gpgauthenticate)r�fZsigrrr�authenticateDs�

�
z#DistUpgradeFetcherCore.authenticateNcCs@dg}|sd}|d|g7}|d||g7}tj|tjd�}|dkS)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	--keyringZverify)rr)�
subprocess�call�PIPE)rr!r"ZkeyringZgpgZretrrrr*Psz&DistUpgradeFetcherCore.gpgauthenticatec
Cs�tj�|jtj�|j��}ttd�tj�|��tj�|�sBdSz@t	�
|jdtj�|j�d�}|D]}|�|�qh|��Wn8t	j
k
r�}zt�d|�WY�dSd}~XYnXdS)Nzextracting '%s'Fr �rzfailed to open tarfile (%s)T)r%r&�joinr$r'�urirr)�exists�tarfile�open�extract�closeZ	ReadError�loggingr)r�fnameZtarZtarinfo�errr�extractDistUpgrader`s"��z*DistUpgradeFetcherCore.extractDistUpgradercCsHd|j|jjf|_}tj�|�sD|�td�td�dtd��SdS)Nz%s/%szCould 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)	r$r�name�scriptr%r&r3rr))rr=rrr�verifyDistUpraderqs

��z(DistUpgradeFetcherCore.verifyDistUpradercCs�|�d|j�tdd�}t�}|jD]�}|js&|js&|jdksBq&|j|krNq&|j�	|�rz|j
|jkrz|j|jkrz|S|j
|jkr&d|jkr&|j|t
|�d�}t||j�r�|S|�|j�q&|�d�dS)	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)ZwithMatcherZdebrNzno mirror found�)rr
r�set�listZdisabledZinvalid�typer2�
startswithZdist�DEFAULT_COMPONENT�comps�lenr�add)rr2Zdefault_uriZsources�seenr:Z
mirror_urirrr�mirror_from_sources_list�s*



�
�
z/DistUpgradeFetcherCore.mirror_from_sources_listc
Cs�|�|j�r,|�d�|�||j�}|r,|St|�}t�}|j|d�}zt||j�s`td|��Wn<tk
r�}z|�d|�|jdd�}W5d}~XYnX|S)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)Z
countrymirrorzfailed to download %sz url '%s' could not be downloadedr?N)	rC�DEFAULT_MIRRORrrIrrZsafe_substituter�	Exception)rr2Znew_uriZuri_template�mr:rrr�
_expandUri�s
z!DistUpgradeFetcherCore._expandUricCsNtjdd�}||_t�|�t�d|�|jdkrPtj	�
dd�tj	�
dd�t�|j�}|j
jdk	r�|�|j
j�}tj||td	�d
�}||j
jdk	�rJ|�|j
j�|_tj||jtd�d
�}||��}||jkr�t�d|�d
Stj�|j
j�tj�|j
j�fD]:}tj�|��r.tj�|�dk�s
t�d|�d
S�q
dSd
S)z. download the tarball with the upgrade script zubuntu-release-upgrader-)�prefixzusing tmpdir: '%s'rzDebug::Acquire::http�1zDebug::Acquire::ftpNzUpgrade tool signature)ZdescrzUpgrade toolzfetch result != continue (%s)Fzfile '%s' missingT)�tempfileZmkdtempr$r%�chdirr8�debugr�apt_pkgZconfigr@ZAcquirerrr#rMZAcquireFiler)r(r2�runZRESULT_CONTINUEZwarningr&r'r3�getsize)rr$Zfetcherr2Zaf1Zaf2�resultr+rrr�fetchDistUpgrader�sD

��
� 
z(DistUpgradeFetcherCore.fetchDistUpgradercCsB|jg|j}t��dkr0t�dddg|�nt�|j|�dS)Nrz
/usr/bin/sudoZsudoz-E)r=rr%�getuid�execv)r�argsrrr�runDistUpgrader�sz&DistUpgradeFetcherCore.runDistUpgradercCst�d�t�|j�dS)Nz..)r%rQ�shutilZrmtreer$rrrr�cleanup�s
zDistUpgradeFetcherCore.cleanupc
Cs>|��sdS|��s,|�td�td��dS|��sT|�td�td��|��dS|��st|�td�td��dS|��s�|�td�td��|��dSz4t�	|j
tj�s�td	|j
�}d
|_
|�|��Wnhtk
�r8}zH|j
d
k�r|�td�td��WY�"d
S|�td�td�|j�W5d}~XYnXdS)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)rrWrr)r,r]r;r>r%�accessr=�X_OK�OSError�errnor[�strerror)r�exr:rrrrT�sP
�
�
�
�
�

�zDistUpgradeFetcherCore.run)N)�__name__�
__module__�__qualname__�__doc__rJrDr%�environrrrrrr,r*r;r>rIrMrWr[r]rTrrrrr	&s&

�
'r	�__main__zgot mirror: '%s'zghttp://archive.ubuntu.com/ubuntu/dists/intrepid-proposed/main/dist-upgrader-all/0.93.34/intrepid.tar.gzr
)�stringrr%rSr8r4rPr\rr-rr)Zaptsources.sourceslistrZutilsrrr�objectr	re�drrIrrrr�<module>s*v
��