Ë
    &£ËeÉ1  ã                   ó  — d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlmZ d dlmZ d dlmZ d dlmZ ddlmZmZmZ dd	lmZ  G d
„ de«      Zedk(  r% edd«      Z edej=                  dd«      z  «       yy)é    )ÚTemplateN)Úgettext)ÚSourcesList)Úurlopen)Ú	HTTPErroré   )Úget_distÚurl_downloadableÚcountry_mirror)Úreadlinec                   óŒ   — e Zd ZdZdZdZdej                  v Zd„ Z	d„ Z
d„ Zd„ Zd	„ Z	 dd„Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zy
)Ú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__zDistUpgradeFetcherCore.__init__1   s"   € Ø ˆŒÜ!)£ˆÔØ!ˆŒàˆÕó    c                 ób   — | j                   r#t        j                  j                  |dz   «       yy)z" helper to show debug information ú
N)ÚDEBUGÚsysÚstderrÚwrite)r   Úmsgs     r   Ú_debugzDistUpgradeFetcherCore._debug8   s$   € à�:Š:Ü�J‰J×Ñ˜S 4™ZÕ(ð r   c                 ó  — d| j                   v ry| j                  j                  ��| j                  | j                  j                  «      }t	        j
                  «       }	 t	        j                  d«       t        |«      }|j                  «       j                  dd«      }t	        j                  |«       t        «        t        «       t        t        d«      d¬«       t        «       }|j!                  «       j#                  «       j%                  t        d«      «      ryy# t        $ r' | j                  t        d«      t        d«      «       Y yt        $ r' | j                  t        d	«      t        d
«      «       Y yw xY w)Nz(--frontend=DistUpgradeViewNonInteractiveTé   zUTF-8Úreplacez'Could not find the release announcementzThe server may be overloaded.Fz+Could not download the release announcementz&Please check your internet connection.zContinue [yN] Ú )ÚendÚy)r   r   Ú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   Á A D" Ä"-F Å,F Å?F c                 ó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      r   r2   zDistUpgradeFetcherCore.errorX   s   € ô 	ˆgŒÜˆgŒØr   c                 ó
  — | j                   j                  rí| j                  dz   t        j                  j                  | j                   j                  «      z   }| j                  dz   t        j                  j                  | j                   j                  «      z   }t        t        d«      t        j                  j                  |«      t        j                  j                  |«      dœz  «       | j                  ||«      ryy)Nú/z0authenticate '%(file)s' against '%(signature)s' )ÚfileÚ	signatureTF)
r   ÚupgradeToolSigÚtmpdirÚosÚpathÚbasenameÚupgradeToolr5   r3   Ú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ñK4ñ 4ô 5ð ×#Ñ# A sÔ+ØØr   Nc                 ó‚   — dg}|sd}|d|gz  }|d||gz  }t        j                  |t         j                  ¬«      }|dk(  S )zx authenticated a file against a given signature, if no keyring
            is given use the apt default keyring
        zapt-keyz./usr/share/keyrings/ubuntu-archive-keyring.gpgz	--keyringÚverify)r!   r   )Ú
