D[c@sgddlmZddlZddlZddlZddlZddlmZddlmZ ddl Zde fdYZ de fdYZ d e fd YZd efd YZd efdYZdefdYZdefdYZdefdYZdefdYZdZdZdZedkrcendS(i(tprint_functionN(tPackage(tgettexttFetchCancelledExceptioncBseZdZRS(sAException that is thrown when the user cancels a fetch operation.(t__name__t __module__t__doc__(((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR"stFetchFailedExceptioncBseZdZRS(s-Exception that is thrown when fetching fails.(RRR(((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR&stLockFailedExceptioncBseZdZRS(s,Exception that is thrown when locking fails.(RRR(((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR*stCacheClosedExceptioncBseZdZRS(s>Exception that is thrown when the cache is used after close().(RRR(((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR .stCachecBseZdZd(d(edZdZdZdZd(dZ dZ dZ dZ d Z d Zd Zd Zd ZdZdZdZedZedZedZedZdZdZd(d(dZdZeedZd(ded(dZ dZ!d(d(dZ"dZ#dZ$d Z%d!Z&d"Z'ed#Z(ed$Z)ed%Z*ed&Z+ed'Z,RS()sDictionary-like package cache. The APT cache file contains a hash table mapping names of binary packages to their metadata. A Cache object is the in-core representation of the same. It provides access to APTs idea of the list of available packages. The cache can be used like a mapping from package names to Package objects (although only getting items is supported). Keyword arguments: progress -- a OpProgress object rootdir -- a alternative root directory. if that is given the system sources.list and system lists/ files are not read, only files relative to the given rootdir memonly -- build the cache in memory only cCsd|_d|_d|_d|_i|_tj|_tj |_ t |_ t |_ d|_d|_|jd|j|jd|j|rtjj ddn|rtjj|}tjj|drtjtj|dntjj|dr/tjtj|dntjj d|tjj d |d tjj d tjj|d d d|j|tjn|j|dS(Nitcache_post_opentcache_post_changesDir::Cache::pkgcachets/etc/apt/apt.confs/etc/apt/apt.conf.dtDirsDir::State::statuss/var/lib/dpkg/statussDir::bin::dpkgtusrtbintdpkg(tNonet_cachet _depcachet_recordst_listt _callbackstweakreftWeakValueDictionaryt_weakreftWeakSett _weakversionstsett_sett _fullnamesett_changes_countt _sorted_settconnectt_inc_changes_counttapt_pkgtconfigtostpathtabspathtexiststread_config_filetisdirtread_config_dirtjoint_check_and_create_required_dirst init_systemtopen(tselftprogresstrootdirtmemonly((s-/usr/lib/python2.7/dist-packages/apt/cache.pyt__init__Es>                cCs|jd7_dS(sIncrease the number of changesiN(R (R1((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR#nscCsddg}ddddg}x8|D]0}tjj||s%tj||q%q%Wx>|D]6}tjj||s`t||djq`q`WdS( sf check if the required apt directories/files are there and if not create them s/var/lib/dpkg/statuss/etc/apt/sources.lists /var/lib/dpkgs /etc/apt/s/var/cache/apt/archives/partials/var/lib/apt/lists/partialtwN(R&R'R)tmakedirsR0tclose(R1R3tfilestdirstdtf((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR.rs    cCs5||jkr1x|j|D] }|qWndS(s# internal helper to run a callback N(R(R1tnametcallback((s-/usr/lib/python2.7/dist-packages/apt/cache.pyt_run_callbacksscCs|dkr!tjjj}n|j||_|jdtj ||_ tj |j |_ tj |j |_tj|_|jj|jj|jjd|_|jttjdk|_td|_d}}t|j j}x|j jD]}|dk r_|d|kr_|j|t|d|}n|jr|jj |j!dt"|jr|jj |j!dt#qn|d7}qW|j$|jddS( sY Open the package cache, after that it can be used like a dictionary tcache_pre_openisBuilding data structuresiidtprettyR N(%RtaptR2tbaset OpProgressR8t op_progressR?R$R RtDepCacheRtPackageRecordsRt SourceListRtread_main_listRtclearRR!t _Cache__remaptlentget_architecturest_have_multi_archt_toptpackagestupdatetfloatt has_versionstaddt get_fullnametTruetFalsetdone(R1R2titlasttsizetpkg((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR0s:             " c CsVxt|jjD]r}y|j|}Wntk rCqnXy&|j|jj|jjf|_Wqtk r|j|=qXqWxt|j D]}x|j jj D]}|j |j j kr|jdks|j jdks|j|j jkr|j|j jkr|j|j jkr||_ PqqW|j j|qWdS(sCalled after cache reopen() to relocate to new cache. Relocate objects like packages and versions from the old underlying cache to the new one. iN(tlistRtkeystKeyErrorRt_pkgR=t architecturet LookupErrorRtpackaget version_listthasht_candR\t multi_archtver_strtremove(R1tkeyR]tvertv((s-/usr/lib/python2.7/dist-packages/apt/cache.pyt__remaps& & ! cCs|`d|_dS(s Close the package cache N(RR(R1((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR8scCs|S(s Enter the with statement ((R1((s-/usr/lib/python2.7/dist-packages/apt/cache.pyt __enter__scCs|jdS(s Exit the with statement N(R8(R1texc_typet exc_valuet traceback((s-/usr/lib/python2.7/dist-packages/apt/cache.pyt__exit__scCsy|j|SWnptk r||jks=||jkrnt|}t||j|}|j|<|Std|nXdS(s" look like a dictionary (get key) s!The cache has no package named %rN(RR`RRtstrRR(R1RkR]((s-/usr/lib/python2.7/dist-packages/apt/cache.pyt __getitem__s  !ccsK|jdkr$t|j|_nx|jD]}||Vq.WtdS(N(R!RtsortedRt StopIteration(R1tpkgname((s-/usr/lib/python2.7/dist-packages/apt/cache.pyt__iter__s  cCs||jkp||jkS(N(RR(R1Rk((s-/usr/lib/python2.7/dist-packages/apt/cache.pythas_keyscCs||jkp||jkS(N(RR(R1Rk((s-/usr/lib/python2.7/dist-packages/apt/cache.pyt __contains__scCs t|jS(N(RLR(R1((s-/usr/lib/python2.7/dist-packages/apt/cache.pyt__len__scCs t|jS(N(R^R(R1((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR_scCsg}|jj}x|jjD]z}||s|jdt}y|j|j|Wqtk rt ||}|j|<|j|qXqqW|S(s Get the marked changes RA( Rt marked_keepRRQRVRWtappendRR`R(R1tchangesR}R]R=Rd((s-/usr/lib/python2.7/dist-packages/apt/cache.pyt get_changes s   cCs(|j|jj||jdS(sUpgrade all packages. If the parameter *dist_upgrade* is True, new dependencies will be installed as well (and conflicting packages may be removed). The default value is False. N(tcache_pre_changeRtupgradeR (R1t dist_upgrade((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRs cCs\|jdkrtdntj|j}tj}|j||j|j|j S(s;Get the size of the packages that are required to download.s&Cache object used after close() calledN( RRR R$tPackageManagerRtAcquiret get_archivesRt fetch_needed(R1tpmtfetcher((s-/usr/lib/python2.7/dist-packages/apt/cache.pytrequired_download"s  cCs |jjS(s8Get the size of the additional required space on the fs.(Rtusr_size(R1((s-/usr/lib/python2.7/dist-packages/apt/cache.pytrequired_space-scCst}|jj}ttjtjf}x[|jjD]M}||}|r:|j r:|j |kr:|j |j dt q:q:W|S(sAReturn the packages not downloadable packages in reqreinst state.RA(RRtget_candidate_vert frozensetR$tINSTSTATE_REINSTREQtINSTSTATE_HOLD_REINSTREQRRQt downloadablet inst_stateRURVRW(R1t reqreinstRtstatesR]tcand((s-/usr/lib/python2.7/dist-packages/apt/cache.pytreq_reinstall_pkgs2s     cCs|j}t}d}xX|jD]M}|j|jkr@q"n|jrOq"n|d|j|jf7}t}q"W||j krt |n|rt |n|S(NR sFailed to fetch %s %s ( trunRXtitemststatust STAT_DONEt STAT_IDLEtdesc_urit error_textRWtRESULT_CANCELLEDRR(R1Rtrestfailedterr_msgtitem((s-/usr/lib/python2.7/dist-packages/apt/cache.pyt _run_fetcher?s     cCs|jdkrtdntjjdd}tj|}|dkrbtd|nz0|j||j |jst S|j |SWdt j |XdS(s fetch the needed archives s&Cache object used after close() calledsDir::Cache::ArchivestlockisFailed to lock %sN(RRR R$R%tfind_dirtget_lockRRRRXRR&R8(R1RRtlockfileR((s-/usr/lib/python2.7/dist-packages/apt/cache.pyt_fetch_archivesVs  cCs|dk r'|dk r'tdn|dkrHtjjj}n|dkrftj|}n|j|tj |j S(s Fetch the archives for all packages marked for install/upgrade. You can specify either an :class:`apt.progress.base.AcquireProgress()` object for the parameter *progress*, or specify an already existing :class:`apt_pkg.Acquire` object for the parameter *fetcher*. The return value of the function is undefined. If an error occured, an exception of type :class:`FetchFailedException` or :class:`FetchCancelledException` is raised. .. versionadded:: 0.8.0 s'Takes a progress or a an Acquire objectN( Rt ValueErrorRBR2ttexttAcquireProgressR$RRRR(R1R2R((s-/usr/lib/python2.7/dist-packages/apt/cache.pytfetch_archivesls    cCsAy|j|}Wntk r%tSXt|jo9|j SdS(s0Return whether the package is a virtual package.N(RR`RXtboolt has_providesRT(R1RxR]((s-/usr/lib/python2.7/dist-packages/apt/cache.pytis_virtual_packages  c Cs t}|jj}y+|j|}|jr?| r?t|SWntk rZt|SXx|jD]\}}} | j} | s| || kre| j dt } y|j |j | Wqtk rt || } |j | <|j | qXqeqeWt|S(s)Return a list of all packages providing a package. Return a list of packages which provide the virtual package of the specified name. If 'candidate_only' is False, return all packages with at least one version providing the virtual package. Otherwise, return only those packages where the candidate version provides the virtual package. If 'include_nonvirtual' is True then it will search for all packages providing pkgname, even if pkgname is not itself a virtual pkg. RA(RRRRRTR^R`t provides_listt parent_pkgRVRWRURR( R1Rxtcandidate_onlytinclude_nonvirtualt providersRtvptprovidest providesvertversionR]R=Rd((s-/usr/lib/python2.7/dist-packages/apt/cache.pytget_providing_packagess$       ic Cstjjdd}tj|}|dkrDtd|n|rtjjd}tjjd}tjjd} tjjdtjj |tjjddtjjdd tj } | j n |j } z|d kr tjjj}ny|jj|| |} Wntk rH} t| nX| rb|rbtn| SWd tj||rtjjd|tjjd|tjjd| nXd S( sRun the equivalent of apt-get update. You probably want to call open() afterwards, in order to utilise the new cache. Otherwise, the old cache will be used which can lead to strange bugs. The first parameter *fetch_progress* may be set to an instance of apt.progress.FetchProgress, the default is apt.progress.FetchProgress() . sources_list -- Update a alternative sources.list than the default. Note that the sources.list.d directory is ignored in this case sDir::State::ListsRisFailed to lock %ssDir::Etc::sourcelistsDir::Etc::sourcepartssAPT::List-Cleanuptxxxt0N(R$R%RRRtfindRR&R'R(RHRIRRRBR2RCRRRRt SystemErrorRR8( R1tfetch_progresstpulse_intervaltraise_on_errort sources_listRRtold_sources_listtold_sources_list_dt old_cleanuptslistRte((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRRs>          cCsky|jWntk r+|jnX|j|}y|jWntk rf|jnX|S(s The first parameter *pm* refers to an object returned by apt_pkg.PackageManager(). The second parameter *install_progress* refers to an InstallProgress() object of the module apt.progress. (t startUpdatetAttributeErrort start_updateRt finishUpdatet finish_update(R1Rtinstall_progressR((s-/usr/lib/python2.7/dist-packages/apt/cache.pytinstall_archivess   cCs|dkr!tjjj}n|dkrBtjjj}ntj|j}tj |}xt r|j ||}|j ||}||j krPn@||jkrtdn"||jkrntd||jqfW||j kS(sCApply the marked changes to the cache. The first parameter, *fetch_progress*, refers to a FetchProgress() object as found in apt.progress, the default being apt.progress.FetchProgress(). The second parameter, *install_progress*, is a apt.progress.InstallProgress() object. sinstallArchives() faileds<internal-error: unknown result code from InstallArchives: %sN(RRBR2RCRtInstallProgressR$RRRRWRRtRESULT_COMPLETEDt RESULT_FAILEDRtRESULT_INCOMPLETEtshutdown(R1RRRRR((s-/usr/lib/python2.7/dist-packages/apt/cache.pytcommits&    cCs|jjdS(s Unmark all changes N(Rtinit(R1((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRJ$scCs|jddS(s@ called internally if the cache has changed, emit a signal then R N(R?(R1((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR *scCs|jddS(sS called internally if the cache is about to change, emit a signal then RN(R?(R1((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR.scCs7||jkrg|j|((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR"3scCstj|jS(sReturn an `ActionGroup` object for the current cache. Action groups can be used to speedup actions. The action group is active as soon as it is created, and disabled when the object is deleted or when release() is called. You can use the action group as a context manager, this is the recommended way:: with cache.actiongroup(): for package in my_selected_packages: package.mark_install() This way, the action group is automatically released as soon as the with statement block is left. It also has the benefit of making it clear which parts of the code run with a action group and which don't. (R$t ActionGroupR(R1((s-/usr/lib/python2.7/dist-packages/apt/cache.pyt actiongroup:scCsatjjtjjd}x<tjtjj|dD]}tj|dr=t Sq=Wt S(sReturn True if the dpkg was interrupted All dpkg operations will fail until this is fixed, the action to fix the system if dpkg got interrupted is to run 'dpkg --configure -a' as root. sDir::State::statustupdatess[0-9]*( R&R'tdirnameR$R%t find_filetlistdirR-tfnmatchRWRX(R1tdpkg_status_dirR<((s-/usr/lib/python2.7/dist-packages/apt/cache.pytdpkg_journal_dirtyOs  %cCs |jjS(s7Return the number of packages with broken dependencies.(Rt broken_count(R1((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR^scCs |jjS(s2Return the number of packages marked for deletion.(Rt del_count(R1((s-/usr/lib/python2.7/dist-packages/apt/cache.pyt delete_countcscCs |jjS(s6Return the number of packages marked for installation.(Rt inst_count(R1((s-/usr/lib/python2.7/dist-packages/apt/cache.pyt install_counthscCs |jjS(s-Return the number of packages marked as keep.(Rt keep_count(R1((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRmsN(-RRRRRXR5R#R.R?R0RKR8RoRsRuRyRzR{R|R_RRtpropertyRRRRRRRRWRRRRRRJR RR"RRRRRR(((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR 2sR)    )              $3 +     tProblemResolvercBsMeZdZdZdZdZdZdZdZdZ RS(suResolve problems due to dependencies and conflicts. The first argument 'cache' is an instance of apt.Cache. cCs"tj|j|_||_dS(N(R$RRt _resolverR(R1tcache((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR5yscCs|jj|jdS(s'Reset the package to the default state.N(RRJRa(R1Rd((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRJ}scCs|jjdS(s/mark protected packages for install or removal.N(Rtinstall_protect(R1((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRscCs|jj|jdS(s)Protect a package so it won't be removed.N(RtprotectRa(R1Rd((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRscCs|jj|jdS(sMark a package for removal.N(RRjRa(R1Rd((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRjscCs+|jj|jj|jjdS(s:Resolve dependencies, try to remove packages where needed.N(RRRtresolveR (R1((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRs  cCs+|jj|jj|jjdS(s4Resolve dependencies, do not try to remove packages.N(RRRtresolve_by_keepR (R1((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRs  ( RRRR5RJRRRjRR(((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRss      tFiltercBseZdZdZRS(s Filter base class cCstS(sn Filter function, return True if the package matchs a filter criteria and False otherwise (RW(R1R]((s-/usr/lib/python2.7/dist-packages/apt/cache.pytapplys(RRRR(((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRstMarkedChangesFiltercBseZdZdZRS(s( Filter that returns all marked changes cCs'|js|js|jrtStSdS(N(tmarked_installt marked_deletetmarked_upgradeRWRX(R1R]((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRs(RRRR(((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRst FilteredCachecBsweZdZd d dZdZdZdZdZdZ dZ dZ d Z d Z d ZRS( sa A package cache that is filtered. Can work on a existing cache or create a new one cCsi|dkrt||_n ||_|jjd|j|jjd|ji|_g|_dS(NR R (RR RR"tfilter_cache_post_changet _filteredt_filters(R1RR2((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR5s   cCs t|jS(N(RLR(R1((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR|scCs |j|S(N(R(R1Rk((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRusccs$x|jD]}|j|Vq WdS(N(RR(R1Rx((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRyscCs |jjS(N(RR_(R1((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR_scCs ||jkS(N(R(R1Rk((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRzscCs ||jkS(N(R(R1Rk((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR{scCsXi|_xH|jD]=}x4|jD])}|j|r#d|j|js.     C*  B   6