+eT& @s}ddlmZmZddlZejddeddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZyddlZWnek rddlZYnXddlmZmZddlmZddlmZdd lmZmZGd d d eZGd d d eZGdddeZddZ e Z!Gddde"Z#GdddeZ$Gdddej%Z&e'dkryddl(Z(ddl)m*Z*ddl+m+Z+e,de&e*de+dZ-e,e-j.e(j/e-j0e-j1e-j2e-j3dge,e-j4e-j5ndS))absolute_importprint_functionNignorezapt API not stable yet)PopenPIPE)gettext)ngettext) inside_chrootestimate_kernel_size_in_bootc@seZdZdS)CacheExceptionN)__name__ __module__ __qualname__rr>/usr/lib/python3/dist-packages/DistUpgrade/DistUpgradeCache.pyr .s r c@seZdZdS)CacheExceptionLockingFailedN)r rrrrrrr0s rc@seZdZdS)CacheExceptionDpkgInterruptedN)r rrrrrrr2s rcCs9t}|dkr+tjdd}n|d 7}|S) Nrz,estimate_kernel_size_in_boot() returned '0'?iripiii)r loggingwarn)sizerrr_set_kernel_initrd_size7s      rc@s.eZdZdZddZddZdS)FreeSpaceRequiredz FreeSpaceRequired object: This exposes: - the total size required (size_total) - the dir that requires the space (dir) - the additional space that is needed (size_needed) cCs||_||_||_dS)N) size_totaldir size_needed)selfrrrrrr__init__Is  zFreeSpaceRequired.__init__cCsd|j|j|jfS)Nz@FreeSpaceRequired Object: Dir: %s size_total: %s size_needed: %s)rrr)rrrr__str__MszFreeSpaceRequired.__str__N)r rr__doc__rrrrrrrAs  rc@s"eZdZdZddZdS)NotEnoughFreeSpaceErrorzI Exception if there is not enough free space for this operation cCs ||_dS)N)free_space_required_list)rr"rrrrVsz NotEnoughFreeSpaceError.__init__N)r rrr rrrrrr!Qs r!c@seZdZdZdZddddZddZed d Zd d Z d dZ ddZ ddZ ddZ eddZeddZeddZddZddZddd Zd!d"Zdd#d$Zdd%d&Zdd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8d9Zd7d:d;Z d7d<d=Z!d7d>d?Z"d@dAZ#dBdCZ$dDdEZ%dFdGZ&dHdIZ'dJdKZ(dLdMZ)dNdOZ*dPdQZ+e dRdSZ,dTdUZ-dVdWZ.edXdYZ/dZd[Z0d\d]Z1d^d_Z2d`daZ3e dbdcZ4dddeZ5dfdgZ6dhdiZ7djdkZ8dldmZ9dndodpZ:dS)qMyCacherNTcCsg|_g|_||_||_d|_d|_||_|jjdd|_d|_ |ry!t j |j d|_Wqt k r}z2dt|krt|nt|WYdd}~XqXntjj|||jdd|_tdd gd td djd j|_|j|jd ddkrdtjkrt jjddndS)NFDistroMetaPkgsrTzdpkg --configure -aZRemovalBlacklistFileunamez-rstdoutZuniversal_newlinesrZSourcesZFromZhardyZRELEASE_UPGRADE_NO_RECOMMENDSzAPT::Install-Recommendstrue) to_install to_removeviewquirkslockpartialUpgradeconfiggetlistmetapkgs _listsLockapt_pkgpkgsystem_locklock_lists_dir SystemErrorstrrraptCacherZgetListFromFileremoval_blacklistrr communicatestripr' _initAptLoggetosenvironset)rr1r-r.Zprogressr/errrr^s4           " zMyCache.__init__cCsRxK|D]C}|jrqn|jjtjkr|jddddqqWdS)z! honor the dselect install state auto_instFauto_fixN) is_installed_pkgZselected_stater5ZSELSTATE_INSTALL mark_install)rpkgrrr_apply_dselect_upgrades   zMyCache._apply_dselect_upgradecCsrt}xb|D]Z}|j s-|jj r|jj|jksW|jj|jkr|j|jqqW|S)zB return the packages not downloadable packages in reqreinst state ) rC candidate downloadablerHZ inst_state ReInstReq HoldReInstReqaddname)r reqreinstrJrrrreq_reinstall_pkgss  zMyCache.req_reinstall_pkgscCs|j}t|dkrtddt|}tddt|dj|}|j||r|jddd gt|}|jj||j d Snd S) z/ check for reqreinst state and offer to fix it rzRemove package in bad statezRemove packages in bad statezThe package '%s' is in an inconsistent state and needs to be reinstalled, but no archive can be found for it. Do you want to remove this package now to continue?zThe packages '%s' are in an inconsistent state and need to be reinstalled, but no archives can be found for them. Do you want to remove these packages now to continue?z, z /usr/bin/dpkgz--removez--force-remove-reinstreqTF) rSlenr joinZaskYesNoQuestion release_locklistZ getTerminalcallget_lock)rr-rRheaderZsummarycmdrrrfix_req_reinsts   zMyCache.fix_req_reinstcCs |jjddd}tjj|s:tj|ntjjd|tjjddtjtjj |dtj tj Btj Bd|_ tjj}d |}tj|j |jd tjjd d tjjd d tjjdd dS)z init logging, create log fileZFilesZLogDirz/var/log/dist-upgradezDir::LogzDir::Log::Terminalz apt-term.logzapt.logiz Log time: %s zutf-8zDebug::pkgProblemResolverr)zDebug::pkgDepCache::MarkerzDebug::pkgDepCache::AutoInstallN)r1getWithDefaultrApathexistsmakedirsr5rCopenrUO_RDWRO_CREATO_APPENDlogfddatetimenowwriteencode)rZlogdirrgrZrrrr?s   zMyCache._initAptLogcCst|dr2tj|jtj|jntjd|_tjd|_tj|jdtj|jddS)N old_stdoutr)hasattrrAcloserj old_stderrdupdup2re)rrrr_startAptResolverLogszMyCache._startAptResolverLogcCsDtjdtjdtj|jdtj|jddS)Nrrk)rAfsyncrprjrn)rrrr_stopAptResolverLogs  zMyCache._stopAptResolverLogcsfdd}|S)z3 decorator to ensure that the apt output is logged cs/|dj||}|dj|S)Nr)rqrs)argskwargsres)frrwrappersz(MyCache.withResolverLog..wrapperr)rwrxr)rwrwithResolverLogszMyCache.withResolverLogcCs>tj|j}tj}|j||j|j|jS)z< get the size of the packages that are required to download )r5ZPackageManager _depcacheZAcquireZ get_archives_list_recordsZ fetch_needed)rZpmZfetcherrrrrequired_downloads zMyCache.required_downloadcCs |jjS)z9 get the size of the additional required space on the fs )rzZusr_size)rrrradditional_required_spacesz!MyCache.additional_required_spacecCs|jjdkS)z is the cache broken r)rzZ broken_count)rrrr is_brokenszMyCache.is_brokencCsTtjjdd}tj||_|jdkrPd|}t|ndS)NzDir::State::Listsr/rzCan not lock '%s' )r5r1find_dirrYr4r)rrQrDrrrr7s  zMyCache.lock_lists_dircCs/|jdkr+tj|jd|_ndS)Nrrr*)r4rArm)rrrrunlock_lists_dirszMyCache.unlock_lists_dircCsl|jtjj||}|j|rM|jrMttdn|dkrhtdndS)zf our own update implementation is required because we keep the lists dir lock zThe server may be overloadedFzAapt.cache.update() returned False, but did not raise exception?!?N)rr:r;updater7Zrelease_file_download_errorIOError_)r fprogressrvrrrrs   zMyCache.updatecCs=tjd|jr#|jntjj|||dS)Nzcache.commit())rinfor/rVr:r;commit)rrZ iprogressrrrrs   zMyCache.commitcCs`|jr\ytjd|_Wq\tk rX}ztjd|WYdd}~Xq\XndS)NFzfailed to SystemUnLock() (%s) )r/r5Zpkgsystem_unlockr8rdebug)r pkgSystemOnlyrDrrrrV s    zMyCache.release_lockcCs`|js\ytjd|_Wq\tk rX}ztjd|WYdd}~Xq\XndS)NTzfailed to SystemLock() (%s) )r/r5r6r8rr)rrrDrrrrYs    zMyCache.get_lockcCs[|r|jj|j}n |jj}|dkrTtjd|j|fdS|jS)z* check if the given pkg can be downloaded Nz1no version information for '%s' (useCandidate=%s)F)rzget_candidate_verrHZ current_verrwarningrQrM)rrJZ useCandidateverrrrrMs  zMyCache.downloadablecCs|jo|jj|jS)z$ check if the pkg is auto-removable )rGrz is_garbagerH)rrJrrrpkg_auto_removable's zMyCache.pkg_auto_removablecCs |jjS)z^ try to fix broken dependencies on the system, may throw SystemError when it can't)rz fix_broken)rrrrr,szMyCache.fix_brokencCstg|_g|_x[|jD]M}|js7|jrM|jj|jn|jr|jj|jqqWdS)z* create a snapshot of the current changes N)r+r, get_changesmarked_installmarked_upgradeappendrQ marked_delete)rrJrrrcreate_snapshot1s   zMyCache.create_snapshotcCs|jjdS)N)rzZinit)rrrrclear;sz MyCache.clearcCstj|j}||jx%|jD]}||}|jq*Wx1|jD]&}||}|jddddqRWdS)z restore a snapshot rFFrEN)r5 ActionGrouprzrr, mark_deleter+rI)r actiongrouprQrJrrrrestore_snapshot>s   zMyCache.restore_snapshotcCs|jjdd}x|D]}||krP||jrPtjd|dSd}x:|jj|dD]#}|||ko||jM}qlW|rtjd|dSqWtjddS) ac This checks if we run on a desktop or a server install. A server install has more freedoms, for a desktop install we force a desktop meta package to be install on the upgrade. We look for a installed desktop meta pkg and for key dependencies, if none of those are installed we assume server mode r%r&z@need_server_mode(): run in 'desktop' mode, (because of pkg '%s')FTKeyDependencieszIneed_server_mode(): run in 'desktop' mode, (because of key deps for '%s')z[need_server_mode(): can not find a desktop meta package or key deps, running in server mode)r1r2rGrr)rr3key deps_foundrJrrrneed_server_modeLs  ! zMyCache.need_server_modec Cs`|jr\ytjd|jWq\tk rX|jtdtddSYq\XndS)zY check if the cache is ok and if the required metapkgs are installed z$Have broken pkgs, trying to fix themzBroken packageszYour system contains broken packages that couldn't be fixed with this software. Please fix them first using synaptic or apt-get before proceeding.FT)rrrrr8errorr)rr-rrr sanity_checkjs     zMyCache.sanity_checkcCsgtjd||f||krc||j||jpH||jsctjd|dSndS)NzInstalling '%s' (%s)z Installing/upgrading '%s' failedFT)rrrIrrr)rrJreasonrrrrI|s zMyCache.mark_installcCsgtjd||f||krc||jrc||j||jsctjd|dSndS)NzUpgrading '%s' (%s)zUpgrading '%s' failedFT)rrrG mark_upgraderr)rrJrrrrrs zMyCache.mark_upgradecCs8tjd||f||kr4||jndS)NzRemoving '%s' (%s))rrr)rrJrrrr mark_removes zMyCache.mark_removecCsDtjd||f||kr@|jj||jdndS)NzPurging '%s' (%s)T)rrrzrrH)rrJrrrr mark_purges zMyCache.mark_purgecCs=||kr9||jr9||jr9|j||ndS)N)rGrrI)rpkgnamerrrr_keep_installeds   zMyCache._keep_installedcCsx-|jjddD]}|j|dqWxn|jD]c}||kr:||jsf||jr:x4|jj|dD]}|j|d|q|Wq:q:W|jjdddkrtjdxu|jjdd D]^}xU|D]M}|j r|j j r|j r|j |kr|j|j d |qqWqWx|jD]}||krK||jsw||jrKx~|jj|d D]d}x[|D]S}|j r|j j r|j r|j |kr|j|j d ||fqqWqWqKqKWnd S) z[ run after the dist-upgrade to ensure that certain packages are kept installed r%ZKeepInstalledPkgszDistro KeepInstalledPkgs rulez%s KeepInstalledPkgs ruleZOptionsZ withNetworkTruez"Running KeepInstalledSection rulesKeepInstalledSectionz$Distro KeepInstalledSection rule: %sz %s KeepInstalledSection rule: %sN)r1r2rr3rGrr@rrrLrMrsectionrQ)rrrrrJrrrkeep_installed_rules.   "   zMyCache.keep_installed_rulecCsxd|jfd|jfd|jfd|jfgD]\}}x2|jjdd|D]}||d|q]Wxu|jD]j}||kr||js||jrx;|jj|d|D]}||d||fqWqqWq7W|j s|j j d nd S) z- run after the upgrade was done in the cache ZInstallZUpgradeZRemoveZPurger%z PostUpgrade%szDistro PostUpgrade%s rulez%s PostUpgrade%s ruleZPostDistUpgradeCacheN) rIrrrr1r2r3rGrr0r.Zrun)rZruleactionrJrrrrpost_upgrade_rules     & zMyCache.post_upgrade_rulec Cs7tjdt}|jjdd}|jjdd}|jjdd}x|D]}x|D]}d||f}x|D]}|jj|r|jj|r|j r|jd||j fkrtjd|jqntjd |j|j |jqqWqiWq\Wtjd ||S) NzidentifyObsoleteKernels()Z KernelRemovalZVersionZ BaseNamesZTypesz%s-%s-z%s-%szskipping running kernel %szremoving obsolete kernel '%s'z"identifyObsoleteKernels found '%s') rrrCr1r@r2rQ startswithendswithrGr'rP) rZobsolete_kernelsversionZ basenamestypesrJbasebasenametyperrridentifyObsoleteKernelss&      zMyCache.identifyObsoleteKernelscCstjdyddlm}Wn@ttfk rc}ztjd|dSWYdd}~XnXy|dd}xO|jD]3}||kr||jr|j |d PqqWtj d dS|j }tjd |||krtj d |dS||j p||jsC||jtj d |dSWn6tk r|}ztjd|WYdd}~XnXdS)zR this checks for nvidia hardware and checks what driver is needed znvidiaUpdate()r)NvidiaDetectionz%NvidiaDetector can not be imported %sFNZobsoletez./ubuntu-drivers-obsolete.pkgszold nvidia driverz1no old nvidia driver installed, installing no newznv.selectDriver() returned '%s'z no '%s' foundz,installing %s as suggested by NvidiaDetectorTz$NvidiaDetection returned a error: %s)rrZNvidiaDetector.nvidiadetectorr ImportError SyntaxErrorrZ oldPackagesrGrrZ selectDriverrrrrI Exception)rrrDZnvZ oldDriverZdriverrrrcheckForNvidias4    $zMyCache.checkForNvidiacCs4x-|D]%}|jjdr|jrdSqWdS)Nzlinux-headers-TF)rQrrG)rrJrrr_has_kernel_headers_installeds   z%MyCache._has_kernel_headers_installedcCstjd|jy|jjd\}}}Wn:tk ro}ztjd|dSWYdd}~XnXtdgdtjd}d |krtjd nd S) zd check for the running kernel and try to ensure that we have an updated version zKernel uname: '%s' -z/Can't parse kernel uname: '%s' (self compiled?)FNdmesgr(rsWARNING: NR_CPUS limitzUP kernel on SMP system!?!T) rrr'splitrrrrr=)rrZbuildZflavourrDrrrrcheckForKernel s zMyCache.checkForKernelcCsd}|jjdd}x|D]}|jjj|j}|ro|jdkrotjd|j q"n|j r"|j j r"|j p|j r"|j |kr"d|j kr"|j j|kr"|j|j d|q"q"WdS) Nrequiredr%RemoveEssentialOkrzPackage %s has no priority set:z;priority in required set '%s' but not scheduled for install)r)r1r2_pcacherzrrHZpriorityrrrQrLrMrGrrI)rneedremoveEssentialOkrJrrrr checkPriority0s zMyCache.checkPrioritycCsud}xN|jrV|ddkr2|jn|jtjd|d7}q W|jdd|jdS)Nrg{Gz?rZfinishedT)lockedZ pulseProgress processEventstimeZsleep)rr-r/irrr updateGUIEs   zMyCache.updateGUIc!Cstj}|jtjd|jd|j|f}|jy|jd|j|j t rt j dn |j |j|j|j||s|j|n|jWntk r}z|j|jtd}|r|td7}n|td7}|j|jtd|t|}t jd ||jd SWYdd}~XnX|j|jg} x |jD]} | jrqn| jrax| jjD]}} t j!| j"| j#j$d krxS| j%D]E\} } | j&j'j(| }|r |j) r | j*| j+Pq q WqqWqn| j,j-}d }x|D]}||j.O}qzW|s| j*| j+qqWy0|j/j0d d }|rt j1ddSWn(t2j3k r}zWYdd}~XnXt4| d kr| j5t jddj| |j|jtdtddj| |jd SdS)NtargetrtTz5skipping kernel checks because we run inside a chrootzAn unresolvable problem occurred while calculating the upgrade. This can be caused by: * Upgrading to a pre-release version of Ubuntu * Running the current pre-release version of Ubuntu * Unofficial software packages not provided by Ubuntu z@This is most likely a transient problem, please try again later.zIf none of this applies, then please report this bug using the command 'ubuntu-bug ubuntu-release-upgrader-core' in a terminal.zCould not calculate the upgradezDist-upgrade failed: '%s'Frr%ZAllowUnauthenticatedzAllowUnauthenticated set!z$Unauthenticated packages found: '%s' z"Error authenticating some packageszIt was not possible to authenticate some packages. This may be a transient network problem. You may want to try again later. See below for a list of unauthenticated packages. )6 threadingZLockacquireZThreadrr-startZupgraderrr rrrrr_keepBaseMetaPkgsInstalled_installMetaPkgs_verifyChangesr8releaserUrrsrZunicoderqrrZmarked_downgraderH version_listr5Zversion_compareZver_str installedr file_listrr{Z find_indexZ is_trustedrrQrLoriginstrustedr1 getbooleanr configparser NoOptionErrorrTsort)rr-Z serverModer0r/trDZdetailsZ error_msgZ untrustedrJrZ verFileIterindexZ indexfilerroriginbrrr distUpgradePs  $                           zMyCache.distUpgradecCstjjd}|jjdd}x|jD]}|jr|j|jrtj d|jt t d|jn|jr4|j j dkr4|jj|dfkr4|j|kr4tj d|jt t d |jq4q4W|jjdd }x|D]}}|jd \}}||kr||jr||jj|kr||jsy||jrt t d |qqWdS) zx this function tests if the current changes don't violate our constrains (blacklisted removals etc) zAPT::Architecturer%rzHThe package '%s' is marked for removal but it's in the removal blacklistzJThe package '%s' is marked for removal but it is in the removal blacklist.TallzDThe package '%s' is marked for removal but it's an ESSENTIAL packagez1The essential package '%s' is marked for removal.Z BadVersionsrz*Trying to install blacklisted version '%s')r5r1findr2rr_inRemovalBlacklistrQrrr8rrHZ essentialrZ architecturerrLrrr)rZ main_archrrJZ badVersionsZbvrrrrrrs*     zMyCache._verifyChangescCs|jjj|j}|dkr8td|jdS|jdkrbtd|jjdS|jjd\}}|jjj ||fdS)a helper to make sure that the pkg._records is pointing to the right location - needed because python-apt 0.7.9 dropped the python-apt version but we can not yet use the new version because on upgrade the old version is still installed NzNo candidate ver: FzNo file_list for: %s rT) rrzrrHprintrQrpopr|lookup)rrJrrwrrrr_lookupPkgRecords zMyCache._lookupPkgRecordcCsAi}t}x|D]}|j|sEtjd|jqnx|jjjjdD]~}|j dr^xf|t ddjdD]B}|j }||krt||rPrG)rtasksZinstalled_tasksrJlinetaskrrrrrinstalledTaskss,  &  #  zMyCache.installedTaskscCs tjdx|D]}|js|jr2qn|j|t|jjdo`|jjjs}tj d|j qnx|jjjj dD]g}|j drxO|t ddj dD]+}|j}||kr|jqqWqqWqWdS)Nzrunning installTasksrzcan not find Record for '%s'rzTask:rT)rrrrGrrlrr|rrrQrrrTr>rI)rrrJrrrrr installTaskss   $&  zMyCache.installTaskscCs4x-|jjddD]}|j|dqWdS)Nr% BaseMetaPkgsz%base meta package keep installed rule)r1r2r)rr-rJrrrr+sz"MyCache._keepBaseMetaPkgsInstalledcsmfdd}jjddx+jjddD]}|jq@WxD]}yL|kr|jr|jrtjd||jnWq_tk r}ztj d||fWYdd}~Xq_Xq_W|stjdxD]}d }x:jj|d D]#}||koV|jM}q7W|rtjd |y|jWnftt fk r}z@tj d ||f|j t d |t ddSWYdd}~XnXtjd||j fPqqWn|sidjdd}|j t dt d|dfdSd S)Ncs{xtD]l}|kr|}|jrL|jrLtjd|jn|jr_|j sl|jrsdSqqWdS)zy internal helper that checks if at least one meta-pkg is installed or marked install z(metapkg '%s' installed but marked_deleteTF)rGrrrrQr)rrJ)r3rrrmetaPkgInstalled1s     z2MyCache._installMetaPkgs..metaPkgInstalledr%r&rzMarking '%s' for upgradez Can't mark '%s' for upgrade (%s)z$none of the '%s' meta-pkgs installedTrz!guessing '%s' as missing meta-pkgz$failed to mark '%s' for install (%s)zCan't install '%s'zIt was impossible to install a required package. Please report this as a bug using 'ubuntu-bug ubuntu-release-upgrader-core' in a terminal.Fzmarked_install: '%s' -> '%s'z, rrzCan't guess meta-packagezYour system does not contain a %s or %s package and it was not possible to detect which version of Ubuntu you are running. Please install one of the packages above first using synaptic or apt-get before proceeding.r*r*)r1r2rIrGZ is_upgradablerrrr8rKeyErrorrrrrU)rr-rrJrrDrZ meta_pkgsr)r3rrr/sL    .  !     zMyCache._installMetaPkgscCsKxD|jD]9}tj|j|r tjd||fdSq WdS)Nz blacklist expr '%s' matches '%s'TF)r<recompilematchrr)rrexprrrrr{s zMyCache._inRemovalBlacklistc Cs|j|jr'tjd|dS|j|rKtjd|dSxQ|jjddD]:}||kra||j|kratjd|dSqaW||krdSy|jjdd}Wn.t j k r}z d}WYdd}~XnXt j |j }||jy||jd ||jjxc|jD]U}|j|ks|j|ks|j|jrJtjd ||jdSqJWWnYttfk r}z3tjd |t||f|jdSWYdd}~XnXdS) Nz skipping running kernel pkg '%s'Fz#skipping '%s' (in removalBlacklist)r%rz'skipping '%s' (in KeepInstalledSection)TZPurgeObsoletespurgez,package '%s' has unwanted removals, skippingz3_tryMarkObsoleteForRemoval failed for '%s' (%s: %s))rr'rrrr1r2rrrrr5rrzrrr-rrrQrr8rrrepr) rrZremove_candidates foreign_pkgsrrrDrrJrrrtryMarkObsoleteForRemovalsD       z!MyCache.tryMarkObsoleteForRemovalcCsLt}x<|D]4}|jr|j|sD|j|jqDqqW|S)z1 get all package names that are not downloadable )rCrGanyVersionDownloadablerPrQ)rZ obsolete_pkgsrJrrr_getObsoletesPkgss    zMyCache._getObsoletesPkgscCs(x!|jjD]}|jr dSq WdS)zA helper that checks if any of the version of pkg is downloadable TF)rHrrM)rrJrrrrrs zMyCache.anyVersionDownloadablecCsOt}x?|D]7}|jr|jj|jr|j|jqqW|S)z1 get all package names that are not downloadable )rCrGrzrrHrPrQ)rZunused_dependenciesrJrrr_getUnusedDependenciess   zMyCache._getUnusedDependenciesc Cst}|jjdd}tjj|r~t|=}x3|D]+}|jdsF|j|j qFqFWWdQXnt}xe|D]]}||krqn||}|j s|j j |j s|jrqn|j|qWt|S)z return list of installed and demoted packages If a demoted package is a automatic install it will be skipped r%Z Demotions#N)rCr1r@rAr^r_rarrPr>rGrzZis_auto_installedrHrrW)rZ demotionsZdemotions_fileZ demotions_frZinstalled_demotionsZdemoted_pkgnamerJrrrget_installed_demoted_packagess$  #      z&MyCache.get_installed_demoted_packagescCst}x|D]}|jr|j|r|js=qnd}xb|jjD]T}||jkr}|j|kr}d}n||jkrP|j|krPd}qPqPW|r|j|jqqqW|S)zm get all packages that are installed from a foreign repo (and are actually downloadable) TF) rCrGrMrLrarchiverrPrQ)rZallowed_originZfromDistZtoDistrrJZforeignrrrr_getForeignPkgss      zMyCache._getForeignPkgsFcsGdddt}fdd}gi}i}td}x|D]}y"|j\}} } } } } Wn?tk r}ztjd||fwPWYdd}~XnX| krPj| qPqPWWdQXjdtd d t j j d }d }t |d ro|j j dddro|j jdd}tjj|sotj|qontjd|xdddd||dd gD]}tjj|}||}tjj|rtj|}|j|j}ntjd|d}||krJtjd|||f|||||.FreeSpacez@ helper class that represents the free space on each mounted fs cSs||_d|_dS)Nr)freer)rZ initialFreerrrr s z2MyCache.checkFreeSpace..FreeSpace.__init__N)r rrr rrrrr FreeSpace s rcs(x!D]}|j|r|SqWdS)z return 'id' of a directory so that directories on the same filesystem get the same id (simply the mount_point) /)r)dZ mount_point)mountedrr make_fs_ids z*MyCache.checkFreeSpace..make_fs_idz /proc/mountsz-line '%s' in /proc/mounts not understood (%s)NrreverseTzDir::Cache::archivesz/tmp/r1ZAufsZEnabledFZRWDirzcache aufs_rw_dir: %sr/usrz/varz/bootz/homezdirectory '%s' does not existsrzDir %s mounted on %szFree space on %s: %szfs_free contains: '%s'z%^linux-(image|image-debug)-[0-9.]*-.*z,%s (new-install) added with %s to boot spacerkgz*taking aufs overlay into space calculationz&additional space for the snapshots: %s2i/tmp z dir '%s' needs '%s' of '%s' (%f)rzNot enough free space: %scSsg|]}t|qSr)r9).0rrrr s z*MyCache.checkFreeSpace..i )r riP)rri()rr)4objectrar ValueErrorrrrrrTr5r1rrlr]r@rAr^r_r`realpathstatvfsf_bavailf_frsizerrrrQrKERNEL_INITRD_SIZErrLZinstalled_sizerGrrr}r~rrZ size_to_strfloatabs isinstancebytesdecodelocalegetpreferredencodingrrr!rWvalues)rZsnapshots_in_userr Zmnt_mapZfs_freeZmountsrZwhatZwhereZfsZoptionsarrDZ archivedirZ aufs_rw_dirrZfs_idstrZ space_in_bootrJZrequired_for_aufsZrequired_for_snapshotsrrZ required_listZ free_at_leastZ free_neededr)r rcheckFreeSpaces  " %               ( &)zMyCache.checkFreeSpace);r rrrNrOrrKpropertyrSr\r?rqrsryr}r~rr7rrrrVrYrMrrrrrrrrIrrrrrrrrrrrrrrrrrrrrrrrrrrr'rrrrr#Ysn "                  "   *         L 3    r#__main__)DistUpgradeConfig)DistUpgradeViewZfoo.zubuntu-desktop)6Z __future__rrwarningsfilterwarnings FutureWarningr:r5r"rArrrrfrrr ConfigParser subprocessrrZDistUpgradeGettextrrr Zutilsr r rr rrrrrrr!r;r#r sysZDistUpgradeConfigParserr*r+rcr'exitrrrrrrrrrrsZ             I