subprocessÚcallÚPIPE)r   rD   rE   ÚkeyringÚgpgÚrets         r   rL   z&DistUpgradeFetcherCore.gpgauthenticatel   sP   € ð
 ˆkˆáØFˆGà�˜WÐ%Ñ%ˆà�˜) TÐ*Ñ*ˆÜ�o‰o˜c¬*¯/©/Ô:ˆØ�a‰xˆr   c                 óª  — t         j                  j                  | j                  t         j                  j	                  | j
                  «      «      }t        t        d«      t         j                  j	                  |«      z  «       t         j                  j                  |«      sy	 t        j                  | j                  dz   t         j                  j	                  | j
                  «      z   d«      }|D ]  }|j                  |«       Œ |j                  «        y# t        j                  $ r"}t        j                  d|z  «       Y d }~yd }~ww xY w)Nzextracting '%s'FrC   Úrzfailed to open tarfile (%s)T)rH   rI   ÚjoinrG   rJ   r9   r5   r3   Ú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Ä0EÅEc                 ó   — | j                   ›d| j                  j                  ›�x| _        }t        j
                  j                  |«      s3| j                  t        d«      t        d«      dz   t        d«      z   «      S y)NrC   zCould 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)	rG   r   ÚnameÚscriptrH   rI   r[   r2   r3   )r   ri   s     r   ÚverifyDistUpraderz(DistUpgradeFetcherCore.verifyDistUprader�   sv   € ð
 +/¯+«+°t·}±}×7IÒ7IÐJÐJˆŒ�fÜ�w‰w�~‰~˜fÔ%Ø—:‘:œaÐ @ÓAÜÐ @ÓAÀEÑIÜð !Aó BñBóCð Cð r   c                 ó´  — | j                  d| j                  z  «       t        d¬«      }t        «       }|j                  D �]  }|j
                  s|j                  s|j                  dk(  sŒ,|j                  |v rŒ;|j                  j                  |«      r5|j                  | j                  k(  r| j                  |j                  v r|c S |j                  | j                  k(  sŒ¥d|j                  v sŒ´|j                  |t        |«      d z   }t        || j                   «      r|c S |j                  |j                  «       �Œ | j                  d«       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
        zmirror_from_sources_list: %sF)ÚwithMatcherÚdebr   Nzno mirror foundr(   )r$   r   r   ÚsetÚlistÚdisabledÚinvalidÚtyper9   r8   ÚdistÚDEFAULT_COMPONENTÚcompsÚlenr
   Úadd)r   r9   Ú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°·±Ô<Ø%Ò%Ø—‘˜Ÿ™–ð	 ð  	�‰Ð%Ô&Ør   c                 ó²  — |j                  | j                  «      r1| j                  d«       | j                  || j                  «      }|r|S t	        |«      }t        «       }|j                  |¬«      }	 t        || j                  «      st        d|z  «      ‚	 |S # t        $ r1}| j                  d|z  «       |j                  d¬«      }Y d}~|S d}~ww xY w)z†
        expand the uri so that it uses a mirror if the url starts
        with a well known string (like archive.ubuntu.com)
        ztrying to find suitable mirror)Úcountrymirrorzfailed to download %sz url '%s' could not be downloadedr(   N)	r8   ÚDEFAULT_MIRRORr$   r|   r   r   Úsafe_substituter
   Ú	Exception)r   r9   Únew_uriÚuri_templateÚmre   s         r   r,   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ÃCc                 ó
  — t        j                  d¬«      }|| _        t        j                  |«       t        j                  d|z  «       | j                  dkD  r@t        j                  j                  dd«       t        j                  j                  dd«       t        j                  | j                  «      }| j                  j                  �H| j                  | j                  j                  «      }t        j                   ||t#        d«      ¬	«      }| | j                  j$                  ��V| j                  | j                  j$                  «      | _        t        j                   || j&                  t#        d
