s_c@sddlmZddlZddlZddlZddlZddlZddlmZddl Zde fdYZ de fdYZ de fd YZ d e fd YZd efd YZdefdYZdefdYZdefdYZdefdYZdefdYZdefdYZdefdYZdZdZdZedkrendS( i(tprint_functionN(tPackagetFetchCancelledExceptioncBseZdZRS(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&stUntrustedExceptioncBseZdZRS(s>Exception that is thrown when fetching fails for trust reasons(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 2stCachecBseZdZd+d+edZdZdZdZd+dZ dZ dZ dZ d Z d+d Zd Zd Zd ZdZdZdZdZdZedZedZedZedZdZd+dZd+d+d+dZdZe edZ!d+de d+dZ"dZ#d+d+d+dZ$d Z%d!Z&d"Z'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 -- an alternative root directory. if that is given the system sources.list and system lists/files are not read, only file relative to the given rootdir, memonly -- build the cache in memory only. .. versionchanged:: 1.0 The cache now supports package names with special architecture qualifiers such as :all and :native. It does not export them in :meth:`keys()`, though, to keep :meth:`keys()` a unique set. cCsd|_d|_d|_d|_i|_i|_tj|_ d|_ d|_ |j dd|j dd|rt jjddn|rwtjj|}tjj|drt jt j|dntjj|dr t jt j|dnt jjd |t jjd |d t jjd tjj|d dd|j|t jn|j|dS(Nitcache_post_opent_inc_changes_counttcache_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 _callbackst _callbacks2tweakreftWeakValueDictionaryt_weakreft_changes_countt _sorted_settconnecttapt_pkgtconfigtsettostpathtabspathtexiststread_config_filetisdirtread_config_dirtjoint_check_and_create_required_dirst init_systemtopen(tselftprogresstrootdirtmemonly((s-/usr/lib/python2.7/dist-packages/apt/cache.pyt__init__Ps:               cCs|jd7_dS(sIncrease the number of changesiN(R(R.((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR wscCsddg}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&tmakedirsR-tclose(R.R0tfilestdirstdtf((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR+{s    cCs||jkrJx8|j|D]&}|dkr<|jq|qWn||jkrx1|j|D]\}}}||||qgWndS(s# internal helper to run a callback R N(RR R(R.tnametcallbacktargstkwds((s-/usr/lib/python2.7/dist-packages/apt/cache.pyt_run_callbackss  cCs|dkr!tjjj}n|j||_|jdtj ||_ tj |j |_ tj |j |_tj|_|jjd|_|jjttjdk|_|j|jddS(sY Open the package cache, after that it can be used like a dictionary tcache_pre_openiR N(RtaptR/tbaset OpProgressR5t op_progressR>R R RtDepCacheRtPackageRecordsRt SourceListRtread_main_listRRtcleartlentget_architecturest_have_multi_archtdone(R.R/((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR-s        cCs|`d|_dS(s Close the package cache N(RR(R.((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR5scCs|S(s Enter the with statement ((R.((s-/usr/lib/python2.7/dist-packages/apt/cache.pyt __enter__scCs|jdS(s Exit the with statement N(R5(R.texc_typet exc_valuet traceback((s-/usr/lib/python2.7/dist-packages/apt/cache.pyt__exit__scCsy|j|SWntk rt|}y|j|}Wn!tk r_td|nX|j|std|n|j|}||j|<|SXdS(s" look like a dictionary (get key) s!The cache has no package named %rN(RtKeyErrortstrRt_Cache__is_real_pkgt_rawpkg_to_pkg(R.tkeytrawpkgtpkg((s-/usr/lib/python2.7/dist-packages/apt/cache.pyt __getitem__s    cCs%y ||SWntk r |SXdS(saReturn *self*[*key*] or *default* if *key* not in *self*. .. versionadded:: 1.1 N(RR(R.RVtdefault((s-/usr/lib/python2.7/dist-packages/apt/cache.pytgets  cCsW|jdt}y|j|}Wn-tk rRt||}||j| s(RRtsortedRtpackagestlist(R.((R.s-/usr/lib/python2.7/dist-packages/apt/cache.pyR`scCsRg}|jj}x9|jjD]+}||s|j|j|qqW|S(s Get the marked changes (Rt marked_keepRRltappendRU(R.tchangesRnRW((s-/usr/lib/python2.7/dist-packages/apt/cache.pyt get_changess   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 (R.t dist_upgrade((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRss 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(R.tpmtfetcher((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(R.((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.R\(R"Rtget_candidate_vert frozensetR tINSTSTATE_REINSTREQtINSTSTATE_HOLD_REINSTREQRRlt downloadablet inst_statetaddR]Rh(R.t reqreinstR~tstatesRXtcand((s-/usr/lib/python2.7/dist-packages/apt/cache.pytreq_reinstall_pkgs2s     cCs&|dkr$tjjdt}ng|jD]}|js.|^q.}|r|| r|tddjd|Dn|j }t}d}xX|jD]M}|j |j krqn|j rqn|d|j |jf7}t}qW||jkr t|n|r"t|n|S(NsAPT::Get::AllowUnauthenticatedsUntrusted packages: %ss css|]}|jVqdS(N(tdesc_uri(Riti((s-/usr/lib/python2.7/dist-packages/apt/cache.pys GsRsFailed to fetch %s %s (RR R!tfind_bR^titemst is_trustedRR*truntstatust STAT_DONEt STAT_IDLERt error_textRhtRESULT_CANCELLEDRR(R.Rztallow_unauthenticatedtitemt untrustedtrestfailedterr_msg((s-/usr/lib/python2.7/dist-packages/apt/cache.pyt _run_fetcher?s.   %      cCs|jdkrtdntjjdd}tj|}|dkrbtd|nz3|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_lockRRwRR^RR#R5(R.RzRyRtlockfileR((s-/usr/lib/python2.7/dist-packages/apt/cache.pyt_fetch_archives_s  cCs|dk r'|dk r'tdn|dkrHtjjj}n|dkrftj|}n|j|tj |j |S(sFetch 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 occurred, an exception of type :class:`FetchFailedException` or :class:`FetchCancelledException` is raised. The keyword-only parameter *allow_unauthenticated* specifies whether to allow unauthenticated downloads. If not specified, it defaults to the configuration option `APT::Get::AllowUnauthenticated`. .. versionadded:: 0.8.0 s'Takes a progress or a an Acquire objectN( Rt ValueErrorR@R/ttexttAcquireProgressR RvRRuR(R.R/RzR((s-/usr/lib/python2.7/dist-packages/apt/cache.pytfetch_archivesus   cCsAy|j|}Wntk r%tSXt|jo9|j SdS(s0Return whether the package is a virtual package.N(RRRR^tboolt has_providesRc(R.RaRX((s-/usr/lib/python2.7/dist-packages/apt/cache.pytis_virtual_packages  c Cst}|jj}y+|j|}|jr?| r?t|SWntk rZt|SXxU|jD]J\}}} | j} | s| || kre|j |j | qeqeWt|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. ( R"RR~RRcRmRRt provides_listt parent_pkgRRU( R.Ratcandidate_onlytinclude_nonvirtualt providersR~tvptprovidest providesvertversionRW((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!RRRtfindR"R#R$R%RFRGRRR@R/RARRtupdatet SystemErrorRR5( R.tfetch_progresstpulse_intervaltraise_on_errort sources_listRRtold_sources_listtold_sources_list_dt old_cleanuptslistRte((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRs>          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(R.Rytinstall_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(s!Apply 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. The keyword-only parameter *allow_unauthenticated* specifies whether to allow unauthenticated downloads. If not specified, it defaults to the configuration option `APT::Get::AllowUnauthenticated`. sinstallArchives() faileds<internal-error: unknown result code from InstallArchives: %sN(RR@R/RARtInstallProgressR RuRRvRhRRtRESULT_COMPLETEDt RESULT_FAILEDRtRESULT_INCOMPLETEtshutdown(R.RRRRyRzR((s-/usr/lib/python2.7/dist-packages/apt/cache.pytcommits&    cCs|jjdS(s Unmark all changes N(Rtinit(R.((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRH3scCs|jddS(s@ called internally if the cache has changed, emit a signal then R N(R>(R.((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR 9scCs|jddS(sS called internally if the cache is about to change, emit a signal then RrN(R>(R.((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRr=scCsY|dkr"tjdtdn||jkrAg|j|R-R5RMRQRYR[RURbRTReRfRgR`RqRstpropertyR{R}RRRRRRhRRRRRHR RrRRRRRRRR(((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR 6s\'                  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(R.tcache((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR2scCs|jj|jdS(s'Reset the package to the default state.N(RRHt_pkg(R.tpackage((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRHscCs|jjdS(s/mark protected packages for install or removal.N(Rtinstall_protect(R.((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRscCs|jj|jdS(s)Protect a package so it won't be removed.N(RtprotectR(R.R((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRscCs|jj|jdS(sMark a package for removal.N(RtremoveR(R.R((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRscCs+|jj|jj|jjdS(s:Resolve dependencies, try to remove packages where needed.N(RRrRtresolveR (R.((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRs  cCs+|jj|jj|jjdS(s4Resolve dependencies, do not try to remove packages.N(RRrRtresolve_by_keepR (R.((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRs  ( RRRR2RHRRRRR(((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRs      tFiltercBseZdZdZRS(s Filter base class cCstS(sn Filter function, return True if the package matchs a filter criteria and False otherwise (Rh(R.RX((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_upgradeRhR^(R.RX((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRs(RRRR(((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRstInstalledFiltercBseZdZdZRS(sMFilter that returns all installed packages. .. versionadded:: 1.0.0 cCs|jS(N(t is_installed(R.RX((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRs(RRRR(((s-/usr/lib/python2.7/dist-packages/apt/cache.pyRst_FilteredCacheHelpercBs2eZdZdZdZdZdZRS(s:Helper class for FilteredCache to break a reference cycle.cCs<i|_i|_|jd|j|jd|jdS(NR R (t _filteredt_filtersRtfilter_cache_post_change(R.R((s-/usr/lib/python2.7/dist-packages/apt/cache.pyR2s  cCsUi|_xE|D]=}x4|jD])}|j|r d|j|js4      j*    2   6