%\`@s~ddlmZmZddlZejddeddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZyFddlmZejdkrddlmZnddlmZWn(ek r)dd lmZmZYnXd d lmZmZmZmZmZmZmZmZdd l m!Z!ydd l"m#Z#Wn"ek rdd l$m#Z#YnXd dl%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+d dl,m-Z-d dl.m/Z/d dl0m0Z0d dl1m2Z2d dl3m4Z4m5Z5d dl6m7Z7d dl6m8Z8e7j9e8_9d dl8m:Z:m;Z;d dl<m=Z=m>Z>d dl?m@ZAd dl?mBZBddl@Z@d dl,mCZCmDZDmEZEd dlFmGZGdZHddZIGdd d eJZKGd!d"d"eLZMeNd#krzd d$lOmOZOe jPd%e jQeOZReMeRZSeSjTeSjUndS)&)absolute_importprint_functionNignorezapt API not stable yet) NoOptionErrorz3.2) ConfigParser)SafeConfigParser)rr)country_mirrorurl_downloadablecheck_and_fix_xbitget_archiptables_active inside_chroot)get_string_with_no_auth_from_source_entryis_child_of_process_name)Template)urlsplit) STEP_PREPARESTEP_MODIFY_SOURCES STEP_FETCH STEP_INSTALL STEP_CLEANUP STEP_REBOOT)MyCache)DistUpgradeConfig)DistUpgradeQuirks)AptCdrom) setupAufsaufsOptionsAndEnvironmentSetup)distinfo) sourceslist) SourcesList is_mirror) get_distroNoDistroTemplateException)gettext)ngettext)CacheExceptionDpkgInterruptedCacheExceptionLockingFailedNotEnoughFreeSpaceError) run_apportz/var/run/reboot-requiredc CsJddddg}y|j|SWn tk rEt|dSYnXdS)zB key() function for sorted to ensure "correct" component ordering main restrictedZuniverseZ multiverserN)index ValueErrorlen)aZorderingr1C/usr/lib/python3/dist-packages/DistUpgrade/DistUpgradeController.pycomponent_ordering_key\s  r3c@seZdZdS)NoBackportsFoundExceptionN)__name__ __module__ __qualname__r1r1r1r2r4gs r4c@seZdZdZddddZddddZd d Zd d Zd dZddZ ddZ ddZ ddZ dddZ ddZddZddZdddd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Zd=d>Z d?d@Z!dAdBZ"ddCdDZ#ddEdFZ$dGdHZ%dIdJZ&dKdLZ'dMdNZ(dOdPZ)dS)QDistUpgradeControllerz3 this is the controller that does most of the work NcCsd}|dks|dkrBtj}tjj|d}n||_||_tjd|tjdt j d|j j ||_ |j jtdd|_|j s|jjdkrd|_n|jj|_|r|j}nd}t|||_t||_d|jjdd |_|jjd |jjd d t|jt|j|j|jjd d |_|jjd d|_|jjd d|_ t!|_"dtj#krt j dt$jjddnd|_%t&||j|_'dtj#ds z2DistUpgradeController.__init__..iii)2osgetcwdpathjoindatadiroptionsr%bindtextdomain textdomainloggingdebug __class__r5_view updateStatus_cacher; useNetworkZ cdromPathraptcdromrconfiggetsources_backup_extZ add_sectionsetstrrfromDisttoDistoriginr archenvironapt_pkg_partialUpgraderquirksr getintgetlistforced_obsoletesZgetListFromFile valid_mirrorsvalid_3p_mirrors has_sectionitems_aptCronJobPerms)selfZdistUpgradeViewrMrLZ localedir cdrompath maxRetriesr1r1r2__init__nsh                zDistUpgradeController.__init__TFcCs-tjd|jdkr/|jjdn|jj|jjd}d}xy|j|SWqXtk r$}z|d7}|j j t j dtjd|||krtj d||j j td td |r|jqtjdnWYdd}~XqXXqXWdS) Nz openCache()Z PreCacheOpenrrg?z'failed to lock the cache, retrying (%i)zCache can not be locked (%s)zUnable to get exclusive lockzThis usually means that another package management application (like apt-get or aptitude) already running. Please close that application first.)rPrQrVrerun release_lockZunlock_lists_dir _openCacher(rS processEventstimesleeperrorrUabortsysexit)rnlockrestore_sources_list_on_failZMAX_LOCK_RETRIESZ lock_retryer1r1r2 openCaches.          zDistUpgradeController.openCachec Csy=t|j|j|j|jj||_|j|_Wntk rtj ddddg}t j j ddkr|j dn|jjj|t|j|j|j|jj|_YnX|j|j_tjdt|jdS) Nz-dpkg interrupted, calling dpkg --configure -az /usr/bin/dpkgz --configurez-aDEBIAN_FRONTENDnoninteractivez--force-confoldz/openCache(), new cache size %i)rrYrSregetOpCacheProgressrVZ apt_cacher'rPwarningrHrbrZappend getTerminalcallrdZpartialUpgraderQr/)rnr}cmdr1r1r2rus&      z DistUpgradeController._openCachecCs2|jjdd}|jjj|kr.dSdS)z Returns True if this view support upgrades over ssh. In theory all views should support it, but for savety we do only allow text ssh upgrades (see LP: #322482) ViewZ SupportSSHTF)rYrgrSrRr5)rnZ supportedr1r1r2_viewSupportsSSH sz&DistUpgradeController._viewSupportsSSHcCsjtjjd}tjj| rftjjdrftdrf|jstjd|j jt dt dt j ddSd }|j j t d t d |}|dkrt j dntjd d d|dt|g}|dkrft d}t d|}trMd|}|t d|7}n|j j||qfndS)z this will check for server mode and if we run over ssh. if this is the case, we will ask and spawn a additional daemon (to be sure we have a spare one around in case of trouble) z"/var/run/release-upgrader-sshd.pidz/procZsshdzupgrade over ssh not allowedz.Upgrading over remote connection not supportedzYou are running the upgrade over a remote ssh connection with a frontend that does not support this. Please try a text mode upgrade with 'do-release-upgrade'. The upgrade will abort now. Please try without ssh.rFizContinue running under SSH?aThis session appears to be running under ssh. It is not recommended to perform a upgrade over ssh currently because in case of failure it is harder to recover. If you continue, an additional ssh daemon will be started at port '%s'. Do you want to continue?z/usr/sbin/sshdz-oz PidFile=%sz-przStarting additional sshdzTo make recovery in case of failure easier, an additional sshd will be started on port '%s'. If anything goes wrong with the running ssh you can still connect to the additional one. z-iptables -I INPUT -p tcp --dport %s -j ACCEPTzIf you run a firewall, you may need to temporarily open this port. As this is potentially dangerous it's not done automatically. You can open the port with e.g.: '%s'T)rHrJrKexistsisdirrrrPryrSrUr{r|askYesNoQuestion subprocessrr]r information)rnZpidfileZportressummaryZdescrrr1r1r2 _sshMagics>                 zDistUpgradeController._sshMagicc Csddlm}ddlm}d}|jdksb|jdksb|jdksb|jdkrkd }n|d dd |}|jjx#|jjd s|jjqW|jd krt j ddS|jj }|d|jd|d|j d|j}|j d S)z this is a helper that is run if we are started from a CD and we have network - we will then try to fetch a update of ourself r)MetaReleaseCore)DistUpgradeFetcherSelfFZdapperZhardyZlucidZpreciseTZuseDevelopmentReleaseforceLTSg?NzNo new dist foundnew_distprogressrMZview)Z MetaReleaserrreleaserSrvZ downloadedwaitrrPrygetAcquireProgressrMrs)rnrrrmrfetcherr1r1r2_tryUpdateSelfOs,       z$DistUpgradeController._tryUpdateSelfcCs tjdtjjdrt}|jtdy|jdd}Wn't k rztjd|dSYnXytj d}Wn:t k r}ztj d|dSWYd d }~XnX||tjj d |fkrtjd ||tjj d |fdSnd S) z sanity check that /usr/bin/python points to the default python version. Users tend to modify this symlink, which breaks stuff in obscure ways (Ubuntu #75557). z_pythonSymlinkCheck runz!/usr/share/python/debian_defaultsZDEFAULTzdefault-versionz+no default version for python found in '%s'Fz/usr/bin/pythonzos.readlink failed (%s)Nz/usr/binzd}| jsf| j3d6ksfd7| jksfdj| jksfd8j| jksfd9| jksfd:| jkrod}n| j|krtjd;t0| | |O} n| j|kr| |O} ||j4| j| _tjd<t0| nG| j3d6krqn2|r5d| _d_tjd=t0| n| j3d>krd?| jkrj5d@ksqj5dAkrtjdBj5dC| _nxGdDjdjdjgD]}jj6|t7| j r| j|kr| j3d>krx:| j(D],}||krqnj|j8|qWqqWq| jjkr_j| _ndEt,dFj}t9| j+t:r| j+|j;dG7_+n| j+|7_+d| _d_tjdHt0| qWxjjddD]} | j!s| js| j3d6ks| jj"d s| jjkrG qn| jjkrjjj| j}|r tj/dIt0| | j(j<t=|dJt>tj/dKt0| j| j=q qqW| S)LNzrewriteSourcesList()r<Z ComponentsZAllowThirdPartyFZ!RELEASE_UPRADER_ALLOW_THIRD_PARTYz,mirror check skipped, *overriden* via configTrD BaseMetaPkgsrrZnowz)BaseMetaPkg '%s' has no candidate.originsr+z]get_distro().enable_component("main") failed, overwriting sources.list instead as last resortz+# auto generated by ubuntu-release-upgraderz7deb http://archive.ubuntu.com/ubuntu %s main restrictedz?deb http://archive.ubuntu.com/ubuntu %s-updates main restrictedzAdeb http://security.ubuntu.com/ubuntu %s-security main restrictedz/etc/apt/sources.listwZPocketscs#g|]}dj|fqS)z%s-%s)r^)rFx)rnr1r2rGDs z.cs#g|]}dj|fqS)z%s-%s)r_)rFr)rnr1r2rGFs zesm.ubuntu.com/ubuntuz %s-updatesz %s-securityzubuntu-esm-v2-keyring.gpgz/etc/apt/trusted.gpg.d/zcdrom:z,disabled '%s' cdrom entry (dist == fromDist)zDir::State::listsz %s/%s%s_%s_%sZdistsZReleasez;disabling cdrom source '%s' because it has no Release filez %s-commercialzhttp://archive.canonical.comZpartnerz transitioned commercial to '%s' z*http://landscape.canonical.com/packages/%sz&commenting landscape.canonical.com outz %s-proposedz2upgrade to development release, disabling proposedz5Not for humans during development stage of release %szold-releases.ubuntu.com/z-upgrade from old-releases.ubuntu.com detectedz"http://%sarchive.ubuntu.com/ubuntuz http://archive.ubuntu.com/ubuntuz%transition from old-release.u.c to %szexamining: '%s'zdeb-srcz/security.ubuntu.comz %s-backportsz/archive.canonical.comz/extras.ubuntu.comz%entry '%s' is already set to new distzentry '%s' updated to new distz&entry '%s' was disabled (unknown dist)debzports.ubuntu.comZpowerpcZsparcz-moving %s source entry to 'ports.ubuntu.com' z%http://ports.ubuntu.com/ubuntu-ports/z%s zdisabled on upgrade to %szUTF-8z(entry '%s' was disabled (unknown mirror)z)fixing components inconsistency from '%s'keyzto new entry '%s')?rPrQrYrgrrHrbrrWrV candidater/originsarchiver#Z get_sourcessourcesZenable_componentr$r_rwriter^sources_disabledfound_componentslistdisabledrendswithrcopyrshutilinvalid startswithrcfind_dirrJrZuri_to_filenamecompsrMZ devel_releaseZcommentrUr rrrisMirrorisThirdPartyMirrortyper-ra setdefaultr\add isinstancebytesencodeextendsortedr3)rn mirror_checkZsync_componentspkgnamedistrosZpocketsZ fromDistsZtoDistsZ foundToDistrZ sec_entrylistdirZcdistrZ test_entryZ validMirrorZthirdPartyMirrorZvalidTodcompZdisable_commentZcomponent_diffr1)rnr2rewriteSourcesLists>              $                                "  !$ z(DistUpgradeController.rewriteSourcesListc Cs}tjdtdd|_|jj|j|jddstjd|jj t dt d|j |j f}|rtdd|_|jdd r|j rt d }t d |j |j f}|jj ||s|jntjd d }d dg}|jjd||j ||jjd||j d||jjdd|j d|qq|jn|jjytj}|jWntk rMtjdtjjdr|jjt dt dtjddgn,|jjt dt dtjddSYnX|jry|jjt dt dndS)NzupdateSourcesList() matcherPathr9rTzNo valid mirror foundaWWhile scanning your repository information no mirror entry for the upgrade was found. This can happen if you run an internal mirror or if the mirror information is out of date. Do you want to rewrite your 'sources.list' file anyway? If you choose 'Yes' here it will update all '%s' to '%s' entries. If you select 'No' the upgrade will cancel.FzGenerate default sources?zAfter scanning your 'sources.list' no valid entry for '%s' was found. Should default entries for '%s' be added? If you select 'No', the upgrade will cancel.z!generate new default sources.listz http://archive.ubuntu.com/ubuntur+r,rz-updatesz"http://security.ubuntu.com/ubuntu/z -securityz.zfound components: %sz!Do you want to start the upgrade?)rSrTrUrVZ distUpgraderrdZ installTasksr get_changesrvrrZget_installed_demoted_packagesinstalled_demotionsr/sortrPrQrKrconfirmChangesZrequired_download)rnchangesrr1r1r2askDistUpgrades0!       * z$DistUpgradeController.askDistUpgradecCsCtjjdr?tjdt|jtjddndS)Nz/etc/cron.daily/aptzdisabling apt cron job (%s)i)rHrJrrPrQoctrmchmod)rnr1r1r2_disableAptCronJobsz(DistUpgradeController._disableAptCronJobcCs9tjjdr5tjdtjd|jndS)Nz/etc/cron.daily/aptzenabling apt cron job)rHrJrrPrQrrm)rnr1r1r2_enableAptCronJobs z'DistUpgradeController._enableAptCronJobc Cs|jd}|jj}|jjddd}|ry!tjdjdd}Wntj dd}YnX|jj j d||fn|jj dd }d }d}x||kry;t j|jj}t j|} |jj| |Wntjjk rQ} ztjd d }| }PWYdd} ~ XnOtk r} z/tjd | |f|d7}| }wWYdd} ~ XnXd SW|r|jjtdtdn3tjd|jjtdtdd||j|jdS)NrrDZ SlideshowUrlrUgetdefaultlocaleZenz %s#locale=%sr?r@Fz user canceledTz:IOError in cache.commit(): '%s'. Retrying (currentTry: %s)rzUpgrade canceledzwThe upgrade will cancel now and the original system state will be restored. You can resume the upgrade at a later time.z+giving up on fetching after maximum retrieszCould not download the upgradeszThe upgrade has aborted. Please check your Internet connection or installation media and try again. All files downloaded so far have been kept.z%s)rrSrrYrlocalersplitrP exceptionZ getHtmlViewrrfrcZPackageManagerrV _depcacheZAcquireZ_fetch_archivesaptZFetchCancelledExceptionrrryrrUrrz) rnr fprogressZurlZlangrpZ user_canceledrZpmrrr1r1r2doDistUpgradeFetchingsN !  #      z+DistUpgradeController.doDistUpgradeFetchingcCsvyddl}Wntk r(dSYnXy|j}|j}WntjddSYnXtjd||S)z' check if apt-btrfs-snapshot is usable rNzfailed to check btrfs supportFz!apt btrfs snapshots supported: %s)apt_btrfs_snapshot ImportErrorAptBtrfsSnapshotZsnapshots_supportedrPrrQ)rnr  apt_btrfsrr1r1r2rQs     z6DistUpgradeController._is_apt_btrfs_snapshot_supportedcCs_|jsdSddl}|j}d|j}|j|}tjd||fdS)z2 create btrfs snapshot (if btrfs layout is there) Nrzrelease-upgrade-%s-z#creating snapshot '%s' (success=%s))rr rr_Zcreate_btrfs_root_snapshotrPr)rnr rprefixrr1r1r2 _maybe_create_apt_btrfs_snapshot`s    z6DistUpgradeController._maybe_create_apt_btrfs_snapshotc Csd}|jj}|jj|j}|jjdd}|jse|jjd|j nd}x||krVy*|jj ||}t j d|Wnt k r_}zt jd|tjjdrtdj}t jd |d d g}x|D]}t|j|rt j d |jtd } | dt|7} | td7} |jjtd| |jqqWntd} |jsts| td|7} qn|jjtd| dddg} tjjddkr)| jdn|jjj| |jdSWYdd}~Xntk r}z)t jd||f|d7}wnWYdd}~Xnt k rG}zt j!d|j"dkr5|jtd } | dt|7} | td7} |jjtd| |jnWYdd}~XnX|jdSWt jd|jjtdtd d!||jdS)"Nrr?r@Z StartUpgradeFzcache.commit() returned %sz#SystemError from cache.commit(): %sz./var/run/ubuntu-release-upgrader-apt-exceptionzfound exception: '%s'z;E:Internal Error, Could not perform immediate configurationz E:Couldn't configure pre-depend z-detected preconfigure error, restorting statezError during commitz '%s' zRestoring original system statezCould not install the upgradeszrThe upgrade has aborted. Your system could be in an unusable state. A recovery will run now (dpkg --configure -a).z Please report this bug in a browser at http://bugs.launchpad.net/ubuntu/+source/ubuntu-release-upgrader/+filebug and attach the files in /var/log/dist-upgrade/ to the bug report. %sz /usr/bin/dpkgz --configurez-arrz--force-confoldz:IOError in cache.commit(): '%s'. Retrying (currentTry: %s)rzcache.commit() Tz+giving up on fetching after maximum retrieszCould not download the upgradeszdThe upgrade has aborted. Please check your Internet connection or installation media and try again. z%s)#rSrgetInstallProgressrVrYrfrdrersrcommitrPrQrryrHrJrrreadr]rrrUrzr*rbrZrrrrrrerrno) rnrr  iprogressrprrZpre_configure_errorsZ preconf_errormsgrr1r1r2 doDistUpgradejsx                     z#DistUpgradeController.doDistUpgradecCsY|j|jjd|jj}|jj|j|j|j}t j ddj |t j ddj |xG|j j ddD]0}||krt jd|t}PqqW|j jddd st j d d Sx^|j j dd D]G}||jkr|j|jr|jj|j j |d qqW|jj|jjt j d |j|jr||j}ntdd|jD}|t|jO}|jj}t j ddj ||t|O}|j jddd s0t j dt}nt j d|t j d|jj}xt|D]z\}}|j|tt|d||jkrj|jj |jj!|||jst j d|qqjqjWt j d|j"|jj#} t j ddj dd| Dt$d} t$dt$dg} t| dkr/|jj%| | gd| dr/|jj&} |jj'|j} y|jj(| | Wq/t)t*fk r+}z<t jd||jjt$dt$d d!|WYdd}~Xq/Xn|jjd"|j+sU|j,nd S)#NZ PostUpgradez Obsolete: %srz Foreign: %srDrzXthe BaseMetaPkg '%s' is in the obsolete list, something is wrong, ignoring the obsoletesZRemoveObsoletesTzSkipping obsolete RemovalZMetaPkgsrEzforced_obsoletes: %scSsg|]}|jqSr1)r)rFpr1r1r2rGs z7DistUpgradeController.doPostUpgrade..zUnused dependencies: %sz0Skipping RemoveObsoletes as stated in the configzremove_candidates: '%s'z Start checking for obsolete pkgsgY@z:'%s' scheduled for remove but not safe to remove, skippingz!Finish checking for obsolete pkgsz1The following packages are marked for removal: %scSsg|]}|jqSr1)r)rFrr1r1r2rGs zRemove obsolete packages?Z_KeepZ_RemoverFz,cache.commit() in doPostUpgrade() failed: %szError during commitz[A problem occurred during the clean-up. Please see the below message for more information. z%sZ PostCleanup)-rrersrVrrr`r^r_rPrQrKrYrgryr\rrrhrZidentifyObsoleteKernelsrWrrZ_getUnusedDependenciesrSr enumeraterfloatr/rrvZtryMarkObsoleteForRemovaldonerrUrrrrrrrdrunPostInstallScripts)rnZ now_obsoleteZ now_foreignrZremove_candidatesZunused_dependenciesrirrrZactionsr rrr1r1r2 doPostUpgradesv !   &    !   ' ! !  z#DistUpgradeController.doPostUpgradecCsx|jjddD]}tjj|sEtjd|qntjd|y-t||j j j |gddWqt k r}ztj d||fWYdd}~XqXqWdS) z| scripts that are run in any case after the distupgrade finished whether or not it was successful rDZPostInstallScriptsz!PostInstallScript: '%s' not foundzRunning PostInstallScript: '%s'ZhiddenTz(got error from PostInstallScript %s (%s)N)rYrgrHrJrrPrrQr rSrr Exceptionry)rnZscriptrr1r1r2r-s #z+DistUpgradeController.runPostInstallScriptscCstjdt|dr2|jj|jnt|drW|jj|jn|jjt d|jj |j t j ddS)z2 abort the upgrade, cleanup (as much as possible) z abort calledrrXzRestoring original system staterN)rPrQhasattrrZrestore_backupr[rXrSrTrUrzrr{r|)rnr1r1r2rz?s   zDistUpgradeController.abortc Csxtj|D]}tjd|x|D]}|d}|d}|d}||jkrvtjd|dS|j|}t|jdd}|dkr.tj|||d kr.d Sq.WqWtjd |dS) z+ check if a given depends can be satisfied zchecking: '%s' rrz_checkDep: '%s' not in cacheFversionNTzdepends '%s' is not satisfied) rcZ parse_dependsrPrQrVrygetattrZ installedZ check_dep) rnZdepstrZor_groupdepZdepnameverZoperrZinstverr1r1r2 _checkDepLs        zDistUpgradeController._checkDepcCstjdd}|jjdd}|j|jj|jjjdxj|D]b}tjd|||j|M}|sT|jj t dt d|t j dqTqTW|S) z check if depends are satisfied zcheckViewDepends()TrZDependsz depends: '%s'z!Required depends is not installedz/The required dependency '%s' is not installed. r) rPrQrYrgrrSrRr5r(ryrUr{r|)rnrZdependsr&r1r1r2r_s    z&DistUpgradeController.checkViewDependscCs#|jjdd}d}tjjdd}|jjdd}x||kr|jdd |jx=|D]5}||jkrutj d |t |ququW|j |rPntj d tjj dd |d 7}qHW||kr tj dd Stjj d|dS)N PreRequistsPackagesrzAcquire::http::No-CacherCr?r@rFzCan not find backport '%s'z>setting a cache control header to turn off caching temporarilytruerz+pre-requists item is NOT trusted, giving upT)rYrgrcfindrfrrrVrPryr4_allBackportsAuthenticatedrQr\)rn backportslistrZnoCacherprr1r1r2_verifyBackportsss*     z&DistUpgradeController._verifyBackportsc Cstjjdddkr,tjddSy#|jjdd}|rNdSWntk rcYnXxP|D]H}|j|}|jsdSx%|jj D]}|j rPqqWdSqkWdS)NzAPT::Get::AllowUnauthenticatedFTzIskip authentication check because of APT::Get::AllowUnauthenticated==truerDZAllowUnauthenticated) rcrYZfind_brPrZ getbooleanrrVrrZtrusted)rnr.brrZcandr1r1r2r-s$      z0DistUpgradeController._allBackportsAuthenticatedc Cs|jd}t|\}}}}}d|krL|jdd}nd|||f}xj|jD]_}|jd}t||rdS|jdd} |j| ritjd|dSqiWdS) z check if uri is a known mirror /@rz %s://%s%sTz//z)found apt-cacher/apt-torrent style uri %sF)rstriprrrir"rrPrQ) rnrZraw_urischemeZnetlocrJZqueryZfragmentmirrorZmirror_host_partr1r1r2rs zDistUpgradeController.isMirrorcCsI|jd}x3|jD](}|jd}t||rdSqWdS)z2 check if uri is a whitelisted third-party mirror r1TF)r3rjr")rnrr5r1r1r2rs z(DistUpgradeController.isThirdPartyMirrorcCsd}tdd}x|jD]}|js|jr=qn|jdkr|jdkr|j|jrd|jkrd|j|j kr|jj d r|jj d  rd |j|jf}||kr||7}qqqW|S) z7 get sources.list snippet lines for the current mirror rr9rFr+z %s-updateszhttp://security.ubuntu.comzhttp://archive.ubuntu.comzdeb %s %s-updates main ) r!rrrrrrrr^rr)rndumblinesrrZnew_liner1r1r2_getPreReqMirrorLiness  z+DistUpgradeController._getPreReqMirrorLinescCstjd|t|d}|j|}xPt|D]B}t|}|jd|}|j|tjd|q<W|jdS)z9 add prerequists based on template into the path outfile z*writing prerequists sources.list at: '%s' rr5zadding '%s' prerequistsT)rPrQrr9rZsafe_substituterclose)rntemplateoutr7outfileZ mirrorlineslineZoutliner1r1r2_addPreRequistsSourcesLists   z0DistUpgradeController._addPreRequistsSourcesListc8Csptjdd}tjjtjd}tjj|sPtj|n|jj dd}|j r:|j r:tjdtjj|j j dt jjd}t}xXtj|d D]C}tjd ||f|jtjj|jd d qWt|j|sJtjd t||fdS|jjtjddgtj|d dtjdtjdd}d}x6|dkr|j}|jjtj dqW|jjdd|jj!tj"d|tjd|j#d |d kr0dS|j$Sd}|jj%d|d|j&rt|d|j&}n|jj'd|}tjj|stjd|dStjjt jj(d|} tjjt jj(d|} |j)|| y|j*Wnt+k r} zf|j)|| ddy|j*Wn6t+k r} ztj,d| WYdd} ~ XnXdSWYdd} ~ XnXx|D]} |j| } |jj-j.| j/}|stjd| tj0| dS|j1dkr$tjd | tj0| dStjd!| | j2d"dd#dqWd}y1|jj3|jj4|jj5|j}Wnwt6k r} ztjd$| d}WYdd} ~ Xn<t7k r} ztjd%| d}WYdd} ~ XnX|dkrtj,d&nytj0| Wn6t8k re} ztjd'| WYdd} ~ XnX|j$S)(z5 download the backports specified in DistUpgrade.cfg zgetRequiredBackports()TZ backportsr)r*z#Searching for pre-requists on CDROMz*dists/stable/main/dist-upgrader/binary-%s/zAPT::Architecturez*_*.debzfound pre-req '%s' to '%s'rUrz%Expected backports: '%s' but got '%s'Fz /usr/bin/dpkgz-irstderrrNg{Gz?Zfinishedz'installing backport debs exit code '%s'zdpkg output: %sr!z-%szsourceslist not found '%s'zDir::Etc::sourcepartsr7zno backport for '%s' foundzNo candidate for '%s'zNo ver.file_list for '%s'zmarking '%s' for installZ auto_instZauto_fixzfetch_archives returned '%s'zinstall_archives returned '%s'z,_fetch_archives for backports returned Falsez(failed to unlink pre-requists file: '%s')9rPrQrHrJrKrIrmkdirrYrgrXrWrorcr,r\rrbasenamerissubsetryrVrtrrrZSTDOUTZpollrSZ pulseProgressrwrxZget_lockrrsetupRequiredBackportsZ has_optionrarZrr?r/r4rrZget_candidate_verZ_pkgunlinkZ file_listZ mark_installrrrrrr!)rnrrr.rZ found_pkgsrZ conf_optionZprereq_templateZoutpathr=rrrr'r1r1r2getRequiredBackportss   *        !!$     $z*DistUpgradeController.getRequiredBackportscCsdtjdsv             : .