«      ¬	«      }| |j)                  «       }||j*                  k7  rt        j,                  d|z  «       yt        j.                  j1                  | j                  j                  «      t        j.                  j1                  | j                  j$                  «      fD ]]  }t        j.                  j3                  |«      r#t        j.                  j5                  |«      dkD  rŒEt        j,                  d|z  «        y yy)z. download the tarball with the upgrade script zubuntu-release-upgrader-)Úprefixzusing tmpdir: '%s'r   zDebug::Acquire::httpÚ1zDebug::Acquire::ftpzUpgrade tool signature)ÚdescrzUpgrade toolzfetch result != continue (%s)Fzfile '%s' missingT)ÚtempfileÚmkdtemprG   rH   Úchdirra   Údebugr   Úapt_pkgÚconfigrn   ÚAcquirer   r   rF   r,   ÚAcquireFiler3   rK   r9   ÚrunÚRESULT_CONTINUEÚwarningrI   rJ   r[   Úgetsize)r   rG   Úfetcherr9   Úaf1Úaf2ÚresultrM   s           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¸!Ñ$;Ô<Ù ð	!ð
 Ør   c                 óÞ   — | j                   g| j                  z   }t        j                  «       dk7  rt        j                  dddg|z   «       y t        j                  | j                   |«       y )Nr   z/usr/bin/sudoÚsudoz-E)ri   r   rH   ÚgetuidÚexecv)r   Úargss     r   ÚrunDistUpgraderz&DistUpgradeFetcherCore.runDistUpgraderú   sO   € Ø—‘ˆ}˜t×/Ñ/Ñ/ˆÜ�9‰9‹;˜!ÒÜ�H‰H�_ v¨t n°tÑ&;Õ<ä�H‰H�T—[‘[ $Õ'r   c                 ól   — t        j                  d«       t        j                  | j                  «       y )Nz..)rH   r‹   ÚshutilÚrmtreerG   )r   s    r   ÚcleanupzDistUpgradeFetcherCore.cleanup  s   € ä
�‰�Œä�‰�d—k‘kÕ"r   c                 óÌ  — | j                  «       sy | j                  «       s%| j                  t        d«      t        d«      «       y | j	                  «       s5| j                  t        d«      t        d«      «       | j                  «        y | j                  «       s%| j                  t        d«      t        d«      «       y | j                  «       s5| j                  t        d«      t        d«      «       | j                  «        y 	 t        j                  | j                  t        j                  «      s!t        d	| j                  z  «      }d
|_        |‚| j                  «        y# t        $ rs}|j                  d
k(  r)| j                  t        d«      t        d«      «       Y d }~y| j                  t        d«      t        d«      |j                  z  «       Y d }~yd }~ww xY w)NzFailed to fetchz=Fetching the upgrade failed. There may be a network problem. zAuthentication failedz_Authenticating the upgrade failed. There may be a problem with the network or with the server. zFailed to extractz[Extracting the upgrade failed. There may be a problem with the network or with the server. zVerification failedz[Verifying the upgrade failed.  There may be a problem with the network or with the server. zCan not execute '%s'é   zCan not run the upgradezyThis usually is caused by a system where /tmp is mounted noexec. Please remount without noexec and run the upgrade again.FzThe error message is '%s'.T)r>   r™   r2   r3   rO   r£   rf   rj   rH   Úaccessri   ÚX_OKÚOSErrorÚerrnorŸ   Ústrerror)r   Úexre   s      r   r‘   zDistUpgradeFetcherCore.run  s»  € à×$Ñ$Ô&ØØ×%Ñ%Ô'Ø�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   ÄAE' Å'	G#Å03GÆ(1GÇG#r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   rt   rH   Úenvironr   r   r$   r>   r2   rO   rL   rf   rj   r|   r,   r™   rŸ   r£   r‘   © r   r   r   r   *   sj   „ Ù8à7€NØÐØ" b§j¡jÐ0€Eòò)ò
ò6ò
ð !%óò ò"òò<ò2%òN(ò#ó-r   r   Ú__main__zgot mirror: '%s'zghttp://archive.ubuntu.com/ubuntu/dists/intrepid-proposed/main/dist-upgrader-all/0.93.34/intrepid.tar.gzr   )Ústringr   rH   r�   ra   r\   r‰   r¡   r-   r    rR   r   r3   Úaptsources.sourceslistr   Úurllib.requestr   Úurllib.errorr   Úutilsr	   r
   r   ÚDistUpgradeViewTextr   Úobjectr   r¬   Údr5   r|   r±   r   r   ú<module>r»      sŠ   ðõ. Û 	Û Û Û Û Û Û Û 
Û Ý  Ý .Ý "Ý "ç =Ñ =Ý )ôJ˜Vô JðZ ˆzÒÙ˜t TÓ*€Aá	Ð
Ø
×
$Ñ
$ð:à0ó2ñ2õ 3ð r   